當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.next方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.query.ResultSet.next方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.next方法的具體用法?Java ResultSet.next怎麽用?Java ResultSet.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.query.ResultSet的用法示例。


在下文中一共展示了ResultSet.next方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testBulkLoad

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testBulkLoad() throws URISyntaxException, IOException, OperationNotSupportedException {
	URL[] files = new URL[1];
	URL url = TDBTest.class.getResource("/org/aksw/kbox/kibe/dbpedia_3.9.xml");
	files[0] = url;
	java.nio.file.Path f = Files.createTempDirectory("kb");
	String path = f.toFile().getPath();
	TDB.bulkload(f.toFile().getPath(), files);
	Date start = new Date();
	ResultSet rs = TDB.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}", path);
	int i = 0;
	Date end = new Date();
	System.out.println(end.getTime() - start.getTime());
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:20,代碼來源:TDBTest.java

示例2: testQueryInstalledKB

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testQueryInstalledKB() throws Exception {
	ResultSet rs = KBox.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}",
			new URL("http://dbpedia39"));
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
	
	rs = KBox.query( 
			"Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}",
			new URL("http://dbpedia39"));
	i = 0;
	while (rs != null && rs.hasNext()) {
	rs.next();
	i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:22,代碼來源:KBoxTest.java

示例3: getTestListFromManifest

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
public static Collection<Object[]> getTestListFromManifest(String manifestFileURL) {
		// We'd like to use FileManager.loadModel() but it doesn't work on jar: URLs
//		Model m = FileManager.get().loadModel(manifestFileURL);
		Model m = ModelFactory.createDefaultModel();
		m.read(manifestFileURL, "TURTLE");

		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource mapping = qs.getResource("mapping");
			Resource schema = qs.getResource("schema");
//			if (!mapping.getLocalName().equals("constant-object.ttl")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{baseIRI.relativize(mapping.getURI()).toString(), mapping.getURI(), 
					schema.getURI(), expectedTriples});
		}
		return result;
	}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:23,代碼來源:ProcessorTestBase.java

示例4: getTestLists

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Parameters(name="{index}: {0}")
	public static Collection<Object[]> getTestLists() {
		Model m = D2RQTestUtil.loadTurtle(MANIFEST_FILE);
		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource testCase = qs.getResource("case");
//			if (!case.getLocalName().equals("expression")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{
					baseIRI.relativize(testCase.getURI()).toString(), 
					qs.getLiteral("sql").getLexicalForm(), 
					expectedTriples});
		}
		return result;
	}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:21,代碼來源:MappingGeneratorTest.java

示例5: getTypesFromSPARQL

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private Set<String> getTypesFromSPARQL(String sparqlQueryString) {

        Query query = QueryFactory.create(sparqlQueryString);
        QueryExecution qexec = QueryExecutionFactory.sparqlService(this.endpoint, query);
        Set<String> types = new HashSet<>();

        ResultSet results = qexec.execSelect();
        while(results.hasNext()) {
            QuerySolution qs = results.next();
            Resource type = qs.getResource("?type");
            types.add(type.getURI());
        }

        qexec.close();
        return types;
    }
 
開發者ID:freme-project,項目名稱:freme-ner,代碼行數:17,代碼來源:SPARQLProcessor.java

示例6: getResources

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private Collection<String> getResources(String query, String varName)
{
	Collection<String> ret = new HashSet<String>();
	QueryEngineHTTP endpoint = new QueryEngineHTTP(SPARQL_ENDPOINT, query);
	try {
		ResultSet rs = endpoint.execSelect();
        while (rs.hasNext()) {
            QuerySolution qs = rs.next();
            ret.add(qs.getResource(varName).getURI());
        }
	}
	catch (Throwable t) {
		t.printStackTrace();
	}
	finally {
		endpoint.close();
	}
	return ret;
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:20,代碼來源:WikidataFetch.java

示例7: harvest

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private void harvest(String query, CSVWriter p)
{
    QueryEngineHTTP endpoint = new QueryEngineHTTP(_sparql, query);
    try {
        System.err.println(query);
        ResultSet rs = endpoint.execSelect();
        if ( !rs.hasNext() ) { return; }

        int cursor = 0;
        while (rs.hasNext())
        {
            QuerySolution sol = rs.next();
            String src = sol.getResource("src").getURI();
            String trg = sol.getResource("trg").getURI();
            p.println(src, trg);
            if (++cursor % 1000 == 0) { System.out.println("fetched: " + cursor); }
        }
    }
    catch (Throwable t) {
        t.printStackTrace();
    }
    finally {
        endpoint.close();
    }
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:26,代碼來源:CoRefCacheHarvester.java

示例8: testRelatives

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
/**
 * Perform a query about relatives against the ontology obtained by
 * aggregating a set of ontologies and using the specified engine.
 * 
 * @param engine
 * @param expected
 *            pairs expected to be returned as result of the relative query
 * @throws InterruptedException
 */
public void testRelatives(final QueryEngine engine, final List<RelativePair> expected) throws InterruptedException {
	engine.write(System.out, "http://example.org");
	final ResultSet actual = engine.execQuery(RELATIVES_QUERY);
	final Iterator<RelativePair> expectedIt = expected.iterator();
	int n = 0;
	while (expectedIt.hasNext()) {
		n++;
		final RelativePair expectedPair = expectedIt.next();
		assertTrue("Too less pairs returned rows=" + n, actual.hasNext());
		final QuerySolution actualPair = actual.next();
		final String actualx = actualPair.get("x").asResource().getURI();
		final String actualy = actualPair.get("y").asResource().getURI();
		System.out.println("Expected (x=" + expectedPair.x + ",y=" + expectedPair.y + "); Actual (x=" + actualx
				+ ",y=" + actualy + ")");
		assertEquals("row=" + n, expectedPair.x, actualx);
		assertEquals("row=" + n, expectedPair.y, actualy);
	}
	assertFalse("Too much pairs returned. Rows=" + n, actual.hasNext());
}
 
開發者ID:opendatahacklab,項目名稱:semanticoctopus,代碼行數:29,代碼來源:AggregationTestUtils.java

示例9: queryLabels

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private Set<String> queryLabels(QueryExecutionFactory qef, String query) throws IOException {
	QueryExecution exec = qef.createQueryExecution(query);
	ResultSet resultSet = null;
	try {
		resultSet = exec.execSelect();
	} catch (Exception e) {
		throw new IOException("Couldn't query labels.", e);
	}
	Set<String> labels = new HashSet<String>();
	QuerySolution result = null;
	RDFNode predicate, object;
	while (resultSet.hasNext()) {
		result = resultSet.next();
		predicate = result.get(PREDICATE);
		if ((predicate != null) && (LABEL_PROPERTIES.contains(predicate.toString()))) {
			object = result.get(OBJECT);
			if (object != null) {
				labels.add(object.toString());
			}
		}
	}
	return labels;
}
 
開發者ID:dice-group,項目名稱:Tapioca,代碼行數:24,代碼來源:SPARQLEndpointLabelExtractor.java

示例10: getUsage

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
private List<Statement> getUsage(Property property, Model model){
	
	List<Statement> stmts = new ArrayList<Statement>();
	String sparql = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
			+ "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
			+ "SELECT DISTINCT ?concept "
			+ "WHERE{"
			+ "  {<" + property.getURI() + "> rdfs:domain ?concept} "
			+ "  UNION "
			+ "  { "
			+ "    ?concept rdfs:subClassOf|owl:equivalentClass ?restriction . "
			+ "    ?restriction a owl:Restriction; "
			+ "      owl:onProperty <" + property.getURI() + "> "
			+ "  } "
			+ "}";
	Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
	QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
	
	ResultSet resultSet = queryExecution.execSelect();
	while(resultSet.hasNext()){
		QuerySolution querySolution = resultSet.next();
		Resource concept = querySolution.getResource("concept");
		
		stmts.add(new StatementImpl(property, usage, concept));
	}
	
	return stmts;
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:30,代碼來源:IndexingJob.java

示例11: testMultiGraphQuery

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testMultiGraphQuery() throws URISyntaxException, IOException, OperationNotSupportedException {
	URL[] files = new URL[1];
	URL url = TDBTest.class.getResource("/org/aksw/kbox/kibe/foaf.rdf");
	files[0] = url;
	java.nio.file.Path f = Files.createTempDirectory("kb");
	String foafPath = f.toFile().getPath();
	TDB.bulkload(f.toFile().getPath(), files);
	Date start = new Date();
	ResultSet rs = TDB.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}", foafPath, graphPath);
	int i = 0;
	Date end = new Date();
	System.out.println(end.getTime() - start.getTime());
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
	
	start = new Date();
	rs = TDB.query("Select ?p where {<http://xmlns.com/foaf/0.1/Agent> ?p ?o}", foafPath, graphPath);
	i = 0;
	end = new Date();
	System.out.println(end.getTime() - start.getTime());
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(9, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:31,代碼來源:TDBTest.java

示例12: testQuery2

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testQuery2() throws URISyntaxException, IOException, OperationNotSupportedException {
	ResultSet rs = TDB.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}", graphPath);
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:10,代碼來源:TDBTest.java

示例13: testInstallProcess

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testInstallProcess() throws Exception {
	ResultSet rs = KBox.query("Select ?p where {<http://dbpedia.org/ontology/Place> ?p ?o}",
			new URL("http://dbpedia39"));
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:12,代碼來源:KBoxTest.java

示例14: testDescribeQuery

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testDescribeQuery() throws Exception {
	ResultSet rs = KBox.query("Describe <http://dbpedia.org/ontology/Place>",
			new URL("http://dbpedia39"));
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(19, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:12,代碼來源:KBoxTest.java

示例15: testAskQuery

import com.hp.hpl.jena.query.ResultSet; //導入方法依賴的package包/類
@Test
public void testAskQuery() throws Exception {
	ResultSet rs = KBox.query("ASK {  <http://dbpedia.org/ontology/Place> ?p ?o.  " +
		" FILTER(?o = 'test') . }",
		new URL("http://dbpedia39"));
	int i = 0;
	while (rs != null && rs.hasNext()) {
		rs.next();
		i++;
	}
	assertEquals(1, i);
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:13,代碼來源:KBoxTest.java


注:本文中的com.hp.hpl.jena.query.ResultSet.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。