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

ASF GitHub Bot commented on JENA-1520:
--------------------------------------

Github user afs commented on a diff in the pull request:

    https://github.com/apache/jena/pull/396#discussion_r181468935
  
    --- Diff: 
jena-db/jena-tdb2/src/main/java/org/apache/jena/tdb2/solver/stats/StatsCollectorNodeId.java
 ---
    @@ -18,39 +18,39 @@
     
     package org.apache.jena.tdb2.solver.stats;
     
    -import java.util.HashMap ;
    -import java.util.Map ;
    +import java.util.HashMap;
    +import java.util.Map;
     
    -import org.apache.jena.graph.Node ;
    -import org.apache.jena.sparql.graph.NodeConst ;
    +import org.apache.jena.graph.Node;
    +import org.apache.jena.sparql.graph.NodeConst;
     import org.apache.jena.tdb2.store.NodeId;
     import org.apache.jena.tdb2.store.nodetable.NodeTable;
     
     /** Statistics collector, aggregates based on NodeId */
    -public class StatsCollectorNodeId extends StatsCollectorBase<NodeId>
    -{
    -    private NodeTable nodeTable ;
    -    
    -    public StatsCollectorNodeId(NodeTable nodeTable)
    -    {
    -        super(findRDFType(nodeTable)) ;
    -        this.nodeTable = nodeTable ;
    +public class StatsCollectorNodeId extends StatsCollectorBase<NodeId> {
    +    private NodeTable nodeTable;
    +
    +    public StatsCollectorNodeId(NodeTable nodeTable) {
    +        super(findRDFType(nodeTable));
    +        this.nodeTable = nodeTable;
         }
    -    
    -    private static NodeId findRDFType(NodeTable nodeTable2)
    -    {
    -        return nodeTable2.getAllocateNodeId(NodeConst.nodeRDFType) ;
    +
    +    private static NodeId findRDFType(NodeTable nodeTable) {
    +        // It may not exist.
    +        NodeId nodeId = nodeTable.getNodeIdForNode(NodeConst.nodeRDFType);
    +        if ( NodeId.isDoesNotExist(nodeId) )
    --- End diff --
    
    Yes, that's right.  The stats engine gathers details for `rdf:type` 
specially so it needs to know the trigger for that. `StatsCollectorBase` is a 
generic and works on an index scan, no touching the node table for every tuple 
of a triple/quad. Here, it's a `NodeId`. if it isn't in the node table, it is 
not in the data.
    
    As it was, it tried to update the node table to add the `rdf:type`, but it 
is in a read transaction so `NodeTable.getAllocateNodeId` fails.



> tdb2.tdbstats
> -------------
>
>                 Key: JENA-1520
>                 URL: https://issues.apache.org/jira/browse/JENA-1520
>             Project: Apache Jena
>          Issue Type: Bug
>          Components: TDB2
>    Affects Versions: Jena 3.7.0
>            Reporter: Andy Seaborne
>            Assignee: Andy Seaborne
>            Priority: Minor
>             Fix For: Jena 3.8.0
>
>
> {{tdb2.tdbstats}} works mostly but breaks when trying to find the 
> {{rdf:type}} node.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to