fr.inria.corese.kgram.core.Query类的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(215)

本文整理了Java中fr.inria.corese.kgram.core.Query类的一些代码示例,展示了Query类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query类的具体详情如下:
包路径:fr.inria.corese.kgram.core.Query
类名称:Query

Query介绍

[英]KGRAM Query also used for subquery
[中]KGRAM查询也用于子查询

代码示例

代码示例来源:origin: fr.inria.corese/kgram

  1. Query complete(Query q1, Query q2) {
  2. q1.setOuterQuery(this);
  3. q2.setOuterQuery(this);
  4. setGlobalQuery(getBody());
  5. setSelect(q1, q2);
  6. collect();
  7. setAST(q2.getAST());
  8. return this;
  9. }

代码示例来源:origin: fr.inria.corese/compiler

  1. void count(Query q){
  2. if (q.getSelectFun().size() == 1
  3. && q.getGroupBy().isEmpty()
  4. && q.getLimit() == Integer.MAX_VALUE
  5. && ! q.isTemplate()){
  6. Exp exp = q.getSelectFun().get(0);
  7. Filter f = exp.getFilter();
  8. if (f != null
  9. && f.getExp().oper() == ExprType.COUNT
  10. && ! f.getExp().isDistinct()
  11. && f.getExp().getExpList().isEmpty()){
  12. q.setQueryProfile(Query.COUNT_PROFILE);
  13. }
  14. }
  15. }

代码示例来源:origin: fr.inria.corese/kgram

  1. public boolean isSelect(){
  2. return ! (isConstruct() || isUpdate() || isDelete());
  3. }

代码示例来源:origin: fr.inria.corese/kgram

  1. public int getLimitOffset() {
  2. // when order by/group by/count(), return all results, group sort agg, and then apply offset/limit
  3. if (!isConstruct()
  4. && (isOrderBy() || hasGroupBy() || isAggregate())) {
  5. return Integer.MAX_VALUE;
  6. }
  7. if (limit < Integer.MAX_VALUE - offset) {
  8. return limit + offset;
  9. } else {
  10. return limit;
  11. }
  12. }

代码示例来源:origin: fr.inria.corese/compiler

  1. Query create(Exp exp) {
  2. Query q = Query.create(exp);
  3. if (sort != null) {
  4. q.set(sort);
  5. }
  6. return q;
  7. }

代码示例来源:origin: fr.inria.corese/compiler

  1. query.setTest(value(object));
  2. query.setOptimize(value(object));
  3. query.setDebug(value(object));
  4. query.setSort(value(object));
  5. query.setListGroup(value(object));
  6. query.setDetail(value(object));
  7. if (property.equals(MODE)){
  8. int mode = getMode(object);
  9. query.setMode(mode);
  10. query.setListPath(value(object));
  11. query.setPathType(value(object));
  12. query.setStorePath(value(object));
  13. query.setCachePath(value(object));
  14. query.setCountPath(value(object));
  15. query.setCheckLoop(! value(object));
  16. query.addInfo("AST:\n", ast);

代码示例来源:origin: fr.inria.corese/kgram

  1. for (int i = 0; i < exp.nbNode(); i++) {
  2. Node node = exp.getNode(i);
  3. n = qIndex(query, node);
  4. min = Math.min(min, n);
  5. for (int i = 0; i < ep.nbNode(); i++) {
  6. Node node = ep.getNode(i);
  7. n = qIndex(query, node);
  8. min = Math.min(min, n);
  9. n = qIndex(query, node);
  10. min = Math.min(min, n);
  11. min = qIndex(query, node);
  12. break;
  13. min = qIndex(query, qn);
  14. if (exp.getNodeList() != null){
  15. for (Node bn : exp.getNodeList()){
  16. int ii = qIndex(query, bn);
  17. min = Math.min(min, ii);
  18. boolean hasExist = index(query, exp.getFilter());
  19. Node qNode = query.getProperAndSubSelectNode(var);
  20. if (qNode != null) {
  21. n = qIndex(query, qNode);
  22. min = Math.min(min, n);
  23. } else if (!isExist && !hasExist) {

代码示例来源:origin: fr.inria.corese/corese-core

  1. Query gq = q.getGlobalQuery();
  2. try {
  3. if (gq.isDebug()) {logger.info("Skip slice for absence of relevant binding");}
  4. return Mappings.create(q);
  5. if (gq.isDebug()) {
  6. logger.info("** Provider query: \n" + q.getAST());
  7. if (gq.isDebug()) {
  8. if (res.size() <= 100 || gq.isDetail()) {
  9. logger.info("** Provider result: \n" + res.toString(true));
  10. logger.error(q.getAST().toString(), e);
  11. gq.addError(SERVICE_ERROR, e);
  12. } catch (ParserConfigurationException e) {
  13. if (gq.isDebug()) {
  14. logger.info("** Provider error");

代码示例来源:origin: Wimmics/corese

  1. ASTQuery ast = (ASTQuery) q.getAST();
  2. boolean oneValue = !map.getQuery().isListGroup();
  3. resultXML = toString(map);
  4. textAreaXMLResult.setText(resultXML.toString());
  5. if (q.isTemplate() || ast.isAsk() || ast.getErrors() != null){
  6. tabbedPaneResults.setSelectedIndex(XML_PANEL);
  7. } else{
  8. if (q.isConstruct()) {
  9. displayGraph((Graph) map.getGraph(), ast.getNSM());
  10. else if (map.getQuery().isTemplate() && map.getQuery().isPragma(KGGRAPH)) {
  11. display(map, ast.getNSM());

代码示例来源:origin: Wimmics/corese

  1. /**
  2. * Compile Graph into a BGP Generate a Query
  3. */
  4. public Query getQuery() {
  5. Transformer t = Transformer.create();
  6. ASTQuery ast = ASTQuery.create();
  7. ast.setSelectAll(true);
  8. ast.setBody(BasicGraphPattern.create());
  9. ast = visitor.visit(ast);
  10. graph = visitor.visit(graph);
  11. Exp exp = getExp(graph);
  12. Query q = Query.create(exp);
  13. q.setAST(ast);
  14. q = t.transform(q, ast);
  15. q.setDebug(isDebug);
  16. q = visitor.visit(q);
  17. if (isConstruct()) {
  18. // TODO: blanks in construct should be renamed
  19. q.setConstruct(q.getBody());
  20. q.setConstruct(true);
  21. }
  22. return q;
  23. }

代码示例来源:origin: fr.inria.corese/compiler

  1. Exp pat = q.getPattern(exp);
  2. Node gNode = env.getGraphNode();
  3. Memory memory = null;
  4. qq.setFun(true);
  5. if (qq.isConstruct() || qq.isUpdate()) {
  6. if (qq.getService() != null) {

代码示例来源:origin: fr.inria.corese/compiler

  1. void debug(Query query){
  2. if (query.isDebug()){
  3. logger.debug(query.getBody().toString());
  4. logger.debug("limit " + query.getLimit());
  5. if (query.isFail()){
  6. logger.debug("Fail at compile time");
  7. }
  8. }
  9. }

代码示例来源:origin: Wimmics/corese

  1. String mapToString(){
  2. Query q = map.getQuery();
  3. if (q == null) {
  4. return "";
  5. }
  6. ASTQuery ast = (ASTQuery) q.getAST();
  7. if (q.isTemplate()
  8. || (q.hasPragma(Pragma.TEMPLATE) && map.getGraph() != null)) {
  9. return TemplateFormat.create(map).toString();
  10. } else {
  11. if (type == UNDEF_FORMAT) {
  12. if (q.isConstruct()) {
  13. type = getConstructFormat();
  14. }
  15. else {
  16. type = getSelectFormat();
  17. }
  18. }
  19. return process(map, type);
  20. }
  21. }

代码示例来源:origin: Wimmics/corese

  1. void query(Query q, Mappings m){
  2. ASTQuery ast = (ASTQuery) q.getAST();
  3. trace("Query: " + query.size() + " " + ast.getText());
  4. if (isQuery){
  5. query.add(ast.getText());
  6. }
  7. }

代码示例来源:origin: fr.inria.corese/compiler

  1. /**
  2. * For query and subquery Generate a new compiler for each (sub) query in
  3. * order to get fresh new nodes
  4. */
  5. Query compile(ASTQuery ast) {
  6. Exp ee = compile(ast.getExtBody(), false);
  7. Query q = Query.create(ee);
  8. q.setUseBind(isUseBind);
  9. compileFunction(q, ast);
  10. q.setAST(ast);
  11. q.setHasFunctional(ast.hasFunctional());
  12. q.setService(ast.getService());
  13. // use same compiler
  14. values(q, ast);
  15. path(q, ast);
  16. return q;
  17. }

代码示例来源:origin: Wimmics/corese

  1. m = createMapping(m, ds);
  2. pragma(q);
  3. if (q.getService() != null) {
  4. if (q.isUpdate() || q.isRule()) {
  5. log(Log.UPDATE, q);
  6. map = synUpdate(q, m, ds);
  7. map = synQuery(q, m);
  8. if (q.isConstruct()) {

代码示例来源:origin: fr.inria.corese/compiler

  1. void bindings(Query q, ASTQuery ast) {
  2. Exp bind = bindings(ast.getValues());
  3. if (bind == null) {
  4. q.setCorrect(false);
  5. q.addError("Value Bindings: ", "#values != #variables");
  6. } else {
  7. q.setValues(bind);
  8. if (ast.getValues().isMoved()) {
  9. //q.setTemplateMappings(bind.getMappings());
  10. q.getValues().setPostpone(true);
  11. }
  12. // else {
  13. // q.setMappings(bind.getMappings());
  14. // q.setBindingNodes(bind.getNodeList());
  15. // }
  16. }
  17. }

代码示例来源:origin: fr.inria.corese/corese-core

  1. else if (map.getQuery().isTemplate()){
  2. return process(map, g, getTransformation(constructTransform));
  3. else if (map.getQuery().isUpdate() && graph != null){
  4. return process(map, graph, getTransformation(constructTransform));

代码示例来源:origin: fr.inria.corese/kgram

  1. /**
  2. * Select Query is empty and does nothing
  3. */
  4. boolean isEmpty(){
  5. return isSelect()
  6. && getSelectFun().isEmpty()
  7. && getBody().size() == 0
  8. && getValues().getMappings() == null;
  9. }

代码示例来源:origin: Wimmics/corese

  1. public void defQuery(Query q) {
  2. if (q.isTemplate()) {
  3. defTemplate(q);
  4. } else {
  5. list.add(q);
  6. }
  7. }

相关文章