Encoder encoder = new BinaryEncoder(bos);
encoder.writeInt(hashKeys.size());
for (Map.Entry<String, Integer> entry : hashKeys.entrySet()) {
encoder.writeString(entry.getKey()).writeInt(entry.getValue());
}
encoder.writeInt(0); // per Avro spec, end with a (block of length) zero
return bos.toByteArray();
}
public static Map<String, Integer> deserializeHashKeys(byte[] bytes) throws IOException {
return deserializeHashKeys(bytes, 0, bytes.length);