}
ByteArrayOutputStream bos = new ByteArrayOutputStream();
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();
}