本文整理了Java中org.apache.jena.query.Query.setDistinct
方法的一些代码示例,展示了Query.setDistinct
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setDistinct
方法的具体详情如下:
包路径:org.apache.jena.query.Query
类名称:Query
方法名:setDistinct
暂无
代码示例来源:origin: apache/jena
/**
* Set the reduced flag. Set or unset the reduced flag. Will set the reduced
* flag if it was previously set.
*
* @param state
* the state to set the reduced flag to.
*/
public void setReduced(boolean state) {
query.setReduced(state);
if (state) {
query.setDistinct(false);
}
}
代码示例来源:origin: apache/jena
/**
* Set the distinct flag. Set or unset the distinct flag. Will set the
* reduced flag if it was previously set.
*
* @param state
* the state to set the distinct flag to.
*/
public void setDistinct(boolean state) {
query.setDistinct(state);
if (state) {
query.setReduced(false);
}
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Set the distinct flag. Set or unset the distinct flag. Will set the
* reduced flag if it was previously set.
*
* @param state
* the state to set the distinct flag to.
*/
public void setDistinct(boolean state) {
query.setDistinct(state);
if (state) {
query.setReduced(false);
}
}
代码示例来源:origin: org.apache.jena/jena-querybuilder
/**
* Set the reduced flag. Set or unset the reduced flag. Will set the reduced
* flag if it was previously set.
*
* @param state
* the state to set the reduced flag to.
*/
public void setReduced(boolean state) {
query.setReduced(state);
if (state) {
query.setDistinct(false);
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public void visit(OpDistinct opDistinct)
{
query.setDistinct(true) ;
opDistinct.getSubOp().visit(this) ;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
default Query asQuery() {
Element e = getElement();
List<Var> vs = getVars();
Query result = new Query();
result.setQuerySelectType();
result.setQueryPattern(getElement());
result.setDistinct(true);
for(Var v : vs) {
result.getProjectVars().add(v);
}
return result;
}
代码示例来源:origin: com.github.galigator.openllet/openllet-jena
q.setDistinct( true );
代码示例来源:origin: Galigator/openllet
q.setDistinct( true );
代码示例来源:origin: apache/jena
@Override
public void visitSelectResultForm(Query query) {
newQuery.setQuerySelectType();
newQuery.setDistinct(query.isDistinct());
VarExprList x = query.getProject();
for (Var v : x.getVars()) {
Expr expr = x.getExpr(v);
if (expr == null)
newQuery.addResultVar(v);
else
newQuery.addResultVar(v, expr);
}
}
代码示例来源: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;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
@Override
public void visitSelectResultForm(Query query) {
newQuery.setQuerySelectType() ;
newQuery.setDistinct(query.isDistinct()) ;
VarExprList x = query.getProject() ;
for (Var v : x.getVars()) {
Expr expr = x.getExpr(v) ;
if ( expr == null )
newQuery.addResultVar(v) ;
else
newQuery.addResultVar(v, expr) ;
}
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query createQueryCount(Concept concept, Var outputVar, Long itemLimit, Long rowLimit) {
Query subQuery = createQueryList(concept);
if(rowLimit != null) {
subQuery.setDistinct(false);
subQuery.setLimit(rowLimit);
subQuery = QueryGenerationUtils.wrapAsSubQuery(subQuery, concept.getVar());
subQuery.setDistinct(true);
}
if(itemLimit != null) {
subQuery.setLimit(itemLimit);
}
Element esq = new ElementSubQuery(subQuery);
Query result = new Query();
result.setQuerySelectType();
result.getProject().add(outputVar, new ExprAggregator(null, new AggCount()));//new ExprAggregator(concept.getVar(), new AggCount()));
result.setQueryPattern(esq);
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
try {
query.setOffset(Query.NOLIMIT);
query.setDistinct(true);
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query createQueryCount(Concept concept, Long itemLimit, Long rowLimit, Var resultVar) {
Query subQuery = concept.asQuery();
if(rowLimit != null) {
subQuery.setDistinct(false);
subQuery.setLimit(rowLimit);
subQuery = createSubQuery(subQuery, concept.getVar());
subQuery.setDistinct(true);
}
if(itemLimit != null) {
subQuery.setLimit(itemLimit);
}
Element esq = new ElementSubQuery(subQuery);
Query result = new Query();
result.setQuerySelectType();
result.getProject().add(resultVar, new ExprAggregator(concept.getVar(), new AggCount()));
result.setQueryPattern(esq);
return result;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query constructBySubjects(Collection<Node> ss) {
ExprVar vs = new ExprVar(s);
Query query = QueryFactory.create();
query.setQueryConstructType();
query.setDistinct(true);
Triple triple = new Triple(s, p, o);
ElementGroup group = new ElementGroup();
group.addTriplePattern(triple);
List<Expr> exprs = new ArrayList<Expr>();
for(Node item : ss) {
if(!item.isURI()) {
continue;
}
exprs.add(new E_Equals(vs, NodeValue.makeNode(item)));
}
if(exprs.isEmpty()) {
return null;
}
Expr or = ExprUtils.orifyBalanced(exprs);
group.addElementFilter(new ElementFilter(or));
BasicPattern bgp = new BasicPattern();
bgp.add(triple);
query.setConstructTemplate(new Template(bgp));
query.setQueryPattern(group);
return query;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query createQueryList(UnaryRelation concept, Long limit, Long offset) {
Query result = new Query();
result.setQuerySelectType();
result.setDistinct(true);
result.setLimit(limit == null ? Query.NOLIMIT : limit);
result.setOffset(offset == null ? Query.NOLIMIT : offset);
result.getProject().add(concept.getVar());
Element e = concept.getElement();
if(e instanceof ElementSubQuery) {
e = ElementUtils.createElementGroup(e);
}
result.setQueryPattern(e);
// String str = result.toString();
// System.out.println(str);
return result;
}
代码示例来源:origin: SmartDataAnalytics/DL-Learner
newQuery.setDistinct(true);
newQuery.setQueryPattern(el);
代码示例来源:origin: SmartDataAnalytics/DL-Learner
newQuery.setQueryPattern(eg);
newQuery.addProjectVars(query.getProjectVars());
newQuery.setDistinct(true);
queries.add(newQuery);
代码示例来源:origin: SmartDataAnalytics/DL-Learner
@Override
public Query toQuery(){
Query query = QueryFactory.make();
query.setQuerySelectType();
query.addResultVar(NodeFactory.createVariable("x0"));
query.setDistinct(true);
query.setPrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
query.setPrefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
query.setPrefix("yago", "http://dbpedia.org/class/yago/");
query.setPrefix("cyc", "http://sw.opencyc.org/2008/06/10/concept/");
query.setPrefix("owl", "http://www.w3.org/2002/07/owl#");
query.setPrefix("dbp", "http://dbpedia.org/property/");
query.setPrefix("dbo", "http://dbpedia.org/ontology/");
query.setPrefix("dbr", "http://dbpedia.org/resource/");
query.setPrefix("dc", "http://purl.org/dc/terms/");
ElementGroup whereClause = new ElementGroup();
ElementTriplesBlock triples = new ElementTriplesBlock();
for(Triple t : buildTriples(this)){
triples.addTriple(t);
}
whereClause.addElement(triples);
query.setQueryPattern(whereClause);
return query;
}
代码示例来源:origin: SmartDataAnalytics/jena-sparql-api
public static Query inOutTemplate(Node s, Node p, Node o)
{
Query query = QueryFactory.create();
query.setQueryConstructType();
query.setDistinct(true);
Triple triple = new Triple(s, p, o);
ElementGroup group = new ElementGroup();
group.addTriplePattern(triple);
// Avoid non-uris as objects
if(o.isVariable()) {
group.addElementFilter(new ElementFilter(new E_IsURI(new ExprVar(o))));
group.addElementFilter(new ElementFilter(new E_LogicalNot(new E_IsBlank(new ExprVar(o)))));
}
BasicPattern bgp = new BasicPattern();
bgp.add(triple);
query.setConstructTemplate(new Template(bgp));
query.setQueryPattern(group);
return query;
}
内容来源于网络,如有侵权,请联系作者删除!