adelapena commented on code in PR #2989:
URL: https://github.com/apache/cassandra/pull/2989#discussion_r1431354842
##########
src/java/org/apache/cassandra/index/sai/disk/v1/segment/SegmentBuilder.java:
##########
@@ -78,31 +75,36 @@ public abstract class SegmentBuilder
int rowCount = 0;
int maxSegmentRowId = -1;
- public static class BlockBalancedTreeSegmentBuilder extends SegmentBuilder
+ public static abstract class RamBufferSegmentBuilder extends SegmentBuilder
{
- private final byte[] scratch;
- private final BlockBalancedTreeRamBuffer trieBuffer;
+ protected final SegmentRamBuffer segmentRamBuffer;
- public BlockBalancedTreeSegmentBuilder(IndexTermType indexTermType,
NamedMemoryLimiter limiter)
+ protected RamBufferSegmentBuilder(IndexTermType indexTermType,
NamedMemoryLimiter namedMemoryLimiter)
{
- super(indexTermType, limiter);
+ super(indexTermType,namedMemoryLimiter);
- scratch = new byte[indexTermType.fixedSizeOf()];
- trieBuffer = new
BlockBalancedTreeRamBuffer(indexTermType.fixedSizeOf());
- totalBytesAllocated = this.trieBuffer.memoryUsed();
+ segmentRamBuffer = new SegmentRamBuffer();
+ totalBytesAllocated = this.segmentRamBuffer.memoryUsed();
}
@Override
public boolean isEmpty()
{
- return trieBuffer.numRows() == 0;
+ return segmentRamBuffer.numRows() == 0;
+ }
+ }
+
+ public static class BlockBalancedTreeSegmentBuilder extends
RamBufferSegmentBuilder
+ {
+ public BlockBalancedTreeSegmentBuilder(IndexTermType indexTermType,
NamedMemoryLimiter limiter)
+ {
+ super(indexTermType, limiter);
}
@Override
protected long addInternal(ByteBuffer term, int segmentRowId)
{
- indexTermType.toComparableBytes(term, scratch);
- return trieBuffer.add(segmentRowId, scratch);
+ return segmentRamBuffer.add(v ->
indexTermType.asComparableBytes(term, v), term.limit(), segmentRowId);
Review Comment:
The new `SegmentWriter` interface looks great :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]