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; }
public static DatasetPrefixStorage makePrefixes(Location location) { DatasetGraphTDB ds = (DatasetGraphTDB)TDBBuilder.build(location) ; ds.begin(ReadWrite.WRITE); return ds.getPrefixes() ; }
private StoreConnection(DatasetGraphTDB dsg, ProcessFileLock fileLock) { this.datasetGraph = dsg ; this.location = dsg.getLocation() ; this.lock = fileLock; }
@Override protected Iterator<Quad> findInDftGraph(Node s, Node p, Node o) { checkNotClosed() ; return isolate(triples2quadsDftGraph(getTripleTable().find(s, p, o))) ; }
@Override protected void addToNamedGraph(Node g, Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyAdd(g, s, p, o) ; getQuadTable().add(g, s, p, o) ; }
@Override protected void addToDftGraph(Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyAdd(null, s, p, o) ; getTripleTable().add(s,p,o) ; }
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"); }
@Override public boolean isEmpty() { checkNotClosed(); return getTripleTable().isEmpty() && getQuadTable().isEmpty(); }
public static Set<NodeId> convertToNodeIds(Collection<Node> nodes, DatasetGraphTDB dataset) { Set<NodeId> graphIds = new HashSet<>() ; NodeTable nt = dataset.getQuadTable().getNodeTupleTable().getNodeTable() ; for ( Node n : nodes ) graphIds.add(nt.getNodeIdForNode(n)) ; return graphIds ; }
@Override protected void deleteFromNamedGraph(Node g, Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyDelete(g, s, p, o) ; getQuadTable().delete(g, s, p, o) ; }
@Override protected Iterator<Quad> findInSpecificNamedGraph(Node g, Node s, Node p, Node o) { checkNotClosed(); return isolate(getQuadTable().find(g, s, p, o)); }
@Test public void store_04() { StoreConnection sConn = StoreConnection.connectCreate(location) ; DatasetGraphTDB dsg = sConn.getDatasetGraphTDB() ; Txn.executeWrite(dsg, ()->{ dsg.add(q1) ; }) ; Txn.executeWrite(dsg, ()->{ assertTrue(dsg.contains(q1)) ; }) ; dsg.begin(ReadWrite.WRITE); dsg.add(q2) ; dsg.abort() ; dsg.end() ; Txn.executeRead(dsg, ()->{ assertTrue(dsg.contains(q1)) ; assertFalse(dsg.contains(q2)) ; }) ; }
@Override protected void deleteFromDftGraph(Node s, Node p, Node o) { checkNotClosed() ; requireWriteTxn() ; notifyDelete(null, s, p, o) ; getTripleTable().delete(s, p, o) ; }
@Override protected ExtendedIterator<Triple> graphUnionFind(Node s, Node p, Node o) { Node g = Quad.unionGraph ; Iterator<Quad> iterQuads = getDSG().find(g, s, p, o) ; Iterator<Triple> iter = GLib.quads2triples(iterQuads) ; // Suppress duplicates after projecting to triples. // TDB guarantees that duplicates are adjacent. // See SolverLib. iter = Iter.distinctAdjacent(iter) ; return WrappedIterator.createNoRemove(iter) ; }
private TripleTable createTripleTableMem() { DatasetGraphTxn dsx = TDBBuilder.build(Location.mem()) ; dsx.begin(ReadWrite.WRITE); DatasetGraphTDB ds = (DatasetGraphTDB)dsx ; return ds.getTripleTable() ; } }
private DatasetPrefixStorage dps() { return getDSG().getPrefixes(); }
if ( ! dsgCurrent.getLocation().equals(loc1) ) throw new TDBException("Inconsistent locations for base : "+dsgCurrent.getLocation()+" , "+dsgCurrent.getLocation()); throw new TDBException("Inconsistent datasets : "+dsgCurrent.getLocation()+" , "+dsgBase.getLocation()); TransactionalSystem txnSystem = dsgBase.getTxnSystem(); TransactionCoordinator txnMgr = dsgBase.getTxnSystem().getTxnMgr(); CopyDSG.copy(dsgBase, dsgCompact); TransactionCoordinator txnMgr2 = dsgCompact.getTxnSystem().getTxnMgr(); txnMgr2.startExclusiveMode(); StoreConnection.release(dsgBase.getLocation());
@Override public void begin(ReadWrite readWrite) { begin(TxnType.convert(readWrite)); }
protected DatasetGraphTxn build$() { NodeTable nodeTable = buildNodeTable(params.getNodeTableBaseName()); TripleTable tripleTable = buildTripleTable(nodeTable); QuadTable quadTable = buildQuadTable(nodeTable); NodeTable nodeTablePrefixes = buildNodeTable(params.getPrefixTableBaseName()); DatasetPrefixesTDB prefixes = buildPrefixTable(nodeTablePrefixes); TransactionalSystem trans = new TransactionalBase(txnCoord); DatasetGraphTxn dsg = new DatasetGraphTDB(trans, tripleTable, quadTable, prefixes, ReorderLib.fixed(), location, params); QC.setFactory(dsg.getContext(), OpExecutorTDB2.OpExecFactoryTDB); txnCoord.start(); return dsg; }
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"); }