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
Modifier and TypeClassDescriptionstatic class
static interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ColumnSource[]
The keys for our hash entries, for the old alternative smaller table.protected ImmutableIntArraySource
The state value for the bucket, parallel to alternateKeySources (the state is an output row key for the aggregation).protected int
The 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 int
protected static final int
Our state value used when nothing is there.protected boolean
Should we rehash the entire table fully (true
) or incrementally (false
)?protected int
The 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 ImmutableIntArraySource
The state value for the bucket, parallel to mainKeySources (the state is an output row key for the aggregation).protected MutableInt
State variables that exist as part of the update.protected long
protected WritableIntChunk<RowKeys>
protected final IntegerArraySource
Used as a row redirection for the output key sources, updated using the mainInsertMask to identify the main vs.protected int
How much of the alternate sources are necessary to rehash?protected int
The number of slots in our table.static final int
-
Constructor Summary
ModifierConstructorDescriptionprotected
IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase
(ColumnSource<?>[] tableKeySources, int tableSize, double maximumLoadFactor) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(@NotNull SafeCloseable bc, @NotNull RowSequence rowSequence, @NotNull ColumnSource<?>[] sources, @NotNull MutableInt nextOutputPosition, @NotNull WritableIntChunk<RowKeys> outputPositions) protected abstract void
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.void
Allow our managers to do a little bit of work at the very start of the update cycle.protected abstract void
build
(RowSequence rowSequence, Chunk<Values>[] sourceKeyChunks) protected void
buildTable
(IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildContext bc, RowSequence buildRows, ColumnSource<?>[] buildSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.BuildHandler buildHandler) protected void
boolean
doRehash
(MutableInt rehashCredits, int nextChunkSize) void
findModifications
(@NotNull SafeCloseable pc, @NotNull RowSequence rowSequence, @NotNull ColumnSource<?>[] sources, @NotNull WritableIntChunk<RowKeys> outputPositions) abstract int
findPositionForKey
(Object key) protected int
hashToTableLocation
(int hash) protected int
hashToTableLocationAlternate
(int hash) makeAggregationStateBuildContext
(ColumnSource<?>[] buildSources, long maxSize) makeProbeContext
(ColumnSource<?>[] buildSources, long maxSize) final int
protected abstract void
protected abstract void
probe
(RowSequence chunkOk, Chunk[] sourceKeyChunks) protected void
probeTable
(TypedHasherUtil.BuildOrProbeContext.ProbeContext pc, RowSequence probeRows, boolean usePrev, ColumnSource<?>[] probeSources, IncrementalChunkedOperatorAggregationStateManagerOpenAddressedBase.ProbeHandler handler) protected abstract void
rehashInternalFull
(int oldSize) protected abstract int
rehashInternalPartial
(int numEntriesToRehash) boolean
rehashRequired
(int nextChunkSize) void
remove
(@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:
makeProbeContext
in 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:IncrementalOperatorAggregationStateManager
Allow 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:
beginUpdateCycle
in 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:
remove
in interfaceIncrementalOperatorAggregationStateManager
-
findModifications
public void findModifications(@NotNull @NotNull SafeCloseable pc, @NotNull @NotNull RowSequence rowSequence, @NotNull @NotNull ColumnSource<?>[] sources, @NotNull @NotNull WritableIntChunk<RowKeys> outputPositions) - Specified by:
findModifications
in interfaceIncrementalOperatorAggregationStateManager
-
startTrackingPrevValues
public void startTrackingPrevValues()- Specified by:
startTrackingPrevValues
in interfaceIncrementalOperatorAggregationStateManager
-