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

Java EnumerableConvention类代码示例

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

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



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

示例1: create

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Creates an DirPrunedEnumerableTableScan. */
public static EnumerableTableScan create(RelOptCluster cluster,
    RelOptTable relOptTable, String digestFromSelection) {
  final Table table = relOptTable.unwrap(Table.class);
  Class elementType = EnumerableTableScan.deduceElementType(table);
  final RelTraitSet traitSet =
      cluster.traitSetOf(EnumerableConvention.INSTANCE)
          .replaceIfs(RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  if (table != null) {
                    return table.getStatistic().getCollations();
                  }
                  return ImmutableList.of();
                }
              });
  return new DirPrunedEnumerableTableScan(cluster, traitSet, relOptTable, elementType, digestFromSelection);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:DirPrunedEnumerableTableScan.java


示例2: plan

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
public RelNode plan(String sql) {
    try {
        // hack to capitalize group by columns...not sure why the parser complains if the group by columns
        // are not capitalized
        final int groupByIndex = sql.toLowerCase().indexOf("group by");
        if(groupByIndex > -1) {
            final String firstPart = sql.substring(0, groupByIndex + "group by".length());
            final String groupPart = sql.substring(groupByIndex + "group by".length(), sql.length());
            sql = firstPart + groupPart.toUpperCase();
            // from index
            final int fromIndex = sql.toLowerCase().indexOf("from");
            sql = sql.substring(0, fromIndex).toUpperCase() + sql.substring(fromIndex, sql.length());
        }
        final SqlNode parse = planner.parse(sql);

        final SqlNode validate = planner.validate(parse);
        final RelNode convert = planner.convert(validate);
        final RelTraitSet traitSet = planner.getEmptyTraitSet()
                .replace(EnumerableConvention.INSTANCE);
        final RelNode transform = planner.transform(0, traitSet, convert);

        return transform;
    } catch (Exception e) {
        throw new ParseException("Error parsing: " + sql, e);
    }
}
 
开发者ID:twilmes,项目名称:sql-gremlin,代码行数:27,代码来源:QueryPlanner.java


示例3: runProjectQueryWithLex

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
private static void runProjectQueryWithLex(Lex lex, String sql)
    throws SqlParseException, ValidationException, RelConversionException {
  Config javaLex = SqlParser.configBuilder().setLex(lex).build();
  Planner planner = getPlanner(null, javaLex, Programs.ofRules(Programs.RULE_SET));
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet =
      planner.getEmptyTraitSet().replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(transform, instanceOf(EnumerableProject.class));
  List<String> fieldNames = transform.getRowType().getFieldNames();
  assertThat(fieldNames.size(), is(2));
  if (lex.caseSensitive) {
    assertThat(fieldNames.get(0), is("EMPID"));
    assertThat(fieldNames.get(1), is("empid"));
  } else {
    assertThat(fieldNames.get(0) + "-" + fieldNames.get(1),
        anyOf(is("EMPID-empid0"), is("EMPID0-empid")));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LexCaseSensitiveTest.java


示例4: testPlan

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Unit test that parses, validates, converts and plans. */
@Test public void testPlan() throws Exception {
  Program program =
      Programs.ofRules(
          FilterMergeRule.INSTANCE,
          EnumerableRules.ENUMERABLE_FILTER_RULE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE);
  Planner planner = getPlanner(null, program);
  SqlNode parse = planner.parse("select * from \"emps\"");
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform),
      equalTo(
          "EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
          + "  EnumerableTableScan(table=[[hr, emps]])\n"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:PlannerTest.java


示例5: testSortPlan

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Unit test that parses, validates, converts and
 * plans for query using order by */
@Test public void testSortPlan() throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          SortRemoveRule.INSTANCE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE,
          EnumerableRules.ENUMERABLE_SORT_RULE);
  Planner planner = getPlanner(null, Programs.of(ruleSet));
  SqlNode parse = planner.parse(
      "select * from \"emps\" "
          + "order by \"emps\".\"deptno\"");
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = convert.getTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform),
      equalTo("EnumerableSort(sort0=[$1], dir0=[ASC])\n"
          + "  EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
          + "    EnumerableTableScan(table=[[hr, emps]])\n"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:PlannerTest.java


示例6: runDuplicateSortCheck

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
private void runDuplicateSortCheck(String sql, String plan) throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          SortRemoveRule.INSTANCE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE,
          EnumerableRules.ENUMERABLE_WINDOW_RULE,
          EnumerableRules.ENUMERABLE_SORT_RULE,
          ProjectToWindowRule.PROJECT);
  Planner planner = getPlanner(null,
      SqlParser.configBuilder().setLex(Lex.JAVA).build(),
      Programs.of(ruleSet));
  SqlNode parse = planner.parse(sql);
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  if (traitSet.getTrait(RelCollationTraitDef.INSTANCE) == null) {
    // SortRemoveRule can only work if collation trait is enabled.
    return;
  }
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform), equalTo(plan));
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:PlannerTest.java


示例7: testDuplicateSortPlanWORemoveSortRule

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Unit test that parses, validates, converts and
 * plans for query using two duplicate order by.*/
@Test public void testDuplicateSortPlanWORemoveSortRule() throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          EnumerableRules.ENUMERABLE_PROJECT_RULE,
          EnumerableRules.ENUMERABLE_SORT_RULE);
  Planner planner = getPlanner(null, Programs.of(ruleSet));
  SqlNode parse = planner.parse(
      "select \"empid\" from ( "
          + "select * "
          + "from \"emps\" "
          + "order by \"emps\".\"deptno\") "
          + "order by \"deptno\"");
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).rel;
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform),
      equalTo("EnumerableSort(sort0=[$1], dir0=[ASC])\n"
          + "  EnumerableProject(empid=[$0], deptno=[$1])\n"
          + "    EnumerableSort(sort0=[$1], dir0=[ASC])\n"
          + "      EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
          + "        EnumerableTableScan(table=[[hr, emps]])\n"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:PlannerTest.java


示例8: testPlanWithExplicitTraitDefs

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Unit test that parses, validates, converts and plans. Planner is
 * provided with a list of RelTraitDefs to register. */
@Test public void testPlanWithExplicitTraitDefs() throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          FilterMergeRule.INSTANCE,
          EnumerableRules.ENUMERABLE_FILTER_RULE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE);
  final List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);

  Planner planner = getPlanner(traitDefs, Programs.of(ruleSet));

  SqlNode parse = planner.parse("select * from \"emps\"");
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform),
      equalTo(
          "EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
          + "  EnumerableTableScan(table=[[hr, emps]])\n"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:PlannerTest.java


示例9: testPlanTransformTwice

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Unit test that calls {@link Planner#transform} twice. */
@Test public void testPlanTransformTwice() throws Exception {
  RuleSet ruleSet =
      RuleSets.ofList(
          FilterMergeRule.INSTANCE,
          EnumerableRules.ENUMERABLE_FILTER_RULE,
          EnumerableRules.ENUMERABLE_PROJECT_RULE);
  Planner planner = getPlanner(null, Programs.of(ruleSet));
  SqlNode parse = planner.parse("select * from \"emps\"");
  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  RelNode transform2 = planner.transform(0, traitSet, transform);
  assertThat(toString(transform2),
      equalTo(
          "EnumerableProject(empid=[$0], deptno=[$1], name=[$2], salary=[$3], commission=[$4])\n"
          + "  EnumerableTableScan(table=[[hr, emps]])\n"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:PlannerTest.java


示例10: checkJoinNWay

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
private void checkJoinNWay(int n) throws Exception {
  final StringBuilder buf = new StringBuilder();
  buf.append("select *");
  for (int i = 0; i < n; i++) {
    buf.append(i == 0 ? "\nfrom " : ",\n ")
        .append("\"depts\" as d").append(i);
  }
  for (int i = 1; i < n; i++) {
    buf.append(i == 1 ? "\nwhere" : "\nand").append(" d")
        .append(i).append(".\"deptno\" = d")
        .append(i - 1).append(".\"deptno\"");
  }
  Planner planner = getPlanner(null,
      Programs.heuristicJoinOrder(Programs.RULE_SET, false, 6));
  SqlNode parse = planner.parse(buf.toString());

  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform),
      containsString(
          "EnumerableJoin(condition=[=($0, $5)], joinType=[inner])"));
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:PlannerTest.java


示例11: checkBushy

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/** Checks that a query returns a particular plan, using a planner with
 * MultiJoinOptimizeBushyRule enabled. */
private void checkBushy(String sql, String expected) throws Exception {
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(
          CalciteAssert.addSchema(rootSchema,
              CalciteAssert.SchemaSpec.CLONE_FOODMART))
      .traitDefs((List<RelTraitDef>) null)
      .programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
      .build();
  Planner planner = Frameworks.getPlanner(config);
  SqlNode parse = planner.parse(sql);

  SqlNode validate = planner.validate(parse);
  RelNode convert = planner.rel(validate).project();
  RelTraitSet traitSet = planner.getEmptyTraitSet()
      .replace(EnumerableConvention.INSTANCE);
  RelNode transform = planner.transform(0, traitSet, convert);
  assertThat(toString(transform), containsString(expected));
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:PlannerTest.java


示例12: register

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
public static void register(final Kryo kryo) {
  final EnumSerializer enumSerializer = new EnumSerializer();
  kryo.addDefaultSerializer(BindableConvention.class, enumSerializer);
  kryo.addDefaultSerializer(EnumerableConvention.class, enumSerializer);
  kryo.addDefaultSerializer(InterpretableConvention.class, enumSerializer);
  kryo.addDefaultSerializer(Convention.Impl.class, ConventionSerializer.class);

  kryo.addDefaultSerializer(RelDistributions.SINGLETON.getClass(), RelDistributionSerializer.class);
  kryo.addDefaultSerializer(DistributionTrait.class, DistributionTraitSerializer.class);
  kryo.addDefaultSerializer(RelCollation.class, RelCollationSerializer.class);

  kryo.addDefaultSerializer(RelTraitSet.class, RelTraitSetSerializer.class);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:14,代码来源:RelTraitSerializers.java


示例13: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    // keep it for having clause
    RexBuilder rexBuilder = getCluster().getRexBuilder();
    RelDataType inputRowType = getInput().getRowType();
    RexProgramBuilder programBuilder = new RexProgramBuilder(inputRowType, rexBuilder);
    programBuilder.addIdentity();
    programBuilder.addCondition(this.condition);
    RexProgram program = programBuilder.getProgram();

    return new EnumerableCalc(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), //
            sole(inputs), program);
}
 
开发者ID:apache,项目名称:kylin,代码行数:14,代码来源:OLAPFilterRel.java


示例14: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    ArrayList<RelNode> relInputs = new ArrayList<>(inputs.size());
    for (EnumerableRel input : inputs) {
        if (input instanceof OLAPRel) {
            ((OLAPRel) input).replaceTraitSet(EnumerableConvention.INSTANCE);
        }
        relInputs.add(input);
    }
    return new EnumerableUnion(getCluster(), traitSet, relInputs, localAll);
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:OLAPUnionRel.java


示例15: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    for (EnumerableRel input : inputs) {
        if (input instanceof OLAPRel) {
            ((OLAPRel) input).replaceTraitSet(EnumerableConvention.INSTANCE);
        }
    }
    return EnumerableWindowBridge.createEnumerableWindow(getCluster(), traitSet, inputs.get(0), constants, rowType,
            groups);
}
 
开发者ID:apache,项目名称:kylin,代码行数:11,代码来源:OLAPWindowRel.java


示例16: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    EnumerableRel input = sole(inputs);
    if (input instanceof OLAPRel) {
        ((OLAPRel) input).replaceTraitSet(EnumerableConvention.INSTANCE);
    }
    return EnumerableLimit.create(input, localOffset, localFetch);
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:OLAPLimitRel.java


示例17: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    if (this.hasSubQuery) {
        try {
            return constr.newInstance(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), //
                    inputs.get(0), inputs.get(1), condition, leftKeys, rightKeys, variablesSet, joinType);
        } catch (Exception e) {
            throw new IllegalStateException("Can't create EnumerableJoin!", e);
        }
    } else {
        return this;
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:14,代码来源:OLAPJoinRel.java


示例18: implementEnumerable

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
@Override
public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) {
    try {
        return new EnumerableAggregate(getCluster(), getCluster().traitSetOf(EnumerableConvention.INSTANCE), //
                sole(inputs), indicator, this.groupSet, this.groupSets, rewriteAggCalls);
    } catch (InvalidRelException e) {
        throw new IllegalStateException("Can't create EnumerableAggregate!", e);
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:10,代码来源:OLAPAggregateRel.java


示例19: convert_

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
private ParseResult convert_(Context context, String sql, boolean analyze,
                             boolean fail, CalciteCatalogReader catalogReader, SqlValidator validator,
                             SqlNode sqlNode1) {
  final JavaTypeFactory typeFactory = context.getTypeFactory();
  final Convention resultConvention =
      enableBindable ? BindableConvention.INSTANCE
          : EnumerableConvention.INSTANCE;
  final HepPlanner planner = new HepPlanner(new HepProgramBuilder().build());
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

  final SqlToRelConverter.ConfigBuilder configBuilder =
      SqlToRelConverter.configBuilder().withTrimUnusedFields(true);
  if (analyze) {
    configBuilder.withConvertTableAccess(false);
  }

  final CalcitePreparingStmt preparingStmt =
      new CalcitePreparingStmt(this, context, catalogReader, typeFactory,
          context.getRootSchema(), null, planner, resultConvention,
          createConvertletTable());
  final SqlToRelConverter converter =
      preparingStmt.getSqlToRelConverter(validator, catalogReader,
          configBuilder.build());

  final RelRoot root = converter.convertQuery(sqlNode1, false, true);
  if (analyze) {
    return analyze_(validator, sql, sqlNode1, root, fail);
  }
  return new ConvertResult(this, validator, sql, sqlNode1,
      validator.getValidatedNodeType(sqlNode1), root);
}
 
开发者ID:apache,项目名称:kylin,代码行数:32,代码来源:CalcitePrepareImpl.java


示例20: CassandraToEnumerableConverterRule

import org.apache.calcite.adapter.enumerable.EnumerableConvention; //导入依赖的package包/类
/**
 * Creates a CassandraToEnumerableConverterRule.
 *
 * @param relBuilderFactory Builder for relational expressions
 */
public CassandraToEnumerableConverterRule(
    RelBuilderFactory relBuilderFactory) {
  super(RelNode.class, Predicates.<RelNode>alwaysTrue(),
      CassandraRel.CONVENTION, EnumerableConvention.INSTANCE,
      relBuilderFactory, "CassandraToEnumerableConverterRule");
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:CassandraToEnumerableConverterRule.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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