try {
// Write the schema hash
os.write(STREAM_EVENT_SCHEMA.getSchemaHash().toByteArray());
StreamEventDataCodec.encode(event, encoder);
encoder.writeLong(timestamp);
return os.toByteArray();
} catch (IOException e) {
// It should never happens, otherwise something very wrong.
throw Throwables.propagate(e);