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


Java RelTraitDef类代码示例

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


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

示例1: prepare

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

示例2: GremlinCompiler

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

示例3: createPlanner

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

示例4: buildPlanner

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

示例5: config

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
public Frameworks.ConfigBuilder config() throws Exception {
  final Holder<SchemaPlus> root = Holder.of(null);
  CalciteAssert.model(TPCDS_MODEL)
      .doWithConnection(
          new Function<CalciteConnection, Object>() {
            public Object apply(CalciteConnection input) {
              root.set(input.getRootSchema().getSubSchema("TPCDS"));
              return null;
            }
          });
  return Frameworks.newConfigBuilder()
      .parserConfig(SqlParser.Config.DEFAULT)
      .defaultSchema(root.get())
      .traitDefs((List<RelTraitDef>) null)
      .programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2));
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:TpcdsTest.java

示例6: StdFrameworkConfig

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
StdFrameworkConfig(Context context,
    SqlRexConvertletTable convertletTable,
    SqlOperatorTable operatorTable,
    ImmutableList<Program> programs,
    ImmutableList<RelTraitDef> traitDefs,
    SqlParser.Config parserConfig,
    SqlToRelConverter.Config sqlToRelConverterConfig,
    SchemaPlus defaultSchema,
    RelOptCostFactory costFactory,
    RelDataTypeSystem typeSystem,
    RexExecutor executor) {
  this.context = context;
  this.convertletTable = convertletTable;
  this.operatorTable = operatorTable;
  this.programs = programs;
  this.traitDefs = traitDefs;
  this.parserConfig = parserConfig;
  this.sqlToRelConverterConfig = sqlToRelConverterConfig;
  this.defaultSchema = defaultSchema;
  this.costFactory = costFactory;
  this.typeSystem = typeSystem;
  this.executor = executor;
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:Frameworks.java

示例7: testPlanWithExplicitTraitDefs

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

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

示例9: testUpdate

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

示例10: DrillSqlWorker

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

示例11: BeamQueryPlanner

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
public BeamQueryPlanner(SchemaPlus schema) {
  String defaultCharsetKey = "saffron.default.charset";
  if (System.getProperty(defaultCharsetKey) == null) {
    System.setProperty(defaultCharsetKey, ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
    System.setProperty("saffron.default.nationalcharset",
      ConversionUtil.NATIVE_UTF16_CHARSET_NAME);
    System.setProperty("saffron.default.collation.name",
      String.format("%s$%s", ConversionUtil.NATIVE_UTF16_CHARSET_NAME, "en_US"));
  }

  final List<RelTraitDef> traitDefs = new ArrayList<>();
  traitDefs.add(ConventionTraitDef.INSTANCE);
  traitDefs.add(RelCollationTraitDef.INSTANCE);

  List<SqlOperatorTable> sqlOperatorTables = new ArrayList<>();
  sqlOperatorTables.add(SqlStdOperatorTable.instance());
  sqlOperatorTables.add(new CalciteCatalogReader(CalciteSchema.from(schema), false,
      Collections.<String>emptyList(), TYPE_FACTORY));

  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)
      .operatorTable(new ChainedSqlOperatorTable(sqlOperatorTables))
      .build();
  this.planner = Frameworks.getPlanner(config);

  for (String t : schema.getTableNames()) {
    sourceTables.put(t, (BaseBeamTable) schema.getTable(t));
  }
}
 
开发者ID:apache,项目名称:beam,代码行数:32,代码来源:BeamQueryPlanner.java

示例12: getBuilder

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
/**
 * Creates a {@link RelBuilder} with the given schema.
 *
 * @param dataSource  The dataSource for the jdbc schema.
 * @param schemaName  The name of the schema used for the database.
 *
 * @return the relbuilder from Calcite.
 *
 * @throws SQLException if can't readSqlResultSet from database.
 */
public static RelBuilder getBuilder(DataSource dataSource, String schemaName) throws SQLException {
    SchemaPlus rootSchema = Frameworks.createRootSchema(true);
    return RelBuilder.create(
            Frameworks.newConfigBuilder()
                    .parserConfig(SqlParser.Config.DEFAULT)
                    .defaultSchema(addSchema(rootSchema, dataSource, schemaName))
                    .traitDefs((List<RelTraitDef>) null)
                    .programs(Programs.heuristicJoinOrder(Programs.RULE_SET, true, 2))
                    .build()
    );
}
 
开发者ID:yahoo,项目名称:fili,代码行数:22,代码来源:CalciteHelper.java

示例13: ConverterImpl

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
/**
 * Creates a ConverterImpl.
 *
 * @param cluster  planner's cluster
 * @param traitDef the RelTraitDef this converter converts
 * @param traits   the output traits of this converter
 * @param child    child rel (provides input traits)
 */
protected ConverterImpl(
    RelOptCluster cluster,
    RelTraitDef traitDef,
    RelTraitSet traits,
    RelNode child) {
  super(cluster, traits, child);
  this.inTraits = child.getTraitSet();
  this.traitDef = traitDef;
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:ConverterImpl.java

示例14: ready

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
private void ready() {
  switch (state) {
  case STATE_0_CLOSED:
    reset();
  }
  ensure(State.STATE_1_RESET);
  Frameworks.withPlanner(
      new Frameworks.PlannerAction<Void>() {
        public Void apply(RelOptCluster cluster, RelOptSchema relOptSchema,
            SchemaPlus rootSchema) {
          Util.discard(rootSchema); // use our own defaultSchema
          typeFactory = (JavaTypeFactory) cluster.getTypeFactory();
          planner = cluster.getPlanner();
          planner.setExecutor(executor);
          return null;
        }
      },
      config);

  state = State.STATE_2_READY;

  // If user specify own traitDef, instead of default default trait,
  // first, clear the default trait def registered with planner
  // then, register the trait def specified in traitDefs.
  if (this.traitDefs != null) {
    planner.clearRelTraitDefs();
    for (RelTraitDef def : this.traitDefs) {
      planner.addRelTraitDef(def);
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:PlannerImpl.java

示例15: emptyTraitSet

import org.apache.calcite.plan.RelTraitDef; //导入依赖的package包/类
@Override public RelTraitSet emptyTraitSet() {
  RelTraitSet traitSet = super.emptyTraitSet();
  for (RelTraitDef traitDef : traitDefs) {
    if (traitDef.multiple()) {
      // TODO: restructure RelTraitSet to allow a list of entries
      //  for any given trait
    }
    traitSet = traitSet.plus(traitDef.getDefault());
  }
  return traitSet;
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:VolcanoPlanner.java


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