当前位置: 首页>>代码示例>>Java>>正文


Java RexVisitorImpl类代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexVisitorImpl的典型用法代码示例。如果您正苦于以下问题:Java RexVisitorImpl类的具体用法?Java RexVisitorImpl怎么用?Java RexVisitorImpl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RexVisitorImpl类属于org.apache.calcite.rex包,在下文中一共展示了RexVisitorImpl类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rexVisitor

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) {
	return new RexVisitorImpl<Void>(true) {
		@Override
		public Void visitFieldAccess(RexFieldAccess fieldAccess) {
			final RexNode ref = fieldAccess.getReferenceExpr();
			if (ref instanceof RexCorrelVariable) {
				final RexCorrelVariable var = (RexCorrelVariable) ref;
				final Correlation correlation = new Correlation(var.id, fieldAccess.getField().getIndex(), corrIdGenerator++);
				mapFieldAccessToCorVar.put(fieldAccess, correlation);
				mapRefRelToCorVar.put(rel, correlation);
			}
			return super.visitFieldAccess(fieldAccess);
		}

		@Override
		public Void visitSubQuery(RexSubQuery subQuery) {
			subQuery.rel.accept(FlinkRelDecorrelator.CorelMapBuilder.this);
			return super.visitSubQuery(subQuery);
		}
	};
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:FlinkRelDecorrelator.java

示例2: containsGet

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
private static boolean containsGet(RexNode node) {
  try {
    node.accept(
        new RexVisitorImpl<Void>(true) {
          @Override public Void visitCall(RexCall call) {
            if (call.getOperator() == RexBuilder.GET_OPERATOR) {
              throw Util.FoundOne.NULL;
            }
            return super.visitCall(call);
          }
        });
    return false;
  } catch (Util.FoundOne e) {
    return true;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelOptUtil.java

示例3: findItemOrFlatten

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
private RexCall findItemOrFlatten(
    final RexNode node,
    final List<RexNode> projExprs) {
  try {
    RexVisitor<Void> visitor =
        new RexVisitorImpl<Void>(true) {
      public Void visitCall(RexCall call) {
        if ("item".equals(call.getOperator().getName().toLowerCase()) ||
          "flatten".equals(call.getOperator().getName().toLowerCase())) {
          throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this is similar to
                                            other utility methods in RexUtil.java */
        }
        return super.visitCall(call);
      }

      public Void visitInputRef(RexInputRef inputRef) {
        final int index = inputRef.getIndex();
        RexNode n = projExprs.get(index);
        if (n instanceof RexCall) {
          RexCall r = (RexCall) n;
          if ("item".equals(r.getOperator().getName().toLowerCase()) ||
              "flatten".equals(r.getOperator().getName().toLowerCase())) {
            throw new Util.FoundOne(r);
          }
        }

        return super.visitInputRef(inputRef);
      }
    };
    node.accept(visitor);
    return null;
  } catch (Util.FoundOne e) {
    Util.swallow(e, null);
    return (RexCall) e.getNode();
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:37,代码来源:DrillPushFilterPastProjectRule.java

示例4: findItemOrFlatten

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
private RexCall findItemOrFlatten(
    final RexNode node,
    final List<RexNode> projExprs) {
  try {
    RexVisitor<Void> visitor =
        new RexVisitorImpl<Void>(true) {
      @Override
      public Void visitCall(RexCall call) {
        if ("item".equals(call.getOperator().getName().toLowerCase()) ||
          "flatten".equals(call.getOperator().getName().toLowerCase())) {
          throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this is similar to
                                            other utility methods in RexUtil.java */
        }
        return super.visitCall(call);
      }

      @Override
      public Void visitInputRef(RexInputRef inputRef) {
        final int index = inputRef.getIndex();
        RexNode n = projExprs.get(index);
        if (n instanceof RexCall) {
          RexCall r = (RexCall) n;
          if ("item".equals(r.getOperator().getName().toLowerCase()) ||
              "flatten".equals(r.getOperator().getName().toLowerCase())) {
            throw new Util.FoundOne(r);
          }
        }

        return super.visitInputRef(inputRef);
      }
    };
    node.accept(visitor);
    return null;
  } catch (Util.FoundOne e) {
    Util.swallow(e, null);
    return (RexCall) e.getNode();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:39,代码来源:PushFilterPastProjectRule.java

示例5: computeTopologicalOrdering

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
/**
 * Computes the order in which to visit expressions, so that we decide the
 * level of an expression only after the levels of lower expressions have
 * been decided.
 *
 * <p>First, we need to ensure that an expression is visited after all of
 * its inputs.
 *
 * <p>Further, if the expression is a member of a cohort, we need to visit
 * it after the inputs of all other expressions in that cohort. With this
 * condition, expressions in the same cohort will very likely end up in the
 * same level.
 *
 * <p>Note that if there are no cohorts, the expressions from the
 * {@link RexProgram} are already in a suitable order. We perform the
 * topological sort just to ensure that the code path is well-trodden.
 *
 * @param exprs   Expressions
 * @param cohorts List of cohorts, each of which is a set of expr ordinals
 * @return Expression ordinals in topological order
 */
private List<Integer> computeTopologicalOrdering(
    RexNode[] exprs,
    List<Set<Integer>> cohorts) {
  final DirectedGraph<Integer, DefaultEdge> graph =
      DefaultDirectedGraph.create();
  for (int i = 0; i < exprs.length; i++) {
    graph.addVertex(i);
  }
  for (int i = 0; i < exprs.length; i++) {
    final RexNode expr = exprs[i];
    final Set<Integer> cohort = findCohort(cohorts, i);
    final Set<Integer> targets;
    if (cohort == null) {
      targets = Collections.singleton(i);
    } else {
      targets = cohort;
    }
    expr.accept(
        new RexVisitorImpl<Void>(true) {
          public Void visitLocalRef(RexLocalRef localRef) {
            for (Integer target : targets) {
              graph.addEdge(localRef.getIndex(), target);
            }
            return null;
          }
        });
  }
  TopologicalOrderIterator<Integer, DefaultEdge> iter =
      new TopologicalOrderIterator<>(graph);
  final List<Integer> permutation = new ArrayList<>();
  while (iter.hasNext()) {
    permutation.add(iter.next());
  }
  return permutation;
}
 
开发者ID:apache,项目名称:calcite,代码行数:57,代码来源:CalcRelSplitter.java

示例6: rexVisitor

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
private RexVisitorImpl<Void> rexVisitor(final RelNode rel) {
  return new RexVisitorImpl<Void>(true) {
    @Override public Void visitFieldAccess(RexFieldAccess fieldAccess) {
      final RexNode ref = fieldAccess.getReferenceExpr();
      if (ref instanceof RexCorrelVariable) {
        final RexCorrelVariable var = (RexCorrelVariable) ref;
        if (mapFieldAccessToCorVar.containsKey(fieldAccess)) {
          // for cases where different Rel nodes are referring to
          // same correlation var (e.g. in case of NOT IN)
          // avoid generating another correlation var
          // and record the 'rel' is using the same correlation
          mapRefRelToCorRef.put(rel,
              mapFieldAccessToCorVar.get(fieldAccess));
        } else {
          final CorRef correlation =
              new CorRef(var.id, fieldAccess.getField().getIndex(),
                  corrIdGenerator++);
          mapFieldAccessToCorVar.put(fieldAccess, correlation);
          mapRefRelToCorRef.put(rel, correlation);
        }
      }
      return super.visitFieldAccess(fieldAccess);
    }

    @Override public Void visitSubQuery(RexSubQuery subQuery) {
      subQuery.rel.accept(CorelMapBuilder.this);
      return super.visitSubQuery(subQuery);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:31,代码来源:RelDecorrelator.java

示例7: findItemOrFlatten

import org.apache.calcite.rex.RexVisitorImpl; //导入依赖的package包/类
/**
 * Travesal RexNode to find the item/flattern operator. Continue search if RexNode has a
 * RexInputRef which refers to a RexNode in project expressions.
 *
 * @param node : RexNode to search
 * @param projExprs : the list of project expressions. Empty list means there is No project operator underneath.
 * @return : Return null if there is NONE; return the first appearance of item/flatten RexCall.
 */
public static RexCall findItemOrFlatten(
    final RexNode node,
    final List<RexNode> projExprs) {
  try {
    RexVisitor<Void> visitor =
        new RexVisitorImpl<Void>(true) {
          public Void visitCall(RexCall call) {
            if ("item".equals(call.getOperator().getName().toLowerCase()) ||
                "flatten".equals(call.getOperator().getName().toLowerCase())) {
              throw new Util.FoundOne(call); /* throw exception to interrupt tree walk (this is similar to
                                            other utility methods in RexUtil.java */
            }
            return super.visitCall(call);
          }

          public Void visitInputRef(RexInputRef inputRef) {
            if (projExprs.size() == 0 ) {
              return super.visitInputRef(inputRef);
            } else {
              final int index = inputRef.getIndex();
              RexNode n = projExprs.get(index);
              if (n instanceof RexCall) {
                RexCall r = (RexCall) n;
                if ("item".equals(r.getOperator().getName().toLowerCase()) ||
                    "flatten".equals(r.getOperator().getName().toLowerCase())) {
                  throw new Util.FoundOne(r);
                }
              }

              return super.visitInputRef(inputRef);
            }
          }
        };
    node.accept(visitor);
    return null;
  } catch (Util.FoundOne e) {
    Util.swallow(e, null);
    return (RexCall) e.getNode();
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:49,代码来源:DrillRelOptUtil.java


注:本文中的org.apache.calcite.rex.RexVisitorImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。