Class BaseDynamicFillByOperator
- All Implemented Interfaces:
ChunkedUpdateByOperator
- Direct Known Subclasses:
BooleanChunkedFillByOperator
,ByteChunkedFillByOperator
,CharChunkedFillByOperator
,DoubleChunkedFillByOperator
,FloatChunkedFillByOperator
,IntChunkedFillByOperator
,LongChunkedFillByOperator
,ObjectChunkedFillByOperator
,ShortChunkedFillByOperator
public abstract class BaseDynamicFillByOperator extends Object implements ChunkedUpdateByOperator
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
BaseDynamicFillByOperator.SingletonContext
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.updateby.ChunkedUpdateByOperator
ChunkedUpdateByOperator.BucketedUpdateContext, ChunkedUpdateByOperator.UpdateContext
-
Field Summary
Fields Modifier and Type Field Description protected boolean
initialized
protected RedirectionIndex
redirection
Fields inherited from interface com.illumon.iris.db.v2.updateby.ChunkedUpdateByOperator
ZERO_LENGTH_OP_ARRAY
-
Method Summary
Modifier and Type Method Description void
addChunk(ChunkedUpdateByOperator.BucketedUpdateContext context, Chunk<Attributes.Values> values, LongChunk<? extends Attributes.KeyIndices> keyChunk, IntChunk<Attributes.KeyIndices> bucketPositions, IntChunk<Attributes.ChunkPositions> startPositions, IntChunk<Attributes.ChunkLengths> length)
Add a chunk of bucketed items to the operation.boolean
anyModified(ChunkedUpdateByOperator.BucketedUpdateContext inCtx)
Check if the update has modified any rows for this operator.boolean
anyModified(ChunkedUpdateByOperator.UpdateContext inCtx)
Check if the update has modified any rows for this operator.void
applyShift(ChunkedUpdateByOperator.UpdateContext inCtx, ReadOnlyIndex toShift, IndexShiftData shiftData)
Apply the specified shifts to this operator.void
finishFor(ChunkedUpdateByOperator.BucketedUpdateContext inCtx, UpdateBy.UpdateType type)
Perform and bookkeeping required at the end of a single part of the update.void
finishFor(ChunkedUpdateByOperator.UpdateContext inCtx, UpdateBy.UpdateType type)
Perform and bookkeeping required at the end of a single part of the update.ReadOnlyIndex
getAdditionalModifications(ChunkedUpdateByOperator.UpdateContext inCtx)
Get an index of rows that were modified beyond the input set of modifications from the upstream.String
getInputColumnName()
Get the name of the input column this operator depends on.String[]
getOutputColumnNames()
Get an array of the output column names.Map<String,ColumnSource<?>>
getOutputColumns()
Get a map of outputName to outputColumnSource
for this operation.void
initializeFor(ChunkedUpdateByOperator.BucketedUpdateContext inCtx, UpdateBy.UpdateType type, ReadOnlyIndex updateIndex)
Initialize the context for the specified stage of the update process.void
initializeFor(ChunkedUpdateByOperator.UpdateContext inCtx, UpdateBy.UpdateType type, ReadOnlyIndex updateIndex)
Initialize the context for the specified stage of the update process.ChunkedUpdateByOperator.BucketedUpdateContext
makeBucketedContext(int chunkSize)
Make anChunkedUpdateByOperator.UpdateContext
suitable for use with bucketed updates.ChunkedUpdateByOperator.UpdateContext
makeUpdateContext(int chunkSize)
Make anChunkedUpdateByOperator.UpdateContext
suitable for use with non-bucketed updates.void
removeChunk(ChunkedUpdateByOperator.UpdateContext inCtx, LongChunk<Attributes.OrderedKeyIndices> keyChunk, Chunk<Attributes.Values> previousValuesChunk, long groupPosition)
Remove a chunk of values.void
setBucketCapacity(int intValue)
Notify the operator of the current maximum bucket.void
setUpstream(ChunkedUpdateByOperator.BucketedUpdateContext inCtx, ShiftAwareListener.Update upstream)
Set theupstream
update object for this update cycle.void
setUpstream(ChunkedUpdateByOperator.UpdateContext inCtx, ShiftAwareListener.Update upstream)
Set theupstream
update object for this update cycle.void
startTrackingPrev()
Indicate that the operation should start tracking previous values for ticking updates.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.illumon.iris.db.v2.updateby.ChunkedUpdateByOperator
addChunk, modifyChunk
-
Field Details
-
redirection
-
initialized
protected boolean initialized
-
-
Method Details
-
setBucketCapacity
public void setBucketCapacity(int intValue)Description copied from interface:ChunkedUpdateByOperator
Notify the operator of the current maximum bucket.- Specified by:
setBucketCapacity
in interfaceChunkedUpdateByOperator
- Parameters:
intValue
- the capacity
-
startTrackingPrev
public void startTrackingPrev()Description copied from interface:ChunkedUpdateByOperator
Indicate that the operation should start tracking previous values for ticking updates.- Specified by:
startTrackingPrev
in interfaceChunkedUpdateByOperator
-
getInputColumnName
Description copied from interface:ChunkedUpdateByOperator
Get the name of the input column this operator depends on.- Specified by:
getInputColumnName
in interfaceChunkedUpdateByOperator
- Returns:
- the name of the input column
-
getOutputColumnNames
Description copied from interface:ChunkedUpdateByOperator
Get an array of the output column names.- Specified by:
getOutputColumnNames
in interfaceChunkedUpdateByOperator
- Returns:
- the output column names.
-
getOutputColumns
Description copied from interface:ChunkedUpdateByOperator
Get a map of outputName to outputColumnSource
for this operation.- Specified by:
getOutputColumns
in interfaceChunkedUpdateByOperator
- Returns:
- a map of output column name to output column source
-
makeUpdateContext
Description copied from interface:ChunkedUpdateByOperator
Make anChunkedUpdateByOperator.UpdateContext
suitable for use with non-bucketed updates.- Specified by:
makeUpdateContext
in interfaceChunkedUpdateByOperator
- Parameters:
chunkSize
- The expected size of chunks that will be provided during the update,- Returns:
- a new updateContext
-
makeBucketedContext
Description copied from interface:ChunkedUpdateByOperator
Make anChunkedUpdateByOperator.UpdateContext
suitable for use with bucketed updates.- Specified by:
makeBucketedContext
in interfaceChunkedUpdateByOperator
- Parameters:
chunkSize
- The expected size of chunks that will be provided during the update,- Returns:
- a new updateContext
-
initializeFor
public void initializeFor(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx, @NotNull UpdateBy.UpdateType type, @NotNull ReadOnlyIndex updateIndex)Description copied from interface:ChunkedUpdateByOperator
Initialize the context for the specified stage of the update process. This will always be followed by a call to
ChunkedUpdateByOperator.finishFor(UpdateContext, UpdateBy.UpdateType)
at the end of each successful update.- Specified by:
initializeFor
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objecttype
- the type of update being appliedupdateIndex
- the index of rows associated with the update.
-
initializeFor
public void initializeFor(@NotNull ChunkedUpdateByOperator.BucketedUpdateContext inCtx, @NotNull UpdateBy.UpdateType type, @NotNull ReadOnlyIndex updateIndex)Description copied from interface:ChunkedUpdateByOperator
Initialize the context for the specified stage of the update process. This will always be followed by a call to
ChunkedUpdateByOperator.finishFor(UpdateContext, UpdateBy.UpdateType)
at the end of each successful update.- Specified by:
initializeFor
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objecttype
- the type of update being appliedupdateIndex
- the index of rows associated with the update.
-
finishFor
public void finishFor(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx, @NotNull UpdateBy.UpdateType type)Description copied from interface:ChunkedUpdateByOperator
Perform and bookkeeping required at the end of a single part of the update. This is always preceded with a call toChunkedUpdateByOperator.initializeFor(UpdateContext, UpdateBy.UpdateType, ReadOnlyIndex)
- Specified by:
finishFor
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objecttype
- the type of update being applied
-
finishFor
public void finishFor(@NotNull ChunkedUpdateByOperator.BucketedUpdateContext inCtx, @NotNull UpdateBy.UpdateType type)Description copied from interface:ChunkedUpdateByOperator
Perform and bookkeeping required at the end of a single part of the update. This is always preceded with a call toChunkedUpdateByOperator.initializeFor(UpdateContext, UpdateBy.UpdateType, ReadOnlyIndex)
- Specified by:
finishFor
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objecttype
- the type of update being applied
-
anyModified
Description copied from interface:ChunkedUpdateByOperator
Check 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:
anyModified
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context object- Returns:
- true if the update modified any rows.
-
anyModified
Description copied from interface:ChunkedUpdateByOperator
Check 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:
anyModified
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context object- Returns:
- true if the update modified any rows.
-
getAdditionalModifications
@NotNull public ReadOnlyIndex getAdditionalModifications(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx)Description copied from interface:ChunkedUpdateByOperator
Get 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) ifChunkedUpdateByOperator.anyModified(UpdateContext)
has returned true.- Specified by:
getAdditionalModifications
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context object- Returns:
- a
index
of additional rows that were modified
-
setUpstream
public void setUpstream(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx, @NotNull ShiftAwareListener.Update upstream)Description copied from interface:ChunkedUpdateByOperator
Set theupstream
update object for this update cycle.- Specified by:
setUpstream
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objectupstream
- the upstream update
-
setUpstream
public void setUpstream(@NotNull ChunkedUpdateByOperator.BucketedUpdateContext inCtx, @NotNull ShiftAwareListener.Update upstream)Description copied from interface:ChunkedUpdateByOperator
Set theupstream
update object for this update cycle.- Specified by:
setUpstream
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objectupstream
- the upstream update
-
applyShift
public void applyShift(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx, @NotNull ReadOnlyIndex toShift, @NotNull IndexShiftData shiftData)Apply the specified shifts to this operator. This has a few steps1: In order to shift the
redirection
properly, we have to visit each shifted range and inspect the keys that are affected. If the value of a particular redirection fell within the shifted range, it too must be adjusted. If it did not, then we leave it alone.It is worth noting that while we can create a single forward search iterator to visit affected keys that are being shifted to the left (negative delta), we can't do the same for right shifts (positive delta). We need to iterate the affected keys in reverse order, but advance in normal order, so we have to create a new reverse iterator on each separate right shifted range
2: After the
redirection
has been shifted, we can then apply the shift to the redirected row index. Then we have to shift any accumulated modified rows in the context3: Finally, we have to repair any redirections that were broken by shifting. This is easy because we know that broken redirections will end up in between shifted ranges. So we can start at the first redirection after the first shifted range. Since shifts don't change data, we can locate the last valid row before the next redirection index using a
ReadOnlyIndex.SearchIterator
. We will fix each indirection that it incorrect until we find a good one, then move the ShiftData position to the first range past the last redirection, and repeat the process until we are done.- Specified by:
applyShift
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objecttoShift
- the set of rows that can be shiftedshiftData
- the shift data
-
addChunk
public void addChunk(@NotNull ChunkedUpdateByOperator.BucketedUpdateContext 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> length)Description copied from interface:ChunkedUpdateByOperator
Add a chunk of bucketed items to the operation.- Specified by:
addChunk
in interfaceChunkedUpdateByOperator
- 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 chunklength
- the length of each run of bucket values
-
removeChunk
public void removeChunk(@NotNull ChunkedUpdateByOperator.UpdateContext inCtx, @NotNull LongChunk<Attributes.OrderedKeyIndices> keyChunk, @NotNull Chunk<Attributes.Values> previousValuesChunk, long groupPosition)Remove a chunk of values. This is very simple, if the key being removed affect redirections to the right, simply find the previous valid row before the one being removed and propagate it forward to all the subsequent rows that were directed to this one.- Specified by:
removeChunk
in interfaceChunkedUpdateByOperator
- Parameters:
inCtx
- the context objectkeyChunk
- the chunk of keys being removed.groupPosition
-previousValuesChunk
- the chunk of values being removed
-