Interface WritableRowRedirection

All Superinterfaces:
ChunkSink<RowKeys>, ChunkSource<RowKeys>, ChunkSource.WithPrev<RowKeys>, DefaultChunkSource<RowKeys>, DefaultChunkSource.WithPrev<RowKeys>, FillContextMaker, FillUnordered<RowKeys>, GetContextMaker, RowRedirection
All Known Implementing Classes:
ContiguousWritableRowRedirection, GroupedWritableRowRedirection, IntColumnSourceWritableRowRedirection, LongColumnSourceWritableRowRedirection, WritableRowRedirectionLockFree

public interface WritableRowRedirection extends RowRedirection, ChunkSink<RowKeys>
Writable RowRedirection. A WritableRowRedirection can be in one of two states: tracking prev values or not. The typical lifecycle looks like this:
  1. A WritableRowRedirection is created with an initial map, but not tracking prev values. In this state, get() and getPrev() behave identically; put() and remove() affect current values but do no "prev value" tracking.
  2. Prev value tracking begins when the caller calls startTrackingPrevValues(). Immediately after this call, the data is logically "forked": getPrev() will still refer to the same set of entries as before; this set will be frozen until the end of the generation.
  3. Additionally, a terminal listener will be registered so that the prev map will be updated at the end of the generation.
  4. Meanwhile, get(), put(), and remove() will logically refer to a fork of that map: it will initially have the same entries as prev, but it will diverge over time as the caller does put() and remove() operations.
  5. At the end of the generation (when the TerminalListener runs), the prev set is (logically) discarded, prev gets current, and current becomes the new fork of the map.
  • Field Details

  • Method Details

    • startTrackingPrevValues

      void startTrackingPrevValues()
      Initiate previous value tracking.
    • put

      long put(long outerRowKey, long innerRowKey)
      Add or change a mapping from outerRowKey to innerRowKey.
      Parameters:
      outerRowKey - The outer row key to map from
      innerRowKey - The inner row key to map to
      Returns:
      The inner row key previously mapped from outerRowKey, or RowSequence.NULL_ROW_KEY if there was no mapping
    • remove

      long remove(long outerRowKey)
      Remove a mapping from outerRowKey.
      Parameters:
      outerRowKey - The outer row key to unmap
      Returns:
      The inner row key previously mapped from outerRowKey, or RowSequence.NULL_ROW_KEY if there was no mapping
    • putVoid

      default void putVoid(long outerRowKey, long innerRowKey)
      Like put(long, long), but without requiring the implementation to provide a return value. May be more efficient in some cases.
      Parameters:
      outerRowKey - The outer row key to map from
      innerRowKey - The inner row key to map to
    • removeVoid

      default void removeVoid(long outerRowKey)
      Like remove(long) (long, long)}, but without requiring the implementation to provide a return value. May be more efficient in some cases.
      Parameters:
      outerRowKey - The outer row key to map from
    • removeAll

      default void removeAll(RowSequence rowSequence)
      Remove the specified rowSequence.
      Parameters:
      rowSequence - The outer row keys to remove
    • removeAllUnordered

      default void removeAllUnordered(LongChunk<RowKeys> outerRowKeys)
      Remove the specified outerRowKeys.
      Parameters:
      outerRowKeys - The outer row keys to remove
    • makeFillFromContext

      default ChunkSink.FillFromContext makeFillFromContext(int chunkCapacity)
      Make a ChunkSink.FillFromContext for this WritableRowRedirection. The default implementation supplies DEFAULT_FILL_FROM_INSTANCE, suitable for use with the default implementation of fillFromChunk(ChunkSink.FillFromContext, Chunk, RowSequence).
      Specified by:
      makeFillFromContext in interface ChunkSink<RowKeys>
      Parameters:
      chunkCapacity - The maximum number of mappings that will be supplied in one operation
      Returns:
      The ChunkSink.FillFromContext to use
    • fillFromChunk

      default void fillFromChunk(@NotNull ChunkSink.FillFromContext fillFromContext, @NotNull @NotNull Chunk<? extends RowKeys> innerRowKeys, @NotNull @NotNull RowSequence outerRowKeys)
      Insert mappings from each element in a RowSequence to the parallel element in a LongChunk. h
      Specified by:
      fillFromChunk in interface ChunkSink<RowKeys>
      Parameters:
      fillFromContext - THe FillFromContext
      innerRowKeys - The inner row keys to map to
      outerRowKeys - The outer row keys to map from
    • fillFromChunkUnordered

      default void fillFromChunkUnordered(@NotNull @NotNull ChunkSink.FillFromContext context, @NotNull @NotNull Chunk<? extends RowKeys> innerRowKeys, @NotNull @NotNull LongChunk<RowKeys> outerRowKeys)
      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<RowKeys>
      Parameters:
      context - A context containing all mutable/state related data used in writing the Chunk.
      innerRowKeys - The source of the data RowSequence
      outerRowKeys - A LongChunk representing the keys to be written
    • applyShift

      default void applyShift(RowSet tableRowSet, RowSetShiftData shiftData)
      Update this WritableRowRedirection according to a RowSetShiftData.
      Parameters:
      tableRowSet - A RowSet to filter which rows should be shifted
      shiftData - The RowSetShiftData for this update