@Test public void testHeader() throws IOException { final HortonworksEncodedSchemaReferenceWriter writer = new HortonworksEncodedSchemaReferenceWriter(); final RecordSchema schema = new SimpleRecordSchema(Collections.emptyList(), SchemaIdentifier.builder().name("name").id( 48L).version( 2).build()); final byte[] header; try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) { writer.writeHeader(schema, baos); header = baos.toByteArray(); } try (final DataInputStream dis = new DataInputStream(new ByteArrayInputStream(header))) { assertEquals(1, dis.read()); assertEquals(48, dis.readLong()); assertEquals(2, dis.readInt()); assertEquals(-1, dis.read()); } }
@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(); final ByteBuffer bb = ByteBuffer.allocate(13); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); out.write(bb.array()); }
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(); final ByteBuffer bb = ByteBuffer.allocate(13); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); out.write(bb.array()); } }
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(); final ByteBuffer bb = ByteBuffer.allocate(13); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); out.write(bb.array()); }  }
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(); final ByteBuffer bb = ByteBuffer.allocate(13); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); out.write(bb.array()); }  @Override void writeHeader(final RecordSchema schema, final OutputStream out); @Override Map<String, String> getAttributes(final RecordSchema schema); @Override void validateSchema(RecordSchema schema); @Override Set<SchemaField> getRequiredSchemaFields(); }
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(); final ByteBuffer bb = ByteBuffer.allocate(13); bb.put((byte) LATEST_PROTOCOL_VERSION); bb.putLong(id); bb.putInt(version); out.write(bb.array()); }  @Override void writeHeader(final RecordSchema schema, final OutputStream out); @Override Map<String, String> getAttributes(final RecordSchema schema); @Override void validateSchema(RecordSchema schema); @Override Set<SchemaField> getRequiredSchemaFields();  }