当前位置: 首页>>代码示例>>Java>>正文


Java TupleQueryResult.next方法代码示例

本文整理汇总了Java中org.eclipse.rdf4j.query.TupleQueryResult.next方法的典型用法代码示例。如果您正苦于以下问题:Java TupleQueryResult.next方法的具体用法?Java TupleQueryResult.next怎么用?Java TupleQueryResult.next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.rdf4j.query.TupleQueryResult的用法示例。


在下文中一共展示了TupleQueryResult.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: serialize

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Override
public void serialize(@NonNull TupleQueryResult tupleQueryResult,
    @NonNull JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
    throws IOException {

  writeStart(jsonGenerator);

  while (tupleQueryResult.hasNext()) {
    writeStartItem(jsonGenerator);

    BindingSet bindingSet = tupleQueryResult.next();
    for (Binding binding : bindingSet) {
      jsonGenerator.writeObjectField(binding.getName(), serializeValue(binding.getValue()));
    }

    writeEndItem(jsonGenerator);
  }

  writeEnd(jsonGenerator);
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:AbstractTupleQueryResultSerializer.java

示例2: size

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Returns number of triples in the entire triple store.
 *
 * @return long
 * @throws RepositoryException
 */
@Override
public long size() throws RepositoryException{
    try {
        MarkLogicTupleQuery tupleQuery = prepareTupleQuery(COUNT_EVERYTHING);
        tupleQuery.setIncludeInferred(false);
        tupleQuery.setRulesets((SPARQLRuleset)null);
        tupleQuery.setConstrainingQueryDefinition((QueryDefinition)null);
        TupleQueryResult qRes = tupleQuery.evaluate();
        // just one answer
        BindingSet result = qRes.next();
        qRes.close();
        return ((Literal) result.getBinding("ct").getValue()).longValue();
    } catch (QueryEvaluationException | MalformedQueryException e) {
        throw new RepositoryException(e);
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:23,代码来源:MarkLogicRepositoryConnection.java

示例3: testSPARQLQueryWithRuleset

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithRuleset()
        throws Exception {
    String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
    MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);

    tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL);
    TupleQueryResult results = tupleQuery.evaluate();

    Assert.assertEquals(results.getBindingNames().get(0), "s");
    Assert.assertEquals(results.getBindingNames().get(1), "p");
    Assert.assertEquals(results.getBindingNames().get(2), "o");

    BindingSet bindingSet = results.next();

    Value sV = bindingSet.getValue("s");
    Value pV = bindingSet.getValue("p");
    Value oV = bindingSet.getValue("o");

    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
    Assert.assertEquals("0", oV.stringValue());
    results.close();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicTupleQueryTest.java

示例4: testSPARQLQueryWithMultipleRulesets

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithMultipleRulesets()
        throws Exception {
    String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
    MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);

    tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL,SPARQLRuleset.DOMAIN);
    TupleQueryResult results = tupleQuery.evaluate();

    Assert.assertEquals(results.getBindingNames().get(0), "s");
    Assert.assertEquals(results.getBindingNames().get(1), "p");
    Assert.assertEquals(results.getBindingNames().get(2), "o");

    BindingSet bindingSet = results.next();

    Value sV = bindingSet.getValue("s");
    Value pV = bindingSet.getValue("p");
    Value oV = bindingSet.getValue("o");

    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
    Assert.assertEquals("0", oV.stringValue());
    results.close();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:25,代码来源:MarkLogicTupleQueryTest.java

示例5: executeQuery

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Execute query and return the number of results
 * @param query SPARQL 	query
 * @param bgpGroups BGPs
 * @param stmtToSources Triple Pattern to sources
 * @param repo  repository
 * @return Number of results
 * @throws RepositoryException
 * @throws MalformedQueryException
 * @throws QueryEvaluationException
 */
public static int executeQuery(String query, HashMap<Integer, List<StatementPattern>> bgpGroups, Map<StatementPattern, List<StatementSource>> stmtToSources, SPARQLRepository repo) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	String newQuery = QueryRewriting.doQueryRewriting(query,bgpGroups,stmtToSources);
		System.out.println(newQuery);
	TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, newQuery); 
	int count = 0;
	TupleQueryResult result = tupleQuery.evaluate();
	while(result.hasNext())
	{
		//System.out.println(result.next());
		result.next();
		count++;
	}

	return count;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:ExecuteTBSSQuery.java

示例6: executeQuery

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
* Execute query and return the number of results
* @param query SPARQL 	query
* @param bgpGroups BGPs
* @param stmtToSources Triple Pattern to sources
* @param repo  repository
* @return Number of results
* @throws RepositoryException
* @throws MalformedQueryException
* @throws QueryEvaluationException
*/
public static int executeQuery(String query, HashMap<Integer, List<StatementPattern>> bgpGroups, Map<StatementPattern, List<StatementSource>> stmtToSources, SPARQLRepository repo) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	String newQuery = QueryRewriting.doQueryRewriting(query,bgpGroups,stmtToSources);
	//	System.out.println(newQuery);
		TupleQuery tupleQuery = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, newQuery); 
		int count = 0;
		TupleQueryResult result = tupleQuery.evaluate();
		while(result.hasNext())
		{
			//System.out.println(result.next());
			result.next();
			count++;
		}

	return count;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:ExecuteHibiscusQuery.java

示例7: buildPrefixes

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
void buildPrefixes(RepositoryConnection conn, String query, SortedMap<KeyTuple, ValueTuple> prefixMap, boolean isSbjPrefix) {
	TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
	TupleQueryResult result = tupleQuery.evaluate();
	while (result.hasNext())
	{
		BindingSet row = result.next();
		
		String endpoint = row.getValue("url").stringValue();
		String predicate = row.getValue("p").stringValue();
		String prefix = row.getValue("prefix").stringValue();
		long unique = Long.parseLong(row.getValue("unique").stringValue());
		long card = Long.parseLong(row.getValue("card").stringValue());
		
		//log.info(predicate + " : " + prefix + " : " + card);
		
		String eid = getEID(endpoint);
		KeyTuple kt = new KeyTuple(predicate, prefix);
		updateMap(prefixMap, kt, eid);
		KeyTuple kt0 = new KeyTuple(null, prefix);
		updateMap(prefixMap, kt0, eid);
		
		updateCapabilityPrefix(eid, predicate, prefix, unique, card, isSbjPrefix);
	}
	result.close();
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:CostFedSummary.java

示例8: getCurrentResult

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
private static Set<String> getCurrentResult(TupleQueryResult res) throws QueryEvaluationException 
{
	List<String> bindingNames = res.getBindingNames();
	Set<String> curResults = new HashSet<String>() ;
	while (res.hasNext()) {
		BindingSet result = res.next();
		String recordLine ="";
		for(int i = 0 ; i < bindingNames.size(); i++)
		{
			String bindingName = bindingNames.get(i);
			String bindingVal = result.getBinding(bindingName).getValue().toString().replaceAll("\n", " ").replace("]", "").replace("[", "");
			if(i< bindingNames.size()-1)					
			recordLine = recordLine+bindingName+"="+bindingVal+";";
			else
				recordLine = recordLine+bindingName+"="+bindingVal;	
			
		}
		curResults.add("["+recordLine+"]");
		}

	return curResults;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:23,代码来源:StatsGenerator.java

示例9: getStatementListBySPARQL

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Executes SPARQL query against triplestore.  Note, the query must return a list containing spoc in order to convert 
 * the results to a list of statements.
 *
 * @param sparqlQuery the SPARQL query
 * @return list of statements returned by SPARQL query
 * @throws Exception the exception
 */
public List<Statement> getStatementListBySPARQL(String sparqlQuery) 
		throws Exception {
	List <Statement> stmts = new ArrayList <Statement>();
	TupleQuery tupleQuery = getConnection().prepareTupleQuery(QueryLanguage.SPARQL, sparqlQuery);
	TupleQueryResult resultset = tupleQuery.evaluate();
	while (resultset.hasNext()) {
		BindingSet bindingSet = resultset.next();
		Statement stmt = getValueFactory().createStatement((Resource) bindingSet.getBinding("s").getValue(),
											(IRI)bindingSet.getBinding("p").getValue(),
											bindingSet.getBinding("o").getValue(),
											(Resource) bindingSet.getBinding("c").getValue());
		stmts.add(stmt);
		
	}		
	return stmts;
}
 
开发者ID:rmap-project,项目名称:rmap,代码行数:25,代码来源:Rdf4jTriplestore.java

示例10: testLikeAndNamespace

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testLikeAndNamespace() throws Exception {
    ValueFactory vf = con.getValueFactory();
    con.add(vf.createIRI("urn:test/subjx"), vf.createIRI("urn:test/pred"), vf.createLiteral("valuex"));
    con.add(vf.createIRI("urn:test/xsubj"), vf.createIRI("urn:test/pred"), vf.createLiteral("xvalue"));
    String serql = "SELECT * FROM {s} test:pred {o} WHERE s LIKE \"urn:test/subj*\" USING NAMESPACE test = <urn:test/>";
    TupleQueryResult res = con.prepareTupleQuery(QueryLanguage.SERQL, serql).evaluate();
    assertTrue(res.hasNext());
    res.next();
    assertFalse(res.hasNext());
    serql = "SELECT * FROM {s} test:pred {o} WHERE o LIKE \"value*\" USING NAMESPACE test = <urn:test/>";
    res = con.prepareTupleQuery(QueryLanguage.SERQL, serql).evaluate();
    assertTrue(res.hasNext());
    res.next();
    assertFalse(res.hasNext());
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:17,代码来源:HalyardStrategyExtendedTest.java

示例11: testSPARQLQueryWithPrepareQuery

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithPrepareQuery()
        throws Exception {
    String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 1 ";
    Query q = conn.prepareQuery(QueryLanguage.SPARQL, queryString);

    try {
        if (q instanceof TupleQuery) {
            TupleQueryResult result = ((TupleQuery) q).evaluate();
            while (result.hasNext()) {
                BindingSet tuple = result.next();
                Assert.assertEquals("s", tuple.getBinding("s").getName());
                Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", tuple.getBinding("s").getValue().stringValue());
            }
            result.close();
        }
    }
    catch(Exception ex)
    {
        throw ex;
    }
    finally {
        conn.close();
        Thread.sleep(1000);
    }

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:28,代码来源:MarkLogicTupleQueryTest.java

示例12: testSPARQLQueryWithDefaultInferred

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithDefaultInferred()
        throws Exception {

    String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 2 ";
    TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    tupleQuery.setIncludeInferred(true);
    TupleQueryResult results = tupleQuery.evaluate();
    Assert.assertEquals(results.getBindingNames().get(0), "s");
    Assert.assertEquals(results.getBindingNames().get(1), "p");
    Assert.assertEquals(results.getBindingNames().get(2), "o");

    BindingSet bindingSet = results.next();

    Value sV = bindingSet.getValue("s");
    Value pV = bindingSet.getValue("p");
    Value oV = bindingSet.getValue("o");

    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
    Assert.assertEquals("0", oV.stringValue());

    BindingSet bindingSet1 = results.next();

    Value sV1 = bindingSet1.getValue("s");
    Value pV1 = bindingSet1.getValue("p");
    Value oV1 = bindingSet1.getValue("o");

    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BabylonGeodata", sV1.stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV1.stringValue());
    Assert.assertEquals("0", oV1.stringValue());
    results.close();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:34,代码来源:MarkLogicTupleQueryTest.java

示例13: testSPARQLQueryWithPagination

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithPagination()
        throws Exception {
    try{
        for(int i=0; i<101; i++){
            String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
            MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
            TupleQueryResult results = tupleQuery.evaluate(3, 1);

            Assert.assertEquals(results.getBindingNames().get(0), "s");
            Assert.assertEquals(results.getBindingNames().get(1), "p");
            Assert.assertEquals(results.getBindingNames().get(2), "o");

            BindingSet bindingSet = results.next();

            Value sV = bindingSet.getValue("s");
            Value pV = bindingSet.getValue("p");
            Value oV = bindingSet.getValue("o");

            Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#BethanyBeyondtheJordanGeodata", sV.stringValue());
            Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
            Assert.assertEquals("0", oV.stringValue());

            Assert.assertFalse(results.hasNext());
            results.close();
        }
    }
    catch(Exception ex)
    {
        throw ex;
    }
    finally {
        conn.close();
        Thread.sleep(1000);
    }
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:37,代码来源:MarkLogicTupleQueryTest.java

示例14: testSPARQLQueryWithNullRulesets

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithNullRulesets()
        throws Exception {
    String queryString = "select ?s ?p ?o { ?s ?p ?o } limit 100 ";
    MarkLogicTupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);

    tupleQuery.setRulesets(SPARQLRuleset.RDFS_FULL,null);
    tupleQuery.setRulesets(null);
    Assert.assertTrue(tupleQuery.getRulesets() == null);

    TupleQueryResult results = tupleQuery.evaluate();

    Assert.assertEquals(results.getBindingNames().get(0), "s");
    Assert.assertEquals(results.getBindingNames().get(1), "p");
    Assert.assertEquals(results.getBindingNames().get(2), "o");

    BindingSet bindingSet = results.next();

    Value sV = bindingSet.getValue("s");
    Value pV = bindingSet.getValue("p");
    Value oV = bindingSet.getValue("o");

    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#AttaliaGeodata", sV.stringValue());
    Assert.assertEquals("http://semanticbible.org/ns/2006/NTNames#altitude", pV.stringValue());
    Assert.assertEquals("0", oV.stringValue());

    results.close();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:29,代码来源:MarkLogicTupleQueryTest.java

示例15: testPrepareQuery2

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testPrepareQuery2() throws Exception {

	Reader ir = new BufferedReader(new InputStreamReader(
			MarkLogicRepositoryConnectionTest.class.getResourceAsStream(TEST_DIR_PREFIX + "property-paths.ttl")));
	testAdminCon.add(ir, "", RDFFormat.TURTLE, (Resource) null);

	StringBuilder queryBuilder = new StringBuilder(128);
	queryBuilder.append(" prefix : <http://learningsparql.com/ns/papers#> ");
	queryBuilder.append(" prefix c: <http://learningsparql.com/ns/citations#>");
	queryBuilder.append(" SELECT ?s");
	queryBuilder.append(" WHERE {  ");
	queryBuilder.append(" ?s ^c:cites :paperK2 . ");
	queryBuilder.append(" FILTER (?s != :paperK2)");
	queryBuilder.append(" } ");
	queryBuilder.append(" ORDER BY ?s ");

	Query query = testAdminCon.prepareQuery(queryBuilder.toString());
	query.setBinding("whatcode", vf.createLiteral("33333"));
	TupleQueryResult result = null;
	if (query instanceof TupleQuery) {
		result = ((TupleQuery) query).evaluate();

	}

	try {
		assertThat(result, is(notNullValue()));

		while (result.hasNext()) {
			BindingSet solution = result.next();
			assertThat(solution.hasBinding("s"), is(equalTo(true)));
			Value totalResult = solution.getValue("s");
			Assert.assertEquals(vf.createIRI("http://learningsparql.com/ns/papers#paperJ"), totalResult);

		}
	} finally {
		result.close();
	}
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:40,代码来源:MarkLogicRepositoryConnectionTest.java


注:本文中的org.eclipse.rdf4j.query.TupleQueryResult.next方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。