class HortonworksEncodedSchemaReferenceWriter implements SchemaAccessWriter {

    @Override
    public void writeHeader(final RecordSchema schema, final OutputStream out) throws IOException {
        final SchemaIdentifier identifier = schema.getIdentifier();
        final Long id = identifier.getIdentifier().getAsLong();
        final Integer version = identifier.getVersion().getAsInt();

        // This decoding follows the pattern that is provided for serializing data by the Hortonworks Schema Registry serializer
        // as it is provided at:
        // https://github.com/hortonworks/registry/blob/master/schema-registry/serdes/src/main/java/com/hortonworks/registries/schemaregistry/serdes/avro/AvroSnapshotSerializer.java
        final ByteBuffer bb = ByteBuffer.allocate(13);
        bb.put((byte) LATEST_PROTOCOL_VERSION);
        bb.putLong(id);
        bb.putInt(version);

        out.write(bb.array());
    }

}