You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by afs <gi...@git.apache.org> on 2018/04/12 16:32:59 UTC

[GitHub] jena pull request #396: JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

GitHub user afs opened a pull request:

    https://github.com/apache/jena/pull/396

    JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/afs/jena tdb2-tdbstats

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/jena/pull/396.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #396
    
----
commit 55516f717caba7d41c4b78ca298f4c030cedcddf
Author: Andy Seaborne <an...@...>
Date:   2018-04-12T16:18:29Z

    JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

----


---

[GitHub] jena pull request #396: JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/jena/pull/396


---

[GitHub] jena pull request #396: JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

Posted by ajs6f <gi...@git.apache.org>.
Github user ajs6f commented on a diff in the pull request:

    https://github.com/apache/jena/pull/396#discussion_r181458378
  
    --- 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 --
    
    Jut for my own education-- am I right in understanding this to be the fix for the "no type triples in the data" problem?


---

[GitHub] jena pull request #396: JENA-1520: tdb2.tdbstats: cmd and fix for rdf:type

Posted by afs <gi...@git.apache.org>.
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.



---