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


Java RelCollationTraitDef类代码示例

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


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

示例1: prepare

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的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: trimUnusedFields

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/**
 * Walks over a tree of relational expressions, replacing each
 * {@link RelNode} with a 'slimmed down' relational expression that projects
 * only the fields required by its consumer.
 *
 * <p>This may make things easier for the optimizer, by removing crud that
 * would expand the search space, but is difficult for the optimizer itself
 * to do it, because optimizer rules must preserve the number and type of
 * fields. Hence, this transform that operates on the entire tree, similar
 * to the {@link RelStructuredTypeFlattener type-flattening transform}.
 *
 * <p>Currently this functionality is disabled in farrago/luciddb; the
 * default implementation of this method does nothing.
 *
 * @param ordered Whether the relational expression must produce results in
 * a particular order (typically because it has an ORDER BY at top level)
 * @param rootRel Relational expression that is at the root of the tree
 * @return Trimmed relational expression
 */
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
	// Trim fields that are not used by their consumer.
	if (isTrimUnusedFields()) {
		final RelFieldTrimmer trimmer = newFieldTrimmer();
		final List<RelCollation> collations =
			rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
		rootRel = trimmer.trim(rootRel);
		if (!ordered
			&& collations != null
			&& !collations.isEmpty()
			&& !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
			final RelTraitSet traitSet = rootRel.getTraitSet()
				.replace(RelCollationTraitDef.INSTANCE, collations);
			rootRel = rootRel.copy(traitSet, rootRel.getInputs());
		}
		if (SQL2REL_LOGGER.isDebugEnabled()) {
			SQL2REL_LOGGER.debug(
				RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
					SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
		}
	}
	return rootRel;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:43,代码来源:SqlToRelConverter.java

示例3: create

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

示例4: GremlinCompiler

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的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.rel.RelCollationTraitDef; //导入依赖的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.rel.RelCollationTraitDef; //导入依赖的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: trimUnusedFields

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/**
 * Walks over a tree of relational expressions, replacing each
 * {@link RelNode} with a 'slimmed down' relational expression that projects
 * only the fields required by its consumer.
 *
 * <p>This may make things easier for the optimizer, by removing crud that
 * would expand the search space, but is difficult for the optimizer itself
 * to do it, because optimizer rules must preserve the number and type of
 * fields. Hence, this transform that operates on the entire tree, similar
 * to the {@link RelStructuredTypeFlattener type-flattening transform}.
 *
 * <p>Currently this functionality is disabled in farrago/luciddb; the
 * default implementation of this method does nothing.
 *
 * @param ordered Whether the relational expression must produce results in
 * a particular order (typically because it has an ORDER BY at top level)
 * @param rootRel Relational expression that is at the root of the tree
 * @return Trimmed relational expression
 */
public RelNode trimUnusedFields(boolean ordered, RelNode rootRel) {
  // Trim fields that are not used by their consumer.
  if (isTrimUnusedFields()) {
    final RelFieldTrimmer trimmer = newFieldTrimmer();
    final List<RelCollation> collations =
        rootRel.getTraitSet().getTraits(RelCollationTraitDef.INSTANCE);
    rootRel = trimmer.trim(rootRel);
    if (!ordered
        && collations != null
        && !collations.isEmpty()
        && !collations.equals(ImmutableList.of(RelCollations.EMPTY))) {
      final RelTraitSet traitSet = rootRel.getTraitSet()
          .replace(RelCollationTraitDef.INSTANCE, collations);
      rootRel = rootRel.copy(traitSet, rootRel.getInputs());
    }
    if (SQL2REL_LOGGER.isDebugEnabled()) {
      SQL2REL_LOGGER.debug(
          RelOptUtil.dumpPlan("Plan after trimming unused fields", rootRel,
              SqlExplainFormat.TEXT, SqlExplainLevel.EXPPLAN_ATTRIBUTES));
    }
  }
  return rootRel;
}
 
开发者ID:apache,项目名称:kylin,代码行数:43,代码来源:SqlToRelConverter.java

示例8: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates a LogicalProject, specifying row type rather than field names. */
public static LogicalProject create(final RelNode input,
    final List<? extends RexNode> projects, RelDataType rowType) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet =
      cluster.traitSet().replace(Convention.NONE)
          .replaceIfs(
              RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  return RelMdCollation.project(mq, input, projects);
                }
              });
  return new LogicalProject(cluster, traitSet, input, projects, rowType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:LogicalProject.java

示例9: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
public static LogicalCalc create(final RelNode input,
    final RexProgram program) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet = cluster.traitSet()
      .replace(Convention.NONE)
      .replaceIfs(RelCollationTraitDef.INSTANCE,
          new Supplier<List<RelCollation>>() {
            public List<RelCollation> get() {
              return RelMdCollation.calc(mq, input, program);
            }
          })
      .replaceIf(RelDistributionTraitDef.INSTANCE,
          new Supplier<RelDistribution>() {
            public RelDistribution get() {
              return RelMdDistribution.calc(mq, input, program);
            }
          });
  return new LogicalCalc(cluster, traitSet, input, program);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:LogicalCalc.java

示例10: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates a LogicalFilter. */
public static LogicalFilter create(final RelNode input, RexNode condition,
    ImmutableSet<CorrelationId> variablesSet) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet = cluster.traitSetOf(Convention.NONE)
      .replaceIfs(RelCollationTraitDef.INSTANCE,
          new Supplier<List<RelCollation>>() {
            public List<RelCollation> get() {
              return RelMdCollation.filter(mq, input);
            }
          })
      .replaceIf(RelDistributionTraitDef.INSTANCE,
          new Supplier<RelDistribution>() {
            public RelDistribution get() {
              return RelMdDistribution.filter(mq, input);
            }
          });
  return new LogicalFilter(cluster, traitSet, input, condition, variablesSet);
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:LogicalFilter.java

示例11: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates a LogicalTableScan.
 *
 * @param cluster Cluster
 * @param relOptTable Table
 */
public static LogicalTableScan create(RelOptCluster cluster,
    final RelOptTable relOptTable) {
  final Table table = relOptTable.unwrap(Table.class);
  final RelTraitSet traitSet =
      cluster.traitSetOf(Convention.NONE)
          .replaceIfs(RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  if (table != null) {
                    return table.getStatistic().getCollations();
                  }
                  return ImmutableList.of();
                }
              });
  return new LogicalTableScan(cluster, traitSet, relOptTable);
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:LogicalTableScan.java

示例12: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates an EnumerableValues. */
public static EnumerableValues create(RelOptCluster cluster,
    final RelDataType rowType,
    final ImmutableList<ImmutableList<RexLiteral>> tuples) {
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet =
      cluster.traitSetOf(EnumerableConvention.INSTANCE)
          .replaceIfs(RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  return RelMdCollation.values(mq, rowType, tuples);
                }
              })
          .replaceIf(RelDistributionTraitDef.INSTANCE,
              new Supplier<RelDistribution>() {
                public RelDistribution get() {
                  return RelMdDistribution.values(rowType, tuples);
                }
              });
  return new EnumerableValues(cluster, rowType, tuples, traitSet);
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:EnumerableValues.java

示例13: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates an EnumerableLimit. */
public static EnumerableLimit create(final RelNode input, RexNode offset,
    RexNode fetch) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet =
      cluster.traitSetOf(EnumerableConvention.INSTANCE)
          .replaceIfs(
              RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  return RelMdCollation.limit(mq, input);
                }
              })
          .replaceIf(RelDistributionTraitDef.INSTANCE,
              new Supplier<RelDistribution>() {
                public RelDistribution get() {
                  return RelMdDistribution.limit(mq, input);
                }
              });
  return new EnumerableLimit(cluster, traitSet, input, offset, fetch);
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:EnumerableLimit.java

示例14: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates an EnumerableTableScan. */
public static EnumerableTableScan create(RelOptCluster cluster,
    RelOptTable relOptTable) {
  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 EnumerableTableScan(cluster, traitSet, relOptTable, elementType);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:EnumerableTableScan.java

示例15: create

import org.apache.calcite.rel.RelCollationTraitDef; //导入依赖的package包/类
/** Creates an EnumerableFilter. */
public static EnumerableFilter create(final RelNode input,
    RexNode condition) {
  final RelOptCluster cluster = input.getCluster();
  final RelMetadataQuery mq = cluster.getMetadataQuery();
  final RelTraitSet traitSet =
      cluster.traitSetOf(EnumerableConvention.INSTANCE)
          .replaceIfs(
              RelCollationTraitDef.INSTANCE,
              new Supplier<List<RelCollation>>() {
                public List<RelCollation> get() {
                  return RelMdCollation.filter(mq, input);
                }
              })
          .replaceIf(RelDistributionTraitDef.INSTANCE,
              new Supplier<RelDistribution>() {
                public RelDistribution get() {
                  return RelMdDistribution.filter(mq, input);
                }
              });
  return new EnumerableFilter(cluster, traitSet, input, condition);
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:EnumerableFilter.java


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