Aklakan commented on code in PR #3047:
URL: https://github.com/apache/jena/pull/3047#discussion_r1983151248


##########
jena-arq/src/main/java/org/apache/jena/sparql/exec/RowSetOps.java:
##########
@@ -51,7 +51,7 @@ public static void consume(RowSet rowSet)
      * This operation consumes the RowSet.
      */
     public static long count(RowSet rowSet)
-    { return rowSet.rewindable().size(); }
+    { long c[] = {0}; rowSet.forEach(b -> ++c[0]); return c[0]; }

Review Comment:
   Behavior so far (IIRC):
   * For non-RowSetMem instances counting would create an intermediate 
in-memory copy.
   * The count for a RowSetMem instances would be the number of bindings in the 
row set - rather than the number of remaining bindings.
   
   I added a the method `RowSetStream.forEachRemaining` - the stack trace for 
`RowSetOps.count` then becomes a delegate to the forEachRemaining method (with 
some boilerplate):
   
   
![image](https://github.com/user-attachments/assets/a9726dfa-4a7b-4dbc-b243-47ef2a18db43)
   



-- 
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: pr-unsubscr...@jena.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@jena.apache.org
For additional commands, e-mail: pr-h...@jena.apache.org

Reply via email to