本文整理汇总了Java中org.apache.jena.sparql.sse.SSE类的典型用法代码示例。如果您正苦于以下问题:Java SSE类的具体用法?Java SSE怎么用?Java SSE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SSE类属于org.apache.jena.sparql.sse包,在下文中一共展示了SSE类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeSuppressEmptyCommit_4
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@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);
}
示例2: change_1
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@Test
public void change_1() {
String NAME = "change_1s";
DeltaClient dClient = createRegister(NAME);
try(DeltaConnection dConn = dClient.get(NAME)) {
long verLocal0 = dConn.getLocalVersion();
long verRemotel0 = dConn.getRemoteVersionLatest();
DatasetGraph dsg = dConn.getDatasetGraph();
Txn.executeWrite(dsg, ()->{
dsg.add(SSE.parseQuad("(:gx :sx :px :ox)"));
});
long verLocal1 = dConn.getLocalVersion();
long verRemotel1 = dConn.getRemoteVersionLatest();
assertEquals(verLocal1, dConn.getLocalVersion());
assertEquals(verRemotel1, dConn.getRemoteVersionLatest());
assertFalse(dConn.getDatasetGraph().isEmpty());
if ( dConn.getStorage() != null )
assertFalse(dConn.getStorage().isEmpty());
}
}
示例3: change_2
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@Test
public void change_2() {
String NAME = "change_2";
DeltaClient dClient = createRegister(NAME);
try(DeltaConnection dConn = dClient.get(NAME)) {
Id dsRef = dConn.getDataSourceId();
long version = dConn.getRemoteVersionLatest();
DatasetGraph dsg = dConn.getDatasetGraph();
Txn.executeWrite(dsg, ()->{
Quad q = SSE.parseQuad("(_ :s1 :p1 :o1)");
dsg.add(q);
});
// Rebuild directly.
DatasetGraph dsg2 = DatasetGraphFactory.createTxnMem();
long ver = dConn.getRemoteVersionLatest();
RDFPatch patch1 = dConn.getLink().fetch(dsRef, ver) ;
RDFPatchOps.applyChange(dsg2, patch1);
Set<Quad> set1 = Txn.calculateRead(dsg, ()->Iter.toSet(dsg.find()));
Set<Quad> set2 = Txn.calculateRead(dsg2, ()->Iter.toSet(dsg2.find()));
assertEquals(set1, set2);
}
}
示例4: update_3
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@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, TxnSyncPolicy.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);
}
示例5: execEvaluated
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@Override
public QueryIterator execEvaluated(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
Table table = getTable(predicate) ;
if ( table == null ) {
Log.warn(this, "No table for "+SSE.str(predicate));
return IterLib.noResults(execCxt) ;
}
if ( subject.isVariable() ) {
if ( object.isVariable() )
return execVarVar(binding, table, subject, object, execCxt) ;
else
return execVarTerm(binding, table, subject, object, execCxt) ;
} else {
if ( object.isVariable() )
return execTermVar(binding, table, subject, object, execCxt) ;
else
return execTermTerm(binding, table, subject, object, execCxt) ;
}
}
示例6: eval
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
/** Evaluate to match a pattern */
public static void eval(Triple query, Graph source, RuleSet rules) {
List<Triple> heads = rules.getHeads();
Triple triple = query ;
System.out.println() ;
System.out.println("Query: "+SSE.str(triple)) ;
List<Triple> answers = new ArrayList<>() ;
// Find rules.
List<Rule> matches = rules.stream().filter((r) -> matchHead(triple, r)).collect(toList()) ;
System.out.println() ;
if ( matches.isEmpty() )
System.out.println("<empty>") ;
else
System.out.println(Rule.str(matches)) ;
matches.forEach((m)-> {
if ( checkForRecursion1(m, rules) )
System.out.println("R: "+m);
}) ;
}
示例7: compare
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
static void compare(String label, Graph testGraph, Graph refGraph, Node s, Node p , Node o) {
if ( label != null )
System.out.println("** Compare ("+label+"):") ;
else
System.out.println("** Compare") ;
System.out.printf("find(%s, %s, %s)\n", str(s), str(p), str(o)) ;
List<Triple> x1 = testGraph.find(s, p, o).toList() ;
List<Triple> x2 = refGraph.find(s, p, o).toList() ;
if ( true )
x2 = InfGlobal.removeRDFS(x2) ;
boolean b = sameElts(x1, x2) ;
if ( !b ) {
System.out.println(" Different:") ;
x1.stream().map(SSE::str).forEach(t -> System.out.println("Test: "+t)) ;
x2.stream().map(SSE::str).forEach(t -> System.out.println("Ref : "+t)) ;
} else {
System.out.println(" Same:") ;
x1.stream().map(SSE::str).forEach(t -> System.out.println(" "+t)) ;
}
System.out.println() ;
}
示例8: main
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
public static void main(String[] args) {
// Example aggregate that counts literals.
// Returns unbound for no rows.
String aggUri = "http://example/countLiterals" ;
/* Registration */
AggregateRegistry.register(aggUri, myAccumulatorFactory, NodeConst.nodeMinusOne);
// Some data.
Graph g = SSE.parseGraph("(graph (:s :p :o) (:s :p 1))") ;
String qs = "SELECT (<http://example/countLiterals>(?o) AS ?x) {?s ?p ?o}" ;
// Execution as normal.
Query q = QueryFactory.create(qs) ;
try ( QueryExecution qexec = QueryExecutionFactory.create(q, ModelFactory.createModelForGraph(g)) ) {
ResultSet rs = qexec.execSelect() ;
ResultSetFormatter.out(rs);
}
}
示例9: main
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
public static void main(String []args)
{
// Create an empty GraphStore (has an empty default graph and no named graphs)
Dataset dataset = DatasetFactory.createTxnMem() ;
// ---- Read and update script in one step.
UpdateAction.readExecute("update.ru", dataset) ;
// ---- Reset.
UpdateAction.parseExecute("DROP ALL", dataset) ;
// ---- Read the update script, then execute, in separate two steps
UpdateRequest request = UpdateFactory.read("update.ru") ;
UpdateAction.execute(request, dataset) ;
// Write in debug format.
System.out.println("# Debug format");
SSE.write(dataset) ;
System.out.println();
System.out.println("# N-Quads: S P O G") ;
RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ;
}
示例10: ex3
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
public static void ex3(Dataset dataset)
{
// Build up the request then execute it.
// This is the preferred way for complex sequences of operations.
UpdateRequest request = UpdateFactory.create() ;
request.add("DROP ALL")
.add("CREATE GRAPH <http://example/g2>") ;
// Different style.
// Equivalent to request.add("...")
UpdateFactory.parse(request, "LOAD <file:etc/update-data.ttl> INTO GRAPH <http://example/g2>") ;
// And perform the operations.
UpdateAction.execute(request, dataset) ;
System.out.println("# Debug format");
SSE.write(dataset) ;
System.out.println();
System.out.println("# N-Quads: S P O G") ;
RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ;
}
示例11: main
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
public static void main(String []args)
{
Dataset dataset = DatasetFactory.createTxnMem() ;
UpdateRequest request = UpdateFactory.create() ;
request.add(new UpdateDrop(Target.ALL)) ;
request.add(new UpdateCreate("http://example/g2")) ;
request.add(new UpdateLoad("file:etc/update-data.ttl", "http://example/g2")) ;
UpdateAction.execute(request, dataset) ;
System.out.println("# Debug format");
SSE.write(dataset) ;
System.out.println();
System.out.println("# N-Quads: S P O G") ;
RDFDataMgr.write(System.out, dataset, Lang.NQUADS) ;
}
示例12: update_1
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@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, TxnSyncPolicy.NONE);
DeltaConnection dConn = dClient.get(DS_NAME);
assertNotNull(dConn);
assertEquals(0, dConn.getLocalVersion());
assertEquals(0, dConn.getRemoteVersionLatest());
Quad quad = SSE.parseQuad("(_ :s :p :o)");
DatasetGraph dsg = dConn.getDatasetGraph();
long x0 = Iter.count(dsg.find());
assertEquals(0, x0);
dsg.add(quad);
long x1 = Iter.count(dsg.find());
assertEquals(1, x1);
long x2 = Iter.count(dConn.getStorage().find());
assertEquals(1, x1);
}
示例13: update_2
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@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, TxnSyncPolicy.NONE);
DeltaConnection dConn = dClient.get(DS_NAME);
assertNotNull(dConn);
assertEquals(0, dConn.getLocalVersion());
assertEquals(0, 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);
}
示例14: zone_03
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
@Test public void zone_03() {
assertTrue(zone.localConnections().isEmpty());
DatasetGraph dsgBase = DatasetGraphFactory.createTxnMem();
String NAME = "ABC";
Id dsRef = createExternal(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(1, info.getMaxVersion());
}
示例15: main
import org.apache.jena.sparql.sse.SSE; //导入依赖的package包/类
public static void main(String...argv) {
JenaSystem.init();
Table table = new PFbyTable.Table() ;
add(table, ":s1", ":o1") ;
add(table, ":s1", ":o2") ;
add(table, ":s2", ":o1") ;
add(table, ":s2", ":o2") ;
add(table, ":s2", ":o3") ;
Dataset ds = DatasetFactory.create() ;
PropertyFunctionFactory pff = (uri)->new PFbyTable() ;
// rdf:rest is special to property functions!
String iri = "http://example/trans" ;
PFbyTable.addTable(NodeFactory.createURI(iri), table);
PropertyFunctionRegistry.get().put(iri, pff) ;
String x = StrUtils.strjoinNL
("PREFIX : <http://example/>"
,"PREFIX rdf: <"+RDF.getURI()+">"
,"PREFIX rdfs: <"+RDFS.getURI()+">"
//,"SELECT * { ?s ?p ?o . ?s rdfs:member :o1 . ?s rdf:rest :o1 }"
//,"SELECT * { ?s rdfs:member :o1 }"
,"SELECT * { { ?s :trans :o1 } UNION { :s2 :trans ?o } UNION { ?X :trans ?Y } }"
) ;
Query query = QueryFactory.create(x) ;
System.out.println(query);
Op op = Algebra.compile(query) ;
Op op1 = Algebra.optimize(op) ;
System.out.println(op1);
SSE.write(op1);
QueryExecution qExec = QueryExecutionFactory.create(query, ds) ;
QueryExecUtils.executeQuery(qExec);
}