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.ContextNested classes/interfaces inherited from interface com.illumon.iris.db.v2.updateby.UpdateByOperator
UpdateByOperator.UpdateContext -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final EmaControlprotected final LongRecordingUpdateByOperatorprotected final doubleFields inherited from class com.illumon.iris.db.v2.updateby.internal.BaseDoubleUpdateByOperator
bucketLastVal, initialized, isRedirected, maybeInnerSource, outputSource, singletonGroup, singletonValFields 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 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.protected voiddoAddChunk(BaseDoubleUpdateByOperator.Context context, OrderedKeys inputKeys, Chunk<Attributes.Values> workingChunk, long groupPosition) voidinitializeFor(UpdateByOperator.UpdateContext updateContext, ReadOnlyIndex updateIndex, UpdateBy.UpdateType type) Initialize the context for the specified stage of the update process.voidinitializeForUpdate(UpdateByOperator.UpdateContext context, ShiftAwareListener.Update upstream, ReadOnlyIndex resultSourceIndex, boolean usingBuckets, boolean isAppendOnly) Initialize the operator for an update cycle.makeUpdateContext(int chunkSize) Make anUpdateByOperator.UpdateContextsuitable for use with non-bucketed updates.voidonBucketsRemoved(ReadOnlyIndex removedBuckets) Called when some buckets have been completely emptied.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 ctx, 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.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- theMatchPairthat 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 notimeRecorderis 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:UpdateByOperatorNotify the operator of the current maximum bucket.- Specified by:
setBucketCapacityin interfaceUpdateByOperator- Overrides:
setBucketCapacityin classBaseDoubleUpdateByOperator- Parameters:
capacity- the capacity
-
makeUpdateContext
Description copied from interface:UpdateByOperatorMake anUpdateByOperator.UpdateContextsuitable for use with non-bucketed updates.- Specified by:
makeUpdateContextin interfaceUpdateByOperator- Overrides:
makeUpdateContextin 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:UpdateByOperatorInitialize the operator for an update cycle. This is invoked before any other update processing occurs.- Specified by:
initializeForUpdatein interfaceUpdateByOperator- Overrides:
initializeForUpdatein 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: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- Overrides:
initializeForin 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:UpdateByOperatorCalled when some buckets have been completely emptied. Operators can use this to reset internal states.- Specified by:
onBucketsRemovedin interfaceUpdateByOperator- Overrides:
onBucketsRemovedin 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:
doAddChunkin 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:UpdateByOperatorAdd 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: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- Overrides:
resetForReprocessin 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: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- Overrides:
resetForReprocessin 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.
-