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.voidbeginUpdateCycle(long step) Allow 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) voidfindPositionsForKeys(@NotNull Chunk<? extends Values>[] keyChunks, @NotNull WritableLongChunk<RowKeys> positions) Search the table for a chunk of keys, without changing it.protected inthashToTableLocation(int hash) protected inthashToTableLocationAlternate(int hash) longThe step of the last update cycle thatbeganchanging the hash table, set before its first change.protected abstract voidlookup(RowSequence rowSequence, Chunk[] sourceKeyChunks, WritableLongChunk<RowKeys> outputPositions) 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(long step) 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. Called before any change to the hash table in the cycle.- Specified by:
beginUpdateCyclein interfaceIncrementalOperatorAggregationStateManager- Parameters:
step- the clock step of the update cycle
-
lastStateChangeStep
public long lastStateChangeStep()Description copied from interface:IncrementalOperatorAggregationStateManagerThe step of the last update cycle thatbeganchanging the hash table, set before its first change. A cycle that has rehash work left, adds rows or modifies keys may change the hash table, so it records its step; a cycle that only removes rows or modifies other columns leaves the hash table unchanged, and records nothing. A reader on another thread reads the clock's step before its reads, and this after them behind afence. Compared to the reader's step, this is:- less: no cycle at or after the reader's step changed the hash table during the reads, so they saw its state at that step, which is both its previous and current state;
- equal: the reader's step's cycle has begun changing the hash table, so the reads may not have seen its previous state; they saw its current state if the reader waited for that cycle to finish;
- greater: a later cycle has begun changing the hash table, so the reads may not have seen either state at the reader's step.
- Specified by:
lastStateChangeStepin interfaceIncrementalOperatorAggregationStateManager- Returns:
- the step of the last update cycle that began changing the hash table, or
QueryConstants.NULL_LONGif none has
-
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
-
lookup
protected abstract void lookup(RowSequence rowSequence, Chunk[] sourceKeyChunks, WritableLongChunk<RowKeys> outputPositions) -
findPositionsForKeys
public void findPositionsForKeys(@NotNull @NotNull Chunk<? extends Values>[] keyChunks, @NotNull @NotNull WritableLongChunk<RowKeys> positions) Search the table for a chunk of keys, without changing it. The search keeps no state in this manager, so that any number of readers may search at once.
-