Class BasePrimitiveEMAOperator
java.lang.Object
com.illumon.iris.db.v2.updateby.internal.BaseDoubleUpdateByOperator
com.illumon.iris.db.v2.updateby.ema.BasePrimitiveEMAOperator
- All Implemented Interfaces:
UpdateByOperator
- Direct Known Subclasses:
ByteEMAOperator
,DoubleEMAOperator
,FloatEMAOperator
,IntEMAOperator
,LongEMAOperator
,ShortEMAOperator
-
Nested Class Summary
Nested classes/interfaces inherited from class com.illumon.iris.db.v2.updateby.internal.BaseDoubleUpdateByOperator
BaseDoubleUpdateByOperator.Context
Nested classes/interfaces inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
UpdateByOperator.UpdateContext
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EmaControl
protected final LongRecordingUpdateByOperator
protected final double
Fields inherited from class com.illumon.iris.db.v2.updateby.internal.BaseDoubleUpdateByOperator
bucketLastVal, initialized, isRedirected, maybeInnerSource, outputSource, singletonGroup, singletonVal
Fields inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
ZERO_LENGTH_OP_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionBasePrimitiveEMAOperator
(MatchPair pair, String[] affectingColumns, EmaControl control, LongRecordingUpdateByOperator timeRecorder, long timeScaleUnits, RedirectionIndex redirectionIndex) An operator that computes an EMA from a short column using an exponential decay function. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
(BaseDoubleUpdateByOperator.Context context, OrderedKeys inputKeys, Chunk<Attributes.Values> workingChunk, long groupPosition) 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.makeUpdateContext
(int chunkSize) Make anUpdateByOperator.UpdateContext
suitable for use with non-bucketed updates.void
onBucketsRemoved
(ReadOnlyIndex removedBuckets) Called when some buckets have been completely emptied.void
resetForReprocess
(UpdateByOperator.UpdateContext context, ReadOnlyIndex sourceIndex, ColumnSource<?> inputSource, long firstUnmodifiedKey) Reset the operator to the state at the `firstModifiedKey` for non-bucketed operation.void
resetForReprocess
(UpdateByOperator.UpdateContext ctx, ReadOnlyIndex bucketIndex, ColumnSource<?> inputSource, 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.BaseDoubleUpdateByOperator
addChunk, anyModified, applyOutputShift, applyShift, canProcessNormalUpdate, finishFor, getAdditionalModifications, getAffectingColumnNames, getInputColumnName, getOutputColumnNames, getOutputColumns, modifyChunk, removeChunk, reprocessChunk, reprocessChunk, requiresKeys, requiresValues, setChunkSize, startTrackingPrev
-
Field Details
-
control
-
timeRecorder
-
timeScaleUnits
protected final double timeScaleUnits
-
-
Constructor Details
-
BasePrimitiveEMAOperator
public BasePrimitiveEMAOperator(@NotNull MatchPair pair, @NotNull String[] affectingColumns, @NotNull EmaControl control, @Nullable LongRecordingUpdateByOperator timeRecorder, long timeScaleUnits, @Nullable RedirectionIndex redirectionIndex) An operator that computes an EMA from a short 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
- the control parameters for EMAtimeRecorder
- 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 measured in ticks, otherwise it is measured in nanoseconds.redirectionIndex
-
-
-
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 classBaseDoubleUpdateByOperator
- 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 classBaseDoubleUpdateByOperator
- 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 classBaseDoubleUpdateByOperator
- 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 classBaseDoubleUpdateByOperator
- Parameters:
updateContext
- the context objectupdateIndex
- the index of rows associated with the update.type
- the type of update being applied
-
onBucketsRemoved
Description copied from interface:UpdateByOperator
Called when some buckets have been completely emptied. Operators can use this to reset internal states.- Specified by:
onBucketsRemoved
in interfaceUpdateByOperator
- Overrides:
onBucketsRemoved
in classBaseDoubleUpdateByOperator
- Parameters:
removedBuckets
- an index of removed bucket positions.
-
doAddChunk
protected void doAddChunk(@NotNull BaseDoubleUpdateByOperator.Context context, @NotNull OrderedKeys inputKeys, @NotNull Chunk<Attributes.Values> workingChunk, long groupPosition) - Specified by:
doAddChunk
in classBaseDoubleUpdateByOperator
-
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, @NotNull ColumnSource<?> inputSource, 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 classBaseDoubleUpdateByOperator
- 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 ctx, @NotNull ReadOnlyIndex bucketIndex, @NotNull ColumnSource<?> inputSource, 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 classBaseDoubleUpdateByOperator
- Parameters:
ctx
- 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.
-