use of org.apache.cassandra.io.util.OutputBuffer in project eiger by wlloyd.
the class SerDeUtils method serializeWithSchema.
/**
* Serializes a single object along with its Schema. NB: For performance critical areas, it is <b>much</b>
* more efficient to store the Schema independently.
* @param o Object to serialize
*/
public static <T extends SpecificRecord> ByteBuffer serializeWithSchema(T o) throws IOException {
OutputBuffer buff = new OutputBuffer();
BinaryEncoder enc = new BinaryEncoder(buff);
enc.writeString(new Utf8(o.getSchema().toString()));
SpecificDatumWriter<T> writer = new SpecificDatumWriter<T>(o.getSchema());
writer.write(o, enc);
enc.flush();
return ByteBuffer.wrap(buff.asByteArray());
}
use of org.apache.cassandra.io.util.OutputBuffer in project eiger by wlloyd.
the class SerDeUtils method serialize.
/**
* Serializes a single object.
* @param o Object to serialize
*/
public static <T extends SpecificRecord> ByteBuffer serialize(T o) throws IOException {
OutputBuffer buff = new OutputBuffer();
BinaryEncoder enc = new BinaryEncoder(buff);
SpecificDatumWriter<T> writer = new SpecificDatumWriter<T>(o.getSchema());
writer.write(o, enc);
enc.flush();
return ByteBuffer.wrap(buff.asByteArray());
}
Aggregations