本文整理了Java中fr.inria.corese.kgram.core.Query.getProperAndSubSelectNode
方法的一些代码示例,展示了Query.getProperAndSubSelectNode
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.getProperAndSubSelectNode
方法的具体详情如下:
包路径:fr.inria.corese.kgram.core.Query
类名称:Query
方法名:getProperAndSubSelectNode
[英]get node with going in select sub query go into its own select because order by may reuse a select variable use case: transformer find node for select & group by
[中]进入选择子查询获取节点进入其自己的选择,因为order by可能会重用选择变量用例:transformer find node for select&group by
代码示例来源:origin: fr.inria.corese/kgram
/**
* Used by aggregate, stack is empty, search in query go also into subquery
* select because outer query may reference an inner variable in an outer
* aggregate use case: select count(?x) as ?count where { {select ?x where
* {...}} }
*/
@Override
public Node getQueryNode(String name) {
Node node = query.getProperAndSubSelectNode(name);
return node;
}
代码示例来源:origin: fr.inria.corese/compiler
Node getProperAndSubSelectNode(Query q, String name) {
Node node;
if (Query.test) {
node = q.getSelectNodes(name);
} else {
node = q.getProperAndSubSelectNode(name);
}
return node;
}
代码示例来源:origin: Wimmics/corese
Node getProperAndSubSelectNode(Query q, String name) {
Node node;
if (Query.test) {
node = q.getSelectNodes(name);
} else {
node = q.getProperAndSubSelectNode(name);
}
return node;
}
代码示例来源:origin: fr.inria.corese/kgram
public List<Node> getNodes(Filter f) {
List<String> lVar = f.getVariables();
ArrayList<Node> lNode = new ArrayList<Node>();
for (String var : lVar) {
Node node = getProperAndSubSelectNode(var);
if (node != null && !lNode.contains(node)) {
lNode.add(node);
}
}
return lNode;
}
代码示例来源:origin: fr.inria.corese/kgram
void getAggNodes(Expr exp, ArrayList<Node> lNode) {
if (exp.type() == ExprType.VARIABLE) {
Node node = getProperAndSubSelectNode(exp.getLabel());
if (node != null && !lNode.contains(node)) {
lNode.add(node);
}
} else {
for (Expr ee : exp.getExpList()) {
getAggNodes(ee, lNode);
}
}
}
代码示例来源:origin: fr.inria.corese/kgram
/**
* TODO: remove duplicates in getVariables()
* use case:
* function us:fun(?x){let (select ?x where {}) {}}
* variable ?x appears twice in the stack because it is redefined in the let clause
*/
public Mapping getMapping(Query q) {
ArrayList<Node> lvar = new ArrayList();
ArrayList<Node> lval = new ArrayList();
for (Expr var : getVariables()) {
Node node = q.getProperAndSubSelectNode(var.getLabel());
if (node != null && ! lvar.contains(node)) {
lvar.add(node);
lval.add(get(var));
}
}
Mapping m = Mapping.create(lvar, lval);
return m;
}
代码示例来源:origin: fr.inria.corese/kgram
/**
* TODO: remove duplicates in getVariables()
* use case:
* function us:fun(?x){let (select ?x where {}) {}}
* variable ?x appears twice in the stack because it is redefined in the let clause
*/
public static Mapping create(Query q, Binder b) {
ArrayList<Node> lvar = new ArrayList();
ArrayList<Node> lval = new ArrayList();
for (Expr var : b.getVariables()) {
Node node = q.getProperAndSubSelectNode(var.getLabel());
if (node != null && !lvar.contains(node)) {
lvar.add(node);
lval.add(b.get(var));
}
}
Mapping m = Mapping.create(lvar, lval);
return m;
}
代码示例来源:origin: fr.inria.corese/kgram
Exp buildCst(Exp exp, int type){
Filter ff = exp.getFilter();
Expr ee = ff.getExp();
Node node = query.getProperAndSubSelectNode(ff.getVariables().get(0));
if (node != null){
// variable ?x
Exp bind = Exp.create(type, Exp.create(Exp.NODE, node));
List<Expr> list = new ArrayList<Expr>();
list.add(getConstants(ee).get(0));
bind.setObject(list);
return bind;
}
return null;
}
代码示例来源:origin: fr.inria.corese/kgram
/**
* ! bound(?x)
*/
void not(Exp exp){
Filter ff = exp.getFilter();
Expr ee = ff.getExp();
Pattern pat = new Pattern(BOOLEAN, NOT, new Pattern(FUNCTION, BOUND, VARIABLE));
if (matcher.match(pat, ee)){
// ! bound(?x)
List<String> list = ff.getVariables();
if (list.size()>0){
Node node = query.getProperAndSubSelectNode(list.get(0));
if (node != null){
exp.setNode(node);
exp.status(true);
}
}
}
}
代码示例来源:origin: fr.inria.corese/kgram
/**
* Generate or retrieve index of node If node is in a sub query, return the
* index of the outer node corresponding to node and rec.
*/
int qIndex(Query query, Node node) {
int n = index(node);
if (query != this && query.inSelect(node)) {
// get the outer node for this sub select sNode
Node oNode = query.getOuterQuery().getProperAndSubSelectNode(node.getLabel());
if (oNode != null) {
n = qIndex(query.getOuterQuery(), oNode);
}
}
return n;
}
代码示例来源:origin: fr.inria.corese/kgram
void in(Exp exp) {
Filter ff = exp.getFilter();
Expr expr = ff.getExp();
List<String> lvar = ff.getVariables();
Expr var = expr.getExp(0);
if (! var.isVariable()){
return;
}
List<Expr> values = expr.getExp(1).getExpList();
List<Expr> list = new ArrayList<Expr>();
//all has to be constants
for (Expr e : values) {
if (e.type() != CONSTANT) {
return;
}
list.add(e);
}
Node node = query.getProperAndSubSelectNode(lvar.get(0));
if (node != null) {
Exp bind = Exp.create(Exp.OPT_BIND, Exp.create(Exp.NODE, node));
bind.setObject(list);
exp.add(bind);
}
}
代码示例来源:origin: fr.inria.corese/kgram
/**
* ?x = cst1 || ?x = cst2
*/
void or(Exp exp){
Filter ff = exp.getFilter();
Expr ee = ff.getExp();
Pattern pat = new Pattern(BOOLEAN, OR, new Pattern(TERM, EQ, VARIABLE, CONSTANT));
pat.setRec(true);
pat.setMatchConstant(false);
if (matcher.match(pat, ee)) {
Node node = query.getProperAndSubSelectNode(ff.getVariables().get(0));
if (node != null){
List<Expr> list = getConstants(ee);
Exp bind = Exp.create(Exp.OPT_BIND, Exp.create(Exp.NODE, node));
bind.setObject(list);
exp.add(bind);
}
}
}
代码示例来源:origin: fr.inria.corese/kgram
Node qNode = query.getProperAndSubSelectNode(var);
if (qNode != null) {
n = qIndex(query, qNode);
内容来源于网络,如有侵权,请联系作者删除!