@Override public byte[] getBytes(AvroGenericRecordWritable writable) {
      GenericRecord record = writable.getRecord();
      byte[] valueBytes = null;
      try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        BinaryEncoder be = EncoderFactory.get().directBinaryEncoder(out, null);
        gdw.setSchema(record.getSchema());
        gdw.write(record, be);
        out.flush();
        valueBytes = out.toByteArray();
      } catch (IOException e) {
        Throwables.propagate(new SerDeException(e));
      }
      return valueBytes;
    }
Class that encapsulate the logic of serialize and deserialize bytes array to/from the delegate writable format.

@param <K> delegate writable class.
kafka-handler/src/java/org/apache/hadoop/hive/kafka/KafkaSerDe.java