Class ValueTracker

java.lang.Object
io.deephaven.clientsupport.plotdownsampling.ValueTracker
Direct Known Subclasses:
ByteValueTracker, CharValueTracker, DoubleValueTracker, FloatValueTracker, IntValueTracker, LongValueTracker, ObjectValueTracker, ShortValueTracker

public abstract class ValueTracker extends Object
Wraps all values in a given Y column when downsampling and apply operations consistently to supported column types. Each operation includes an offset, which is the BucketState.offset value - internally this is transformed to the position in the array sources. Each tracker maintains 6 pieces of data/metadata on all possible buckets, spread across 3 array sources: o the min and max value o the indexes of those min and max values in the original table o a flag indicating whether or not the each min and max are presently valid - these must always be true except when a shift aware update is currently being processed. It is possible that there are gaps in the data - this is not understood directly by the ValueTracker, but instead by the fact that no BucketState exists with a corresponding offset.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    append(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int indexInChunk, @Nullable WritableRowSet nulls)
    Indicates that a new value is being added to the original table being downsampled, and its value should be considered as possibly interesting.
    protected void
    ensureCapacity(int bucketCount)
     
    protected final long
    maxIndex(int offset)
     
    protected final long
    maxValuePosition(int offset)
    Transforms the given BucketState.offset into the position in the array sources that represents the max value of that bucket state.
    protected final boolean
    maxValueValid(int offset)
     
    protected final void
    maxValueValid(int offset, boolean isValid)
     
    protected final long
    minIndex(int offset)
     
    protected final long
    minValuePosition(int offset)
    Transforms the given BucketState.offset into the position in the array sources that represents the min value of that bucket state.
    protected final boolean
    minValueValid(int offset)
     
    protected final void
    minValueValid(int offset, boolean isValid)
     
    static ValueTracker[]
    of(List<ColumnSource<?>> valueColumnSources, int bucketCount)
    Creates a set of value trackers to share across a given RunChartDownsample's BucketState instances.
    final void
    remove(int offset, long rowKey)
    Indicates that a row was removed from the original table being downsampled.
    protected final void
    setMaxIndex(int offset, long maxIndex)
     
    protected final void
    setMinIndex(int offset, long minIndex)
     
    final void
    shiftMaxIndex(int offset, RowSetShiftData shiftData)
     
    final void
    shiftMinIndex(int offset, RowSetShiftData shiftData)
     
    abstract String
    toString(int offset)
    Create a String representation of the tracked values and metadata at the given offset for logging/debugging purposes.
    abstract void
    update(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int chunkIndex, @Nullable WritableRowSet nulls)
    Indicates that a value has changed in the original table that is being downsampled, and we should consider if the old value or the new value was interesting.
    abstract void
    validate(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int indexInChunk, @Nullable RowSet nulls)
    Scan the given chunk and confirm that whichever values are currently selected as max and min are correct, and that the current data is now valid.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ValueTracker

      public ValueTracker()
  • Method Details

    • of

      public static ValueTracker[] of(List<ColumnSource<?>> valueColumnSources, int bucketCount)
      Creates a set of value trackers to share across a given RunChartDownsample's BucketState instances.
      Parameters:
      valueColumnSources - the Y columns being downsampled and tracked
      bucketCount - the initial size to allocate in each tracker, usually the number of pixels to be displayed
      Returns:
      an array of correctly typed and sizes value trackers for use with the given Y value column sources
    • ensureCapacity

      protected void ensureCapacity(int bucketCount)
    • append

      public abstract void append(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int indexInChunk, @Nullable @Nullable WritableRowSet nulls)
      Indicates that a new value is being added to the original table being downsampled, and its value should be considered as possibly interesting. Implementations should read the value from the chunk and specialize based on that type of data. If it is the only value in the bucket (specified by the offset), include this value as both the max and the min. If there are other values, check to see if the new value is either the new max or the new min. In any case where this becomes the new max or the new min, mark that position as being valid, indicating that we are confident that we have the largest or smallest value at that offset. Implementations must take care to check if the value is null. If so, if nulls is present, the current row key should be added to it. If the
      Parameters:
      offset - the offset of the bucket state to use - use this with minValuePosition/maxValuePosition to compute the actual position in the underlying array sources
      rowKey - the row key in the original table of the specified value. If the current given value is interesting in some way, record this using setMinIndex/setMaxIndex so we can construct the full downsampled table row set later
      valuesChunk - the chunk that we're currently examining
      indexInChunk - the index in the chunk that we're currently examining
    • remove

      public final void remove(int offset, long rowKey)
      Indicates that a row was removed from the original table being downsampled. If that row key was previously considered to be interesting, mark this offset as invalid, so that we can rescan later to find the next interesting value.
      Parameters:
      offset - the offset of the bucket state to use
      rowKey - the row key in the original table.
    • update

      public abstract void update(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int chunkIndex, @Nullable @Nullable WritableRowSet nulls)
      Indicates that a value has changed in the original table that is being downsampled, and we should consider if the old value or the new value was interesting. Implementations should read the value from the chunk and specialize based on that type of data. There are three cases to consider for each min and max, so six cases in total. Here is the summary for the three "max" cases, the opposite must be likewise done for the min cases: If the updated row was the old max, then we cover two of the cases: o if the new value is greater than the old value, record the new value, but we are still the max and still valid. o if the new value is less than the old value, invalidate this row but keep the old max, we may need to rescan later Otherwise, if the new value is greater than the old max, then the current row is now the new max, and are now valid.
      Parameters:
      offset - the offset of the bucket state to use - use this with minValuePosition/maxValuePosition to compute the actual position in the underlying array sources
      rowKey - the row key in the original table of the specified value. If the current given value is interesting in some way, record this using setMinIndex/setMaxIndex so we can construct the full downsampled table row set later
      valuesChunk - the chunk that we're currently examining
      chunkIndex - the index in the chunk that we're currently examining
    • minValuePosition

      protected final long minValuePosition(int offset)
      Transforms the given BucketState.offset into the position in the array sources that represents the min value of that bucket state.
    • maxValuePosition

      protected final long maxValuePosition(int offset)
      Transforms the given BucketState.offset into the position in the array sources that represents the max value of that bucket state.
    • minIndex

      protected final long minIndex(int offset)
    • maxIndex

      protected final long maxIndex(int offset)
    • setMinIndex

      protected final void setMinIndex(int offset, long minIndex)
    • setMaxIndex

      protected final void setMaxIndex(int offset, long maxIndex)
    • minValueValid

      protected final void minValueValid(int offset, boolean isValid)
    • maxValueValid

      protected final void maxValueValid(int offset, boolean isValid)
    • minValueValid

      protected final boolean minValueValid(int offset)
    • maxValueValid

      protected final boolean maxValueValid(int offset)
    • toString

      public abstract String toString(int offset)
      Create a String representation of the tracked values and metadata at the given offset for logging/debugging purposes.
    • validate

      public abstract void validate(int offset, long rowKey, Chunk<? extends Values> valuesChunk, int indexInChunk, @Nullable @Nullable RowSet nulls)
      Scan the given chunk and confirm that whichever values are currently selected as max and min are correct, and that the current data is now valid.
    • shiftMaxIndex

      public final void shiftMaxIndex(int offset, RowSetShiftData shiftData)
    • shiftMinIndex

      public final void shiftMinIndex(int offset, RowSetShiftData shiftData)