本文整理了Java中org.apache.jena.query.Query.cloneQuery
方法的一些代码示例,展示了Query.cloneQuery
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.cloneQuery
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:cloneQuery
[英]Makes a copy of this query. Copies by parsing a query from the serialized form of this query
[中]复制此查询。通过分析此查询的序列化形式中的查询进行复制
代码示例来源:origin: apache/jena
/**
* Make a query from another one by deep copy (a clone).
* The returned query will be .equals to the original.
* The returned query can be mutated without changing the
* original (at which point it will stop being .equals)
*
* @param originalQuery The query to clone.
*
*/
static public Query create(Query originalQuery)
{
return originalQuery.cloneQuery() ;
}
代码示例来源:origin: apache/jena
@Override
public Object clone() { return cloneQuery() ; }
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns a pruned copy of the given query.
* @param query the query
* @return a pruned copy of the given query
*/
public Query pruneQuery(Query query) {
Query copy = query.cloneQuery();
copy.getQueryPattern().visit(this);
return copy;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public QueryExecution createQueryExecution(Query query) {
query = query.cloneQuery();
PaginationQueryIterator queryIterator = new PaginationQueryIterator(query, pageSize);
return new QueryExecutionIterated(query, decoratee, queryIterator);
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public Query apply(Query query) {
Query result = doClone ? query.cloneQuery() : query;
result.getPrefixMapping().setNsPrefixes(prefixMapping);
return result;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public QueryExecution createQueryExecution(Query query) {
Query clone = query.cloneQuery();
QueryUtils.applyDatasetDescription(clone, datasetDescription);
QueryExecution result = super.createQueryExecution(clone);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public Model fetch(String graphName) {
Query tmp = QUERY_CONSTRUCT_SPO.cloneQuery();
tmp.addGraphURI(graphName);
Model result = queryConn.queryConstruct(tmp);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query transform(Query query, Map<Node, BinaryRelation> virtualPredicates, boolean cloneOnChange) {
Element oldQueryPattern = query.getQueryPattern();
Element newQueryPattern = transform(oldQueryPattern, virtualPredicates);
Query result;
if(oldQueryPattern == newQueryPattern) {
result = query;
} else {
result = cloneOnChange ? query.cloneQuery() : query;
result.setQueryPattern(newQueryPattern);
}
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public QueryExecution createQueryExecution(Query query) {
Query q = doClone ? query.cloneQuery() : query;
q.getPrefixMapping().setNsPrefixes(prefixMapping);
QueryExecution result = super.createQueryExecution(q);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query fixVarNames(Query query) {
Query result = query.cloneQuery();
Element element = query.getQueryPattern();
Element repl = ElementUtils.fixVarNames(element);
result.setQueryPattern(repl);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public QueryExecution createQueryExecution(Query query) {
if(limit != null) {
if(query.getLimit() == Query.NOLIMIT) {
if(doCloneQuery) {
query = query.cloneQuery();
}
query.setLimit(limit);
} else {
long adjustedLimit = Math.min(limit, query.getLimit());
if(adjustedLimit != query.getLimit()) {
if(doCloneQuery) {
query = query.cloneQuery();
}
query.setLimit(adjustedLimit);
}
}
}
return super.createQueryExecution(query);
}
代码示例来源:origin: org.aksw.jena-sparql-api/jena-sparql-api-cache
@Override
public Flowable<Binding> apply(Range<Long> range) {
Query clone = query.cloneQuery();
QueryUtils.applyRange(clone, range);
Flowable<Binding> result = ReactiveSparqlUtils.execSelect(() -> qef.createQueryExecution(clone));
// QueryExecution qe = qef.createQueryExecution(clone);
// ResultSet rs = qe.execSelect();
//
//
// Iterator<Binding> it = new IteratorResultSetBinding(rs);
// Stream<Binding> result = Streams.stream(it);
// result.onClose(qe::close);
return result;
//
// ClosableIterator<Binding> result = new IteratorClosable<>(it, () -> qe.close());
// return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public Flowable<Binding> apply(Range<Long> range) {
Query clone = query.cloneQuery();
QueryUtils.applyRange(clone, range);
Flowable<Binding> result = ReactiveSparqlUtils.execSelect(() -> qef.createQueryExecution(clone));
// QueryExecution qe = qef.createQueryExecution(clone);
// ResultSet rs = qe.execSelect();
//
//
// Iterator<Binding> it = new IteratorResultSetBinding(rs);
// Stream<Binding> result = Streams.stream(it);
// result.onClose(qe::close);
return result;
//
// ClosableIterator<Binding> result = new IteratorClosable<>(it, () -> qe.close());
// return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query rewrite(Query query) {
DatasetDescription dd = query.getDatasetDescription();
Query result;
if(dd != null) {
result = query.cloneQuery();
Element before = result.getQueryPattern();
Element after = rewrite(before, dd);
result.setQueryPattern(after);
} else {
result = query;
}
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
private Iterator<Triple> executeConstructStreaming(Query query) {
if (!query.isConstructType()) {
throw new RuntimeException("CONSTRUCT query expected. Got: ["
+ query.toString() + "]");
}
Query clone = query.cloneQuery();
clone.setQuerySelectType();
//Query selectQuery = QueryUtils.elementToQuery(query.getQueryPattern());
clone.setQueryResultStar(true);
ResultSetCloseable rs = executeCoreSelect(clone);
System.out.println("Executing query as: " + clone);
// insertPrefixesInto(result) ;
Template template = query.getConstructTemplate();
Iterator<Triple> result = new ConstructIterator(template, rs);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public Flowable<T> apply(Range<Long> range) {
Query clonedQuery = query.cloneQuery();
range = Range.atLeast(0l).intersection(range);
QueryUtils.applyRange(clonedQuery, range);
Flowable<T> result = obtainResultIterator(() -> qef.createQueryExecution(clonedQuery)); // new IteratorResultSetBinding(qe.execSelect());
// Stream<T> result = Streams.stream(it);
// result.onClose(() -> qe.close());
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns a modified SPARQL query such that it is similar but different by choosing one of the triple patterns and use
* the negation of its existence.
* @param query
*/
public Query generateSPARQLQuery(Query query){
//choose a random triple for the modification
List<Triple> triplePatterns = new ArrayList<>(triplePatternExtractor.extractTriplePattern(query));
Collections.shuffle(triplePatterns, randomGen);
triple = triplePatterns.get(0);
Query modifiedQuery = query.cloneQuery();
modifiedQuery.getQueryPattern().visit(this);
logger.info("Negative examples query:\n" + modifiedQuery.toString());
return modifiedQuery;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
/**
* Returns a modified SPARQL query such that it is similar but different by choosing one of the triple patterns and use
* the negation of its existence.
* @param query the SPARQL query
*/
public Query generateSPARQLQuery(Query query){
//choose a random triple for the modification
List<Triple> triplePatterns = new ArrayList<>(triplePatternExtractor.extractTriplePattern(query));
Collections.shuffle(triplePatterns, randomGen);
triple = triplePatterns.get(0);
Query modifiedQuery = query.cloneQuery();
modifiedQuery.getQueryPattern().visit(this);
logger.info("Negative examples query:\n" + modifiedQuery.toString());
return modifiedQuery;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public PaginationQueryIterator createQueryIterator(Long offset, Long limit) {
long o = offset == null ? 0 : offset;
long l = limit == null ? Long.MAX_VALUE : limit;
long queryOffset = proto.getOffset() == Query.NOLIMIT ? 0 : proto.getOffset();
long itemOffset = queryOffset + o;
long queryLimit = proto.getLimit() == Query.NOLIMIT ? Long.MAX_VALUE : proto.getLimit() - o;
long itemLimit = Math.min(queryLimit, l);
itemLimit = itemLimit == Long.MAX_VALUE ? Query.NOLIMIT : itemLimit;
Query clone = proto.cloneQuery();
clone.setOffset(itemOffset);
clone.setLimit(itemLimit);
PaginationQueryIterator result = new PaginationQueryIterator(clone, pageSize);
return result;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query createQueryCount(Query query, Var outputVar, Long itemLimit, Long rowLimit) {
Query subQuery = query.cloneQuery();
if(rowLimit != null) {
subQuery.setDistinct(false);
subQuery.setLimit(rowLimit);
subQuery = QueryGenerationUtils.wrapAsSubQuery(subQuery);
subQuery.setDistinct(true);
}
if(itemLimit != null) {
subQuery.setLimit(itemLimit);
}
Element esq = new ElementSubQuery(subQuery);
Query result = new Query();
Expr aggCount = result.allocAggregate(new AggCount());
result.setQuerySelectType();
result.getProject().add(outputVar, aggCount);
result.setQueryPattern(esq);
return result;
}
内容来源于网络,如有侵权,请联系作者删除!