All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.deephaven.engine.table.impl.sources.LongSingleValueSource Maven / Gradle / Ivy

There is a newer version: 0.37.1
Show newest version
/**
 * Copyright (c) 2016-2022 Deephaven Data Labs and Patent Pending
 */
/*
 * ---------------------------------------------------------------------------------------------------------------------
 * AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY - for any changes edit CharacterSingleValueSource and regenerate
 * ---------------------------------------------------------------------------------------------------------------------
 */
package io.deephaven.engine.table.impl.sources;

import io.deephaven.chunk.WritableLongChunk;
import io.deephaven.chunk.WritableChunk;
import io.deephaven.chunk.attributes.Values;
import io.deephaven.engine.context.ExecutionContext;
import io.deephaven.engine.table.impl.MutableColumnSourceGetDefaults;
import io.deephaven.engine.rowset.chunkattributes.RowKeys;
import io.deephaven.chunk.LongChunk;
import io.deephaven.chunk.Chunk;
import io.deephaven.chunk.LongChunk;
import io.deephaven.engine.rowset.RowSequence;
import org.jetbrains.annotations.NotNull;

import static io.deephaven.util.QueryConstants.NULL_LONG;
import static io.deephaven.util.type.TypeUtils.unbox;

/**
 * Single value source for Long.
 * 

* The C-haracterSingleValueSource is replicated to all other types with * io.deephaven.engine.table.impl.sources.Replicate. * * (C-haracter is deliberately spelled that way in order to prevent Replicate from altering this very comment). */ public class LongSingleValueSource extends SingleValueColumnSource implements MutableColumnSourceGetDefaults.ForLong { private long current; private transient long prev; // region Constructor public LongSingleValueSource() { super(long.class); current = NULL_LONG; prev = NULL_LONG; } // endregion Constructor @Override public final void set(Long value) { if (isTrackingPrevValues) { final long currentStep = updateGraph.clock().currentStep(); if (changeTime < currentStep) { prev = current; changeTime = currentStep; } } current = unbox(value); } // region UnboxedSetter @Override public final void set(long value) { if (isTrackingPrevValues) { final long currentStep = updateGraph.clock().currentStep(); if (changeTime < currentStep) { prev = current; changeTime = currentStep; } } current = value; } // endregion UnboxedSetter @Override public final void setNull() { set(NULL_LONG); } @Override public final void set(long key, long value) { set(value); } @Override public final long getLong(long rowKey) { if (rowKey == RowSequence.NULL_ROW_KEY) { return NULL_LONG; } return current; } @Override public final long getPrevLong(long rowKey) { if (rowKey == RowSequence.NULL_ROW_KEY) { return NULL_LONG; } if (!isTrackingPrevValues || changeTime < updateGraph.clock().currentStep()) { return current; } return prev; } @Override public final void fillFromChunk(@NotNull FillFromContext context, @NotNull Chunk src, @NotNull RowSequence rowSequence) { if (rowSequence.size() == 0) { return; } // We can only hold one value anyway, so arbitrarily take the first value in the chunk and ignore the rest. final LongChunk chunk = src.asLongChunk(); set(chunk.get(0)); } @Override public void fillFromChunkUnordered(@NotNull FillFromContext context, @NotNull Chunk src, @NotNull LongChunk keys) { if (keys.size() == 0) { return; } // We can only hold one value anyway, so arbitrarily take the first value in the chunk and ignore the rest. final LongChunk chunk = src.asLongChunk(); set(chunk.get(0)); } @Override public void fillChunk(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull RowSequence rowSequence) { destination.setSize(rowSequence.intSize()); destination.asWritableLongChunk().fillWithValue(0, rowSequence.intSize(), current); } @Override public void fillPrevChunk(@NotNull FillContext context, @NotNull WritableChunk destination, @NotNull RowSequence rowSequence) { long value = getPrevLong(0); // avoid duplicating the current vs prev logic in getPrevLong destination.setSize(rowSequence.intSize()); destination.asWritableLongChunk().fillWithValue(0, rowSequence.intSize(), value); } @Override public void fillChunkUnordered(@NotNull FillContext context, @NotNull WritableChunk dest, @NotNull LongChunk keys) { final WritableLongChunk destChunk = dest.asWritableLongChunk(); for (int ii = 0; ii < keys.size(); ++ii) { destChunk.set(ii, keys.get(ii) == RowSequence.NULL_ROW_KEY ? NULL_LONG : current); } destChunk.setSize(keys.size()); } @Override public void fillPrevChunkUnordered(@NotNull FillContext context, @NotNull WritableChunk dest, @NotNull LongChunk keys) { long value = getPrevLong(0); // avoid duplicating the current vs prev logic in getPrevLong final WritableLongChunk destChunk = dest.asWritableLongChunk(); for (int ii = 0; ii < keys.size(); ++ii) { destChunk.set(ii, keys.get(ii) == RowSequence.NULL_ROW_KEY ? NULL_LONG : value); } destChunk.setSize(keys.size()); } @Override public boolean providesFillUnordered() { return true; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy