static Map<String, TupleIndex> indexMap(DatasetGraphTDB dsgtdb) { Map<String, TupleIndex> indexMap = new HashMap<>(); // All triple/quad indexes. Arrays.stream(dsgtdb.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes()) .forEach(idx->indexMap.put(idx.getName(), idx)); Arrays.stream(dsgtdb.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes()) .forEach(idx->indexMap.put(idx.getName(), idx)); return indexMap; }
@Override protected void addToDftGraph(Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyAdd(null, s, p, o) ; getTripleTable().add(s,p,o) ; }
@Override protected Iterator<Quad> findInDftGraph(Node s, Node p, Node o) { checkNotClosed() ; return isolate(triples2quadsDftGraph(getTripleTable().find(s, p, o))) ; }
@Override protected void deleteFromDftGraph(Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyDelete(null, s, p, o) ; getTripleTable().delete(s, p, o) ; }
@Override public boolean isEmpty() { checkNotClosed(); return getTripleTable().isEmpty() && getQuadTable().isEmpty(); }
@Override public void clear() { checkNotClosed() ; // Leave the node table alone. getTripleTable().clearTriples() ; getQuadTable().clearQuads() ; }
public NodeTupleTable chooseNodeTupleTable(Node graphNode) { checkNotClosed() ; if ( graphNode == null || Quad.isDefaultGraph(graphNode) ) return getTripleTable().getNodeTupleTable() ; else // Includes Node.ANY and union graph return getQuadTable().getNodeTupleTable() ; }
public DataToTuples(DatasetGraphTDB dsgtdb, Destination<Tuple<NodeId>> tuples3, Destination<Tuple<NodeId>> tuples4, MonitorOutput output) { this.dsgtdb = dsgtdb; this.dest3 = tuples3; this.dest4 = tuples4; this.input = new ArrayBlockingQueue<>(LoaderConst.QueueSizeData); this.nodeTable = dsgtdb.getQuadTable().getNodeTupleTable().getNodeTable(); this.prefixes = dsgtdb.getPrefixes(); this.output = output; NodeTable nodeTable2 = dsgtdb.getTripleTable().getNodeTupleTable().getNodeTable(); if ( nodeTable != nodeTable2 ) throw new BulkLoaderException("Different node tables"); }
public TDBDatasetDetails(DatasetGraphTDB dsg) { ntTop = dsg.getTripleTable().getNodeTupleTable().getNodeTable() ; tripleIndexes = ArrayUtils.copy(dsg.getTripleTable().getNodeTupleTable().getTupleTable().getIndexes()) ; quadIndexes = ArrayUtils.copy(dsg.getQuadTable().getNodeTupleTable().getTupleTable().getIndexes()) ; fillInNodeTableDetails() ; fillInIndexDetails() ; }
private TripleTable createTripleTableMem() { DatasetGraphTxn dsx = TDBBuilder.build(Location.mem()) ; dsx.begin(ReadWrite.WRITE); DatasetGraphTDB ds = (DatasetGraphTDB)dsx ; return ds.getTripleTable() ; } }
private TripleTable createTripleTableMem() { DatasetGraphTxn dsx = TDBBuilder.build(Location.mem()) ; dsx.begin(ReadWrite.WRITE); DatasetGraphTDB ds = (DatasetGraphTDB)dsx ; return ds.getTripleTable() ; } }
public DataToTuplesInlineSingle(DatasetGraphTDB dsgtdb, Consumer<Tuple<NodeId>> dest3, Consumer<Tuple<NodeId>> dest4, MonitorOutput output) { this.dsgtdb = dsgtdb; this.dest3 = dest3; this.dest4 = dest4; this.output = output; this.nodeTable = dsgtdb.getTripleTable().getNodeTupleTable().getNodeTable(); this.prefixes = dsgtdb.getPrefixes(); NodeTable nodeTable2 = dsgtdb.getQuadTable().getNodeTupleTable().getNodeTable(); if ( nodeTable != nodeTable2 ) throw new BulkLoaderException("Different node tables"); }
public DataToTuplesInline(DatasetGraphTDB dsgtdb, Destination<Tuple<NodeId>> dest3, Destination<Tuple<NodeId>> dest4, MonitorOutput output) { this.dsgtdb = dsgtdb; this.dest3 = dest3; this.dest4 = dest4; this.output = output; this.nodeTable = dsgtdb.getTripleTable().getNodeTupleTable().getNodeTable(); this.prefixes = dsgtdb.getPrefixes(); NodeTable nodeTable2 = dsgtdb.getQuadTable().getNodeTupleTable().getNodeTable(); if ( nodeTable != nodeTable2 ) throw new BulkLoaderException("Different node tables"); }
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 ? SolverLib.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(); }
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 ? SolverLib.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(); }
public LoaderSequential(DatasetGraph dsg, Node graphName, MonitorOutput output) { super(dsg, graphName, output); if ( ! TDBInternal.isBackedByTDB(dsg) ) throw new BulkLoaderException("Not a TDB2 database"); this.dsgtdb = TDBInternal.getDatasetGraphTDB(dsg); this.triplesLoader = new LoaderNodeTupleTable(dsgtdb.getTripleTable().getNodeTupleTable(), output, "Triples"); this.quadsLoader = new LoaderNodeTupleTable(dsgtdb.getQuadTable().getNodeTupleTable(), output, "Quads"); StreamRDF s = StreamRDFLib.dataset(dsg); s = new StreamRDFWrapper(s) { @Override public void triple(Triple triple) { triplesLoader.load(triple.getSubject(), triple.getPredicate(), triple.getObject()); countTriples++; } @Override public void quad(Quad quad) { quadsLoader.load(quad.getGraph(), quad.getSubject(), quad.getPredicate(), quad.getObject()); countQuads++; } }; this.stream = LoaderOps.toNamedGraph(s, graphName); }