DestinationTripleGraph(final DatasetGraphTDB dsg, RdfImportFilter importFilter, Logger log) { this.dsg = dsg ; startedEmpty = dsg.isEmpty() ; monitor = new LoadMonitor(dsg, log, "triples", BulkLoader.DataTickPoint, BulkLoader.IndexTickPoint) ; loaderTriples = new LoaderNodeTupleTable(dsg.getTripleTable().getNodeTupleTable(), "triples", monitor) ; if(importFilter == null){ this.importFilter = NO_FILTER; } else { this.importFilter = importFilter; } this.importLog = log; }
static void forceSync(DatasetGraphTDB dsg) { // Force sync - we have been bypassing DSG tables. // THIS DOES NOT WORK IF modules check for SYNC necessity. dsg.getTripleTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getPrefixes().getNodeTupleTable().getNodeTable().sync(); // This is not enough -- modules check whether sync needed. dsg.sync() ; } }
@Override protected PrefixMapping view() { return last.getPrefixMapping() ; }
private static void contains(TripleTable table, Node s, Node p, Node o) { Iterator<Triple> iter = table.find(s, p, o) ; assertNotNull(iter) ; assertTrue(iter.hasNext()) ; assertEquals(new Triple(s, p, o), iter.next()) ; assertFalse(iter.hasNext()) ; }
@Test public void nodeId_01() { NodeId nodeId = NodeId.create(37) ; assertEquals(37L, nodeId.getId()) ; }
private static void notMatch(TripleTable table, Node s, Node p, Node o) { Iterator<Triple> iter = table.find(s, p, o) ; assertNotNull(iter) ; assertFalse(iter.hasNext()) ; }
private static void match(TripleTable table, Node s, Node p, Node o) { Iterator<Triple> iter = table.find(s, p, o) ; assertNotNull(iter) ; assertTrue(iter.hasNext()) ; }
@Test public void find2() { TripleTable table = createTripleTableMem() ; add(table, n1, n2, n3) ; add(table, n1, n2, n4) ; contains(table, n1, n2, n3) ; contains(table, n1, n2, n4) ; }
@Test public void add1() { TripleTable table = createTripleTableMem() ; table.add(new Triple(n1,n2,n3)) ; }
/** Create a TDB graph using a specifc index builder - mainly for testing */ public static GraphTriplesTDB createGraph(IndexBuilder indexBuilder, Location location) { DatasetGraphTDB ds = _createDatasetGraph(indexBuilder, location, tripleIndexes, quadIndexes) ; return (GraphTriplesTDB)ds.getDefaultGraph() ; }
@Test public void dynamic09() { testCount("SELECT * "+ "FROM <graph:1> FROM <graph:2> "+ "FROM NAMED <graph:3> FROM NAMED <graph:4> "+ "{ GRAPH ?g { ?s <uri:q> ?o }}", 2, dataset) ; }
private void test(String x) { test(x, x) ; }
static public TestSuite suite() { return new TestSuiteGraphTDB() ; }
/** Public for testing only : create a quad table.*/ private static QuadTable createQuadTable(IndexBuilder indexBuilder, NodeTable nodeTable, Location location, String[]descs, ConcurrencyPolicy policy) { TupleIndex indexes[] = indexes(indexBuilder, indexRecordQuadFactory, location, primaryIndexQuads, descs) ; return new QuadTable(indexes, nodeTable, policy) ; }
static void forceSync(DatasetGraphTDB dsg) { // Force sync - we have been bypassing DSG tables. // THIS DOES NOT WORK IF modules check for SYNC necessity. dsg.getTripleTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getQuadTable().getNodeTupleTable().getNodeTable().sync(); dsg.getPrefixes().getNodeTupleTable().getNodeTable().sync(); // This is not enough -- modules check whether sync needed. dsg.sync() ; } }
DestinationTripleGraph(final DatasetGraphTDB dsg, RdfImportFilter importFilter, Logger log) { this.dsg = dsg ; startedEmpty = dsg.isEmpty() ; monitor = new LoadMonitor(dsg, log, "triples", BulkLoader.DataTickPoint, BulkLoader.IndexTickPoint) ; loaderTriples = new LoaderNodeTupleTable(dsg.getTripleTable().getNodeTupleTable(), "triples", monitor) ; if(importFilter == null){ this.importFilter = NO_FILTER; } else { this.importFilter = importFilter; } this.importLog = log; }
@Test public void nodeId_02() { NodeId nodeId = NodeId.create(-1L) ; assertEquals(-1L, nodeId.getId()) ; }
@Test public void dynamic12() { testCount("SELECT * "+ "FROM <graph:1>"+ "{ GRAPH ?g { }}", 0, dataset) ; }
@Test public void dynamicAndUnion7() { testCount("SELECT * "+ "FROM <graph:1>"+ "FROM NAMED <graph:3> FROM NAMED <graph:4> "+ "{ GRAPH <urn:x-arq:UnionGraph> { ?s <uri:p> ?o } }", 2, dataset) ; }