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


Java MalformedQueryException类代码示例

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


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

示例1: size

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的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: FedSumClassLookup

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
/**
 * Index lookup for rdf:type and its its corresponding values
 * @param p Predicate i.e. rdf:type
 * @param o Predicate value
 * @param stmt Statement Pattern
 * @throws RepositoryException
 * @throws MalformedQueryException
 * @throws QueryEvaluationException
 */
public void FedSumClassLookup(StatementPattern stmt, String p, String o) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	
	  String  queryString = "Prefix ds:<http://aksw.org/fedsum/> "
		   		+ "SELECT  Distinct ?url "
			   	+ " WHERE {?s ds:url ?url. "
				+ " 		?s ds:capability ?cap. "
				+ "		   ?cap ds:predicate <" + p + ">."
						+ "?cap ds:objAuthority  <" + o + "> }" ;
	    TupleQuery tupleQuery = FedSumConfig.con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
		 TupleQueryResult result = tupleQuery.evaluate();
		   while(result.hasNext())
		   {
			  String endpoint = result.next().getValue("url").stringValue();
				String id = "sparql_" + endpoint.replace("http://", "").replace("/", "_");
				addSource(stmt, new StatementSource(id, StatementSourceType.REMOTE));
		   }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:FedSumSourceSelection.java

示例3: FedSumD_getMatchingSbjAuthorities

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
/**
 *  Get matching Subject authorities from a specific source for a triple pattern 
 * @param stmt Triple pattern
 * @param src Capable source 
 * @return List of authorities
 * @throws RepositoryException
 * @throws MalformedQueryException
 * @throws QueryEvaluationException
 */

public ArrayList<String> FedSumD_getMatchingSbjAuthorities(StatementPattern stmt, StatementSource src) throws RepositoryException, MalformedQueryException, QueryEvaluationException 
{
	String endPointUrl = "http://"+src.getEndpointID().replace("sparql_", "");
	       endPointUrl = endPointUrl.replace("_", "/");
	ArrayList<String> sbjAuthorities = new ArrayList<String>();
	
	  String  queryString = getFedSumSbjAuthLookupQuery(stmt, endPointUrl) ;
	  
	     TupleQuery tupleQuery = FedSumConfig.con.prepareTupleQuery(QueryLanguage.SPARQL, queryString);
	     TupleQueryResult result = tupleQuery.evaluate();
			   while(result.hasNext())
			     sbjAuthorities.add(result.next().getValue("sbjAuth").stringValue());
		      
			   			 return sbjAuthorities;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:FedSumSourceSelection.java

示例4: executeQuery

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

示例5: executeQuery

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

示例6: getObj

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

示例7: getPredicates

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

示例8: FedSumClassLookup

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
/**
 * HiBISCuS Index lookup for rdf:type and its its corresponding values
 * @param p Predicate i.e. rdf:type
 * @param o Predicate value
 * @param stmt Statement Pattern
 * @throws RepositoryException Repository Error
 * @throws MalformedQueryException Query Error
 * @throws QueryEvaluationException Query Execution Error
 */
public void FedSumClassLookup(StatementPattern stmt, String p, String o) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	
	  String  queryString = "Prefix ds:<http://aksw.org/fedsum/> "
		   		+ "SELECT  Distinct ?url "
			   	+ " WHERE {?s ds:url ?url. "
				+ " 		?s ds:capability ?cap. "
				+ "		   ?cap ds:predicate <" + p + ">."
						+ "?cap ds:objAuthority  <" + o + "> }" ;
	    TupleQuery tupleQuery = getSummaryConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
		 TupleQueryResult result = tupleQuery.evaluate();
		   while(result.hasNext())
		   {
			  String endpoint = result.next().getValue("url").stringValue();
				String id = "sparql_" + endpoint.replace("http://", "").replace("/", "_");
				addSource(stmt, new StatementSource(id, StatementSourceType.REMOTE));
		   }
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:HibiscusSourceSelection.java

示例9: FedSumD_getMatchingSbjAuthorities

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
/**
 *  Get matching Subject authorities from a specific source for a triple pattern 
 * @param stmt Triple pattern
 * @param src Capable source 
 * @return List of authorities
 * @throws RepositoryException Repository Exception
 * @throws MalformedQueryException Memory Exception
 * @throws QueryEvaluationException Query Exception
 */

public ArrayList<String> FedSumD_getMatchingSbjAuthorities(StatementPattern stmt, StatementSource src) throws RepositoryException, MalformedQueryException, QueryEvaluationException 
{
	String endPointUrl = "http://"+src.getEndpointID().replace("sparql_", "");
	       endPointUrl = endPointUrl.replace("_", "/");
	ArrayList<String> sbjAuthorities = new ArrayList<String>();
	
	  String  queryString = getFedSumSbjAuthLookupQuery(stmt, endPointUrl) ;
	  
	     TupleQuery tupleQuery = getSummaryConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
	     TupleQueryResult result = tupleQuery.evaluate();
			   while(result.hasNext())
			     sbjAuthorities.add(result.next().getValue("sbjAuth").stringValue());
		      
			   			 return sbjAuthorities;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:26,代码来源:HibiscusSourceSelection.java

示例10: getRankedSources

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
public static List<StatementSource> getRankedSources(Summary summary, String queryString, int k) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
	List<StatementSource> rankedSources = new ArrayList<StatementSource>();
	TupleQuery tupleQuery = summary.getConnection().prepareTupleQuery(QueryLanguage.SPARQL, queryString);
	//System.out.println(queryString);
	TupleQueryResult result = tupleQuery.evaluate();
	int count = 0 ;
	while(result.hasNext() && count <k)
	{
		String endpoint = result.next().getValue("url").stringValue();
		String id = "sparql_" + endpoint.replace("http://", "").replace("/", "_");
		StatementSource src =  new StatementSource(id, StatementSourceType.REMOTE);
		rankedSources.add(src);
		count++;
	}

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

示例11: getFscores

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
public static String getFscores(String queryNo,TupleQueryResult res) throws QueryEvaluationException, RepositoryException, MalformedQueryException 
{
	
	String Fscores = "" ;
	double precision, recall,F1;
	Set<String> curResults =  getCurrentResult(res) ;
	//System.out.println("current:"+ curResults);
	Set<String> actualResults = getActualResults(queryNo) ;
	//System.out.println("actual:" +actualResults);
	Set<String> diffSet = Sets.difference(actualResults, curResults);
	//System.out.println(diffSet);
	//System.out.println(Sets.difference( curResults,actualResults));
	double correctResults = actualResults.size()-diffSet.size();
	precision = (correctResults/curResults.size());
	recall = correctResults/actualResults.size();
	F1 = 2*(precision*recall)/(precision+recall);
	Fscores = "Precision: "+precision+", Recall: " + recall +", F1: "+F1;
	return Fscores;
	
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:21,代码来源:StatsGenerator.java

示例12: prepareQuery

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
/**
 * Base method for prepareQuery
 *
 * Routes to all other query forms (prepareTupleQuery,prepareBooleanQuery,prepareGraphQuery)
 *
 * @param queryLanguage  Query language to be used, for the query string.
 * @param queryString  Query string to be used.
 * @param baseURI Base URI to be used, with query string.
 * @return MarkLogicQuery
 * @throws RepositoryException
 * @throws MalformedQueryException
 */
@Override
public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI)
        throws RepositoryException, MalformedQueryException
{
    // function routing based on query form
    if (SPARQL.equals(queryLanguage)) {
        String queryStringWithoutProlog = QueryParserUtil.removeSPARQLQueryProlog(queryString).toUpperCase();
        if (queryStringWithoutProlog.startsWith("SELECT")) {
            return prepareTupleQuery(queryLanguage, queryString, baseURI);   //must be a TupleQuery
        }
        else if (queryStringWithoutProlog.startsWith("ASK")) {
            return prepareBooleanQuery(queryLanguage, queryString, baseURI); //must be a BooleanQuery
        }
        else {
            return prepareGraphQuery(queryLanguage, queryString, baseURI);   //all the rest use GraphQuery
        }
    }
    throw new UnsupportedQueryLanguageException("Unsupported query language " + queryLanguage.getName());
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:32,代码来源:MarkLogicRepositoryConnection.java

示例13: testStringCombinationQueryWithDefaults

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
@Test
public void testStringCombinationQueryWithDefaults() throws QueryEvaluationException, MalformedQueryException, RepositoryException {

    StringQueryDefinition stringDef = qmgr.newStringDefinition().withCriteria("First");
    String posQuery = "ASK WHERE {<http://example.org/r9928> ?p ?o .}";
    String negQuery = "ASK WHERE {<http://example.org/r9929> ?p ?o .}";

    conn.setDefaultConstrainingQueryDefinition(stringDef);

    MarkLogicBooleanQuery askQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL,posQuery);
    Assert.assertEquals(true, askQuery.evaluate());

    askQuery = conn.prepareBooleanQuery(QueryLanguage.SPARQL,negQuery);
    askQuery.setConstrainingQueryDefinition(stringDef);
    Assert.assertEquals(false, askQuery.evaluate());

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

示例14: getStatements

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> getStatements(
		String preparedQuery, RepositoryConnection conn, final BindingSet bindings, final FilterValueExpr filterExpr)
		throws RepositoryException, MalformedQueryException,
		QueryEvaluationException {
	
	TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, preparedQuery, null);
	disableInference(query);		
	
	// evaluate the query
	CloseableIteration<BindingSet, QueryEvaluationException> res = query.evaluate();
	
	// apply filter and/or insert original bindings
	if (filterExpr!=null) {
		if (bindings.size()>0) 
			res = new FilteringInsertBindingsIteration(strategy, filterExpr, bindings, res);
		else
			res = new FilteringIteration(strategy, filterExpr, res);
		if (!res.hasNext())
			return new EmptyIteration<BindingSet, QueryEvaluationException>();
	} else if (bindings.size()>0) {
		res = new InsertBindingsIteration(res, bindings);
	}
	
	return res;
}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:27,代码来源:SailTripleSource.java

示例15: evaluateExclusiveGroup

import org.eclipse.rdf4j.query.MalformedQueryException; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateExclusiveGroup(
		ExclusiveGroup group, RepositoryConnection conn,
		TripleSource tripleSource, BindingSet bindings)
		throws RepositoryException, MalformedQueryException,
		QueryEvaluationException {

	// simple thing: use a prepared query
	Boolean isEvaluated = false;
	TupleExpr preparedQuery = QueryAlgebraUtil.selectQuery(group, bindings, group.getFilterExpr(), isEvaluated);
	return tripleSource.getStatements(preparedQuery, conn, bindings, (isEvaluated ? null : group.getFilterExpr()));

	// other option (which might be faster for sesame native stores): join over the statements
	// TODO implement this and evaluate if it is faster ..

}
 
开发者ID:dice-group,项目名称:CostFed,代码行数:17,代码来源:SailFederationEvalStrategy.java


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