// many entries will have no hash keys. Reuse a static value for that
if (hashKeys == null || hashKeys.isEmpty()) {
return SERIALIZED_EMPTY_HASH_KEYS;
}
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();
}