/** * Creates a new {@link NestedMapsStateTable} for the given key context and meta info. * * @param keyContext the key context. * @param metaInfo the meta information for this state table. */ public NestedMapsStateTable(InternalKeyContext<K> keyContext, RegisteredKeyValueStateBackendMetaInfo<N, S> metaInfo) { super(keyContext, metaInfo); this.keyGroupOffset = keyContext.getKeyGroupRange().getStartKeyGroup(); @SuppressWarnings("unchecked") Map<N, Map<K, S>>[] state = (Map<N, Map<K, S>>[]) new Map[keyContext.getKeyGroupRange().getNumberOfKeyGroups()]; this.state = state; }
/** * Creates a new {@link NestedMapsStateTable} for the given key context and meta info. * * @param keyContext the key context. * @param metaInfo the meta information for this state table. */ public NestedMapsStateTable(InternalKeyContext<K> keyContext, RegisteredKeyValueStateBackendMetaInfo<N, S> metaInfo) { super(keyContext, metaInfo); this.keyGroupOffset = keyContext.getKeyGroupRange().getStartKeyGroup(); @SuppressWarnings("unchecked") Map<N, Map<K, S>>[] state = (Map<N, Map<K, S>>[]) new Map[keyContext.getKeyGroupRange().getNumberOfKeyGroups()]; this.state = state; }
/** * Creates a new {@link NestedMapsStateTable} for the given key context and meta info. * * @param keyContext the key context. * @param metaInfo the meta information for this state table. */ public NestedMapsStateTable(InternalKeyContext<K> keyContext, RegisteredKeyedBackendStateMetaInfo<N, S> metaInfo) { super(keyContext, metaInfo); this.keyGroupOffset = keyContext.getKeyGroupRange().getStartKeyGroup(); @SuppressWarnings("unchecked") Map<N, Map<K, S>>[] state = (Map<N, Map<K, S>>[]) new Map[keyContext.getKeyGroupRange().getNumberOfKeyGroups()]; this.state = state; }
/** * Creates a new {@link NestedMapsStateTable} for the given key context and meta info. * * @param keyContext the key context. * @param metaInfo the meta information for this state table. */ public NestedMapsStateTable(InternalKeyContext<K> keyContext, RegisteredKeyedBackendStateMetaInfo<N, S> metaInfo) { super(keyContext, metaInfo); this.keyGroupOffset = keyContext.getKeyGroupRange().getStartKeyGroup(); @SuppressWarnings("unchecked") Map<N, Map<K, S>>[] state = (Map<N, Map<K, S>>[]) new Map[keyContext.getKeyGroupRange().getNumberOfKeyGroups()]; this.state = state; }
final KeyGroupRange keyGroupRange = owningStateTable.keyContext.getKeyGroupRange(); final int totalKeyGroups = owningStateTable.keyContext.getNumberOfKeyGroups(); final int baseKgIdx = keyGroupRange.getStartKeyGroup();
final KeyGroupRange keyGroupRange = owningStateTable.keyContext.getKeyGroupRange(); final int totalKeyGroups = owningStateTable.keyContext.getNumberOfKeyGroups(); final int baseKgIdx = keyGroupRange.getStartKeyGroup();
@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); } }
final InternalKeyContext<K> keyContext = owningStateTable.keyContext; final int numberOfKeyGroups = keyContext.getNumberOfKeyGroups(); final KeyGroupRange keyGroupRange = keyContext.getKeyGroupRange(); ElementWriterFunction<CopyOnWriteStateTable.StateTableEntry<K, N, S>> elementWriterFunction = (element, dov) -> {
final InternalKeyContext<K> keyContext = owningStateTable.keyContext; final int numberOfKeyGroups = keyContext.getNumberOfKeyGroups(); final KeyGroupRange keyGroupRange = keyContext.getKeyGroupRange(); ElementWriterFunction<CopyOnWriteStateTable.StateTableEntry<K, N, S>> elementWriterFunction = (element, dov) -> {