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


Java RepositoryConnection类代码示例

本文整理汇总了Java中org.eclipse.rdf4j.repository.RepositoryConnection的典型用法代码示例。如果您正苦于以下问题:Java RepositoryConnection类的具体用法?Java RepositoryConnection怎么用?Java RepositoryConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: select

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> select(Service service, Set<String> projectionVars, BindingSet bindings, String baseUri) throws QueryEvaluationException {
	RepositoryConnection conn = endpoint.getConn();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, service.getSelectQueryString(projectionVars), baseUri);
		Iterator<Binding> bIter = bindings.iterator();
		while (bIter.hasNext()) {
			Binding b = bIter.next();
			if (service.getServiceVars().contains(b.getName()))
				query.setBinding(b.getName(), b.getValue());
		}
		TupleQueryResult qRes = query.evaluate();
		return new InsertBindingsIteration(qRes, bindings);
	} catch(Throwable e) {
		throw new QueryEvaluationException(e);
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:20,代码来源:SAILFederatedService.java

示例2: buildPrefixes

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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

示例3: getObj

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

示例4: getSubjectsCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的package包/类
/**
 * Get total number of distinct subjects of a dataset
 * @return count 
 */
public static Long getSubjectsCount(String endpoint) {
	String strQuery = "SELECT  (COUNT(DISTINCT ?s) AS ?sbjts) " + // 
			"WHERE " +
			"{" +
       		"?s ?p ?o " +
       		"} " ;
	SPARQLRepository repo = createSPARQLRepository(endpoint);
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		return Long.parseLong(rs.next().getValue("sbjts").stringValue());
	} finally {
		conn.close();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:21,代码来源:TBSSSummariesGenerator.java

示例5: getTripleCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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.repository.RepositoryConnection; //导入依赖的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.repository.RepositoryConnection; //导入依赖的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.repository.RepositoryConnection; //导入依赖的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: getDistinctObj

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

示例10: getDistinctSbj

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

示例11: getObjectCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的package包/类
/**
 * Get total number of distinct objects of a dataset
 * @return count
 */
public static long getObjectCount(String endpoint) {
	String strQuery = "SELECT  (COUNT(DISTINCT ?o) AS ?objts) " + // 
			"WHERE " +
			"{" +
       		"?s ?p ?o " +
       		"} " ;
	SPARQLRepository repo = new SPARQLRepository(endpoint);
	repo.initialize();
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		return Long.parseLong(rs.next().getValue("objts").stringValue());
	} finally {
		conn.close();
		repo.shutDown();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:23,代码来源:SemagrowSummariesGenerator.java

示例12: getTripleCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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(?s) AS ?triples) " + // 
			"WHERE " +
			"{" +
       		"?s <"+pred+"> ?o " +
       		"} " ;
	SPARQLRepository repo = new SPARQLRepository(endpoint);
	repo.initialize();
	RepositoryConnection conn = repo.getConnection();
	try {
		TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, strQuery); 
		TupleQueryResult rs = query.evaluate();
		return Long.parseLong(rs.next().getValue("triples").stringValue());
	} finally {
		conn.close();
		repo.shutDown();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:25,代码来源:SemagrowSummariesGenerator.java

示例13: getPredicates

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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 = getPredQuery(graph);
	SPARQLRepository repo = new SPARQLRepository(endPointUrl);
	repo.initialize();
	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);	  		
		}
	} finally {
		conn.close();
		repo.shutDown();
	}
	return predLst;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:28,代码来源:SemagrowSummariesGenerator.java

示例14: getTripleCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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

示例15: getDistinctSubjectCount

import org.eclipse.rdf4j.repository.RepositoryConnection; //导入依赖的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


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