@Override protected Text toWritable(DataByteArray value) throws IOException { return toWritable(value.toString()); }
public static void main(String[] args){ String s = "bla"; DataByteArray dba = new DataByteArray(); dba.set(s.getBytes()); System.out.println(dba.toString()); } }
/** * @param context the context the method is being executed in * @return the string representation of the encapsulated DataByteArray */ @JRubyMethod(name = {"to_s", "inspect"}) public IRubyObject toString(ThreadContext context) { return RubyString.newString(context.getRuntime(), internalDBA.toString()); } }
return new BigDecimal(((DataByteArray)o).toString());
return Integer.valueOf(((DataByteArray)o).toString());
return Double.valueOf(((DataByteArray)o).toString());
return ((DataByteArray)o).toString();
return new BigInteger(((DataByteArray)o).toString());
return Long.valueOf(((DataByteArray)o).toString());
return null; case BYTEARRAY: return new DateTime(((DataByteArray) o).toString()); case CHARARRAY:
static protected Double sum(Tuple input) throws ExecException, IOException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL if(values == null || values.size() == 0) { return null; } double sum = 0; boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try{ DataByteArray dba = (DataByteArray)t.get(0); Double d = dba != null ? Double.valueOf(dba.toString()) : null; if (d == null) continue; sawNonNull = true; sum += d; }catch(RuntimeException exp) { int errCode = 2103; String msg = "Problem while computing sum of doubles."; throw new ExecException(msg, errCode, PigException.BUG, exp); } } if(sawNonNull) { return new Double(sum); } else { return null; } }
static protected Double sum(Tuple input) throws ExecException, IOException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL if(values.size() == 0) { return null; } double sum = 0; boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try{ DataByteArray dba = (DataByteArray)t.get(0); Double d = dba != null ? Double.valueOf(dba.toString()) : null; if (d == null) continue; sawNonNull = true; sum += d; }catch(RuntimeException exp) { int errCode = 2103; String msg = "Problem while computing sum of values."; throw new ExecException(msg, errCode, PigException.BUG, exp); } } if(sawNonNull) { return new Double(sum); } else { return null; } }
static protected Double sumSquare(Tuple input) throws ExecException, IOException { DataBag values = (DataBag)input.get(0); // if we were handed an empty bag, return NULL if(values.size() == 0) { return null; } double sumSquare = 0; boolean sawNonNull = false; for (Iterator<Tuple> it = values.iterator(); it.hasNext();) { Tuple t = it.next(); try{ DataByteArray dba = (DataByteArray)t.get(0); Double d = dba != null ? Double.valueOf(dba.toString()) : null; if (d == null) continue; sawNonNull = true; sumSquare += d*d; }catch(RuntimeException exp) { int errCode = 2103; String msg = "Problem while computing sum of squared values."; throw new ExecException(msg, errCode, PigException.BUG, exp); } } if(sawNonNull) { return new Double(sumSquare); } else { return null; } }
return Float.valueOf(((DataByteArray)o).toString());
@Override public Tuple exec(Tuple input) throws IOException { Tuple t = TupleFactory.getInstance().newTuple(); t.append(((DataByteArray) input.get(0)).toString()); return t; }
@Override public Tuple exec(Tuple input) throws IOException { // Initial is called in the map. // we just send the tuple down try { // input is a bag with one tuple containing // the column we are trying to operate on DataBag bg = (DataBag) input.get(0); if (bg.iterator().hasNext()) { DataByteArray dba = (DataByteArray) bg.iterator().next().get(0); Double d = dba != null ? Double.valueOf(dba.toString()): null; return tfact.newTuple(d); } else { // make sure that we call the object constructor, not the list constructor return tfact.newTuple((Object) null); } } catch (ExecException e) { throw e; } catch (Exception e) { int errCode = 2106; throw new ExecException("Error executing an algebraic function", errCode, PigException.BUG, e); } } }
return (String) v + "0"; case DataType.BYTEARRAY: String str = ((DataByteArray) v).toString(); str = str + "0"; return new DataByteArray(str);
dba = (DataByteArray)tp.get(0); t.set(0, dba != null ? Double.valueOf(dba.toString()) : null); if (dba == null) t.set(1, 0L);
Double d = dba !=null ? Double.valueOf(dba.toString()) : null; if (dba == null){ t.set(0, null);
case DataType.BYTEARRAY: DataByteArray dba = (DataByteArray)t.get(0); d = dba != null ? Double.valueOf(dba.toString()): null; break; case DataType.DOUBLE: