• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SPARQLRepository类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: executeQuery

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


示例2: executeQuery

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


示例3: getObj

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

import org.eclipse.rdf4j.repository.sparql.SPARQLRepository; //导入依赖的package包/类
/**
 * Get total number of distinct subjects of a dataset
 * @return count 
 */
public static long getSubjectCount(String endpoint) {
	String strQuery = "SELECT  (COUNT(DISTINCT ?s) AS ?sbjts) " + // 
			"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("sbjts").stringValue());
	} finally {
		conn.close();
		repo.shutDown();
	}
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:23,代码来源:SemagrowSummariesGenerator.java


示例12: getObjectCount

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


示例13: getTripleCount

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


示例14: getPredicates

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


示例15: getTripleCount

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


示例16: getDistinctSubjectCount

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


示例17: getDistinctObjectCount

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


示例18: getPredicates

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


示例19: create

import org.eclipse.rdf4j.repository.sparql.SPARQLRepository; //导入依赖的package包/类
@Override
public Backend create(Model backendModel, IRI identifier) {
  Literal endpoint =
      Models.objectLiteral(backendModel.filter(identifier, ELMO.ENDPOINT, null)).orElseThrow(
          () -> new ConfigurationException(String.format(
              "No <%s> statement has been found for backend <%s>.", ELMO.ENDPOINT, identifier)));

  if (!XMLSchema.ANYURI.equals(endpoint.getDatatype())) {
    throw new ConfigurationException(
        String.format("Object <%s> for backend <%s> must be of datatype <%s>.", ELMO.ENDPOINT,
            identifier, XMLSchema.ANYURI));
  }

  SPARQLRepository repository = new SPARQLRepository(endpoint.stringValue());

  repository.initialize();

  return new SparqlBackend.Builder(identifier, repository, informationProductFactory).build();
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:20,代码来源:SparqlBackendFactory.java


示例20: getObjectsCount

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Step类代码示例发布时间:2022-05-23
下一篇:
Java ConstraintEvaluator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap