dcapwell commented on code in PR #4561:
URL: https://github.com/apache/cassandra/pull/4561#discussion_r2748393364


##########
src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java:
##########
@@ -453,6 +459,70 @@ public Iterator<ByteBuffer> valuesOf(Row row, long 
nowInSecs)
         }
     }
 
+    public Iterator<ByteBuffer> valuesOfFrozenCollection (Row row, long 
nowInSecs)
+    {
+        Cell<?> cell = row.getCell(columnMetadata);
+        if (cell == null || !cell.isLive(nowInSecs))
+            return null;
+
+        ByteBuffer buffer = cell.buffer();
+        if (buffer == null || buffer.remaining() == 0)
+            return null;
+
+        CollectionType<?> collectionType = (CollectionType<?>) 
columnMetadata.type.unwrap();
+        CollectionSerializer<?> serializer = collectionType.getSerializer();
+        List<ByteBuffer> elements = serializer.unpack(buffer);
+
+        Stream<ByteBuffer> stream;
+        switch (collectionType.kind)
+        {
+            case LIST:
+            case SET:
+                stream = elements.stream();
+                break;
+            case MAP:
+                stream = extractMapElements(elements);
+                break;
+            default:
+                throw new IllegalArgumentException("Unsupported type of 
collection - " + collectionType.kind);

Review Comment:
   Checked and our style guide doesn't call it out (mailing list talked about 
it) but streams are actually slow, so best to avoid them in hotter paths.



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