maedhroz commented on code in PR #2487:
URL: https://github.com/apache/cassandra/pull/2487#discussion_r1262925279


##########
src/java/org/apache/cassandra/index/sai/disk/v1/bbtree/BlockBalancedTreeWalker.java:
##########
@@ -67,9 +105,52 @@ public class BlockBalancedTreeWalker implements Closeable
         }
     }
 
+    @VisibleForTesting
+    public BlockBalancedTreeWalker(DataInput indexInput, long treeIndexRoot) 
throws IOException
+    {
+        treeIndexFile = null;
+
+        indexInput.skipBytes(treeIndexRoot);
+
+        maxPointsInLeafNode = indexInput.readVInt();
+        bytesPerValue = indexInput.readVInt();
+
+        // Read index:
+        numLeaves = indexInput.readVInt();
+        assert numLeaves > 0;
+        treeDepth = indexInput.readVInt();
+        minPackedValue = new byte[bytesPerValue];
+        maxPackedValue = new byte[bytesPerValue];
+
+        indexInput.readBytes(minPackedValue, 0, bytesPerValue);
+        indexInput.readBytes(maxPackedValue, 0, bytesPerValue);
+
+        if (ByteArrayUtil.compareUnsigned(minPackedValue, 0, maxPackedValue, 
0, bytesPerValue) > 0)
+        {
+            String message = String.format("Min packed value %s is > max 
packed value %s.",
+                                           new BytesRef(minPackedValue), new 
BytesRef(maxPackedValue));
+            throw new CorruptIndexException(message, indexInput);
+        }
+
+        valueCount = indexInput.readVLong();
+
+        int numBytes = indexInput.readVInt();
+        packedIndex = new byte[numBytes];
+        indexInput.readBytes(packedIndex, 0, numBytes);
+
+        memoryUsage = ObjectSizes.sizeOfArray(packedIndex) +
+                      ObjectSizes.sizeOfArray(minPackedValue) +
+                      ObjectSizes.sizeOfArray(maxPackedValue);
+    }
+
     public long memoryUsage()
     {
-        return state.memoryUsage;
+        return memoryUsage;
+    }
+
+    public TraversalState createTraversalState()

Review Comment:
   nit: Maybe `newTraversalState()`?
   
   (can just change on commit if you like it)



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