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


Java ConventionTraitDef类代码示例

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


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

示例1: JdbcPrel

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
public JdbcPrel(RelOptCluster cluster, RelTraitSet traitSet, JdbcIntermediatePrel prel) {
  super(cluster, traitSet);
  final RelNode input = prel.getInput();
  rows = input.getRows();
  convention = (DrillJdbcConvention) input.getTraitSet().getTrait(ConventionTraitDef.INSTANCE);

  // generate sql for tree.
  final SqlDialect dialect = convention.getPlugin().getDialect();
  final JdbcImplementor jdbcImplementor = new JdbcImplementor(
      dialect,
      (JavaTypeFactory) getCluster().getTypeFactory());
  final JdbcImplementor.Result result =
      jdbcImplementor.visitChild(0, input.accept(new SubsetRemover()));
  sql = result.asQuery().toSqlString(dialect).getSql();
  rowType = input.getRowType();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:JdbcPrel.java

示例2: prepare

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
@BeforeClass
public static void prepare() {
  relDataType = TYPE_FACTORY.builder()
      .add("order_id", SqlTypeName.BIGINT)
      .add("site_id", SqlTypeName.INTEGER)
      .add("price", SqlTypeName.DOUBLE)
      .add("order_time", SqlTypeName.BIGINT).build();

  beamRowType = CalciteUtils.toBeamRowType(relDataType);
  record = new BeamRecord(beamRowType
      , 1234567L, 0, 8.9, 1234567L);

  SchemaPlus schema = Frameworks.createRootSchema(true);
  final List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);
  FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder().setLex(Lex.MYSQL).build()).defaultSchema(schema)
      .traitDefs(traitDefs).context(Contexts.EMPTY_CONTEXT).ruleSets(BeamRuleSets.getRuleSets())
      .costFactory(null).typeSystem(BeamRelDataTypeSystem.BEAM_REL_DATATYPE_SYSTEM).build();

  relBuilder = RelBuilder.create(config);
}
 
开发者ID:apache,项目名称:beam,代码行数:24,代码来源:BeamSqlFnExecutorTestBase.java

示例3: matches

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
@Override
public boolean matches(RelOptRuleCall call) {
  Project topProject = call.rel(0);
  Project bottomProject = call.rel(1);

  // Make sure both projects be LogicalProject.
  if (topProject.getTraitSet().getTrait(ConventionTraitDef.INSTANCE) != Convention.NONE ||
      bottomProject.getTraitSet().getTrait(ConventionTraitDef.INSTANCE) != Convention.NONE) {
    return false;
  }

  // We have a complex output type do not fire the merge project rule
  if (checkComplexOutput(topProject) || checkComplexOutput(bottomProject)) {
    return false;
  }

  return true;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:DrillMergeProjectRule.java

示例4: GremlinCompiler

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
public GremlinCompiler(Graph graph, SchemaConfig schemaConfig) {
    this.graph = graph;
    this.schemaConfig = schemaConfig;

    final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
    final List<RelTraitDef> traitDefs = new ArrayList<>();
    traitDefs.add(ConventionTraitDef.INSTANCE);
    traitDefs.add(RelCollationTraitDef.INSTANCE);
    final SqlParser.Config parserConfig =
            SqlParser.configBuilder().setLex(Lex.MYSQL).build();

    frameworkConfig = Frameworks.newConfigBuilder()
            .parserConfig(parserConfig)
            .defaultSchema(rootSchema.add("gremlin", new GremlinSchema(graph, schemaConfig)))
            .traitDefs(traitDefs)
            .programs(Programs.sequence(Programs.ofRules(Programs.RULE_SET), Programs.CALC_PROGRAM))
            .build();
}
 
开发者ID:twilmes,项目名称:sql-gremlin,代码行数:19,代码来源:GremlinCompiler.java

示例5: createPlanner

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
private static Planner createPlanner() {
  Connection connection;
  SchemaPlus rootSchema;
  try {
    connection = DriverManager.getConnection("jdbc:calcite:");
    CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
    rootSchema = calciteConnection.getRootSchema();
  } catch (SQLException e) {
    throw new SamzaException(e);
  }

  final List<RelTraitDef> traitDefs = new ArrayList<>();

  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);

  FrameworkConfig frameworkConfig = Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.configBuilder().setLex(Lex.JAVA).build())
      .defaultSchema(rootSchema)
      .operatorTable(SqlStdOperatorTable.instance())
      .traitDefs(traitDefs)
      .context(Contexts.EMPTY_CONTEXT)
      .costFactory(null)
      .build();
  return Frameworks.getPlanner(frameworkConfig);
}
 
开发者ID:apache,项目名称:samza,代码行数:27,代码来源:SamzaSqlQueryParser.java

示例6: buildPlanner

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
private Planner buildPlanner(QueryContext context) {
  final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);
  final ChainedSqlOperatorTable opTab =
      new ChainedSqlOperatorTable(
          ImmutableList.of(SqlStdOperatorTable.instance(),
              HiveSqlOperatorTable.instance(), catalogReader));
  FrameworkConfig config = Frameworks.newConfigBuilder() //
      .parserConfig(SqlParser.configBuilder()
          .setQuotedCasing(Casing.UNCHANGED)
          .setUnquotedCasing(Casing.TO_UPPER)
          .setQuoting(Quoting.DOUBLE_QUOTE)
          .build()) //
      .defaultSchema(context.getDefaultSchema()) //
      .operatorTable(opTab) //
      .traitDefs(traitDefs) //
      .convertletTable(StandardConvertletTable.INSTANCE)//
      .programs(getPrograms()) //
      .typeSystem(RelDataTypeSystem.DEFAULT) //
      .build();
  return Frameworks.getPlanner(config);
}
 
开发者ID:qubole,项目名称:quark,代码行数:24,代码来源:SqlWorker.java

示例7: testPlanWithExplicitTraitDefs

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的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

示例8: testUpdate

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-2039">[CALCITE-2039]
 * AssertionError when pushing project to ProjectableFilterableTable</a>
 * using UPDATE via {@link Frameworks}. */
@Test public void testUpdate() throws Exception {
  Table table = new TableImpl();
  final SchemaPlus rootSchema = Frameworks.createRootSchema(true);
  SchemaPlus schema = rootSchema.add("x", new AbstractSchema());
  schema.add("MYTABLE", table);
  List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelDistributionTraitDef.INSTANCE);
  SqlParser.Config parserConfig =
      SqlParser.configBuilder(SqlParser.Config.DEFAULT)
          .setCaseSensitive(false)
          .build();

  final FrameworkConfig config = Frameworks.newConfigBuilder()
      .parserConfig(parserConfig)
      .defaultSchema(schema)
      .traitDefs(traitDefs)
      // define the rules you want to apply
      .ruleSets(
          RuleSets.ofList(AbstractConverter.ExpandConversionRule.INSTANCE))
      .programs(Programs.ofRules(Programs.RULE_SET))
      .build();
  executeQuery(config, " UPDATE MYTABLE set id=7 where id=1",
      CalcitePrepareImpl.DEBUG);
}
 
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:FrameworksTest.java

示例9: testCombo

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
@Test public void testCombo() {
  VolcanoPlanner planner = new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

  planner.addRule(new ComboRule());
  planner.addRule(new AddIntermediateNodeRule());
  planner.addRule(new GoodSingleRule());

  RelOptCluster cluster = newCluster(planner);
  NoneLeafRel leafRel = new NoneLeafRel(cluster, "a");
  NoneSingleRel singleRel = new NoneSingleRel(cluster, leafRel);
  NoneSingleRel singleRel2 = new NoneSingleRel(cluster, singleRel);
  RelNode convertedRel =
      planner.changeTraits(singleRel2,
          cluster.traitSetOf(PHYS_CALLING_CONVENTION));
  planner.setRoot(convertedRel);
  RelNode result = planner.chooseDelegate().findBestExp();
  assertTrue(result instanceof IntermediateNode);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:ComboRuleTest.java

示例10: testTransformLeaf

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
/**
 * Tests transformation of a leaf from NONE to PHYS.
 */
@Test public void testTransformLeaf() {
  VolcanoPlanner planner = new VolcanoPlanner();

  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

  planner.addRule(new PhysLeafRule());

  RelOptCluster cluster = newCluster(planner);
  NoneLeafRel leafRel =
      new NoneLeafRel(
          cluster,
          "a");
  RelNode convertedRel =
      planner.changeTraits(
          leafRel,
          cluster.traitSetOf(PHYS_CALLING_CONVENTION));
  planner.setRoot(convertedRel);
  RelNode result = planner.chooseDelegate().findBestExp();
  assertTrue(result instanceof PhysLeafRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:VolcanoPlannerTest.java

示例11: testTransformSingleGood

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
/**
 * Tests transformation of a single+leaf from NONE to PHYS.
 */
@Test public void testTransformSingleGood() {
  VolcanoPlanner planner = new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

  planner.addRule(new PhysLeafRule());
  planner.addRule(new GoodSingleRule());

  RelOptCluster cluster = newCluster(planner);
  NoneLeafRel leafRel =
      new NoneLeafRel(
          cluster,
          "a");
  NoneSingleRel singleRel =
      new NoneSingleRel(
          cluster,
          leafRel);
  RelNode convertedRel =
      planner.changeTraits(
          singleRel,
          cluster.traitSetOf(PHYS_CALLING_CONVENTION));
  planner.setRoot(convertedRel);
  RelNode result = planner.chooseDelegate().findBestExp();
  assertTrue(result instanceof PhysSingleRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:28,代码来源:VolcanoPlannerTest.java

示例12: testTransformSingleReformed

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
/**
 * Tests transformation of a single+leaf from NONE to PHYS. In the past,
 * this one didn't work due to the definition of ReformedSingleRule.
 */
@Ignore // broken, because ReformedSingleRule matches child traits strictly
@Test public void testTransformSingleReformed() {
  VolcanoPlanner planner = new VolcanoPlanner();
  planner.addRelTraitDef(ConventionTraitDef.INSTANCE);

  planner.addRule(new PhysLeafRule());
  planner.addRule(new ReformedSingleRule());

  RelOptCluster cluster = newCluster(planner);
  NoneLeafRel leafRel =
      new NoneLeafRel(
          cluster,
          "a");
  NoneSingleRel singleRel =
      new NoneSingleRel(
          cluster,
          leafRel);
  RelNode convertedRel =
      planner.changeTraits(
          singleRel,
          cluster.traitSetOf(PHYS_CALLING_CONVENTION));
  planner.setRoot(convertedRel);
  RelNode result = planner.chooseDelegate().findBestExp();
  assertTrue(result instanceof PhysSingleRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:VolcanoPlannerTest.java

示例13: onMatch

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  LogicalProject rel = call.rel(0);
  RelNode rawInput = call.rel(1);
  RelNode input = convert(rawInput, PHYSICAL);

  if (subsetHack && input instanceof RelSubset) {
    RelSubset subset = (RelSubset) input;
    for (RelNode child : subset.getRels()) {
      // skip logical nodes
      if (child.getTraitSet().getTrait(ConventionTraitDef.INSTANCE)
          == Convention.NONE) {
        continue;
      } else {
        RelTraitSet outcome = child.getTraitSet().replace(PHYSICAL);
        call.transformTo(
            new PhysProj(rel.getCluster(), outcome, convert(child, outcome),
                rel.getChildExps(), rel.getRowType()));
      }
    }
  } else {
    call.transformTo(
        PhysProj.create(input, rel.getChildExps(), rel.getRowType()));
  }

}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:TraitPropagationTest.java

示例14: DrillSqlWorker

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
public DrillSqlWorker(QueryContext context) {
  final List<RelTraitDef> traitDefs = new ArrayList<RelTraitDef>();

  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(DrillDistributionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);
  this.context = context;
  RelOptCostFactory costFactory = (context.getPlannerSettings().useDefaultCosting()) ?
      null : new DrillCostBase.DrillCostFactory() ;
  int idMaxLength = (int)context.getPlannerSettings().getIdentifierMaxLength();

  FrameworkConfig config = Frameworks.newConfigBuilder() //
      .parserConfig(SqlParser.configBuilder()
          .setLex(Lex.MYSQL)
          .setIdentifierMaxLength(idMaxLength)
          .setParserFactory(DrillParserWithCompoundIdConverter.FACTORY)
          .build()) //
      .defaultSchema(context.getNewDefaultSchema()) //
      .operatorTable(context.getDrillOperatorTable()) //
      .traitDefs(traitDefs) //
      .convertletTable(new DrillConvertletTable()) //
      .context(context.getPlannerSettings()) //
      .ruleSets(getRules(context)) //
      .costFactory(costFactory) //
      .executor(new DrillConstExecutor(context.getFunctionRegistry(), context, context.getPlannerSettings()))
      .typeSystem(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM) //
      .build();
  this.planner = Frameworks.getPlanner(config);
  HepProgramBuilder builder = new HepProgramBuilder();
  builder.addRuleClass(ReduceExpressionsRule.class);
  builder.addRuleClass(ProjectToWindowRule.class);
  this.hepPlanner = new HepPlanner(builder.build());
  hepPlanner.addRule(ReduceExpressionsRule.CALC_INSTANCE);
  hepPlanner.addRule(ProjectToWindowRule.PROJECT);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:36,代码来源:DrillSqlWorker.java

示例15: OldScanCrel

import org.apache.calcite.plan.ConventionTraitDef; //导入依赖的package包/类
public OldScanCrel(
    RelOptCluster cluster,
    RelOptTable relOptTable,
    RelTraitSet traits,
    RelDataType rowType,
    GroupScan groupScan,
    LayoutInfo layoutInfo,
    double rowCountDiscount) {
  super(cluster, traits, relOptTable, rowType, groupScan, rowCountDiscount);
  this.layoutInfo = layoutInfo;
  Preconditions.checkArgument(traits.getTrait(ConventionTraitDef.INSTANCE) == Convention.NONE);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:13,代码来源:OldScanCrel.java


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