本文整理了Java中org.apache.jena.query.ResultSet.getRowNumber
方法的一些代码示例,展示了ResultSet.getRowNumber
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResultSet.getRowNumber
方法的具体详情如下:
包路径:org.apache.jena.query.ResultSet
类名称:ResultSet
方法名:getRowNumber
[英]Return the "row" number for the current iterator item
[中]返回当前迭代器项的“行”号
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public int getRowNumber() {
return decoratee.getRowNumber();
}
代码示例来源:origin: apache/jena
@Override
public int getRowNumber() {
// Calculate row number based on whether we have peeked
return this.hasPeeked() ? this.results.getRowNumber() - 1 : this.results.getRowNumber();
}
代码示例来源:origin: apache/jena
private boolean hasPeeked() {
int diff = this.results.getRowNumber() - this.rowNumber;
if (diff == 0) {
// If no difference we have not peeked
return false;
} else if (diff == 1 && this.peeked != null) {
// If difference is one then we have peeked
return true;
} else if (diff >= 1) {
// If difference between what we think the row number is and that of
// the underlying result set is > 1 then someone has moved positions
// in the underlying result set independently
// Sync up with current position and report false
if (warnOnSyncErrors)
LOGGER.warn("Underlying result set was moved forward " + (diff - 1)
+ " result(s), this result set was synced back up but some results have been missed");
this.rowNumber = this.results.getRowNumber();
this.peeked = null;
return false;
} else {
// If difference is negative then someone has reset the underlying
// result set so we are completely out of sync, syncing back up at
// this point would be illegal since we have gone backwards in the
// stream
throw new IllegalStateException(
"Underlying result set position has moved backwards, this result set is no longer usable");
}
}
代码示例来源:origin: apache/jena
@Override
public int getRowNumber() {
check() ;
return other.getRowNumber() ;
}
代码示例来源:origin: apache/jena
@Override
public int getRowNumber() {
return get().getRowNumber() ;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public ResultSetLimited(ResultSet decoratee, long limit) {
super(decoratee, decoratee.hasNext());
offset = decoratee.getRowNumber();
this.limit = limit;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
protected boolean checkClose() {
long rowNumber = decoratee.getRowNumber();
long pos = rowNumber - offset;
if(pos >= limit) {
try {
close();
} catch(Exception e) {
// TODO Throwing an exception here might be unsafe
throw new RuntimeException(e);
}
}
boolean result = super.checkClose();
return result;
}
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
OWLClass candidate = df.getOWLClass(IRI.create(qs.getResource("cls_other").getURI()));
logger.debug("Analyzing candidate class " + candidate.toStringID());
progressMonitor.learningProgressChanged(axiomType, rs.getRowNumber(), size);
代码示例来源:origin: Galigator/openllet
@Test
public void testDAWG4()
{
final Model model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.read("file:test/data/sparql-dawg-tests/data-r2/optional-filter/data-1.ttl", "N3");
final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/optional-filter/expr-5.rq");
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(3, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testDAWG2()
{
// Query PREFIX : <http://example/> SELECT * { ?s ?p ?o }
// The same as testDAWG3 but here we handle the variable SPO pattern
// with the SPARQL-DL engine, i.e. we fall back to ARQ as the SPARQL-DL
// engine cannot handle it. The result set size is 20 because the
// PelletInfGraph contains all inferred triples.
final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.read("file:test/data/sparql-dawg-tests/data-r2/graph/data-g1.ttl", "N3");
final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/graph/graph-01.rq");
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(model.listStatements().toList().size(), rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testDAWG1()
{
final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.read("file:test/data/sparql-dawg-tests/data-r2/basic/data-1.ttl", "N3");
final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/basic/base-prefix-1.rq");
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
//ResultSetFormatter.out( rs );
ResultSetFormatter.consume(rs);
// Type, sameAs, one entry for each property assertion
assertEquals(1 + 1 + 2, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testDAWG3()
{
// Query PREFIX : <http://example/> SELECT * { ?s ?p ?o }
// The same as testDAWG2 but this time we don't handle the variable SPO
// pattern, i.e. we handle the pattern as a property value
final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.read("file:test/data/sparql-dawg-tests/data-r2/graph/data-g1.ttl", "N3");
final Query query = QueryFactory.read("file:test/data/sparql-dawg-tests/data-r2/graph/graph-01.rq");
final QueryExecution qe = SparqlDLExecutionFactory.create(query, DatasetFactory.create(model), null, QueryEngineType.MIXED, false);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(2, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testVariableSPO1()
{
// Handle variable SPO pattern. This query is executed by ARQ (fall back
// from SPARQL-DL)
final String q = "SELECT * WHERE { ?s ?p ?o }";
final Resource s = ResourceFactory.createResource(NS + "i");
final Property p = RDF.type;
final Resource o = ResourceFactory.createResource(NS + "C");
final Model model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.add(s, p, o);
final Query query = QueryFactory.create(q);
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(model.listStatements().toList().size(), rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testVariableSPO2()
{
// Handle variable SPO pattern. This query is executed by ARQ (fall back
// from SPARQL-DL)
final String q = "SELECT * WHERE { ?s ?p ?o }";
final Resource s = ResourceFactory.createResource(NS + "i");
final Property p = ResourceFactory.createProperty(NS + "p");
final Resource o = ResourceFactory.createResource(NS + "C");
final Model model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.add(s, p, o);
final Query query = QueryFactory.create(q);
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(model.listStatements().toList().size(), rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void test421()
{
final String aOnt = "file:" + PelletTestSuite.base + "misc/ticket-421-test-case.owl";
final PelletReasoner aReasoner = PelletReasonerFactory.theInstance().create();
final InfModel aModel = ModelFactory.createInfModel(aReasoner, ModelFactory.createDefaultModel());
aModel.read(aOnt);
final String aQuery = "PREFIX : <http://www.semanticweb.org/ontologies/2010/5/ticket-421-test-case.owl#>\n" + "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "SELECT ?x\n" + "WHERE {\n" + "?x rdf:type :D\n" + "}";
final QueryExecution qe = SparqlDLExecutionFactory.create(QueryFactory.create(aQuery), aModel);
final ResultSet results = qe.execSelect();
// ResultSetFormatter.out(results);
while (results.hasNext())
results.next();
assertTrue(results.getRowNumber() == 1);
}
代码示例来源:origin: Galigator/openllet
@Test
public void testVariableSPO3()
{
// Handle variable SPO pattern. No fall back here
final String q = "PREFIX owl: <http://www.w3.org/2002/07/owl#> " + "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " + "PREFIX ex: <" + NS + "> " + "SELECT * WHERE { ?s ?p ?o . ?p rdf:type owl:ObjectProperty }";
final Resource s = ResourceFactory.createResource(NS + "i");
final Property p = ResourceFactory.createProperty(NS + "p");
final Resource o = ResourceFactory.createResource(NS + "j");
final OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.add(s, p, o);
model.add(p, RDF.type, OWL.ObjectProperty);
final Query query = QueryFactory.create(q);
final QueryExecution qe = SparqlDLExecutionFactory.create(query, model);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(1, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void test444()
{
final String aOnt = "file:" + PelletTestSuite.base + "misc/ticket-444-test-case.owl";
final PelletReasoner aReasoner = PelletReasonerFactory.theInstance().create();
final InfModel aModel = ModelFactory.createInfModel(aReasoner, ModelFactory.createDefaultModel());
aModel.read(aOnt);
final String aQuery = "PREFIX : <http://www.semanticweb.org/ontologies/2010/5/ticket-444-test-case.owl#>\n" + "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "SELECT *\n" + "WHERE {\n" + ":c ?p ?o . OPTIONAL { ?o :hasName ?n }\n" + "}";
final QueryExecution qe = QueryExecutionFactory.create(QueryFactory.create(aQuery), aModel);
// QueryExecution qe = SparqlDLExecutionFactory.create( QueryFactory.create(aQuery), aModel );
final ResultSet results = qe.execSelect();
// ResultSetFormatter.out(results);
while (results.hasNext())
results.next();
assertTrue(results.getRowNumber() == 4);
}
}
代码示例来源:origin: Galigator/openllet
@Test
public void testVariableSPO4()
{
// Don't handle variable SPO pattern in the query. The result set size
// is incomplete.
final String q = "SELECT * WHERE { ?s ?p ?o }";
final Resource s = ResourceFactory.createResource(NS + "i");
final Property p = ResourceFactory.createProperty(NS + "p");
final Resource o = ResourceFactory.createResource(NS + "C");
final Model model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
model.add(s, p, o);
final Query query = QueryFactory.create(q);
final QueryExecution qe = SparqlDLExecutionFactory.create(query, DatasetFactory.create(model), null, QueryEngineType.PELLET, false);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(1, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void testUnsupportedBuiltin()
{
final OntModel ontmodel = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
final String nc = "urn:test:";
final OntClass class1 = ontmodel.createClass(nc + "C1");
final Individual[] inds = new Individual[6];
for (int j = 0; j < 6; j++)
inds[j] = ontmodel.createIndividual(nc + "Ind" + j, OWL.Thing);
ontmodel.add(class1, RDFS.subClassOf, ontmodel.createEnumeratedClass(null, ontmodel.createList(inds)));
final Query query = QueryFactory.create("PREFIX rdf:<" + RDF.getURI() + ">\n" + "SELECT * WHERE {\n" + " ?x rdf:first ?y .\n" + "}");
final QueryExecution qe = SparqlDLExecutionFactory.create(query, ontmodel);
final ResultSet rs = qe.execSelect();
ResultSetFormatter.consume(rs);
assertEquals(6, rs.getRowNumber());
}
代码示例来源:origin: Galigator/openllet
@Test
public void test210()
{
final Object prevValue = ARQ.getContext().get(ARQ.optFilterPlacement);
try
{
ARQ.getContext().set(ARQ.optFilterPlacement, false);
final String aOnt = "file:" + PelletTestSuite.base + "misc/ticket-210-test-case.owl";
final PelletReasoner aReasoner = PelletReasonerFactory.theInstance().create();
final InfModel aModel = ModelFactory.createInfModel(aReasoner, ModelFactory.createDefaultModel());
aModel.read(aOnt);
final String aQuery = "PREFIX : <http://www.semanticweb.org/ontologies/2010/5/ticket-210-test-case.owl#>\n" + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" + "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" + "SELECT ?x\n" + "WHERE {\n" + "?x rdfs:subClassOf [\n" + "owl:onProperty :R ;\n" + "owl:someValuesFrom :C\n" + "]\n" + "FILTER( ?x != owl:Nothing )\n" + "}";
final QueryExecution qe = SparqlDLExecutionFactory.create(QueryFactory.create(aQuery), aModel);
final ResultSet results = qe.execSelect();
while (results.hasNext())
results.next();
assertEquals(2, results.getRowNumber());
}
finally
{
ARQ.getContext().set(ARQ.optFilterPlacement, prevValue);
}
}
内容来源于网络,如有侵权,请联系作者删除!