本文整理汇总了Java中org.apache.calcite.rel.logical.LogicalFilter类的典型用法代码示例。如果您正苦于以下问题:Java LogicalFilter类的具体用法?Java LogicalFilter怎么用?Java LogicalFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogicalFilter类属于org.apache.calcite.rel.logical包,在下文中一共展示了LogicalFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
Filter filterRel = call.rel(0);
Project projRel = call.rel(1);
// Don't push Filter past Project if the Filter is referencing an ITEM or a FLATTEN expression
// from the Project.
//\TODO: Ideally we should split up the filter conditions into ones that
// reference the ITEM expression and ones that don't and push the latter past the Project
if (findItemOrFlatten(filterRel.getCondition(), projRel.getProjects()) != null) {
return;
}
// convert the filter to one that references the child of the project
RexNode newCondition =
RelOptUtil.pushFilterPastProject(filterRel.getCondition(), projRel);
Filter newFilterRel = LogicalFilter.create(projRel.getInput(), newCondition);
Project newProjRel =
(Project) RelOptUtil.createProject(
newFilterRel,
projRel.getNamedProjects(),
false);
call.transformTo(newProjRel);
}
示例2: matches
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public boolean matches(RelOptRuleCall call) {
try {
final LogicalFilter filter = (LogicalFilter) call.rel(0);
for (RexNode node : filter.getChildExps()) {
if (!checkedExpressions.get(node)) {
return false;
}
}
return true;
} catch (ExecutionException e) {
throw new IllegalStateException("Failure while trying to evaluate pushdown.", e);
}
}
示例3: visit
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public RelNode visit(final LogicalFilter filter) {
final RelBuilder relBuilder = newCalciteRelBuilderWithoutContext(filter.getCluster());
RelNode input = filter.getInput().accept(this);
relBuilder.push(input);
RexNode newCondition = filter.getCondition().accept(new RexShuttle() {
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
return relBuilder.field(filter.getRowType().getFieldNames().get(inputRef.getIndex()));
}
});
relBuilder.filter(newCondition);
return relBuilder.build();
}
示例4: translate
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public void translate(final LogicalFilter filter, final TranslatorContext context) {
MessageStream<SamzaSqlRelMessage> inputStream = context.getMessageStream(filter.getInput().getId());
Expression expr =
context.getExpressionCompiler().compile(filter.getInputs(), Collections.singletonList(filter.getCondition()));
MessageStream<SamzaSqlRelMessage> outputStream = inputStream.filter(message -> {
Object[] result = new Object[1];
expr.execute(context.getExecutionContext(), context.getDataContext(), message.getRelFieldValues().toArray(), result);
if (result.length > 0 && result[0] instanceof Boolean) {
boolean retVal = (Boolean) result[0];
log.debug(
String.format("return value for input %s is %s", Arrays.asList(message.getFieldValues()).toString(), retVal));
return retVal;
} else {
log.error("return value is not boolean");
return false;
}
});
context.registerMessageStream(filter.getId(), outputStream);
}
示例5: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
LogicalFilter filter = call.rel(0);
MultiJoin multiJoin = call.rel(1);
MultiJoin newMultiJoin =
new MultiJoin(
multiJoin.getCluster(),
multiJoin.getInputs(),
multiJoin.getJoinFilter(),
multiJoin.getRowType(),
multiJoin.isFullOuterJoin(),
multiJoin.getOuterJoinConditions(),
multiJoin.getJoinTypes(),
multiJoin.getProjFields(),
multiJoin.getJoinFieldRefCountsMap(),
filter.getCondition());
call.transformTo(newMultiJoin);
}
示例6: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
SemiJoin semiJoin = call.rel(0);
LogicalFilter filter = call.rel(1);
RelNode newSemiJoin =
SemiJoin.create(filter.getInput(),
semiJoin.getRight(),
semiJoin.getCondition(),
semiJoin.getLeftKeys(),
semiJoin.getRightKeys());
final RelFactories.FilterFactory factory =
RelFactories.DEFAULT_FILTER_FACTORY;
RelNode newFilter =
factory.createFilter(newSemiJoin, filter.getCondition());
call.transformTo(newFilter);
}
示例7: splitCorrelatedFilterCondition
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Deprecated // to be removed before 2.0
public static RexNode splitCorrelatedFilterCondition(
LogicalFilter filter,
List<RexInputRef> joinKeys,
List<RexNode> correlatedJoinKeys) {
final List<RexNode> nonEquiList = new ArrayList<>();
splitCorrelatedFilterCondition(
filter,
filter.getCondition(),
joinKeys,
correlatedJoinKeys,
nonEquiList);
// Convert the remainders into a list that are AND'ed together.
return RexUtil.composeConjunction(
filter.getCluster().getRexBuilder(), nonEquiList, true);
}
示例8: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = call.rel(0);
final LogicalProject project = call.rel(1);
final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
newProjects.add(filter.getCondition());
final RelOptCluster cluster = filter.getCluster();
RelDataType newRowType =
cluster.getTypeFactory().builder()
.addAll(project.getRowType().getFieldList())
.add("condition", Util.last(newProjects).getType())
.build();
final RelNode newProject =
project.copy(project.getTraitSet(),
project.getInput(),
newProjects,
newRowType);
final RexInputRef newCondition =
cluster.getRexBuilder().makeInputRef(newProject,
newProjects.size() - 1);
call.transformTo(LogicalFilter.create(newProject, newCondition));
}
示例9: toRel
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override public RelNode toRel(ToRelContext context) {
RelNode rel = LogicalTableScan.create(context.getCluster(), fromTable);
final RexBuilder rexBuilder = context.getCluster().getRexBuilder();
rel = LogicalFilter.create(
rel, getConstraint(rexBuilder, rel.getRowType()));
final List<RelDataTypeField> fieldList =
rel.getRowType().getFieldList();
final List<Pair<RexNode, String>> projects =
new AbstractList<Pair<RexNode, String>>() {
@Override public Pair<RexNode, String> get(int index) {
return RexInputRef.of2(mapping.get(index), fieldList);
}
@Override public int size() {
return mapping.size();
}
};
return LogicalProject.create(rel, Pair.left(projects),
Pair.right(projects));
}
示例10: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = (LogicalFilter) call.rel(0);
final RelNode input = filter.getInput();
//final RelTraitSet traits = filter.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
call.transformTo(new DrillFilterRel(filter.getCluster(), convertedInput.getTraitSet(), convertedInput, filter.getCondition()));
}
示例11: visit
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public RelNode visit(LogicalFilter filter) {
final RelNode input = filter.getInput().accept(this);
return new LogicalFilter(
cluster,
copyOf(filter.getTraitSet()),
input,
copyOf(filter.getCondition()),
ImmutableSet.copyOf(filter.getVariablesSet())
);
}
示例12: visit
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public RelNode visit(LogicalFilter filter) {
final RexNode condition = filter.getCondition().accept(unwrappingExpressionVisitor);
filter = filter.copy(
filter.getTraitSet(),
filter.getInput(),
condition);
return visitChild(filter, 0, filter.getInput());
}
示例13: onMatch
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final LogicalFilter filter = (LogicalFilter) call.rel(0);
final RelNode input = filter.getInput();
//final RelTraitSet traits = filter.getTraitSet().plus(Rel.LOGICAL);
final RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify());
call.transformTo(new FilterRel(filter.getCluster(), convertedInput.getTraitSet(), convertedInput, filter.getCondition()));
}
示例14: visit
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
@Override
public RelNode visit(final LogicalFilter filter) {
try {
stack.push(filter);
filter.getCondition().accept(rexVisitor(filter));
} finally {
stack.pop();
}
return super.visit(filter);
}
示例15: convert
import org.apache.calcite.rel.logical.LogicalFilter; //导入依赖的package包/类
public RelNode convert(RelNode rel) {
final LogicalFilter filter = (LogicalFilter) rel;
return new JdbcFilter(
rel.getCluster(),
rel.getTraitSet().replace(getOut()),
convert(filter.getInput(),
filter.getInput().getTraitSet().replace(getOut())),
filter.getCondition());
}