Class LongRecordingUpdateByOperator
java.lang.Object
com.illumon.iris.db.v2.updateby.internal.LongRecordingUpdateByOperator
- All Implemented Interfaces:
UpdateByOperator
An operator that simply remembers the current chunks during the add and reprocess phases.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
UpdateByOperator.UpdateContext -
Field Summary
Fields inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
ZERO_LENGTH_OP_ARRAY -
Constructor Summary
ConstructorsConstructorDescriptionLongRecordingUpdateByOperator(String inputColumnName, String[] affectingColumns, ColumnSource<?> columnSource) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChunk(UpdateByOperator.UpdateContext context, Chunk<Attributes.Values> values, LongChunk<? extends Attributes.KeyIndices> keyChunk, IntChunk<Attributes.KeyIndices> bucketPositions, IntChunk<Attributes.ChunkPositions> startPositions, IntChunk<Attributes.ChunkLengths> runLengths) Add a chunk of bucketed items to the operation.voidaddChunk(UpdateByOperator.UpdateContext updateContext, OrderedKeys inputKeys, LongChunk<Attributes.OrderedKeyIndices> keyChunk, Chunk<Attributes.Values> values, long bucketPosition) Add a chunk of non-bucketed items to the operation.booleanCheck if the update has modified any rows for this operator.voidapplyOutputShift(UpdateByOperator.UpdateContext context, ReadOnlyIndex subIndexToShift, long delta) Apply a shift to the operation.voidapplyShift(UpdateByOperator.UpdateContext updateContext, ReadOnlyIndex prevIndex, IndexShiftData shifted) Apply a shift to the operation.booleanQuery if this operator can process the update normally, or if it can only reprocess.voidfinishFor(UpdateByOperator.UpdateContext updateContext, UpdateBy.UpdateType type) Perform and bookkeeping required at the end of a single part of the update.Get an index of rows that were modified beyond the input set of modifications from the upstream.String[]Get an array of column names that, when modified, affect the result of this computation.longgetCurrentLong(long key) Get the current long value within the underlyingColumnSource.Get the name of the input column this operator depends on.longgetLong(int chunkPosition) Get the long value at the specified position in the currently retained chunk.String[]Get an array of the output column names.Map<String,ColumnSource<?>> Get a map of outputName to outputColumnSourcefor this operation.voidinitializeFor(UpdateByOperator.UpdateContext updateContext, ReadOnlyIndex updateIndex, UpdateBy.UpdateType type) Initialize the context for the specified stage of the update process.voidinitializeForUpdate(UpdateByOperator.UpdateContext ctx, ShiftAwareListener.Update upstream, ReadOnlyIndex resultSourceIndex, boolean usingBuckets, boolean isUpstreamAppendOnly) Initialize the operator for an update cycle.makeUpdateContext(int chunkSize) Make anUpdateByOperator.UpdateContextsuitable for use with non-bucketed updates.voidmodifyChunk(UpdateByOperator.UpdateContext updateContext, LongChunk<Attributes.OrderedKeyIndices> prevKeyChunk, LongChunk<Attributes.OrderedKeyIndices> keyChunk, Chunk<Attributes.Values> prevValuesChunk, Chunk<Attributes.Values> postValuesChunk, long bucketPosition) Modify a chunk of values with the operation.voidonBucketsRemoved(ReadOnlyIndex removedBuckets) Called when some buckets have been completely emptied.voidremoveChunk(UpdateByOperator.UpdateContext updateContext, LongChunk<Attributes.OrderedKeyIndices> keyChunk, Chunk<Attributes.Values> prevValuesChunk, long bucketPosition) Remove a chunk of values from the operation.voidreprocessChunk(UpdateByOperator.UpdateContext updateContext, OrderedKeys chunkOk, Chunk<Attributes.Values> values, LongChunk<? extends Attributes.KeyIndices> keyChunk, IntChunk<Attributes.KeyIndices> bucketPositions, IntChunk<Attributes.ChunkPositions> runStartPositions, IntChunk<Attributes.ChunkLengths> runLengths) Reprocess a chunk of data for a bucketed table.voidreprocessChunk(UpdateByOperator.UpdateContext updateContext, OrderedKeys inputKeys, LongChunk<Attributes.OrderedKeyIndices> keyChunk, Chunk<Attributes.Values> valuesChunk, ReadOnlyIndex postUpdateSourceIndex) Reprocess a chunk of data for a non-bucketed table.booleanQuery if the operator requires key values for the current stage.booleanQuery if the operator requires values for the current stage.voidresetForReprocess(UpdateByOperator.UpdateContext context, ReadOnlyIndex sourceIndex, ColumnSource<?> inputSource, long firstUnmodifiedKey) Reset the operator to the state at the `firstModifiedKey` for non-bucketed operation.voidresetForReprocess(UpdateByOperator.UpdateContext context, ReadOnlyIndex bucketIndex, ColumnSource<?> inputSource, long bucketPosition, long firstUnmodifiedKey) Reset the operator to the state at the `firstModifiedKey` for the specified bucket.voidsetBucketCapacity(int capacity) Notify the operator of the current maximum bucket.voidsetChunkSize(UpdateByOperator.UpdateContext context, int chunkSize) Set the chunk size to be used for operations.voidIndicate that the operation should start tracking previous values for ticking updates.
-
Constructor Details
-
LongRecordingUpdateByOperator
public LongRecordingUpdateByOperator(@NotNull String inputColumnName, @NotNull String[] affectingColumns, @NotNull ColumnSource<?> columnSource)
-
-
Method Details
-
getLong
public long getLong(int chunkPosition) Get the long value at the specified position in the currently retained chunk.- Parameters:
chunkPosition- the position- Returns:
- the value at the position
-
getCurrentLong
public long getCurrentLong(long key) Get the current long value within the underlyingColumnSource.- Parameters:
key- the key- Returns:
- the current value at the key within the column source.
-
reprocessChunk
public void reprocessChunk(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull OrderedKeys inputKeys, @Nullable LongChunk<Attributes.OrderedKeyIndices> keyChunk, @NotNull Chunk<Attributes.Values> valuesChunk, @NotNull ReadOnlyIndex postUpdateSourceIndex) Description copied from interface:UpdateByOperatorReprocess a chunk of data for a non-bucketed table.- Specified by:
reprocessChunkin interfaceUpdateByOperator- Parameters:
updateContext- the context objectinputKeys- the keys contained in the chunkkeyChunk- aLongChunkcontaining the keys if requested byUpdateByOperator.requiresKeys()or null.valuesChunk- the current chunk of working values.postUpdateSourceIndex- the resulting source index af
-
reprocessChunk
public void reprocessChunk(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull OrderedKeys chunkOk, @NotNull Chunk<Attributes.Values> values, @NotNull LongChunk<? extends Attributes.KeyIndices> keyChunk, @NotNull IntChunk<Attributes.KeyIndices> bucketPositions, @NotNull IntChunk<Attributes.ChunkPositions> runStartPositions, @NotNull IntChunk<Attributes.ChunkLengths> runLengths) Description copied from interface:UpdateByOperatorReprocess a chunk of data for a bucketed table.- Specified by:
reprocessChunkin interfaceUpdateByOperator- Parameters:
updateContext- the context objectchunkOk- the keys contained in the chunkvalues- the current chunk of working values.keyChunk- aLongChunkcontaining the keys.bucketPositions- aIntChunkcontaining the bucket position of each key. Parallel to `keyChunk` and `valuesrunStartPositions- the starting positions of each run within the key and value chunkrunLengths- the run runLengths of each run in the key and value chunks. Parallel to `runStartPositions`
-
makeUpdateContext
Description copied from interface:UpdateByOperatorMake anUpdateByOperator.UpdateContextsuitable for use with non-bucketed updates.- Specified by:
makeUpdateContextin interfaceUpdateByOperator- Parameters:
chunkSize- The expected size of chunks that will be provided during the update,- Returns:
- a new context
-
addChunk
public void addChunk(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull OrderedKeys inputKeys, @Nullable LongChunk<Attributes.OrderedKeyIndices> keyChunk, @NotNull Chunk<Attributes.Values> values, long bucketPosition) Description copied from interface:UpdateByOperatorAdd a chunk of non-bucketed items to the operation.- Specified by:
addChunkin interfaceUpdateByOperator- Parameters:
updateContext- the context objectkeyChunk- a chunk of keys for the rows being added. If the operator returnsfalseforUpdateByOperator.requiresKeys()this will be null.values- the chunk of values for the rows being addedbucketPosition- the group position
-
addChunk
public void addChunk(@NotNull UpdateByOperator.UpdateContext context, @NotNull Chunk<Attributes.Values> values, @NotNull LongChunk<? extends Attributes.KeyIndices> keyChunk, @NotNull IntChunk<Attributes.KeyIndices> bucketPositions, @NotNull IntChunk<Attributes.ChunkPositions> startPositions, @NotNull IntChunk<Attributes.ChunkLengths> runLengths) Description copied from interface:UpdateByOperatorAdd a chunk of bucketed items to the operation.- Specified by:
addChunkin interfaceUpdateByOperator- Parameters:
context- the context objectvalues- the value chunkkeyChunk- a chunk of keys for the rows being addedbucketPositions- a chunk of hash bucket positions for each keystartPositions- the start position of a run within the chunkrunLengths- the runLengths of each run of bucket values
-
setBucketCapacity
public void setBucketCapacity(int capacity) Description copied from interface:UpdateByOperatorNotify the operator of the current maximum bucket.- Specified by:
setBucketCapacityin interfaceUpdateByOperator- Parameters:
capacity- the capacity
-
getInputColumnName
Description copied from interface:UpdateByOperatorGet the name of the input column this operator depends on.- Specified by:
getInputColumnNamein interfaceUpdateByOperator- Returns:
- the name of the input column
-
getAffectingColumnNames
Description copied from interface:UpdateByOperatorGet an array of column names that, when modified, affect the result of this computation.- Specified by:
getAffectingColumnNamesin interfaceUpdateByOperator- Returns:
- an array of column names that affect this operator.
-
getOutputColumnNames
Description copied from interface:UpdateByOperatorGet an array of the output column names.- Specified by:
getOutputColumnNamesin interfaceUpdateByOperator- Returns:
- the output column names.
-
getOutputColumns
Description copied from interface:UpdateByOperatorGet a map of outputName to outputColumnSourcefor this operation.- Specified by:
getOutputColumnsin interfaceUpdateByOperator- Returns:
- a map of output column name to output column source
-
initializeForUpdate
public void initializeForUpdate(@NotNull UpdateByOperator.UpdateContext ctx, @NotNull ShiftAwareListener.Update upstream, @NotNull ReadOnlyIndex resultSourceIndex, boolean usingBuckets, boolean isUpstreamAppendOnly) Description copied from interface:UpdateByOperatorInitialize the operator for an update cycle. This is invoked before any other update processing occurs.- Specified by:
initializeForUpdatein interfaceUpdateByOperator- Parameters:
ctx- the context objectupstream- the upstream update to processresultSourceIndex- the result index of the source tableusingBuckets- if the update is bucketed or notisUpstreamAppendOnly- if the upstream update was detected to be append-only.
-
initializeFor
public void initializeFor(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull ReadOnlyIndex updateIndex, @NotNull UpdateBy.UpdateType type) Description copied from interface:UpdateByOperatorInitialize the context for the specified stage of the update process. This will always be followed by a call to
UpdateByOperator.finishFor(UpdateContext, UpdateType)at the end of each successful update.- Specified by:
initializeForin interfaceUpdateByOperator- Parameters:
updateContext- the context objectupdateIndex- the index of rows associated with the update.type- the type of update being applied
-
finishFor
public void finishFor(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull UpdateBy.UpdateType type) Description copied from interface:UpdateByOperatorPerform and bookkeeping required at the end of a single part of the update. This is always preceded with a call toUpdateByOperator.initializeFor(UpdateContext, ReadOnlyIndex, UpdateType)- Specified by:
finishForin interfaceUpdateByOperator- Parameters:
updateContext- the context objecttype- the type of update being applied
-
getAdditionalModifications
@NotNull public ReadOnlyIndex getAdditionalModifications(@NotNull UpdateByOperator.UpdateContext ctx) Description copied from interface:UpdateByOperatorGet an index of rows that were modified beyond the input set of modifications from the upstream. This is invoked once at the end of a complete update cycle (that is, after all adds, removes, modifies and shifts have been processed) ifUpdateByOperator.anyModified(UpdateContext)has returned true.- Specified by:
getAdditionalModificationsin interfaceUpdateByOperator- Parameters:
ctx- the context object- Returns:
- a
indexof additional rows that were modified
-
anyModified
Description copied from interface:UpdateByOperatorCheck if the update has modified any rows for this operator. This is invoked once at the end of a complete update cycle (that is, after all adds, removes, modifies and shifts have been processed).- Specified by:
anyModifiedin interfaceUpdateByOperator- Parameters:
ctx- the context object- Returns:
- true if the update modified any rows.
-
startTrackingPrev
public void startTrackingPrev()Description copied from interface:UpdateByOperatorIndicate that the operation should start tracking previous values for ticking updates.- Specified by:
startTrackingPrevin interfaceUpdateByOperator
-
requiresKeys
public boolean requiresKeys()Description copied from interface:UpdateByOperatorQuery if the operator requires key values for the current stage. This method will always be invoked after an appropriate invocation ofUpdateByOperator.initializeFor(UpdateContext, ReadOnlyIndex, UpdateType)- Specified by:
requiresKeysin interfaceUpdateByOperator- Returns:
- true if the operator requires keys for this operation
-
requiresValues
Description copied from interface:UpdateByOperatorQuery if the operator requires values for the current stage.- Specified by:
requiresValuesin interfaceUpdateByOperator- Parameters:
ctx- the context object- Returns:
- true if values are required for compuitation
-
canProcessNormalUpdate
Description copied from interface:UpdateByOperatorQuery if this operator can process the update normally, or if it can only reprocess. This method is guaranteed to be invoked afterUpdateByOperator.initializeForUpdate(UpdateContext, ShiftAwareListener.Update, ReadOnlyIndex, boolean, boolean)so the operator is aware of the upstreamShiftAwareListener.Update.- Specified by:
canProcessNormalUpdatein interfaceUpdateByOperator- Parameters:
context- the context- Returns:
- true if this operator can process the update normally.
-
setChunkSize
Description copied from interface:UpdateByOperatorSet the chunk size to be used for operations. This is used during theUpdateBy.UpdateType.Reprocessphase when the chunks allocated during the normal processing phase may not be large enough.- Specified by:
setChunkSizein interfaceUpdateByOperator- Parameters:
context- the context objectchunkSize- the new chunk size
-
onBucketsRemoved
Description copied from interface:UpdateByOperatorCalled when some buckets have been completely emptied. Operators can use this to reset internal states.- Specified by:
onBucketsRemovedin interfaceUpdateByOperator- Parameters:
removedBuckets- an index of removed bucket positions.
-
modifyChunk
public void modifyChunk(@NotNull UpdateByOperator.UpdateContext updateContext, @Nullable LongChunk<Attributes.OrderedKeyIndices> prevKeyChunk, @Nullable LongChunk<Attributes.OrderedKeyIndices> keyChunk, @NotNull Chunk<Attributes.Values> prevValuesChunk, @NotNull Chunk<Attributes.Values> postValuesChunk, long bucketPosition) Description copied from interface:UpdateByOperatorModify a chunk of values with the operation.- Specified by:
modifyChunkin interfaceUpdateByOperator- Parameters:
updateContext- the context objectprevKeyChunk- a chunk of pre-shift keys. This will be equal tokeyChunkif no shift is presentkeyChunk- a chunk of post-shift space keys for the update.prevValuesChunk- a chunk of previous values for the updatepostValuesChunk- a chunk of current values for the updatebucketPosition- the position of the current group being processed
-
removeChunk
public void removeChunk(@NotNull UpdateByOperator.UpdateContext updateContext, @Nullable LongChunk<Attributes.OrderedKeyIndices> keyChunk, @NotNull Chunk<Attributes.Values> prevValuesChunk, long bucketPosition) Description copied from interface:UpdateByOperatorRemove a chunk of values from the operation.- Specified by:
removeChunkin interfaceUpdateByOperator- Parameters:
updateContext- the context objectkeyChunk- a chunk of keys being removed.prevValuesChunk- the chunk of values being removedbucketPosition- the position of the current group being processed
-
applyShift
public void applyShift(@NotNull UpdateByOperator.UpdateContext updateContext, @NotNull ReadOnlyIndex prevIndex, @NotNull IndexShiftData shifted) Description copied from interface:UpdateByOperatorApply a shift to the operation.- Specified by:
applyShiftin interfaceUpdateByOperator- Parameters:
updateContext- the context objectprevIndex- the pre-shifted indexshifted- the shifts being applied
-
applyOutputShift
public void applyOutputShift(@NotNull UpdateByOperator.UpdateContext context, @NotNull ReadOnlyIndex subIndexToShift, long delta) Description copied from interface:UpdateByOperatorApply a shift to the operation.- Specified by:
applyOutputShiftin interfaceUpdateByOperator- Parameters:
context- the context object
-
resetForReprocess
public void resetForReprocess(@NotNull UpdateByOperator.UpdateContext context, @NotNull ReadOnlyIndex sourceIndex, @NotNull ColumnSource<?> inputSource, long firstUnmodifiedKey) Description copied from interface:UpdateByOperatorReset the operator to the state at the `firstModifiedKey` for non-bucketed operation. This is invoked immediately prior to calls toUpdateByOperator.reprocessChunk(UpdateContext, OrderedKeys, LongChunk, Chunk, ReadOnlyIndex).
A `firstUnmodifiedKey` ofReadOnlyIndex.NULL_KEYindicates that the entire table needs to be recomputed.- Specified by:
resetForReprocessin interfaceUpdateByOperator- Parameters:
context- the context objectsourceIndex- the current index of the source tableinputSource- the most primitive form of the input column sourcefirstUnmodifiedKey- the first unmodified key after which we will reprocess rows.
-
resetForReprocess
public void resetForReprocess(@NotNull UpdateByOperator.UpdateContext context, @NotNull ReadOnlyIndex bucketIndex, @NotNull ColumnSource<?> inputSource, long bucketPosition, long firstUnmodifiedKey) Description copied from interface:UpdateByOperatorReset the operator to the state at the `firstModifiedKey` for the specified bucket. This is invoked immediately prior to calls toUpdateByOperator.reprocessChunk(UpdateContext, OrderedKeys, Chunk, LongChunk, IntChunk, IntChunk, IntChunk).- Specified by:
resetForReprocessin interfaceUpdateByOperator- Parameters:
context- the context objectbucketIndex- the current index of the specified bucketinputSource- the most primitive form of the input column sourcefirstUnmodifiedKey- the first unmodified key in the bucket after which we will reprocess rows.
-