io.deephaven.engine.table.impl.updateby.rollingcount.ByteRollingCountOperator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deephaven-engine-table Show documentation
Show all versions of deephaven-engine-table Show documentation
Engine Table: Implementation and closely-coupled utilities
/*
* ---------------------------------------------------------------------------------------------------------------------
* AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit CharRollingCountOperator and regenerate
* ---------------------------------------------------------------------------------------------------------------------
*/
package io.deephaven.engine.table.impl.updateby.rollingcount;
import io.deephaven.base.ringbuffer.ByteRingBuffer;
import io.deephaven.base.verify.Assert;
import io.deephaven.chunk.ByteChunk;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.engine.table.impl.MatchPair;
import io.deephaven.engine.table.impl.updateby.UpdateByOperator;
import io.deephaven.engine.table.impl.updateby.internal.BaseLongUpdateByOperator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import static io.deephaven.util.QueryConstants.NULL_BYTE;
public class ByteRollingCountOperator extends BaseLongUpdateByOperator {
private static final int BUFFER_INITIAL_CAPACITY = 128;
// region extra-fields
final byte nullValue;
// endregion extra-fields
protected class Context extends BaseLongUpdateByOperator.Context {
protected ByteChunk extends Values> influencerValuesChunk;
protected ByteRingBuffer buffer;
@SuppressWarnings("unused")
protected Context(final int affectedChunkSize, final int influencerChunkSize) {
super(affectedChunkSize);
buffer = new ByteRingBuffer(BUFFER_INITIAL_CAPACITY, true);
}
@Override
public void close() {
super.close();
buffer = null;
}
@Override
public void setValueChunks(@NotNull final Chunk extends Values>[] valueChunks) {
influencerValuesChunk = valueChunks[0].asByteChunk();
}
@Override
public void push(int pos, int count) {
buffer.ensureRemaining(count);
for (int ii = 0; ii < count; ii++) {
final byte val = influencerValuesChunk.get(pos + ii);
if (val == nullValue) {
buffer.addUnsafe((byte) 0); // 0 signifies null
nullCount++;
} else {
buffer.addUnsafe((byte) 1); // 1 signifies non-null
}
}
}
@Override
public void pop(int count) {
Assert.geq(buffer.size(), "byteWindowValues.size()", count);
for (int ii = 0; ii < count; ii++) {
final byte val = buffer.removeUnsafe();
if (val == 0) {
nullCount--;
}
}
}
@Override
public void writeToOutputChunk(int outIdx) {
curVal = buffer.size() - nullCount;
outputValues.set(outIdx, curVal);
}
@Override
public void reset() {
super.reset();
buffer.clear();
}
}
@NotNull
@Override
public UpdateByOperator.Context makeUpdateContext(final int affectedChunkSize, final int influencerChunkSize) {
return new Context(affectedChunkSize, influencerChunkSize);
}
public ByteRollingCountOperator(
@NotNull final MatchPair pair,
@NotNull final String[] affectingColumns,
@Nullable final String timestampColumnName,
final long reverseWindowScaleUnits,
final long forwardWindowScaleUnits
// region extra-constructor-args
,final byte nullValue
// endregion extra-constructor-args
) {
super(pair, affectingColumns, timestampColumnName, reverseWindowScaleUnits, forwardWindowScaleUnits, true);
// region constructor
this.nullValue = nullValue;
// endregion constructor
}
@Override
public UpdateByOperator copy() {
return new ByteRollingCountOperator(pair,
affectingColumns,
timestampColumnName,
reverseWindowScaleUnits,
forwardWindowScaleUnits
// region extra-copy-args
, nullValue
// endregion extra-copy-args
);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy