Class BigNumberEMAOperator<T>
java.lang.Object
com.illumon.iris.db.v2.updateby.internal.BaseObjectUpdateByOperator<BigDecimal>
com.illumon.iris.db.v2.updateby.ema.BigNumberEMAOperator<T>
- All Implemented Interfaces:
UpdateByOperator
- Direct Known Subclasses:
BigDecimalEMAOperator
,BigIntegerEMAOperator
public abstract class BigNumberEMAOperator<T> extends BaseObjectUpdateByOperator<BigDecimal>
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.updateby.internal.BaseObjectUpdateByOperator
BaseObjectUpdateByOperator.Context
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
UpdateByOperator.UpdateContext
-
Field Summary
Fields Modifier and Type Field Description protected EmaControl
control
protected LongRecordingUpdateByOperator
timeRecorder
protected double
timeScaleUnits
protected ColumnSource<T>
valueSource
Fields inherited from class com.illumon.iris.db.v2.updateby.internal.BaseObjectUpdateByOperator
affectingColumns, bucketLastVal, initialized, isRedirected, maybeInnerSource, outputSource, pair, singletonVal
Fields inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
ZERO_LENGTH_OP_ARRAY
-
Constructor Summary
Constructors Constructor Description BigNumberEMAOperator(MatchPair pair, String[] affectingColumns, EmaControl control, LongRecordingUpdateByOperator timeRecorder, long timeScaleUnits, ColumnSource<T> valueSource, RedirectionIndex redirectionIndex)
An operator that computes an EMA from a int column using an exponential decay function. -
Method Summary
Modifier and Type Method Description void
addChunk(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.protected void
doAddChunk(BaseObjectUpdateByOperator.Context updateContext, OrderedKeys inputKeys, Chunk<Attributes.Values> workingChunk, long groupPosition)
Add a chunk of values to the operator.void
initializeFor(UpdateByOperator.UpdateContext updateContext, ReadOnlyIndex updateIndex, UpdateBy.UpdateType type)
Initialize the context for the specified stage of the update process.void
initializeForUpdate(UpdateByOperator.UpdateContext context, ShiftAwareListener.Update upstream, ReadOnlyIndex resultSourceIndex, boolean usingBuckets, boolean isAppendOnly)
Initialize the operator for an update cycle.UpdateByOperator.UpdateContext
makeUpdateContext(int chunkSize)
Make anUpdateByOperator.UpdateContext
suitable for use with non-bucketed updates.void
resetForReprocess(UpdateByOperator.UpdateContext context, ReadOnlyIndex sourceIndex, long firstUnmodifiedKey)
Reset the operator to the state at the `firstModifiedKey` for non-bucketed operation.void
resetForReprocess(UpdateByOperator.UpdateContext ctx, ReadOnlyIndex bucketIndex, long bucketPosition, long firstUnmodifiedKey)
Reset the operator to the state at the `firstModifiedKey` for the specified bucket.void
setBucketCapacity(int capacity)
Notify the operator of the current maximum bucket.Methods inherited from class com.illumon.iris.db.v2.updateby.internal.BaseObjectUpdateByOperator
addChunk, anyModified, applyOutputShift, applyShift, canProcessNormalUpdate, finishFor, getAdditionalModifications, getAffectingColumnNames, getInputColumnName, getOutputColumnNames, getOutputColumns, modifyChunk, onBucketsRemoved, removeChunk, reprocessChunk, reprocessChunk, requiresKeys, requiresValues, setChunkSize, startTrackingPrev
-
Field Details
-
valueSource
-
control
-
timeRecorder
-
timeScaleUnits
protected final double timeScaleUnits
-
-
Constructor Details
-
BigNumberEMAOperator
public BigNumberEMAOperator(@NotNull MatchPair pair, @NotNull String[] affectingColumns, @NotNull EmaControl control, @Nullable LongRecordingUpdateByOperator timeRecorder, long timeScaleUnits, @NotNull ColumnSource<T> valueSource, @Nullable RedirectionIndex redirectionIndex)An operator that computes an EMA from a int column using an exponential decay function.- Parameters:
pair
- theMatchPair
that defines the input/output for this operationaffectingColumns
- the names of the columns that affect this emacontrol
- defines how to handlenull
input values.timeRecorder
- an optional recorder for a timestamp column. If this is null, it will be assumed time is measured in integer ticks.timeScaleUnits
- the smoothing window for the EMA. If notimeRecorder
is provided, this is measuredvalueSource
- the input column source. Used when determining reset positions for reprocessing
-
-
Method Details
-
setBucketCapacity
public void setBucketCapacity(int capacity)Description copied from interface:UpdateByOperator
Notify the operator of the current maximum bucket.- Specified by:
setBucketCapacity
in interfaceUpdateByOperator
- Overrides:
setBucketCapacity
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
capacity
- the capacity
-
makeUpdateContext
Description copied from interface:UpdateByOperator
Make anUpdateByOperator.UpdateContext
suitable for use with non-bucketed updates.- Specified by:
makeUpdateContext
in interfaceUpdateByOperator
- Overrides:
makeUpdateContext
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
chunkSize
- The expected size of chunks that will be provided during the update,- Returns:
- a new context
-
initializeForUpdate
public void initializeForUpdate(@NotNull UpdateByOperator.UpdateContext context, @NotNull ShiftAwareListener.Update upstream, @NotNull ReadOnlyIndex resultSourceIndex, boolean usingBuckets, boolean isAppendOnly)Description copied from interface:UpdateByOperator
Initialize the operator for an update cycle. This is invoked before any other update processing occurs.- Specified by:
initializeForUpdate
in interfaceUpdateByOperator
- Overrides:
initializeForUpdate
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
context
- the context objectupstream
- the upstream update to processresultSourceIndex
- the result index of the source tableusingBuckets
- if the update is bucketed or notisAppendOnly
- 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:UpdateByOperator
Initialize 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:
initializeFor
in interfaceUpdateByOperator
- Overrides:
initializeFor
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
updateContext
- the context objectupdateIndex
- the index of rows associated with the update.type
- the type of update being applied
-
doAddChunk
protected void doAddChunk(@NotNull BaseObjectUpdateByOperator.Context updateContext, @NotNull OrderedKeys inputKeys, @NotNull Chunk<Attributes.Values> workingChunk, long groupPosition)Description copied from class:BaseObjectUpdateByOperator
Add a chunk of values to the operator.- Specified by:
doAddChunk
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
updateContext
- the context objectinputKeys
- the input keys for the chunkworkingChunk
- the chunk of valuesgroupPosition
- the bucket position that the values belong to.
-
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:UpdateByOperator
Add a chunk of bucketed items to the operation.- 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
-
resetForReprocess
public void resetForReprocess(@NotNull UpdateByOperator.UpdateContext context, @NotNull ReadOnlyIndex sourceIndex, long firstUnmodifiedKey)Description copied from interface:UpdateByOperator
Reset 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_KEY
indicates that the entire table needs to be recomputed.- Specified by:
resetForReprocess
in interfaceUpdateByOperator
- Overrides:
resetForReprocess
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
context
- the context objectsourceIndex
- the current index of the source tablefirstUnmodifiedKey
- the first unmodified key after which we will reprocess rows.
-
resetForReprocess
public void resetForReprocess(@NotNull UpdateByOperator.UpdateContext ctx, @NotNull ReadOnlyIndex bucketIndex, long bucketPosition, long firstUnmodifiedKey)Description copied from interface:UpdateByOperator
Reset 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:
resetForReprocess
in interfaceUpdateByOperator
- Overrides:
resetForReprocess
in classBaseObjectUpdateByOperator<BigDecimal>
- Parameters:
ctx
- the context objectbucketIndex
- the current index of the specified bucketfirstUnmodifiedKey
- the first unmodified key in the bucket after which we will reprocess rows.
-