Class SegmentBuilder

java.lang.Object
org.apache.cassandra.index.sai.disk.v1.segment.SegmentBuilder
Direct Known Subclasses:
SegmentBuilder.TrieSegmentBuilder, SegmentBuilder.VectorSegmentBuilder

@NotThreadSafe public abstract class SegmentBuilder extends Object
Creates an on-heap index data structure to be flushed to an SSTable index.
  • Field Details

    • LAST_VALID_SEGMENT_ROW_ID

      public static final long LAST_VALID_SEGMENT_ROW_ID
      See Also:
  • Method Details

    • getActiveBuilderCount

      public static int getActiveBuilderCount()
    • flush

      public SegmentMetadata flush(IndexDescriptor indexDescriptor) throws IOException
      Throws:
      IOException
    • add

      public long add(ByteBuffer term, PrimaryKey key, long sstableRowId)
    • castToSegmentRowId

      public static int castToSegmentRowId(long sstableRowId, long segmentRowIdOffset)
    • totalBytesAllocated

      public long totalBytesAllocated()
    • hasReachedMinimumFlushSize

      public boolean hasReachedMinimumFlushSize()
    • getMinimumFlushBytes

      public long getMinimumFlushBytes()
    • release

      public long release()
      This method does three things:

      1. It decrements active builder count and updates the global minimum flush size to reflect that. 2. It releases the builder's memory against its limiter. 3. It defensively marks the builder inactive to make sure nothing bad happens if we try to close it twice.

      Returns:
      the number of bytes used by the memory limiter after releasing this builder
    • isEmpty

      public abstract boolean isEmpty()
    • addInternal

      protected abstract long addInternal(ByteBuffer term, int segmentRowId)
    • flushInternal

      protected abstract SegmentMetadata.ComponentMetadataMap flushInternal(IndexDescriptor indexDescriptor) throws IOException
      Throws:
      IOException
    • getRowCount

      public int getRowCount()
    • exceedsSegmentLimit

      public boolean exceedsSegmentLimit(long ssTableRowId)
      Returns:
      true if next SSTable row ID exceeds max segment row ID
    • updateLastValidSegmentRowId

      public static void updateLastValidSegmentRowId(long lastValidSegmentRowID)