@Override protected Object binaryValue(byte[] value) { return new DataByteArray(value); }
@Test public void testNamedByteArray() { String expected = "{\"name\":\"Ynl0ZSBhcnJheQ==\"}"; assertThat(pigTypeToJson(createTuple(new DataByteArray("byte array".getBytes()), createSchema("name:bytearray"))), is(expected)); }
@Test public void testAnonByteArray() { String expected = "{\"val_0\":\"Ynl0ZSBhcnJheQ==\"}"; assertThat(pigTypeToJson(createTuple(new DataByteArray("byte array".getBytes()), createSchema("bytearray"))), is(expected)); }
@Test public void testByteArray() { String expected = "{\"name\":\"Ynl0ZSBhcnJheQ==\"}"; assertThat(pigTypeToJson(createTuple(new DataByteArray("byte array".getBytes()), createSchema("name:bytearray"))), is(expected)); }
switch (itemType) { case BINARY: result = new DataByteArray((byte[]) o); break; case STRUCT:
protected DataByteArray box(byte[] v) { if (v == null) { return null; } return new DataByteArray(v); }
/** * This constructor encapsulated a null DataByteArray. * * @param ruby an instance of the ruby runtime * @param rc an instance of the class object with meatadata */ protected RubyDataByteArray(final Ruby ruby, RubyClass rc) { super(ruby,rc); internalDBA = new DataByteArray(); }
/** * This constructor creates a new DataByteArray with a reference to the provided bytes. * * @param ruby an instance of the ruby runtime * @param rc an instance of the class object with meatadata * @param buf a byte array to encapsulate directly */ protected RubyDataByteArray(final Ruby ruby, RubyClass rc, byte[] buf) { super(ruby,rc); internalDBA = new DataByteArray(buf); }
Tuple t = tupleFactory.newTuple(); t.append(i); t.append(new DataByteArray(Bytes.toBytes(i * 5))); t.append(new DataByteArray(Bytes.toBytes(i * 10.0F))); t.append(new DataByteArray(Bytes.toBytes(i * 15.0D))); t.append(new DataByteArray(Bytes.toBytes(i))); t.append(new DataByteArray(Bytes.toBytes( i % 2 == 0))); t.append(new DataByteArray(Bytes.toBytes(i))); list.add(t);
case DataType.BYTEARRAY: byte[] bytes = PDataType.fromTypeId(PBinary.INSTANCE.getSqlType()).toBytes(object); tuple.set(i, new DataByteArray(bytes, 0, bytes.length)); break; case DataType.CHARARRAY:
private static Object readBytes(DataInput in, int size) throws IOException { byte[] ba = new byte[size]; in.readFully(ba); return new DataByteArray(ba); }
private static void readField(ArrayList<Object> protoTuple, byte[] buf, int start, int end) { if (start == end) { // NULL value protoTuple.add(null); } else { protoTuple.add(new DataByteArray(buf, start, end)); } }
protected DataByteArray bloomOut() throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(vSize / 8); DataOutputStream dos = new DataOutputStream(baos); filter.write(dos); return new DataByteArray(baos.toByteArray()); }
/** * This is the default initializer, which returns an empty DataByteArray. * * @return the initialized RubyDataByteArray */ @JRubyMethod @SuppressWarnings("deprecation") public RubyDataByteArray initialize() { internalDBA = new DataByteArray(); return this; }
public static void main(String[] args){ String s = "bla"; DataByteArray dba = new DataByteArray(); dba.set(s.getBytes()); System.out.println(dba.toString()); } }
@Override public DataByteArray exec(Tuple input) throws IOException { return new DataByteArray(extent(input).asBinary().array()); } }
@Override public DataByteArray read(DataByteArray reuse) { byte[] bytes = column.nextBinary().getBytes(); return new DataByteArray(bytes); } }
@Override public Tuple getNext() throws IOException { byte[] bytes = getNextBinaryValue(typeRef); return bytes != null ? tupleFactory.newTuple(new DataByteArray(bytes)) : null; }
@Override public Tuple exec(Tuple input) throws IOException { return TupleFactory.getInstance().newTuple( new DataByteArray(convexHull(input).asBinary().array())); } }
@Override public DataByteArray exec(Tuple input) throws IOException { Geometry geom = null; try { Object v = input.get(0); geom = GEOMETRY_PARSER.parseGeom(v); Geometry boundary = geom.getBoundary(); return new DataByteArray(WKB_WRITER.write(boundary)); } catch (ExecException e) { throw new GeoException(geom, e); } }