Java Code Examples for org.apache.jena.sparql.sse.SSE#parseQuad()
The following examples show how to use
org.apache.jena.sparql.sse.SSE#parseQuad() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractTestDeltaClient.java From rdf-delta with Apache License 2.0 | 6 votes |
@Test public void update_3() { // Create on the Delta link then setup DeltaClient DeltaLink dLink = getLink(); String DS_NAME = "12345"; Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_3"); DeltaClient dClient = createDeltaClient(); dClient.register(dsRef, LocalStorageType.MEM, SyncPolicy.NONE); DeltaConnection dConn = dClient.get(DS_NAME); Quad quad = SSE.parseQuad("(_ :s :p :o)"); DatasetGraph dsg = dConn.getDatasetGraph(); long x0 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) ); assertEquals(0, x0); dsg.begin(ReadWrite.WRITE); dsg.add(quad); dsg.abort(); long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) ); assertEquals(0, x1); }
Example 2
Source File: TestRDFChangesCancel.java From rdf-delta with Apache License 2.0 | 6 votes |
@Test public void changeSuppressEmptyCommit_4() { Quad q = SSE.parseQuad("(_ :s :p 'object')"); Triple t = SSE.parseTriple("(:t :p 'object')"); Txn.executeRead(dsg, ()->{}); testCounters(counter.summary(), 0, 0); Txn.executeWrite(dsg, ()->{dsg.add(q);}); testCounters(counter.summary(), 1, 0); Txn.executeWrite(dsg, ()->{dsg.getDefaultGraph().add(t);}); testCounters(counter.summary(), 2, 0); Txn.executeWrite(dsg, ()->{dsg.getDefaultGraph().getPrefixMapping().setNsPrefix("", "http://example/");}); testCounters(counter.summary(), 2, 1); Txn.executeWrite(dsg, ()->{}); testCounters(counter.summary(), 2, 1); }
Example 3
Source File: AbstractTestDeltaClient.java From rdf-delta with Apache License 2.0 | 5 votes |
@Test public void update_1() { // Create on the Delta link then setup DeltaClient DeltaLink dLink = getLink(); String DS_NAME = "123"; Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_1"); DeltaClient dClient = createDeltaClient(); dClient.register(dsRef, LocalStorageType.MEM, SyncPolicy.NONE); DeltaConnection dConn = dClient.get(DS_NAME); assertNotNull(dConn); assertEquals(Version.INIT, dConn.getLocalVersion()); assertEquals(Version.INIT, dConn.getRemoteVersionLatest()); Quad quad = SSE.parseQuad("(_ :s :p :o)"); DatasetGraph dsg = dConn.getDatasetGraph(); long x0 = Iter.count(dsg.find()); assertEquals(0, x0); Txn.executeWrite(dsg, ()->dsg.add(quad)); long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find())); assertEquals(1, x1); DatasetGraph dsgx = dConn.getStorage(); long x2 = Txn.calculateRead(dsgx, ()->Iter.count(dsgx.find())); assertEquals(1, x1); }
Example 4
Source File: AbstractTestDeltaClient.java From rdf-delta with Apache License 2.0 | 5 votes |
@Test public void update_2() { // Create on the Delta link then setup DeltaClient DeltaLink dLink = getLink(); String DS_NAME = "1234"; Id dsRef = dLink.newDataSource(DS_NAME, "http://example/datasource_update_2"); DeltaClient dClient = createDeltaClient(); dClient.register(dsRef, LocalStorageType.MEM, SyncPolicy.NONE); DeltaConnection dConn = dClient.get(DS_NAME); assertNotNull(dConn); assertEquals(Version.INIT, dConn.getLocalVersion()); assertEquals(Version.INIT, dConn.getRemoteVersionLatest()); Quad quad = SSE.parseQuad("(_ :s :p :o)"); DatasetGraph dsg = dConn.getDatasetGraph(); long x0 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) ); assertEquals(0, x0); Txn.executeWrite(dsg, ()->dsg.add(quad)); long x1 = Txn.calculateRead(dsg, ()->Iter.count(dsg.find()) ); assertEquals(1, x1); long x2 = Iter.count(dConn.getStorage().find()); assertEquals(1, x1); }
Example 5
Source File: TestZone.java From rdf-delta with Apache License 2.0 | 5 votes |
@Test public void zone_03() { assertTrue(zone.localConnections().isEmpty()); DatasetGraph dsgBase = DatasetGraphFactory.createTxnMem(); String NAME = "ABC"; Id dsRef = registerExternal(NAME, dsgBase); assertFalse(zone.localConnections().isEmpty()); Quad quad = SSE.parseQuad("(_ :s :p :o)"); try(DeltaConnection dConn = deltaClient.get(dsRef)) { DatasetGraph dsg = dConn.getDatasetGraph(); Txn.executeWrite(dsg, ()->dsg.add(quad)); } // read log. PatchLogInfo info = deltaLink.getPatchLogInfo(dsRef); assertEquals(Version.create(1), info.getMaxVersion()); }
Example 6
Source File: ExQuadFilter.java From xcurator with Apache License 2.0 | 5 votes |
/** Example setup - in-memory dataset with two graphs, one triple in each */ private static Dataset setup() { Dataset ds = TDBFactory.createDataset() ; DatasetGraph dsg = ds.asDatasetGraph() ; Quad q1 = SSE.parseQuad("(<http://example/g1> <http://example/s> <http://example/p> <http://example/o1>)") ; Quad q2 = SSE.parseQuad("(<http://example/g2> <http://example/s> <http://example/p> <http://example/o2>)") ; dsg.add(q1) ; dsg.add(q2) ; return ds ; }
Example 7
Source File: DeltaTestLib.java From rdf-delta with Apache License 2.0 | 4 votes |
static Quad freshQuad() { return SSE.parseQuad("(_ :s :p '"+DateTimeUtils.nowAsXSDDateTimeString()+"'^^xsd:dateTimeStamp)"); }
Example 8
Source File: TestManagedDatasetBuilder.java From rdf-delta with Apache License 2.0 | 4 votes |
@Test public void buildManaged_2_sameZone() { Zone zone = Zone.connect(Location.mem()); DatasetGraph dsg1 = ManagedDatasetBuilder.create() .deltaLink(deltaLink) .logName("ABC") .zone(zone) .syncPolicy(SyncPolicy.TXN_RW) .storageType(LocalStorageType.MEM) .build(); // Rebuild from with same zone. Should get the same underlying storage database. // i.e. same Zone item. DeltaLink deltaLink2 = DeltaLinkLocal.connect(localServer); DatasetGraph dsg2 = ManagedDatasetBuilder.create() .deltaLink(deltaLink2) .logName("ABC") .zone(zone) .syncPolicy(SyncPolicy.TXN_RW) .storageType(LocalStorageType.MEM) .build(); assertNotSame(dsg1, dsg2); DeltaConnection conn1 = (DeltaConnection)(dsg1.getContext().get(symDeltaConnection)); DeltaConnection conn2 = (DeltaConnection)(dsg2.getContext().get(symDeltaConnection)); // Same zone, same underlying storage client-side assertSame(conn1.getStorage(), conn2.getStorage()); Quad q1 = SSE.parseQuad("(:g :s :p 1)"); Quad q2 = SSE.parseQuad("(:g :s :p 2)"); Txn.executeWrite(dsg1, ()->dsg1.add(q1)); Txn.executeRead(dsg2, ()->assertTrue(dsg2.contains(q1))); try ( DeltaConnection c = conn1 ) { DatasetGraph dsg = c.getDatasetGraph(); Txn.executeRead( c.getDatasetGraph(), ()->assertTrue(c.getDatasetGraph().contains(q1)) ); Txn.executeWrite( c.getDatasetGraph(), ()->c.getDatasetGraph().add(q2) ); } try ( DeltaConnection c = conn2 ) { Txn.executeRead(c.getDatasetGraph(), ()->assertTrue(c.getDatasetGraph().contains(q2))); } }
Example 9
Source File: TestManagedDatasetBuilder.java From rdf-delta with Apache License 2.0 | 4 votes |
@Test public void buildManaged_3_differentZones() { // Different zones, same local server. Zone zone1 = Zone.connect(Location.mem()); Zone zone2 = Zone.connect(Location.mem()); DatasetGraph dsg1 = ManagedDatasetBuilder.create() .deltaLink(deltaLink) .logName("BCD") .zone(zone1) .syncPolicy(SyncPolicy.TXN_RW) .storageType(LocalStorageType.MEM) .build(); // Different zones. DeltaLink deltaLink2 = DeltaLinkLocal.connect(localServer); DatasetGraph dsg2 = ManagedDatasetBuilder.create() .deltaLink(deltaLink2) .logName("BCD") .zone(zone2) .syncPolicy(SyncPolicy.TXN_RW) .storageType(LocalStorageType.MEM) .build(); Quad q1 = SSE.parseQuad("(:g :s :p 1)"); Quad q2 = SSE.parseQuad("(:g :s :p 2)"); Txn.executeWrite(dsg1, ()->dsg1.add(q1)); Txn.executeRead(dsg2, ()->assertTrue(dsg2.contains(q1))); DeltaConnection conn1 = (DeltaConnection)(dsg1.getContext().get(symDeltaConnection)); DeltaConnection conn2 = (DeltaConnection)(dsg2.getContext().get(symDeltaConnection)); assertNotSame(conn1.getStorage(), conn2.getStorage()); try ( DeltaConnection c = conn1 ) { DatasetGraph dsg = c.getDatasetGraph(); Txn.executeRead( c.getDatasetGraph(), ()->assertTrue(dsg2.contains(q1)) ); Txn.executeWrite( c.getDatasetGraph(), ()->c.getDatasetGraph().add(q2) ); } try ( DeltaConnection c = conn2 ) { Txn.executeRead(c.getDatasetGraph(), ()->assertTrue(dsg2.contains(q2))); } }
Example 10
Source File: AbstractTestDeltaConnection.java From rdf-delta with Apache License 2.0 | 4 votes |
@Test public void change_empty_commit_1() { Quad q = SSE.parseQuad("(:g :s :p :o)") ; String NAME = "change_empty_commit_1"; DeltaClient dClient = createRegister(NAME); try(DeltaConnection dConn = dClient.get(NAME)) { Id patchId0 = dConn.getRemoteIdLatest(); assertNull(patchId0); Version ver0 = dConn.getRemoteVersionLatest(); // The "no empty commits" dsg DatasetGraph dsg = dConn.getDatasetGraphNoEmpty(); Txn.executeWrite(dsg, ()->{}); Id patchId1 = dConn.getLatestPatchId(); Version ver1 = dConn.getRemoteVersionLatest(); // No change at start of log. assertEquals(patchId0, patchId1); assertEquals(ver0, ver1); Txn.executeWrite(dsg, ()->dsg.add(q)); Id patchId2 = dConn.getLatestPatchId(); Version ver2 = dConn.getRemoteVersionLatest(); assertNotEquals(patchId0, patchId2); assertNotEquals(ver0, ver2); DatasetGraph dsgx = dConn.getDatasetGraph(); Txn.executeWrite(dsgx, ()->{}); Id patchId3 = dConn.getLatestPatchId(); Version ver3 = dConn.getRemoteVersionLatest(); assertNotEquals(patchId2, patchId3); assertNotEquals(ver2, ver3); // No change mid log. Txn.executeWrite(dsg, ()->Iter.count(dsg.find())); Id patchId4 = dConn.getLatestPatchId(); Version ver4 = dConn.getRemoteVersionLatest(); assertEquals(patchId3, patchId4); assertEquals(ver3, ver4); } }
Example 11
Source File: TestManagedDatasetBuilder2.java From rdf-delta with Apache License 2.0 | 4 votes |
@Test public void buildManaged_persistentZone() { // Restart. Location loc = Location.create(ZONE_DIR); Zone zone = Zone.connect(loc); Quad q1 = SSE.parseQuad("(:g :s :p 1)"); Quad q2 = SSE.parseQuad("(:g :s :p 2)"); { DatasetGraph dsg = ManagedDatasetBuilder.create() .deltaLink(deltaLink) .logName("ABD") .zone(zone) .syncPolicy(SyncPolicy.TXN_RW) .storageType(LocalStorageType.TDB2) .build(); DeltaConnection conn = (DeltaConnection)(dsg.getContext().get(symDeltaConnection)); Txn.executeWrite(dsg, ()->dsg.add(q1)); Txn.executeRead( conn.getDatasetGraph(), ()->assertTrue(conn.getDatasetGraph().contains(q1)) ); } // Same zone Zone.clearZoneCache(); zone = Zone.connect(loc); // Storage should be recovered from the on-disk state. { DatasetGraph dsg1 = ManagedDatasetBuilder.create() .deltaLink(deltaLink) .logName("ABD") .zone(zone) .syncPolicy(SyncPolicy.TXN_RW) //.storageType(LocalStorageType.TDB2) // Storage required. Should detect [FIXME] .build(); DatasetGraph dsg2 = ManagedDatasetBuilder.create() .deltaLink(deltaLink) .logName("ABD") .zone(zone) .syncPolicy(SyncPolicy.TXN_RW) //.storageType(LocalStorageType.TDB) // Wrong storage - does not matter; dsg1 setup choice applies .build(); DeltaConnection conn1 = (DeltaConnection)(dsg1.getContext().get(symDeltaConnection)); DeltaConnection conn2 = (DeltaConnection)(dsg2.getContext().get(symDeltaConnection)); Txn.executeRead(conn1.getDatasetGraph(), ()->assertTrue(conn1.getDatasetGraph().contains(q1)) ); Txn.executeWrite(conn2.getDatasetGraph(), ()->conn2.getDatasetGraph().add(q2)); Txn.executeRead(conn1.getDatasetGraph(), ()->assertTrue(conn1.getDatasetGraph().contains(q2)) ); } }
Example 12
Source File: TestRestart.java From rdf-delta with Apache License 2.0 | votes |
private static Quad quad() { return SSE.parseQuad("(_ :s :p "+(counter++)+")"); }