Class ImmutableShortArraySource

All Implemented Interfaces:
ChunkSink<Values>, ChunkSource<Values>, ChunkSource.WithPrev<Values>, ColumnSource<Short>, ElementSource<Short>, FillContextMaker, GetContextMaker, ColumnSourceGetDefaults.ForShort, DefaultChunkSource<Values>, DefaultChunkSource.WithPrev<Values>, ImmutableColumnSource<Short>, ImmutableColumnSourceGetDefaults.ForShort, ChunkedBackingStoreExposedWritableSource, DeferredGroupingColumnSource<Short>, FillUnordered<Values>, InMemoryColumnSource, Releasable, TupleExporter<Short>, TupleSource<Short>, WritableColumnSource<Short>, WritableSourceWithPrepareForParallelPopulation

Simple flat array source that supports fillFromChunk for initial creation. No previous value tracking is permitted, so this column source is only useful as a flat static source. A single array backs the result, so getChunk calls with contiguous ranges should always be able to return a reference to the backing store without an array copy. The immediate consequence is that you may not create sources that have a capacity larger than the maximum capacity of an array. If your size is greater than the maximum capacity of an array, prefer Immutable2DShortArraySource.
  • Constructor Details

    • ImmutableShortArraySource

      public ImmutableShortArraySource()
    • ImmutableShortArraySource

      public ImmutableShortArraySource(short[] data)
  • Method Details

    • getShort

      public final short getShort(long rowKey)
      Description copied from interface: ElementSource
      Get the value at the rowKey as a short. RowKeys that are not present are undefined.
      Specified by:
      getShort in interface ElementSource<Short>
      Parameters:
      rowKey - the location in key space to get the value from.
      Returns:
      the short at the rowKey, null values are represented by QueryConstants.NULL_SHORT
    • getUnsafe

      public final short getUnsafe(long rowKey)
    • getAndSetUnsafe

      public final short getAndSetUnsafe(long rowKey, short newValue)
    • setNull

      public final void setNull(long key)
      Specified by:
      setNull in interface WritableColumnSource<Short>
    • set

      public final void set(long key, short value)
      Specified by:
      set in interface WritableColumnSource<Short>
    • ensureCapacity

      public void ensureCapacity(long capacity, boolean nullFilled)
      Description copied from interface: WritableColumnSource
      Ensure that this WritableColumnSource can accept row keys in range [0, capacity).
      Specified by:
      ensureCapacity in interface WritableColumnSource<Short>
      Parameters:
      capacity - The new minimum capacity
      nullFilled - 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.
    • fillChunk

      public void fillChunk(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: ChunkSource
      Populates the given destination chunk with data corresponding to the keys from the given RowSequence.
      Specified by:
      fillChunk in interface ChunkSource<Values>
      Overrides:
      fillChunk in class AbstractColumnSource<Short>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      destination - The chunk to be populated according to rowSequence. No assumptions shall be made about the size of the chunk shall be made. The chunk will be populated from position [0,rowSequence.size()).
      rowSequence - An RowSequence representing the keys to be fetched
    • getChunk

      public Chunk<? extends 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<Values>
      Specified by:
      getChunk in interface DefaultChunkSource<Values>
      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
    • resetWritableChunkToBackingStore

      public long resetWritableChunkToBackingStore(@NotNull @NotNull ResettableWritableChunk<?> chunk, long position)
      Description copied from interface: ChunkedBackingStoreExposedWritableSource
      Resets the given chunk to provide a write-through reference to our backing array.

      Note: This is unsafe to use if previous tracking has been enabled!

      Specified by:
      resetWritableChunkToBackingStore in interface ChunkedBackingStoreExposedWritableSource
      Parameters:
      chunk - the writable chunk to reset to our backing array.
      position - position that we require
      Returns:
      the first position addressable by the chunk
    • resetWritableChunkToBackingStoreSlice

      public long resetWritableChunkToBackingStoreSlice(@NotNull @NotNull ResettableWritableChunk<?> chunk, long position)
      Description copied from interface: ChunkedBackingStoreExposedWritableSource
      Resets the given chunk to provide a write-through reference to our backing array.

      Note: This is unsafe to use if previous tracking has been enabled!

      Specified by:
      resetWritableChunkToBackingStoreSlice in interface ChunkedBackingStoreExposedWritableSource
      Parameters:
      chunk - the writable chunk to reset to a slice of our backing array.
      position - position of the first value in the returned chunk
      Returns:
      the capacity of the returned chunk
    • getChunk

      public Chunk<? extends Values> getChunk(@NotNull @NotNull ChunkSource.GetContext context, long firstKey, long lastKey)
      Description copied from interface: ChunkSource
      Same as ChunkSource.getChunk(GetContext, RowSequence), except that you pass in the begin and last keys representing the begin and last (inclusive) keys of a single range rather than an RowSequence. Typically you want to call this only if you don't have an RowSequence, such as during an RowSequence.forAllRowKeyRanges(LongRangeConsumer) call. In this case, it allows you to avoid creating an intermediary RowSequence object.
      Specified by:
      getChunk in interface ChunkSource<Values>
      Specified by:
      getChunk in interface DefaultChunkSource<Values>
      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
      firstKey - The beginning key (inclusive) of the range to fetch in the chunk
      lastKey - The last key (inclusive) of the range to fetch in the chunk
    • fillFromChunk

      public void fillFromChunk(@NotNull @NotNull ChunkSink.FillFromContext context, @NotNull @NotNull Chunk<? extends Values> src, @NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: WritableColumnSource
      Our default, inefficient, implementation. Inheritors who care should provide a better implementation.
      Specified by:
      fillFromChunk in interface ChunkSink<Values>
      Specified by:
      fillFromChunk in interface WritableColumnSource<Short>
      Parameters:
      context - A context containing all mutable/state related data used in writing the Chunk.
      src - The source of the data rowSequence
      rowSequence - An RowSequence representing the keys to be written
    • fillFromChunkUnordered

      public void fillFromChunkUnordered(@NotNull @NotNull ChunkSink.FillFromContext context, @NotNull @NotNull Chunk<? extends Values> src, @NotNull @NotNull LongChunk<RowKeys> keys)
      Description copied from interface: ChunkSink
      Fills the ChunkSink with data from the source, with data corresponding to the keys from the given key chunk.
      Specified by:
      fillFromChunkUnordered in interface ChunkSink<Values>
      Specified by:
      fillFromChunkUnordered in interface WritableColumnSource<Short>
      Parameters:
      context - A context containing all mutable/state related data used in writing the Chunk.
      src - The source of the data RowSequence
      keys - A LongChunk representing the keys to be written
    • fillChunkUnordered

      public void fillChunkUnordered(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> dest, @NotNull @NotNull LongChunk<? extends RowKeys> keys)
      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<Values>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      dest - The chunk to be populated according to keys
      keys - 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> dest, @NotNull @NotNull LongChunk<? extends RowKeys> keys)
      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<Values>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      dest - The chunk to be populated according to keys
      keys - A chunk of individual, not assumed to be ordered keys to be fetched
    • fillPrevChunk

      public void fillPrevChunk(@NotNull @NotNull ChunkSource.FillContext context, @NotNull @NotNull WritableChunk<? super Values> destination, @NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: ChunkSource.WithPrev
      Populates the given destination chunk with data corresponding to the keys from the given RowSequence.
      Specified by:
      fillPrevChunk in interface ChunkSource.WithPrev<Values>
      Overrides:
      fillPrevChunk in class AbstractColumnSource<Short>
      Parameters:
      context - A context containing all mutable/state related data used in retrieving the Chunk.
      destination - The chunk to be populated according to rowSequence. No assumptions shall be made about the size of the chunk shall be made. The chunk will be populated from position [0,rowSequence.size()).
      rowSequence - An RowSequence representing the keys to be fetched
    • getPrevChunk

      public Chunk<? extends Values> getPrevChunk(@NotNull @NotNull ChunkSource.GetContext context, @NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: ChunkSource.WithPrev
      Returns a chunk of previous data corresponding to the keys from the given RowSequence.
      Specified by:
      getPrevChunk in interface ChunkSource.WithPrev<Values>
      Specified by:
      getPrevChunk in interface DefaultChunkSource.WithPrev<Values>
      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
    • getPrevChunk

      public Chunk<? extends Values> getPrevChunk(@NotNull @NotNull ChunkSource.GetContext context, long firstKey, long lastKey)
      Description copied from interface: ChunkSource.WithPrev
      Same as ChunkSource.WithPrev.getPrevChunk(GetContext, RowSequence), except that you pass in the begin and last keys representing the begin and last (inclusive) keys of a single range rather than an RowSequence.
      Specified by:
      getPrevChunk in interface ChunkSource.WithPrev<Values>
      Specified by:
      getPrevChunk in interface DefaultChunkSource.WithPrev<Values>
    • 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<Values>
      Returns:
      if this column source can provide an unordered fill
    • prepareForParallelPopulation

      public void prepareForParallelPopulation(@NotNull @NotNull RowSequence rowSequence)
      Description copied from interface: WritableSourceWithPrepareForParallelPopulation
      Prepare this column source such that:
      • all values in rowSet may be accessed using getPrev
      • all values in rowSet may be populated in parallel

      Further operations in this cycle need not check for previous when writing data to the column source; you must provide a row set that contains every row that may be written to this column source.

      Specified by:
      prepareForParallelPopulation in interface WritableSourceWithPrepareForParallelPopulation
      Parameters:
      rowSequence - the row sequence of values that will change on this cycle
    • getArray

      public short[] getArray()
    • setArray

      public void setArray(short[] array)