Class Immutable2DByteArraySource

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

Simple almost 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 two-dimension array single array backs the result, with by default segments of 2^30 elements. This is so that getChunk calls with contiguous ranges are often able to return a reference to the backing store without an array copy. If your size is smaller than the maximum array size, prefer ImmutableByteArraySource.
  • Constructor Details

    • Immutable2DByteArraySource

      public Immutable2DByteArraySource()
    • Immutable2DByteArraySource

      public Immutable2DByteArraySource(int segmentShift)
  • Method Details

    • getByte

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

      public final byte getUnsafe(long key)
    • setNull

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

      public final void set(long key, byte value)
      Specified by:
      set in interface WritableColumnSource<Byte>
    • 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<Byte>
      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.
    • 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
    • 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<Byte>
      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
    • 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<Byte>
      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<Byte>
      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<Byte>
      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(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
    • allowsReinterpret

      public <ALTERNATE_DATA_TYPE> boolean allowsReinterpret(@NotNull @NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType)
      Description copied from interface: ColumnSource
      Test if a reinterpret call will succeed.
      Specified by:
      allowsReinterpret in interface ColumnSource<Byte>
      Overrides:
      allowsReinterpret in class AbstractColumnSource<Byte>
      Parameters:
      alternateDataType - The alternative type to consider
      Returns:
      If a reinterpret on this column source with the supplied alternateDataType will succeed.
    • doReinterpret

      protected <ALTERNATE_DATA_TYPE> ColumnSource<ALTERNATE_DATA_TYPE> doReinterpret(@NotNull @NotNull Class<ALTERNATE_DATA_TYPE> alternateDataType)
      Description copied from class: AbstractColumnSource
      Supply allowed reinterpret results. The default implementation handles the most common case to avoid code duplication.
      Overrides:
      doReinterpret in class AbstractColumnSource<Byte>
      Parameters:
      alternateDataType - The alternate data type
      Returns:
      The resulting ColumnSource