public static BlobDatum createBlob(byte[] encoded) { return new BlobDatum(encoded); }
@Override public boolean equals(Object obj) { if (obj instanceof BlobDatum) { BlobDatum other = (BlobDatum) obj; initFromBytes(); other.initFromBytes(); return Arrays.equals(this.val, other.val); } return false; }
public static BlobDatum createBlob(byte[] encoded, int offset, int length) { return new BlobDatum(encoded, offset, length); }
@Override public boolean equals(Object obj) { if (obj instanceof BlobDatum) { BlobDatum other = (BlobDatum) obj; initFromBytes(); other.initFromBytes(); return Arrays.equals(this.val, other.val); } return false; }
public static BlobDatum createBlob(byte[] encoded, int offset, int length) { return new BlobDatum(encoded, offset, length); }
@Override public int hashCode() { initFromBytes(); bb.rewind(); return bb.hashCode(); }
public static BlobDatum createBlob(byte[] encoded) { return new BlobDatum(encoded); }
@Override public double asFloat8() { initFromBytes(); bb.rewind(); return bb.getDouble(); }
public static BlobDatum createBlob(String plainString) { return new BlobDatum(Base64.encodeBase64(plainString.getBytes())); }
@Override public byte[] asByteArray() { initFromBytes(); bb.rewind(); return bb.array(); }
public static BlobDatum createBlob(String plainString) { return new BlobDatum(Base64.encodeBase64(plainString.getBytes())); }
@Override public float asFloat4() { initFromBytes(); bb.rewind(); return bb.getFloat(); }
@Override final public void addBinary(Binary value) { parent.add(new BlobDatum(ByteBuffer.wrap(value.getBytes()))); } }
@Override public double asFloat8() { initFromBytes(); bb.rewind(); return bb.getDouble(); }
@Override final public void addBinary(Binary value) { parent.add(new BlobDatum(ByteBuffer.wrap(value.getBytes()))); } }
@Override public long asInt8() { initFromBytes(); bb.rewind(); return bb.getLong(); }
@Override final public void addBinary(Binary value) { parent.add(new BlobDatum(ByteBuffer.wrap(value.getBytes()))); } }
@Override public int asInt4() { initFromBytes(); bb.rewind(); return bb.getInt(); }
private Datum convertBytes(Object value, TajoDataTypes.Type tajoType, DataType dataType) { ByteBuffer buffer = (ByteBuffer)value; byte[] bytes = new byte[buffer.capacity()]; buffer.get(bytes, 0, bytes.length); switch (tajoType) { case PROTOBUF: try { ProtobufDatumFactory factory = ProtobufDatumFactory.get(dataType.getCode()); Message.Builder builder = factory.newBuilder(); builder.mergeFrom(bytes); return ProtobufDatumFactory.createDatum(builder); } catch (InvalidProtocolBufferException e) { throw new RuntimeException(e); } default: return new BlobDatum(bytes); } }
@Override public byte asByte() { initFromBytes(); bb.rewind(); return bb.get(); }