class HortonworksEncodedSchemaReferenceStrategy implements SchemaAccessStrategy {

    @Override
    public RecordSchema getSchema(final Map<String, String> variables, final InputStream contentStream, final RecordSchema readSchema) throws SchemaNotFoundException, IOException {
        final byte[] buffer = new byte[13];
        try {
            StreamUtils.fillBuffer(contentStream, buffer);
        } catch (final IOException ioe) {
            throw new SchemaNotFoundException("Could not read first 13 bytes from stream", ioe);
        }

        // This encoding 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.wrap(buffer);
        final int protocolVersion = bb.get();
        if (protocolVersion != 1) {
            throw new SchemaNotFoundException("Schema Encoding appears to be of an incompatible version. The latest known Protocol is Version "
                + LATEST_PROTOCOL_VERSION + " but the data was encoded with version " + protocolVersion + " or was not encoded with this data format");
        }

        final long schemaId = bb.getLong();
        final int schemaVersion = bb.getInt();

        final SchemaIdentifier schemaIdentifier = SchemaIdentifier.builder().id(schemaId).version(schemaVersion).build();
        return schemaRegistry.retrieveSchema(schemaIdentifier);
    }

    public  HortonworksEncodedSchemaReferenceStrategy(final SchemaRegistry schemaRegistry);

}