adelapena commented on code in PR #2989:
URL: https://github.com/apache/cassandra/pull/2989#discussion_r1426678189


##########
src/java/org/apache/cassandra/index/sai/disk/v1/segment/SegmentRamBuffer.java:
##########
@@ -55,14 +56,17 @@ public long memoryUsed()
         return trie.sizeOnHeap() + postingsAccumulator.heapAllocations();
     }
 
-    public long add(int segmentRowId, byte[] value)
+    public long add(ByteComparable term, int termLength, int segmentRowId)
     {
         final long initialSizeOnHeap = trie.sizeOnHeap();
         final long reducerHeapSize = postingsAccumulator.heapAllocations();
 
         try
         {
-            trie.putRecursive(v -> ByteSource.fixedLength(value), 
segmentRowId, postingsAccumulator);
+            if (termLength <= MAX_RECURSIVE_TERM_LENGTH)
+                trie.putRecursive(term, segmentRowId, postingsAccumulator);
+            else
+                trie.apply(Trie.singleton(term, segmentRowId), 
postingsAccumulator);

Review Comment:
   Maybe this can be simplified to:
   ```java
   trie.putSingleton(term, segmentRowId, postingsAccumulator, termLength <= 
MAX_RECURSIVE_TERM_LENGTH);
   ```
   There is a similar usage pattern in `TrieMemoryIndex#addTerm(PrimaryKey, 
ByteBuffer)`.



-- 
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]

Reply via email to