/** * Compile AST statements into KGRAM statements Compile triple into Edge, * filter into Filter */ Exp compile(fr.inria.corese.sparql.triple.parser.Exp query, boolean opt) { return compile(query, opt, 0); }
/** * filter(exist {PAT}) */ void compileExist(Expr exp, boolean opt) { if (exp.oper() == ExprType.EXIST) { Term term = (Term) exp; Exp pat = compile(term.getExist(), opt); term.setPattern(pat); } //else { for (Expr ee : exp.getExpList()) { compileExist(ee, opt); } } }
/** * For query and subquery Generate a new compiler for each (sub) query in * order to get fresh new nodes */ Query compile(ASTQuery ast) { Exp ee = compile(ast.getExtBody(), false); Query q = Query.create(ee); q.setUseBind(isUseBind); compileFunction(q, ast); q.setAST(ast); q.setHasFunctional(ast.hasFunctional()); q.setService(ast.getService()); // use same compiler values(q, ast); path(q, ast); return q; }
/** * Compile AST statements into KGRAM statements Compile triple into Edge, * filter into Filter */ Exp compile(fr.inria.corese.sparql.triple.parser.Exp query, boolean opt) { return compile(query, opt, 0); }
/** * filter(exist {PAT}) */ void compileExist(Expr exp, boolean opt) { if (exp.oper() == ExprType.EXIST) { Term term = (Term) exp; Exp pat = compile(term.getExist(), opt); term.setPattern(pat); } //else { for (Expr ee : exp.getExpList()) { compileExist(ee, opt); } } }
/** * For query and subquery Generate a new compiler for each (sub) query in * order to get fresh new nodes */ Query compile(ASTQuery ast) { Exp ee = compile(ast.getExtBody(), false); Query q = Query.create(ee); q.setUseBind(isUseBind); compileFunction(q, ast); q.setAST(ast); q.setHasFunctional(ast.hasFunctional()); q.setService(ast.getService()); // use same compiler values(q, ast); path(q, ast); return q; }
Exp construct(ASTQuery ast) { return compile(ast, ast.getInsert()); }
Exp delete(ASTQuery ast) { return compile(ast, ast.getDelete()); }
Exp delete(ASTQuery ast) { return compile(ast, ast.getDelete()); }
Exp construct(ASTQuery ast) { return compile(ast, ast.getInsert()); }
/** * Delete/Insert/Construct */ Exp compile(ASTQuery ast, fr.inria.corese.sparql.triple.parser.Exp exp) { Compiler save = compiler; compiler = fac.newInstance(); compiler.setAST(ast); Exp ee = compile(exp, false); if (save != null) { compiler = save; } return ee; }
/** * Delete/Insert/Construct */ Exp compile(ASTQuery ast, fr.inria.corese.sparql.triple.parser.Exp exp) { Compiler save = compiler; compiler = fac.newInstance(); compiler.setAST(ast); Exp ee = compile(exp, false); if (save != null) { compiler = save; } return ee; }
Exp compileGraph(Exp exp, Atom at) { Node src = compile(at); // create a NODE kgram expression for graph ?g Exp node = Exp.create(NODE, src); Exp gnode = Exp.create(GRAPHNODE, node); exp.add(0, gnode); return exp; }
Exp compileGraph(Exp exp, Atom at) { Node src = compile(at); // create a NODE kgram expression for graph ?g Exp node = Exp.create(NODE, src); Exp gnode = Exp.create(GRAPHNODE, node); exp.add(0, gnode); return exp; }
void path(Query q, ASTQuery ast) { if (ast.getRegexTest().size() > 0) { Node node = compiler.createNode(Variable.create(THIS)); q.setPathNode(node); } for (Expression test : ast.getRegexTest()) { // ?x c:isMemberOf[?this != <inria>] + ?y Filter f = compile(test); q.addPathFilter(f); } }
void path(Query q, ASTQuery ast) { if (ast.getRegexTest().size() > 0) { Node node = compiler.createNode(Variable.create(THIS)); q.setPathNode(node); } for (Expression test : ast.getRegexTest()) { // ?x c:isMemberOf[?this != <inria>] + ?y Filter f = compile(test); q.addPathFilter(f); } }
void construct(Query q, ASTQuery ast) { validate(ast.getInsert(), ast); Exp cons = compile(ast.getInsert(), false); q.setConstruct(cons); q.setConstruct(true); q.setConstructNodes(cons.getNodes()); }
void construct(Query q, ASTQuery ast) { validate(ast.getInsert(), ast); Exp cons = compile(ast.getInsert(), false); q.setConstruct(cons); q.setConstruct(true); q.setConstructNodes(cons.getNodes()); }
/** * subquery is compiled using a new compiler to get fresh new nodes to * prevent type inference on nodes between outer and sub queries */ Query compileQuery(ASTQuery ast) { // new Compiler save = compiler; compiler = fac.newInstance(); compiler.setAST(ast); Query q = compile(ast); subQueryList.add(q); // complete select, order by, group by complete(q, ast); having(q, ast); // bind is compiled as subquery q.setBind(ast.isBind()); q.setRelax(ast.isMore()); new QueryProfile(q).profile(); if (save != null) { compiler = save; } return q; }
/** * subquery is compiled using a new compiler to get fresh new nodes to * prevent type inference on nodes between outer and sub queries */ Query compileQuery(ASTQuery ast) { // new Compiler save = compiler; compiler = fac.newInstance(); compiler.setAST(ast); Query q = compile(ast); subQueryList.add(q); // complete select, order by, group by complete(q, ast); having(q, ast); // bind is compiled as subquery q.setBind(ast.isBind()); q.setRelax(ast.isMore()); new QueryProfile(q).profile(); if (save != null) { compiler = save; } return q; }