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


Java TupleQueryResult.close方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: getTripleCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Get total number of triple for a predicate
 * @param pred Predicate
 * @param m model
 * @return triples
 */
public static Long getTripleCount(String pred, String endpoint) {
	String strQuery = "SELECT  (COUNT(*) AS ?triples) " + // 
			"WHERE " +
			"{" +
       		"?s <"+pred+"> ?o " +
       		"} " ;
	SPARQLRepository repo = createSPARQLRepository(endpoint);
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		String v = rs.next().getValue("triples").stringValue();
		rs.close();
		return Long.parseLong(v);
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:25,代码来源:TBSSSummariesGenerator.java

示例6: getDistinctSubjectCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
public static Long getDistinctSubjectCount(String endpoint) {
	String strQuery = "SELECT  (COUNT(distinct ?s) AS ?triples) " + // 
			"WHERE " +
			"{" +
       		"?s ?p ?o " +
       		"} " ;
	SPARQLRepository repo = createSPARQLRepository(endpoint);
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		String v = rs.next().getValue("triples").stringValue();
		rs.close();
		return Long.parseLong(v);
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:19,代码来源:TBSSSummariesGenerator.java

示例7: getDistinctObjectCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
public static Long getDistinctObjectCount(String endpoint) {
	String strQuery = "SELECT  (COUNT(distinct ?o) AS ?triples) " + // 
			"WHERE " +
			"{" +
       		"?s ?p ?o " +
			"FILTER isIRI(?o)" +
       		"} " ;
	SPARQLRepository repo = createSPARQLRepository(endpoint);
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		String v = rs.next().getValue("triples").stringValue();
		rs.close();
		return Long.parseLong(v);
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:20,代码来源:TBSSSummariesGenerator.java

示例8: getPredicates

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Get Predicate List
 * @param endPointUrl SPARQL endPoint Url
 * @param graph Named graph
 * @return  predLst Predicates List
 */
private static List<String> getPredicates(String endPointUrl, String graph)
{
	List<String>  predLst = new ArrayList<String>();
	String strQuery = getPredQury(graph);
	SPARQLRepository repo = createSPARQLRepository(endPointUrl);
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult res = query.evaluate();
		while (res.hasNext()) 
		{
			String pred = res.next().getValue("p").toString();
			predLst.add(pred);	  		
		}
		res.close();
	} finally {
		conn.close();
	}
	return predLst;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:TBSSSummariesGenerator.java

示例9: getTripleCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Get total number of triple for a predicate
 * @param pred Predicate
 * @param m model
 * @return triples
 */
public static Long getTripleCount(String pred, String endpoint) {
    String strQuery = "SELECT  (COUNT(*) AS ?triples) " + // 
            "WHERE " +
            "{" +
            "?s <"+pred+"> ?o " +
            "} " ;
    SPARQLRepository repo = createSPARQLRepository(endpoint);
    RepositoryConnection conn = repo.getConnection();
    try {
        TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
        TupleQueryResult rs = query.evaluate();
        String v = rs.next().getValue("triples").stringValue();
        rs.close();
        return Long.parseLong(v);
    } finally {
        conn.close();
    }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:25,代码来源:SummaryGenerator.java

示例10: getDistinctSubjectCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
public static Long getDistinctSubjectCount(String endpoint) {
    String strQuery = "SELECT  (COUNT(distinct ?s) AS ?triples) " + 
            "WHERE " +
            "{" +
            "?s ?p ?o " +
            "} " ;
    SPARQLRepository repo = createSPARQLRepository(endpoint);
    RepositoryConnection conn = repo.getConnection();
    try {
        TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
        TupleQueryResult rs = query.evaluate();
        String v = rs.next().getValue("triples").stringValue();
        rs.close();
        return Long.parseLong(v);
    } finally {
        conn.close();
    }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:19,代码来源:SummaryGenerator.java

示例11: getDistinctObjectCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
public static Long getDistinctObjectCount(String endpoint) {
    String strQuery = "SELECT  (COUNT(distinct ?o) AS ?triples) " +
            "WHERE " +
            "{" +
            "?s ?p ?o " +
            "FILTER isIRI(?o)" +
            "} " ;
    SPARQLRepository repo = createSPARQLRepository(endpoint);
    RepositoryConnection conn = repo.getConnection();
    try {
        TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
        TupleQueryResult rs = query.evaluate();
        String v = rs.next().getValue("triples").stringValue();
        rs.close();
        return Long.parseLong(v);
    } finally {
        conn.close();
    }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:20,代码来源:SummaryGenerator.java

示例12: getObjectsCount

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
/**
 * Get total number of distinct objects of a dataset
 * @return count
 * @throws RepositoryException 
 * @throws MalformedQueryException 
 * @throws QueryEvaluationException 
 */
public static Long getObjectsCount(String endpoint) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	long count = 0;
	String strQuery = "SELECT  (COUNT(DISTINCT ?o) AS ?objts) " + // 
			"WHERE " +
			"{" +

       		"?s ?p ?o " +
       		"} " ;
	SPARQLRepository repo = createSPARQLRepository(endpoint);
	TupleQuery query = repo.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
	TupleQueryResult rs = query.evaluate();
	while( rs.hasNext() ) 
	{
		count = Long.parseLong(rs.next().getValue("objts").stringValue());

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

示例13: 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

示例14: 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

示例15: testSPARQLQueryWithEmptyResults

import org.eclipse.rdf4j.query.TupleQueryResult; //导入方法依赖的package包/类
@Test
public void testSPARQLQueryWithEmptyResults()
        throws Exception {
    String queryString = "select * { <http://marklogic.com/nonexistent> ?p ?o } limit 100 ";
    TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
    TupleQueryResult results = tupleQuery.evaluate();
    Assert.assertFalse(results.hasNext());
    results.close();
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:10,代码来源:MarkLogicTupleQueryTest.java


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