You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@jena.apache.org by GitBox <gi...@apache.org> on 2020/03/12 16:17:35 UTC

[GitHub] [jena] afs commented on a change in pull request #707: JENA-1857: DatasetGraphInMemory.size.

afs commented on a change in pull request #707: JENA-1857: DatasetGraphInMemory.size.
URL: https://github.com/apache/jena/pull/707#discussion_r391733804
 
 

 ##########
 File path: jena-arq/src/main/java/org/apache/jena/sparql/core/mem/DatasetGraphInMemory.java
 ##########
 @@ -400,7 +400,9 @@ public DatasetPrefixStorage prefixes() {
 
     @Override
     public long size() {
-        return quadsIndex().listGraphNodes().count() ;
+        return isInTransaction() 
+                ? quadsIndex().listGraphNodes().count()
+                : calculateRead(this, ()->quadsIndex().listGraphNodes().count());
 
 Review comment:
   `access` returns `Iterator<T>`.
   
   I had tried `quadsIndex().listGraphNodes()::count` -- it does not work.
   
   It is different because is `quadsIndex().listGraphNodes()` is called as a plain argument (i.e. early), the method pointer calculated with `::count` and that passed in so only `count()` is delayed to inside the R transaction.
   
   `()->quadsIndex().listGraphNodes().count()` delays calling `quadsIndex().listGraphNodes()` to inside the R transaction and `listGraphNodes()` is the critical step.
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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