public static <T> int encodeMultiMap(String mapName, Map<String,List<T>> map, ByteBuffer buffer) {
        if (map.isEmpty()) return 0;

        byte[] utf8 = Utf8.toBytes(mapName);
        buffer.putInt(utf8.length);
        buffer.put(utf8);
        buffer.putInt(countEntries(map));
        for (Map.Entry<String, List<T>> property : map.entrySet()) {
            String key = property.getKey();
            for (Object value : property.getValue()) {
                utf8 = Utf8.toBytes(key);
                buffer.putInt(utf8.length);
                buffer.put(utf8);
                utf8 = getUtf8(value);
                buffer.putInt(utf8.length);
                buffer.put(utf8);
            }
        }

        return 1;
    }
Encodes a multi-map as binary.
Does nothing if the value is null.

Returns the number of maps encoded - 0 or 1
container-search/src/main/java/com/yahoo/fs4/MapEncoder.java