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


Java TupleQuery.setIncludeInferred方法代碼示例

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


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

示例1: executeSelectQuery

import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static TupleQueryResult executeSelectQuery(final Repository repo, final String query,
		final QueryLanguage ql) throws OpenRDFException  {

	RepositoryConnection cxn;
	if (repo instanceof BigdataSailRepository) {
		cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
	} else {
		cxn = repo.getConnection();
	}

	try {

		final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
		tupleQuery.setIncludeInferred(true /* includeInferred */);
		return tupleQuery.evaluate();
		
	} finally {
		// close the repository connection
		cxn.close();
	}
}
 
開發者ID:blazegraph,項目名稱:blazegraph-samples,代碼行數:22,代碼來源:SampleBlazegraphSesameEmbedded.java

示例2: executeSelectQuery

import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static TupleQueryResult executeSelectQuery(Repository repo, String query,
		QueryLanguage ql) throws OpenRDFException  {

	RepositoryConnection cxn;
	if (repo instanceof BigdataSailRepository) {
		cxn = ((BigdataSailRepository) repo).getReadOnlyConnection();
	} else {
		cxn = repo.getConnection();
	}

	try {

		final TupleQuery tupleQuery = cxn.prepareTupleQuery(ql, query);
		tupleQuery.setIncludeInferred(true /* includeInferred */);
		return tupleQuery.evaluate();
		
	} finally {
		// close the repository connection
		cxn.close();
	}
}
 
開發者ID:blazegraph,項目名稱:blazegraph-samples,代碼行數:22,代碼來源:Utils.java

示例3: getSelect

import org.openrdf.query.TupleQuery; //導入方法依賴的package包/類
public static final <T> T getSelect( QueryExecutor<T> query,
		RepositoryConnection rc, boolean dobindings ) throws RepositoryException,
		MalformedQueryException, QueryEvaluationException {

	String sparql = processNamespaces( dobindings ? query.getSparql()
			: query.bindAndGetSparql(), query.getNamespaces() );

	ValueFactory vfac = new ValueFactoryImpl();
	TupleQuery tq = rc.prepareTupleQuery( QueryLanguage.SPARQL, sparql );

	if ( null != query.getContext() ) {
		DatasetImpl dataset = new DatasetImpl();
		dataset.addDefaultGraph( query.getContext() );
		tq.setDataset( dataset );
	}

	if ( dobindings ) {
		tq.setIncludeInferred( query.usesInferred() );
		query.setBindings( tq, vfac );
	}

	TupleQueryResult rslt = tq.evaluate();
	query.start( rslt.getBindingNames() );
	while ( rslt.hasNext() ) {
		query.handleTuple( rslt.next(), vfac );
	}
	query.done();
	rslt.close();
	return query.getResults();
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:31,代碼來源:AbstractSesameEngine.java

示例4: testSPARQLQueryWithDefaultInferred

import org.openrdf.query.TupleQuery; //導入方法依賴的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-sesame,代碼行數:34,代碼來源:MarkLogicTupleQueryTest.java


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