Class IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase
java.lang.Object
io.deephaven.engine.table.impl.by.IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase
- All Implemented Interfaces:
IncrementalOperatorAggregationStateManager
public abstract class IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase
extends Object
implements IncrementalOperatorAggregationStateManager
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ColumnSource[]The keys for our hash entries, for the old alternative smaller table.protected ImmutableIntArraySourceThe state value for the bucket, parallel to alternateKeySources (the state is an output row key for the aggregation).protected intThe number of slots in our alternate table, to start with "1" is a lie, but rehashPointer is zero; so our location value is positive and can be compared against rehashPointer safelyprotected AlternatingColumnSource[]Output alternating column sources.static final intprotected static final intOur state value used when nothing is there.protected booleanShould we rehash the entire table fully (true) or incrementally (false)?protected intThe mask for insertion into the main table (this tells our alternating column sources which of the two sources to access for a given key).protected final WritableColumnSource[]The keys for our hash entries.protected ImmutableIntArraySourceThe state value for the bucket, parallel to mainKeySources (the state is an output row key for the aggregation).protected MutableIntState variables that exist as part of the update.protected longprotected WritableIntChunk<RowKeys>protected final IntegerArraySourceUsed as a row redirection for the output key sources, updated using the mainInsertMask to identify the main vs.protected intHow much of the alternate sources are necessary to rehash?protected intThe number of slots in our table.static final int -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedIncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase(ColumnSource<?>[] tableKeySources, int tableSize, double maximumLoadFactor) -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(@NotNull SafeCloseable bc, @NotNull RowSequence rowSequence, @NotNull ColumnSource<?>[] sources, @NotNull MutableInt nextOutputPosition, @NotNull WritableIntChunk<RowKeys> outputPositions) protected abstract voidAfter creating the new alternate key states, advise the derived classes, so they can cast them to the typed versions of the column source and adjust the derived class pointers.voidAllow our managers to do a little bit of work at the very start of the update cycle.protected abstract voidbuild(RowSequence rowSequence, Chunk<Values>[] sourceKeyChunks) protected voidbuildTable(IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildContext bc, RowSequence buildRows, ColumnSource<?>[] buildSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildHandler buildHandler) protected voidbooleandoRehash(MutableInt rehashCredits, int nextChunkSize) voidfindModifications(@NotNull SafeCloseable pc, @NotNull RowSequence rowSequence, @NotNull ColumnSource<?>[] sources, @NotNull WritableIntChunk<RowKeys> outputPositions) abstract intfindPositionForKey(Object key) protected inthashToTableLocation(int hash) protected inthashToTableLocationAlternate(int hash) makeAggregationStateBuildContext(ColumnSource<?>[] buildSources, long maxSize) makeProbeContext(ColumnSource<?>[] buildSources, long maxSize) final intprotected abstract voidprotected abstract voidprobe(RowSequence chunkOk, Chunk[] sourceKeyChunks) protected voidprobeTable(TypedHasherUtil.BuildOrProbeContext.ProbeContext pc, RowSequence probeRows, boolean usePrev, ColumnSource<?>[] probeSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.ProbeHandler handler) protected abstract voidrehashInternalFull(int oldSize) protected abstract intrehashInternalPartial(int numEntriesToRehash) booleanrehashRequired(int nextChunkSize) voidremove(@NotNull SafeCloseable pc, @NotNull RowSequence rowSequence, @NotNull ColumnSource<?>[] sources, @NotNull WritableIntChunk<RowKeys> outputPositions) void
-
Field Details
-
CHUNK_SIZE
public static final int CHUNK_SIZE -
tableSize
protected int tableSizeThe number of slots in our table. -
alternateTableSize
protected int alternateTableSizeThe number of slots in our alternate table, to start with "1" is a lie, but rehashPointer is zero; so our location value is positive and can be compared against rehashPointer safely -
fullRehash
protected boolean fullRehashShould we rehash the entire table fully (true) or incrementally (false)? -
rehashPointer
protected int rehashPointerHow much of the alternate sources are necessary to rehash? -
numEntries
protected long numEntries -
mainKeySources
The keys for our hash entries. -
alternateKeySources
The keys for our hash entries, for the old alternative smaller table. -
EMPTY_OUTPUT_POSITION
protected static final int EMPTY_OUTPUT_POSITIONOur state value used when nothing is there.- See Also:
-
mainOutputPosition
The state value for the bucket, parallel to mainKeySources (the state is an output row key for the aggregation). -
alternateOutputPosition
The state value for the bucket, parallel to alternateKeySources (the state is an output row key for the aggregation). -
outputPositionToHashSlot
Used as a row redirection for the output key sources, updated using the mainInsertMask to identify the main vs. alternate values. -
nextOutputPosition
State variables that exist as part of the update. -
outputPositions
-
alternatingColumnSources
Output alternating column sources. -
mainInsertMask
protected int mainInsertMaskThe mask for insertion into the main table (this tells our alternating column sources which of the two sources to access for a given key). -
UNKNOWN_ROW
static final int UNKNOWN_ROW- See Also:
-
-
Constructor Details
-
IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase
protected IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase(ColumnSource<?>[] tableKeySources, int tableSize, double maximumLoadFactor)
-
-
Method Details
-
maxTableSize
public final int maxTableSize() -
build
-
makeProbeContext
public TypedHasherUtil.BuildOrProbeContext.ProbeContext makeProbeContext(ColumnSource<?>[] buildSources, long maxSize) - Specified by:
makeProbeContextin interfaceIncrementalOperatorAggregationStateManager
-
buildTable
protected void buildTable(IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildContext bc, RowSequence buildRows, ColumnSource<?>[] buildSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildHandler buildHandler) -
migrateFront
protected abstract void migrateFront() -
probeTable
protected void probeTable(TypedHasherUtil.BuildOrProbeContext.ProbeContext pc, RowSequence probeRows, boolean usePrev, ColumnSource<?>[] probeSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.ProbeHandler handler) -
doRehash
- Parameters:
rehashCredits- the number of entries this operation has rehashed (input/output)nextChunkSize- the size of the chunk we are processing- Returns:
- true if a front migration is required
-
adviseNewAlternate
protected abstract void adviseNewAlternate()After creating the new alternate key states, advise the derived classes, so they can cast them to the typed versions of the column source and adjust the derived class pointers. -
clearAlternate
protected void clearAlternate() -
rehashInternalPartial
protected abstract int rehashInternalPartial(int numEntriesToRehash) - Parameters:
numEntriesToRehash- number of entries to rehash into main table- Returns:
- actual number of entries rehashed
-
rehashInternalFull
protected abstract void rehashInternalFull(int oldSize) -
rehashRequired
public boolean rehashRequired(int nextChunkSize) -
hashToTableLocation
protected int hashToTableLocation(int hash) -
hashToTableLocationAlternate
protected int hashToTableLocationAlternate(int hash) -
findPositionForKey
-
makeAggregationStateBuildContext
-
add
public void add(@NotNull @NotNull SafeCloseable bc, @NotNull @NotNull RowSequence rowSequence, @NotNull @NotNull ColumnSource<?>[] sources, @NotNull @NotNull MutableInt nextOutputPosition, @NotNull @NotNull WritableIntChunk<RowKeys> outputPositions) -
getKeyHashTableSources
-
beginUpdateCycle
public void beginUpdateCycle()Description copied from interface:IncrementalOperatorAggregationStateManagerAllow our managers to do a little bit of work at the very start of the update cycle. We have this method so that even if nothing is to be done, we rehash a little bit on each cycle to avoid always rehashing when there is other work to be done.- Specified by:
beginUpdateCyclein interfaceIncrementalOperatorAggregationStateManager
-
probe
-
remove
public void remove(@NotNull @NotNull SafeCloseable pc, @NotNull @NotNull RowSequence rowSequence, @NotNull @NotNull ColumnSource<?>[] sources, @NotNull @NotNull WritableIntChunk<RowKeys> outputPositions) - Specified by:
removein interfaceIncrementalOperatorAggregationStateManager
-
findModifications
public void findModifications(@NotNull @NotNull SafeCloseable pc, @NotNull @NotNull RowSequence rowSequence, @NotNull @NotNull ColumnSource<?>[] sources, @NotNull @NotNull WritableIntChunk<RowKeys> outputPositions) - Specified by:
findModificationsin interfaceIncrementalOperatorAggregationStateManager
-
startTrackingPrevValues
public void startTrackingPrevValues()- Specified by:
startTrackingPrevValuesin interfaceIncrementalOperatorAggregationStateManager
-