@Override public void writeMappingsInKeyGroup(DataOutputView dov, int keyGroupId) throws IOException { if (null == keyGroupOffsets) { partitionEntriesByKeyGroup(); } final CopyOnWriteStateTable.StateTableEntry<K, N, S>[] groupedOut = snapshotData; KeyGroupRange keyGroupRange = owningStateTable.keyContext.getKeyGroupRange(); int keyGroupOffsetIdx = keyGroupId - keyGroupRange.getStartKeyGroup() - 1; int startOffset = keyGroupOffsetIdx < 0 ? 0 : keyGroupOffsets[keyGroupOffsetIdx]; int endOffset = keyGroupOffsets[keyGroupOffsetIdx + 1]; // write number of mappings in key-group dov.writeInt(endOffset - startOffset); // write mappings for (int i = startOffset; i < endOffset; ++i) { CopyOnWriteStateTable.StateTableEntry<K, N, S> toWrite = groupedOut[i]; groupedOut[i] = null; // free asap for GC localNamespaceSerializer.serialize(toWrite.namespace, dov); localKeySerializer.serialize(toWrite.key, dov); localStateSerializer.serialize(toWrite.state, dov); } }
@Override public void writeMappingsInKeyGroup(DataOutputView dov, int keyGroupId) throws IOException { if (null == keyGroupOffsets) { partitionEntriesByKeyGroup(); } final CopyOnWriteStateTable.StateTableEntry<K, N, S>[] groupedOut = snapshotData; KeyGroupRange keyGroupRange = owningStateTable.keyContext.getKeyGroupRange(); int keyGroupOffsetIdx = keyGroupId - keyGroupRange.getStartKeyGroup() - 1; int startOffset = keyGroupOffsetIdx < 0 ? 0 : keyGroupOffsets[keyGroupOffsetIdx]; int endOffset = keyGroupOffsets[keyGroupOffsetIdx + 1]; // write number of mappings in key-group dov.writeInt(endOffset - startOffset); // write mappings for (int i = startOffset; i < endOffset; ++i) { CopyOnWriteStateTable.StateTableEntry<K, N, S> toWrite = groupedOut[i]; groupedOut[i] = null; // free asap for GC localNamespaceSerializer.serialize(toWrite.namespace, dov); localKeySerializer.serialize(toWrite.key, dov); localStateSerializer.serialize(toWrite.state, dov); } }