本文整理汇总了Java中org.eclipse.rdf4j.query.QueryEvaluationException类的典型用法代码示例。如果您正苦于以下问题:Java QueryEvaluationException类的具体用法?Java QueryEvaluationException怎么用?Java QueryEvaluationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
QueryEvaluationException类属于org.eclipse.rdf4j.query包,在下文中一共展示了QueryEvaluationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: size
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的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);
}
}
示例2: executeQuery
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的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;
}
示例3: getRankedSources
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的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;
}
示例4: testGraphQueryWithBaseURIWithEmptyBaseURI
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Ignore
@Test
public void testGraphQueryWithBaseURIWithEmptyBaseURI()
throws Exception {
String queryString =
"PREFIX nn: <http://semanticbible.org/ns/2006/NTNames#>\n" +
"PREFIX test: <http://marklogic.com#test>\n" +
"construct { ?s test:test <relative>} WHERE {?s nn:childOf nn:Eve . }";
GraphQuery graphQuery = conn.prepareGraphQuery(queryString, "");
exception.expect(QueryEvaluationException.class);
GraphQueryResult results = graphQuery.evaluate();
Statement st1 = results.next();
Assert.assertEquals("http://relative", st1.getObject().stringValue());
@SuppressWarnings("unused")
Statement st2 = results.next();
Assert.assertEquals("http://relative", st1.getObject().stringValue());
results.close();
}
示例5: testStringCombinationQueryWithDefaults
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的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());
}
示例6: evaluate
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
/**
* Evaluate a {@link CompareAny} node
* @param node the node to evaluate
* @param bindings the set of named value bindings
* @return
* @throws ValueExprEvaluationException
* @throws QueryEvaluationException
*/
private Value evaluate(CompareAny node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException {
Value leftValue = evaluate(node.getArg(), bindings);
// Result is false until a match has been found
boolean result = false;
// Use first binding name from tuple expr to compare values
String bindingName = node.getSubQuery().getBindingNames().iterator().next();
try (CloseableIteration<BindingSet, QueryEvaluationException> iter = parentStrategy.evaluate(node.getSubQuery(), bindings)) {
while (result == false && iter.hasNext()) {
BindingSet bindingSet = iter.next();
Value rightValue = bindingSet.getValue(bindingName);
try {
result = QueryEvaluationUtil.compare(leftValue, rightValue, node.getOperator());
} catch (ValueExprEvaluationException e) {
// ignore, maybe next value will match
}
}
}
return BooleanLiteral.valueOf(result);
}
示例7: updateIndexAtFixedTime
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
/**
* Update Index regularly on a specific date and time
* @param lstEndPoints List of SPARQL endpoints
* @param date specific date and time in "dd-MM-yyyy HH:mm:ss"
* @param outputFile Output location of index
* @param branchLimit Branching limit
*/
public static void updateIndexAtFixedTime(final List<String> lstEndPoints, Date date, final String outputFile, final int branchLimit) {
Timer timer = new Timer();
timer.schedule(new TimerTask() {public void run() { try {
TBSSSummariesGenerator generator = new TBSSSummariesGenerator(outputFile);
long startTime = System.currentTimeMillis();
generator.generateSummaries(lstEndPoints,null, branchLimit);
System.out.println("Index is secessfully updated to "+ outputFile);
System.out.println("Data Summaries Generation Time (sec): "+ (System.currentTimeMillis()-startTime)/1000);
} catch (IOException | RepositoryException | MalformedQueryException | QueryEvaluationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }, date);
}
示例8: evaluateExclusiveGroup
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> evaluateExclusiveGroup(
ExclusiveGroup group, RepositoryConnection conn,
TripleSource tripleSource, BindingSet bindings)
{
Boolean isEvaluated = false;
try {
String preparedQuery = QueryStringUtil.selectQueryString(group, bindings, group.getFilterExpr(), isEvaluated);
// in order to avoid licking http route while iteration
return new BufferedCloseableIterator<BindingSet, QueryEvaluationException>(
tripleSource.getStatements(preparedQuery, conn, bindings, (isEvaluated ? null : group.getFilterExpr()))
);
} catch (IllegalQueryException e) {
/* no projection vars, e.g. local vars only, can occur in joins */
if (tripleSource.hasStatements(group, conn, bindings))
return new SingleBindingSetIteration(bindings);
return new EmptyIteration<BindingSet, QueryEvaluationException>();
}
}
示例9: evaluateBinaryTupleOperator
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
/**
* Evaluate {@link BinaryTupleOperator} query model nodes
* @param parent
* @param expr
* @param bindings
*/
private void evaluateBinaryTupleOperator(BindingSetPipe parent, BinaryTupleOperator expr, BindingSet bindings) {
if (expr instanceof Join) {
evaluateJoin(parent, (Join) expr, bindings);
} else if (expr instanceof LeftJoin) {
evaluateLeftJoin(parent, (LeftJoin) expr, bindings);
} else if (expr instanceof Union) {
evaluateUnion(parent, (Union) expr, bindings);
} else if (expr instanceof Intersection) {
evaluateIntersection(parent, (Intersection) expr, bindings);
} else if (expr instanceof Difference) {
evaluateDifference(parent, (Difference) expr, bindings);
} else if (expr == null) {
parent.handleException(new IllegalArgumentException("expr must not be null"));
} else {
parent.handleException(new QueryEvaluationException("Unsupported binary tuple operator type: " + expr.getClass()));
}
}
示例10: ask
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Override
public boolean ask(Service service, BindingSet bindings, String baseUri) throws QueryEvaluationException {
RepositoryConnection conn = endpoint.getConn();
try {
BooleanQuery query = conn.prepareBooleanQuery(QueryLanguage.SPARQL, service.getAskQueryString(), 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());
}
return query.evaluate();
} catch(Throwable e) {
throw new QueryEvaluationException(e);
} finally {
conn.close();
}
}
示例11: call
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> call() throws Exception {
try {
TripleSource t = endpoint.getTripleSource();
RepositoryConnection conn = endpoint.getConn();
boolean hasResults = t.hasStatements(stmt, conn, EmptyBindingSet.getInstance());
CacheEntry entry = CacheUtils.createCacheEntry(endpoint, hasResults);
sourceSelection.cache.updateEntry( new SubQuery(stmt), entry);
if (hasResults)
sourceSelection.addSource(stmt, new StatementSource(endpoint.getId(), StatementSourceType.REMOTE));
return null;
} catch (Exception e) {
throw new OptimizationException("Error checking results for endpoint " + endpoint.getId() + ": " + e.getMessage(), e);
}
}
示例12: evaluateTupleExpr
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
/**
* Switch logic appropriate for each type of {@link TupleExpr} query model node, sending each type to it's appropriate evaluation method. For example,
* {@code UnaryTupleOperator} is sent to {@link evaluateUnaryTupleOperator()}.
* @param parent
* @param expr
* @param bindings
*/
private void evaluateTupleExpr(BindingSetPipe parent, TupleExpr expr, BindingSet bindings) {
if (expr instanceof StatementPattern) {
statementEvaluation.evaluateStatementPattern(parent, (StatementPattern) expr, bindings);
} else if (expr instanceof UnaryTupleOperator) {
evaluateUnaryTupleOperator(parent, (UnaryTupleOperator) expr, bindings);
} else if (expr instanceof BinaryTupleOperator) {
evaluateBinaryTupleOperator(parent, (BinaryTupleOperator) expr, bindings);
} else if (expr instanceof SingletonSet) {
evaluateSingletonSet(parent, (SingletonSet) expr, bindings);
} else if (expr instanceof EmptySet) {
evaluateEmptySet(parent, (EmptySet) expr, bindings);
} else if (expr instanceof ExternalSet) {
evaluateExternalSet(parent, (ExternalSet) expr, bindings);
} else if (expr instanceof ZeroLengthPath) {
evaluateZeroLengthPath(parent, (ZeroLengthPath) expr, bindings);
} else if (expr instanceof ArbitraryLengthPath) {
evaluateArbitraryLengthPath(parent, (ArbitraryLengthPath) expr, bindings);
} else if (expr instanceof BindingSetAssignment) {
evaluateBindingSetAssignment(parent, (BindingSetAssignment) expr, bindings);
} else if (expr == null) {
parent.handleException(new IllegalArgumentException("expr must not be null"));
} else {
parent.handleException(new QueryEvaluationException("Unsupported tuple expr type: " + expr.getClass()));
}
}
示例13: call
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Override
public CloseableIteration<BindingSet, QueryEvaluationException> call() {
try {
TripleSource t = endpoint.getTripleSource();
RepositoryConnection conn = endpoint.getConn();
boolean hasResults = t.hasStatements(stmt, conn, EmptyBindingSet.getInstance());
DefaultSourceSelection sourceSelection = control.sourceSelection;
CacheEntry entry = CacheUtils.createCacheEntry(endpoint, hasResults);
sourceSelection.cache.updateEntry( new SubQuery(stmt), entry);
if (hasResults)
sourceSelection.addSource(stmt, new StatementSource(endpoint.getId(), StatementSourceType.REMOTE));
return null;
} catch (Exception e) {
this.control.toss(e);
throw new OptimizationException("Error checking results for endpoint " + endpoint.getId() + ": " + e.getMessage(), e);
}
}
示例14: getService
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
@Override
public FederatedService getService(String serviceUrl) throws QueryEvaluationException {
//provide a service to query over Halyard graphs. Remote service queries are not supported.
if (serviceUrl.startsWith(HALYARD.NAMESPACE)) {
String federatedTable = serviceUrl.substring(HALYARD.NAMESPACE.length());
RepositoryFederatedService s = federatedServices.get(federatedTable);
if (s == null) {
s = new RepositoryFederatedService(new SailRepository(new HBaseSail(config, federatedTable, false, 0, true, evaluationTimeout, null, ticker)));
federatedServices.put(federatedTable, s);
s.initialize();
}
return s;
} else {
throw new QueryEvaluationException("Unsupported service URL: " + serviceUrl);
}
}
示例15: main
import org.eclipse.rdf4j.query.QueryEvaluationException; //导入依赖的package包/类
public static void main(String[] args) throws IOException, RepositoryException, MalformedQueryException, QueryEvaluationException {
List<String> endpoints = (Arrays.asList(
"http://localhost:8890/sparql",
"http://localhost:8891/sparql",
"http://localhost:8892/sparql"
// "http://localhost:8893/sparql",
// "http://localhost:8894/sparql",
// "http://localhost:8895/sparql",
// "http://localhost:8896/sparql",
// "http://localhost:8897/sparql",
// "http://localhost:8898/sparql",
// "http://localhost:8899/sparql"
));
String outputFile = "D:/workspace/HiBISCus/summaries/OntoSum-UOBM-10-owlim.n3";
String namedGraph = "http://aksw.org/ontosum"; //can be null. in that case all graph will be considered
HibiscusSummariesGenerator generator = new HibiscusSummariesGenerator(outputFile);
long startTime = System.currentTimeMillis();
generator.generateSummaries(endpoints,namedGraph);
System.out.println("Data Summaries Generation Time (sec): "+ (System.currentTimeMillis()-startTime)/1000);
System.out.print("Data Summaries are secessfully stored at "+ outputFile);
}