Search in sources :

Example 1 with StatsResults

use of org.apache.jena.tdb2.solver.stats.StatsResults in project jena by apache.

the class tdbstats method stats$.

private static StatsResults stats$(DatasetGraphTDB dsg, Node gn) {
    NodeTable nt = dsg.getTripleTable().getNodeTupleTable().getNodeTable();
    StatsCollectorNodeId stats = new StatsCollectorNodeId(nt);
    if (gn == null) {
        Iterator<Tuple<NodeId>> iter = dsg.getTripleTable().getNodeTupleTable().findAll();
        for (; iter.hasNext(); ) {
            Tuple<NodeId> t = iter.next();
            stats.record(null, t.get(0), t.get(1), t.get(2));
        }
    } else {
        // If the union graph, then we need to scan all quads but with uniqueness.
        boolean unionGraph = Quad.isUnionGraph(gn);
        NodeId gnid = null;
        if (!unionGraph) {
            gnid = nt.getNodeIdForNode(gn);
            if (NodeId.isDoesNotExist(gnid))
                Log.warn(tdbstats.class, "No such graph: " + gn);
        }
        NodeTupleTable ntt = dsg.getQuadTable().getNodeTupleTable();
        Iterator<Tuple<NodeId>> iter = unionGraph ? SolverLibTDB.unionGraph(ntt) : ntt.find(gnid, null, null, null);
        for (; iter.hasNext(); ) {
            Tuple<NodeId> t = iter.next();
            stats.record(t.get(0), t.get(1), t.get(2), t.get(3));
        }
    }
    return stats.results();
}
Also used : NodeTupleTable(org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable) NodeId(org.apache.jena.tdb2.store.NodeId) StatsCollectorNodeId(org.apache.jena.tdb2.solver.stats.StatsCollectorNodeId) NodeTable(org.apache.jena.tdb2.store.nodetable.NodeTable) Tuple(org.apache.jena.atlas.lib.tuple.Tuple) StatsCollectorNodeId(org.apache.jena.tdb2.solver.stats.StatsCollectorNodeId)

Example 2 with StatsResults

use of org.apache.jena.tdb2.solver.stats.StatsResults in project jena by apache.

the class TestStats method stats_04.

@Test
public void stats_04() {
    StatsResults r = statsForGraph(null);
    assertEquals(3, r.getCount());
    assertEquals(1, r.getPredicates().keySet().size());
}
Also used : StatsResults(org.apache.jena.tdb2.solver.stats.StatsResults) Test(org.junit.Test)

Example 3 with StatsResults

use of org.apache.jena.tdb2.solver.stats.StatsResults in project jena by apache.

the class TestStats method stats_01.

@Test
public void stats_01() {
    StatsResults r = statsForDftGraph();
    assertEquals(1, r.getCount());
    assertEquals(1, r.getPredicates().keySet().size());
}
Also used : StatsResults(org.apache.jena.tdb2.solver.stats.StatsResults) Test(org.junit.Test)

Example 4 with StatsResults

use of org.apache.jena.tdb2.solver.stats.StatsResults in project jena by apache.

the class tdbstats method exec.

@Override
protected void exec() {
    DatasetGraphTDB dsg = TDBInternal.getDatasetGraphTDB(getDatasetGraph());
    Node gn = getGraphName();
    StatsResults results = stats(dsg, gn);
    Stats.write(System.out, results);
}
Also used : Node(org.apache.jena.graph.Node) StatsResults(org.apache.jena.tdb2.solver.stats.StatsResults) DatasetGraphTDB(org.apache.jena.tdb2.store.DatasetGraphTDB)

Example 5 with StatsResults

use of org.apache.jena.tdb2.solver.stats.StatsResults in project jena by apache.

the class TestStats method stats_02.

@Test
public void stats_02() {
    NodeId gid = nt.getNodeIdForNode(NodeFactory.createURI("g1"));
    StatsResults r = statsForGraph(gid);
    assertEquals(1, r.getCount());
    assertEquals(1, r.getPredicates().keySet().size());
}
Also used : NodeId(org.apache.jena.tdb2.store.NodeId) StatsCollectorNodeId(org.apache.jena.tdb2.solver.stats.StatsCollectorNodeId) StatsResults(org.apache.jena.tdb2.solver.stats.StatsResults) Test(org.junit.Test)

Aggregations

StatsCollectorNodeId (org.apache.jena.tdb2.solver.stats.StatsCollectorNodeId)5 StatsResults (org.apache.jena.tdb2.solver.stats.StatsResults)5 NodeId (org.apache.jena.tdb2.store.NodeId)5 Test (org.junit.Test)4 Tuple (org.apache.jena.atlas.lib.tuple.Tuple)3 Node (org.apache.jena.graph.Node)1 DatasetGraphTDB (org.apache.jena.tdb2.store.DatasetGraphTDB)1 NodeTable (org.apache.jena.tdb2.store.nodetable.NodeTable)1 NodeTupleTable (org.apache.jena.tdb2.store.nodetupletable.NodeTupleTable)1