/** * Implementation note: we currently chose the same format between {@link NestedMapsStateTable} and * {@link CopyOnWriteStateTable}. * * <p>{@link NestedMapsStateTable} could naturally support a kind of * prefix-compressed format (grouping by namespace, writing the namespace only once per group instead for each * mapping). We might implement support for different formats later (tailored towards different state table * implementations). */ @Override public void writeStateInKeyGroup(@Nonnull DataOutputView dov, int keyGroupId) throws IOException { final Map<N, Map<K, S>> keyGroupMap = owningStateTable.getMapForKeyGroup(keyGroupId); if (null != keyGroupMap) { Map<N, Map<K, S>> filteredMappings = filterMappingsInKeyGroupIfNeeded(keyGroupMap); dov.writeInt(countMappingsInKeyGroup(filteredMappings)); for (Map.Entry<N, Map<K, S>> namespaceEntry : filteredMappings.entrySet()) { final N namespace = namespaceEntry.getKey(); final Map<K, S> namespaceMap = namespaceEntry.getValue(); for (Map.Entry<K, S> keyEntry : namespaceMap.entrySet()) { writeElement(namespace, keyEntry, dov); } } } else { dov.writeInt(0); } }
/** * Implementation note: we currently chose the same format between {@link NestedMapsStateTable} and * {@link CopyOnWriteStateTable}. * * <p>{@link NestedMapsStateTable} could naturally support a kind of * prefix-compressed format (grouping by namespace, writing the namespace only once per group instead for each * mapping). We might implement support for different formats later (tailored towards different state table * implementations). */ @Override public void writeStateInKeyGroup(@Nonnull DataOutputView dov, int keyGroupId) throws IOException { final Map<N, Map<K, S>> keyGroupMap = owningStateTable.getMapForKeyGroup(keyGroupId); if (null != keyGroupMap) { Map<N, Map<K, S>> filteredMappings = filterMappingsInKeyGroupIfNeeded(keyGroupMap); dov.writeInt(countMappingsInKeyGroup(filteredMappings)); for (Map.Entry<N, Map<K, S>> namespaceEntry : filteredMappings.entrySet()) { final N namespace = namespaceEntry.getKey(); final Map<K, S> namespaceMap = namespaceEntry.getValue(); for (Map.Entry<K, S> keyEntry : namespaceMap.entrySet()) { writeElement(namespace, keyEntry, dov); } } } else { dov.writeInt(0); } }