• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Filter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: trans

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
private String trans(String sql) throws Exception {
	Properties info = new Properties();
	info.setProperty("lex", "JAVA");
	String jsonFile = SolrSqlTest.class.getClassLoader().getResource("solr.json").toString().replaceAll("file:/", "");
	try {
		Class.forName("org.apache.calcite.jdbc.Driver");
	} catch (ClassNotFoundException e1) {
		e1.printStackTrace();
	}
	
	CalciteConnection connection = (CalciteConnection) DriverManager.getConnection("jdbc:calcite:model="+jsonFile, info);
	final SchemaPlus schema = connection.getRootSchema().getSubSchema("solr");
	connection.close();

	ConfigBuilder builder = Frameworks.newConfigBuilder().defaultSchema(schema).parserConfig(SqlParser.configBuilder().setCaseSensitive(false).build());
	FrameworkConfig config = builder.build();
	Planner planner = Frameworks.getPlanner(config);
	SqlNode sqlNode = planner.parse(sql);
	SqlNode node = planner.validate(sqlNode);
	RelRoot relRoot = planner.rel(node);
	RelNode project = relRoot.project();
	RexNode condition = ((Filter) ((Project) project).getInput()).getCondition();

	return _trans.translate(condition).toSolrQueryString();
}
 
开发者ID:jenkin2016,项目名称:solr-sql,代码行数:26,代码来源:SqlTranslatorTest.java


示例2: onMatch

import org.apache.calcite.rel.core.Filter; //导入依赖的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);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:27,代码来源:DrillPushFilterPastProjectRule.java


示例3: empty

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
/** Creates a relational expression that reads from an input and throws
 *  all of the rows away.
 */
@Override
public RelBuilder empty() {
  final Frame frame = stack.pop();
  final RelNode input;
  // If the rel that we are limiting the output of a rel, we should just add a limit 0 on top.
  // If the rel that we are limiting is a Filter replace it as well since Filter does not
  // change the row type.
  if (!(frame.rel instanceof Filter)) {
    input = frame.rel;
  } else {
    input = frame.rel.getInput(0);
  }
  final RelNode sort = sortFactory.createSort(input, RelCollations.EMPTY,
    frame.rel.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)),
    frame.rel.getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0)));
  push(sort);
  return this;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:RelBuilder.java


示例4: visitFilter

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override
public Void visitFilter(Filter filter, List<Void> inputStreams) throws Exception {
  beginStage(filter);

  List<RexNode> childExps = filter.getChildExps();
  RelDataType inputRowType = filter.getInput(0).getRowType();

  pw.print("Context context = new StreamlineContext(Processor.dataContext);\n");
  pw.print("context.values = _data.toArray();\n");
  pw.print("Object[] outputValues = new Object[1];\n");

  pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString());

  String r = "((Boolean) outputValues[0])";
  if (filter.getCondition().getType().isNullable()) {
    pw.print(String.format("    if (%s != null && %s) { ctx.emit(_data); }\n", r, r));
  } else {
    pw.print(String.format("    if (%s) { ctx.emit(_data); }\n", r, r));
  }
  endStage();
  return null;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:23,代码来源:RelNodeCompiler.java


示例5: isLatticeFilterSatisfied

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
/**
 * Checks if filter satisfies the lattice filter
 * i.e., it needs data captured by the lattice
 */
private boolean isLatticeFilterSatisfied(final RelOptLattice lattice,
                                 final Filter filter,
                                 final StarTable.StarTableScan scan) {
  if (lattice.lattice.filter == null) {
    return true;
  }
  RexExecutorImpl rexImpl =
      (RexExecutorImpl) (scan.getCluster().getPlanner().getExecutor());
  RexImplicationChecker solver =
      new RexImplicationChecker(scan.getCluster().getRexBuilder(),
          rexImpl, scan.getRowType());
  try {
    return solver.implies(filter.getCondition(), lattice.lattice.filter);
  } catch (Exception e) {
    LOG.debug("Exception thrown while solving "
        + filter.getCondition()
        + "  =>  "
        + lattice.lattice.filter);
    return false;
  }
}
 
开发者ID:qubole,项目名称:quark,代码行数:26,代码来源:FilterAggStarRule.java


示例6: signature

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
/** Returns a string describing the operations inside this query.
 *
 * <p>For example, "sfpaol" means {@link TableScan} (s)
 * followed by {@link Filter} (f)
 * followed by {@link Project} (p)
 * followed by {@link Aggregate} (a)
 * followed by {@link Project} (o)
 * followed by {@link Sort} (l).
 *
 * @see #isValidSignature(String)
 */
String signature() {
  final StringBuilder b = new StringBuilder();
  boolean flag = false;
  for (RelNode rel : rels) {
    b.append(rel instanceof TableScan ? 's'
        : (rel instanceof Project && flag) ? 'o'
        : rel instanceof Filter ? 'f'
        : rel instanceof Aggregate ? 'a'
        : rel instanceof Sort ? 'l'
        : rel instanceof Project ? 'p'
        : '!');
    flag = flag || rel instanceof Aggregate;
  }
  return b.toString();
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:DruidQuery.java


示例7: getDistinctRowCount

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
public Double getDistinctRowCount(Filter rel, RelMetadataQuery mq,
    ImmutableBitSet groupKey, RexNode predicate) {
  if (predicate == null || predicate.isAlwaysTrue()) {
    if (groupKey.isEmpty()) {
      return 1D;
    }
  }
  // REVIEW zfong 4/18/06 - In the Broadbase code, duplicates are not
  // removed from the two filter lists.  However, the code below is
  // doing so.
  RexNode unionPreds =
      RelMdUtil.unionPreds(
          rel.getCluster().getRexBuilder(),
          predicate,
          rel.getCondition());

  return mq.getDistinctRowCount(rel.getInput(), groupKey, unionPreds);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RelMdDistinctRowCount.java


示例8: getSelectivity

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
public Double getSelectivity(Filter rel, RelMetadataQuery mq,
    RexNode predicate) {
  // Take the difference between the predicate passed in and the
  // predicate in the filter's condition, so we don't apply the
  // selectivity of the filter twice.  If no predicate is passed in,
  // use the filter's condition.
  if (predicate != null) {
    return mq.getSelectivity(rel.getInput(),
        RelMdUtil.minusPreds(
            rel.getCluster().getRexBuilder(),
            predicate,
            rel.getCondition()));
  } else {
    return mq.getSelectivity(rel.getInput(), rel.getCondition());
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelMdSelectivity.java


示例9: areColumnsUnique

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
public Boolean areColumnsUnique(RelSubset rel, RelMetadataQuery mq,
    ImmutableBitSet columns, boolean ignoreNulls) {
  int nullCount = 0;
  for (RelNode rel2 : rel.getRels()) {
    if (rel2 instanceof Aggregate
        || rel2 instanceof Filter
        || rel2 instanceof Values
        || rel2 instanceof TableScan
        || simplyProjects(rel2, columns)) {
      try {
        final Boolean unique = mq.areColumnsUnique(rel2, columns, ignoreNulls);
        if (unique != null) {
          if (unique) {
            return true;
          }
        } else {
          ++nullCount;
        }
      } catch (CyclicMetadataException e) {
        // Ignore this relational expression; there will be non-cyclic ones
        // in this set.
      }
    }
  }
  return nullCount == 0 ? false : null;
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelMdColumnUniqueness.java


示例10: onMatch

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
  final Filter filter = call.rel(0);
  final RexBuilder rexBuilder = filter.getCluster().getRexBuilder();
  final String timeZone = filter.getCluster().getPlanner().getContext()
      .unwrap(CalciteConnectionConfig.class).timeZone();
  final RexNode condition =
      replaceTimeUnits(rexBuilder, filter.getCondition(), timeZone);
  if (RexUtil.eq(condition, filter.getCondition())) {
    return;
  }
  final RelBuilder relBuilder =
      relBuilderFactory.create(filter.getCluster(), null);
  relBuilder.push(filter.getInput())
      .filter(condition);
  call.transformTo(relBuilder.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:DateRangeRules.java


示例11: apply

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
protected void apply(RelOptRuleCall call, Filter filter, TableScan scan) {
  final ImmutableIntList projects;
  final ImmutableList.Builder<RexNode> filters = ImmutableList.builder();
  if (scan instanceof Bindables.BindableTableScan) {
    final Bindables.BindableTableScan bindableScan =
        (Bindables.BindableTableScan) scan;
    filters.addAll(bindableScan.filters);
    projects = bindableScan.projects;
  } else {
    projects = scan.identity();
  }

  final Mapping mapping = Mappings.target(projects,
      scan.getTable().getRowType().getFieldCount());
  filters.add(
      RexUtil.apply(mapping, filter.getCondition()));

  call.transformTo(
      Bindables.BindableTableScan.create(scan.getCluster(), scan.getTable(),
          filters.build(), projects));
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:FilterTableScanRule.java


示例12: DrillMergeFilterRule

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
/**
 * Creates a MergeFilterRule.
 */
private DrillMergeFilterRule(RelFactories.FilterFactory filterFactory) {
  super(
      operand(Filter.class,
          operand(Filter.class, any())));
  this.filterFactory = filterFactory;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:DrillMergeFilterRule.java


示例13: onMatch

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
    Filter topFilter = call.rel(0);
    Filter bottomFilter = call.rel(1);

    // use RexPrograms to merge the two FilterRels into a single program
    // so we can convert the two FilterRel conditions to directly
    // reference the bottom FilterRel's child
    RexBuilder rexBuilder = topFilter.getCluster().getRexBuilder();
    RexProgram bottomProgram = createProgram(bottomFilter);
    RexProgram topProgram = createProgram(topFilter);

    RexProgram mergedProgram =
        RexProgramBuilder.mergePrograms(
            topProgram,
            bottomProgram,
            rexBuilder);

    RexNode newCondition =
        mergedProgram.expandLocalRef(
            mergedProgram.getCondition());

//    if(!RexUtil.isFlat(newCondition)){
//      RexCall newCall = (RexCall) newCondition;
//      newCondition = rexBuilder.makeFlatCall( newCall.getOperator(), newCall.getOperands());
//    }

    Filter newFilterRel =
        (Filter) filterFactory.createFilter(
            bottomFilter.getInput(),
            RexUtil.flatten(rexBuilder, newCondition));

    call.transformTo(newFilterRel);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:34,代码来源:DrillMergeFilterRule.java


示例14: createProgram

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
/**
 * Creates a RexProgram corresponding to a LogicalFilter
 *
 * @param filterRel the LogicalFilter
 * @return created RexProgram
 */
private RexProgram createProgram(Filter filterRel) {
  RexProgramBuilder programBuilder =
      new RexProgramBuilder(
          filterRel.getRowType(),
          filterRel.getCluster().getRexBuilder());
  programBuilder.addIdentity();
  programBuilder.addCondition(filterRel.getCondition());
  return programBuilder.getProgram();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:16,代码来源:DrillMergeFilterRule.java


示例15: estimateCpuCost

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
private double estimateCpuCost() {
  RelNode child = this.getInput();
  double compNum = RelMetadataQuery.getRowCount(child);

  for (int i = 0; i< numConjuncts; i++) {
    RexNode conjFilter = RexUtil.composeConjunction(this.getCluster().getRexBuilder(), conjunctions.subList(0, i + 1), false);
    compNum += Filter.estimateFilteredRows(child, conjFilter);
  }

  return compNum * DrillCostBase.COMPARE_CPU_COST;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:DrillFilterRelBase.java


示例16: onMatch

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
  final Filter filterRel = call.rel(0);
  final Project projectRel = call.rel(1);
  final T scanRel = call.rel(2);
  doOnMatch(call, filterRel, projectRel, scanRel);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:PruneScanRuleBase.java


示例17: implement

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override
public LogicalOperator implement(LogicalPlanImplementor implementor) {
  final LogicalOperator input = implementor.visitChild(this, 0, getInput());
  com.dremio.common.logical.data.Filter f = new com.dremio.common.logical.data.Filter(getFilterExpression(implementor.getContext()));
  f.setInput(input);
  return f;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:FilterRel.java


示例18: convert

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override
public RelNode convert(RelNode rel) {
  final Filter filter = (Filter) rel;
  final RelNode input = filter.getInput();

  return new BeamFilterRel(filter.getCluster(),
      filter.getTraitSet().replace(BeamLogicalConvention.INSTANCE),
      convert(input, input.getTraitSet().replace(BeamLogicalConvention.INSTANCE)),
      filter.getCondition());
}
 
开发者ID:apache,项目名称:beam,代码行数:11,代码来源:BeamFilterRule.java


示例19: onMatch

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
  final Filter filterRel = call.rel(0);
  final Project projectRel = call.rel(1);
  final TableScan scanRel = call.rel(2);
  doOnMatch(call, filterRel, projectRel, scanRel);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:8,代码来源:PruneScanRule.java


示例20: estimateCpuCost

import org.apache.calcite.rel.core.Filter; //导入依赖的package包/类
private double estimateCpuCost(RelMetadataQuery mq) {
  RelNode child = this.getInput();
  double compNum = mq.getRowCount(child);

  for (int i = 0; i< numConjuncts; i++) {
    RexNode conjFilter = RexUtil.composeConjunction(this.getCluster().getRexBuilder(), conjunctions.subList(0, i + 1), false);
    compNum += Filter.estimateFilteredRows(child, conjFilter);
  }

  return compNum * DrillCostBase.COMPARE_CPU_COST;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:12,代码来源:DrillFilterRelBase.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ApplicationUser类代码示例发布时间:2022-05-21
下一篇:
Java SerialUtilities类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap