Class ArrayBackedColumnSource<T>

java.lang.Object
io.deephaven.engine.table.impl.AbstractColumnSource<T>
io.deephaven.engine.table.impl.sources.ArrayBackedColumnSource<T>
All Implemented Interfaces:
ChunkSink<Values>, ChunkSource<Values>, ChunkSource.WithPrev<Values>, ColumnSource<T>, ElementSource<T>, FillContextMaker, GetContextMaker, DefaultChunkSource<Values>, DefaultChunkSource.WithPrev<Values>, ChunkedBackingStoreExposedWritableSource, FillUnordered<Values>, InMemoryColumnSource, ShiftData.ShiftCallback, Releasable, TupleExporter<T>, TupleSource<T>, WritableColumnSource<T>
Direct Known Subclasses:
BooleanArraySource, ByteArraySource, CharacterArraySource, DoubleArraySource, FloatArraySource, IntegerArraySource, LongArraySource, ObjectArraySource, ShortArraySource

A ColumnSource backed by in-memory arrays of data.

The column source is dense with keys from 0 to capacity, there can be no holes. Arrays are divided into blocks so that the column source can be incrementally expanded without copying data from one array to another.

  • Field Details

  • Method Details

    • from

      public static WritableColumnSource<?> from(Array<?> array)
    • from

      public static <T> WritableColumnSource<T> from(PrimitiveArray<T> array)
    • set

      public void set(long key, byte value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, char value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, double value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, float value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, int value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, long value)
      Specified by:
      set in interface WritableColumnSource<T>
    • set

      public void set(long key, short value)
      Specified by:
      set in interface WritableColumnSource<T>
    • getMemoryColumnSource

      public static <T> WritableColumnSource<T> getMemoryColumnSource(@NotNull @NotNull Collection<T> data, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType)
      Produces an ArrayBackedColumnSource with the given data.
      Parameters:
      data - a collection containing the data to insert into the ColumnSource.
      dataType - the data type of the resulting column source
      componentType - the component type of the resulting column source
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static <T> WritableColumnSource<T> getMemoryColumnSource(@NotNull @NotNull T[] data, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType)
      Produces an ArrayBackedColumnSource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource
      dataType - the data type of the resulting column source
      componentType - the component type of the resulting column source
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Byte> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull byte[] data)
      Produces an ByteArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getBooleanMemoryColumnSource

      public static ArrayBackedColumnSource<Boolean> getBooleanMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull byte[] data)
      Produces an BooleanArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Character> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull char[] data)
      Produces an CharacterArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Double> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull double[] data)
      Produces an DoubleArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Float> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull float[] data)
      Produces an FloatArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Integer> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull int[] data)
      Produces an IntegerArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Long> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull long[] data)
      Produces an LongArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getInstantMemoryColumnSource

      public static WritableColumnSource<Instant> getInstantMemoryColumnSource(LongChunk<Values> data)
      Produces an InstantArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource, represented as long nanoseconds since the epoch
      Returns:
      an in-memory column source with the requested data
    • getInstantMemoryColumnSource

      public static WritableColumnSource<Instant> getInstantMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull long[] data)
      Produces an InstantArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource, represented as long nanoseconds since the epoch
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static ArrayBackedColumnSource<Short> getMemoryColumnSource(@NotNull @org.jetbrains.annotations.NotNull short[] data)
      Produces an ShortArraySource with the given data.
      Parameters:
      data - an array containing the data to insert into the ColumnSource.
      Returns:
      an in-memory column source with the requested data
    • getMemoryColumnSource

      public static <T> WritableColumnSource<T> getMemoryColumnSource(long size, @NotNull @NotNull Class<T> dataType)
      Produces an empty ArrayBackedColumnSource with the given type and capacity.
      Type Parameters:
      T - the type parameter for the ColumnSource's type
      Parameters:
      size - the capacity of the returned column source
      dataType - the data type of the resultant column source
      Returns:
      an in-memory column source of the requested type
    • getMemoryColumnSource

      public static <T> WritableColumnSource<T> getMemoryColumnSource(@NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType)
    • getMemoryColumnSource

      public static <T> WritableColumnSource<T> getMemoryColumnSource(long size, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType)
      Produces an empty ArrayBackedColumnSource with the given type and capacity.
      Type Parameters:
      T - the type parameter for the ColumnSource's type
      Parameters:
      size - the capacity of the returned column source
      dataType - the data type of the resultant column source
      componentType - the component type for column sources of arrays or Vectors
      Returns:
      an in-memory column source of the requested type
    • ensureCapacity

      public abstract void ensureCapacity(long size, boolean nullFill)
      Description copied from interface: WritableColumnSource
      Ensure that this WritableColumnSource can accept row keys in range [0, capacity).
      Specified by:
      ensureCapacity in interface WritableColumnSource<T>
      Parameters:
      size - The new minimum capacity
      nullFill - Whether data should be "null-filled". If true, get operations at row keys that have not been set will return the appropriate null value; otherwise such gets produce undefined results.
    • shift

      public void shift(long start, long end, long offset)
      Specified by:
      shift in interface ShiftData.ShiftCallback
    • getMemoryColumnSourceUntyped

      public static WritableColumnSource<?> getMemoryColumnSourceUntyped(@NotNull @NotNull Object dataArray)
      Creates an in-memory ColumnSource from the supplied dataArray, using instanceof checks to determine the appropriate type of column source to produce.
      Parameters:
      dataArray - the data to insert into the new column source
      Returns:
      a ColumnSource with the supplied data.
    • getMemoryColumnSourceUntyped

      public static <T> WritableColumnSource<T> getMemoryColumnSourceUntyped(@NotNull @NotNull Object dataArray, @NotNull @NotNull Class<T> dataType, @Nullable @Nullable Class<?> componentType)
      Creates an in-memory ColumnSource from the supplied dataArray, using instanceof checks to determine the appropriate type of column source to produce.
      Parameters:
      dataArray - the data to insert into the new column source
      dataType - the data type of the resultant column source
      componentType - the component type for column sources of arrays or Vectors
      Returns:
      a ColumnSource with the supplied data.
    • isImmutable

      public boolean isImmutable()
      Description copied from interface: ColumnSource
      Determine if this column source is immutable, meaning that the values at a given row key never change.
      Specified by:
      isImmutable in interface ColumnSource<T>
      Returns:
      true if the values at a given row key of the column source never change, false otherwise
    • fillChunkUnordered

      public void fillChunkUnordered(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull LongChunk<? extends RowKeys> keyIndices)
      Description copied from interface: FillUnordered
      Populates a contiguous portion of the given destination chunk with data corresponding to the keys from the given LongChunk.

      It behaves as if the following code were executed:

       destination.setSize(keys.size());
       for (int ii = 0; ii < keys.size(); ++ii) {
           destination.set(ii, get(keys.get(ii)));
       }
       
      Specified by:
      fillChunkUnordered in interface FillUnordered<T>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      destination - The chunk to be populated according to keys
      keyIndices - A chunk of individual, not assumed to be ordered keys to be fetched
    • fillPrevChunkUnordered

      public void fillPrevChunkUnordered(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull LongChunk<? extends RowKeys> keyIndices)
      Description copied from interface: FillUnordered
      Populates a contiguous portion of the given destination chunk with prev data corresponding to the keys from the given LongChunk.

      It behaves as if the following code were executed:

       destination.setSize(keys.size());
       for (int ii = 0; ii < keys.size(); ++ii) {
           destination.set(ii, getPrev(keys.get(ii)));
       }
       
      Specified by:
      fillPrevChunkUnordered in interface FillUnordered<T>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      destination - The chunk to be populated according to keys
      keyIndices - A chunk of individual, not assumed to be ordered keys to be fetched
    • fillSparseChunk

      protected abstract void fillSparseChunk(@NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull RowSequence indices)
    • fillSparsePrevChunk

      protected abstract void fillSparsePrevChunk(@NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull RowSequence indices)
    • fillSparseChunkUnordered

      protected abstract void fillSparseChunkUnordered(@NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull LongChunk<? extends RowKeys> indices)
    • fillSparsePrevChunkUnordered

      protected abstract void fillSparsePrevChunkUnordered(@NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull LongChunk<? extends RowKeys> indices)
    • getChunk

      public Chunk<Values> getChunk(@NotNull @NotNull ChunkSource.GetContext context, @NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: ChunkSource
      Returns a chunk of data corresponding to the keys from the given RowSequence.
      Specified by:
      getChunk in interface ChunkSource<T>
      Specified by:
      getChunk in interface DefaultChunkSource<T>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk. In particular, the Context may be used to provide a Chunk data pool
      rowSequence - An RowSequence representing the keys to be fetched
      Returns:
      A chunk of data corresponding to the keys from the given RowSequence
    • providesFillUnordered

      public boolean providesFillUnordered()
      Description copied from interface: FillUnordered
      Returns true if this column source can efficiently provide an unordered fill. If this method returns false, then fillChunkUnordered and fillPrevChunkUnordered may throw an UnsupportedOperationException.
      Specified by:
      providesFillUnordered in interface FillUnordered<T>
      Returns:
      if this column source can provide an unordered fill