[ 
https://issues.apache.org/jira/browse/JENA-1857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17056305#comment-17056305
 ] 

Andy Seaborne edited comment on JENA-1857 at 3/10/20, 8:38 PM:
---------------------------------------------------------------

This seems more in the style of TIM code:
In {{DatasetGraphInMemory}}

{code:java}
    @Override
    public long size() {
        // WAS: return quadsIndex().listGraphNodes().count();
        return isInTransaction() 
                ? quadsIndex().listGraphNodes().count()
                : calculateRead(this, 
()->quadsIndex().listGraphNodes().count());
    }
{code}

R and W transactions differ because {{begin}} always sets 
{{PMapQuadTable.local()}}. Only W, going into {{PMapQuadTable.commit()}} then 
{{PMapQuadTable.end()}} clears it. R doesn't need to do commit work.



was (Author: andy.seaborne):
This seems more in the style of TIM code:
In {{DatasetGraphInMemory}}

{code:java}
    @Override
    public long size() {
        // WAS: return quadsIndex().listGraphNodes().count();
        return isInTransaction() 
                ? quadsIndex().listGraphNodes().count()
                : calculateRead(this, 
()->quadsIndex().listGraphNodes().count());
    }
{code}

R and W transactions differ because {{begin}} always sets 
{{PMapQuadTable.local()}}. Only W, going into {{PMapQuadTable.commit()}} then 
{{PMapQuadTable.end()}} clears it. R doesn't need to do commit work.

Thinking out loud: W could just leave {{local()}} set, and it initially be set 
the same as {{master()}}. This isn't the style of TIM though where all API 
operations add a transaction as needed.

{code:java}
    //private final ThreadLocal<TupleMapType> local = withInitial(()->null); 
    private final ThreadLocal<TupleMapType> local = withInitial(()->initial()); 
{code}
{code:java}
 @Override
    public void end() {
        debug("Abandoning transactional reference.");
        //local.remove();
    }
{code}

> DatasetGraphInMemory.listGraphNodes causes exception outside a transaction
> --------------------------------------------------------------------------
>
>                 Key: JENA-1857
>                 URL: https://issues.apache.org/jira/browse/JENA-1857
>             Project: Apache Jena
>          Issue Type: Task
>          Components: TIM
>    Affects Versions: Jena 3.14.0
>            Reporter: Andy Seaborne
>            Priority: Major
>
> Test case: 
> {code:java}
>     public static void main(String ... a) {
>         DatasetGraph dsg = DatasetGraphFactory.createTxnMem();
>         Quad q = SSE.parseQuad("(:g :s :p :o)");
>         dsg.add(q);
>         try {
>             System.out.println(dsg.size());
>         } catch (Exception ex) {
>             ex.printStackTrace();
>         }
>     }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to