return ((Timestamp) o).getTime();
} else if (o instanceof BytesWritable) {
BytesWritable bw = (BytesWritable) o;
return ByteBuffer.wrap(bw.getBytes(), 0, bw.getLength());
} else if (o instanceof BlobRef) {
BlobRef br = (BlobRef) o;
// If blob data is stored in an external .lob file, save the ref file
// as Avro bytes. If materialized inline, save blob data as Avro bytes.
byte[] bytes = br.isExternal() ? br.toString().getBytes() : br.getData();
return ByteBuffer.wrap(bytes);
} else if (o instanceof ClobRef) {
throw new UnsupportedOperationException("ClobRef not supported");
}
// primitive types (Integer, etc) are left unchanged