本文整理汇总了Java中org.apache.calcite.rel.logical.LogicalTableScan类的典型用法代码示例。如果您正苦于以下问题:Java LogicalTableScan类的具体用法?Java LogicalTableScan怎么用?Java LogicalTableScan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LogicalTableScan类属于org.apache.calcite.rel.logical包,在下文中一共展示了LogicalTableScan类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
InstanceByClassTableScan scan = call.rel(0);
RelOptTable table = scan.getTable();
RelOptSchema schema = table.getRelOptSchema();
List<String> indexName = new ArrayList<String>(table.getQualifiedName());
indexName.set(indexName.size() - 1, "$ids$:" + indexName.get(indexName.size() - 1));
LogicalTableScan ids = LogicalTableScan.create(scan.getCluster(), schema.getTableForMember(indexName));
InstanceByClassTable instanceByClassTable = table.unwrap(InstanceByClassTable.class);
int snapshotId = SnapshotHolder.put(instanceByClassTable.snapshot);
RelOptCluster cluster = scan.getCluster();
RexInputRef objectId = cluster.getRexBuilder().makeInputRef(ids, 0);
RexBuilderContext rexContext = new ExecutionRexBuilderContext(cluster, snapshotId, objectId);
List<Function<RexBuilderContext, RexNode>> resolvers = instanceByClassTable.getResolvers();
List<RexNode> exprs = new ArrayList<RexNode>(resolvers.size());
for (Function<RexBuilderContext, RexNode> resolver : resolvers) {
exprs.add(resolver.apply(rexContext));
}
call.transformTo(RelOptUtil.createProject(ids, exprs, table.getRowType().getFieldNames(), true));
}
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:24,代码来源:InstanceAccessByClassIdRule.java
示例2: onMatch
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final Delta delta = call.rel(0);
final TableScan scan = call.rel(1);
final RelOptCluster cluster = delta.getCluster();
final RelOptTable relOptTable = scan.getTable();
final StreamableTable streamableTable =
relOptTable.unwrap(StreamableTable.class);
if (streamableTable != null) {
final Table table1 = streamableTable.stream();
final RelOptTable relOptTable2 =
RelOptTableImpl.create(relOptTable.getRelOptSchema(),
relOptTable.getRowType(), table1,
ImmutableList.<String>builder()
.addAll(relOptTable.getQualifiedName())
.add("(STREAM)").build());
final LogicalTableScan newScan =
LogicalTableScan.create(cluster, relOptTable2);
call.transformTo(newScan);
}
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:StreamRules.java
示例3: toRel
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
RelNode toRel(Queryable<T> queryable) {
if (queryable instanceof QueryableDefaults.Replayable) {
//noinspection unchecked
((QueryableDefaults.Replayable) queryable).replay(this);
return rel;
}
if (queryable instanceof AbstractTableQueryable) {
final AbstractTableQueryable tableQueryable =
(AbstractTableQueryable) queryable;
final QueryableTable table = tableQueryable.table;
final CalciteSchema.TableEntry tableEntry =
CalciteSchema.from(tableQueryable.schema)
.add(tableQueryable.tableName, tableQueryable.table);
final RelOptTableImpl relOptTable =
RelOptTableImpl.create(null, table.getRowType(translator.typeFactory),
tableEntry, null);
if (table instanceof TranslatableTable) {
return ((TranslatableTable) table).toRel(translator, relOptTable);
} else {
return LogicalTableScan.create(translator.cluster, relOptTable);
}
}
return translator.translate(queryable.getExpression());
}
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:QueryableRelBuilder.java
示例4: toRel
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override public RelNode toRel(ToRelContext context) {
RelNode rel = LogicalTableScan.create(context.getCluster(), fromTable);
final RexBuilder rexBuilder = context.getCluster().getRexBuilder();
rel = LogicalFilter.create(
rel, getConstraint(rexBuilder, rel.getRowType()));
final List<RelDataTypeField> fieldList =
rel.getRowType().getFieldList();
final List<Pair<RexNode, String>> projects =
new AbstractList<Pair<RexNode, String>>() {
@Override public Pair<RexNode, String> get(int index) {
return RexInputRef.of2(mapping.get(index), fieldList);
}
@Override public int size() {
return mapping.size();
}
};
return LogicalProject.create(rel, Pair.left(projects),
Pair.right(projects));
}
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:MockCatalogReader.java
示例5: copyOf
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
private RelNode copyOf(LogicalTableScan rel) {
return new LogicalTableScan(
cluster,
copyOf(rel.getTraitSet()),
rel.getTable()
);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:CopyWithCluster.java
示例6: visit
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override
public RelNode visit(TableScan scan) {
if (scan instanceof CopyToCluster) {
return ((CopyToCluster) scan).copyWith(this);
} else if (scan instanceof LogicalTableScan) {
return copyOf((LogicalTableScan) scan);
}
notSupported(scan);
return super.visit(scan);
}
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:CopyWithCluster.java
示例7: toRel
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
public RelNode toRel(RelOptTable.ToRelContext context,
RelOptTable relOptTable) {
final RelOptCluster cluster = context.getCluster();
final TableScan scan = LogicalTableScan.create(cluster, relOptTable);
return DruidQuery.create(cluster,
cluster.traitSetOf(BindableConvention.INSTANCE), relOptTable, this,
ImmutableList.<RelNode>of(scan));
}
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:DruidTable.java
示例8: onMatch
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final LogicalTableScan oldRel = call.rel(0);
RelNode newRel =
oldRel.getTable().toRel(
RelOptUtil.getContext(oldRel.getCluster()));
call.transformTo(newRel);
}
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:TableScanRule.java
示例9: convert
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override public RelNode convert(RelNode rel) {
LogicalTableScan scan = (LogicalTableScan) rel;
final RelOptTable relOptTable = scan.getTable();
final Table table = relOptTable.unwrap(Table.class);
if (!EnumerableTableScan.canHandle(table)) {
return null;
}
final Expression expression = relOptTable.getExpression(Object.class);
if (expression == null) {
return null;
}
return EnumerableTableScan.create(scan.getCluster(), relOptTable);
}
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:EnumerableTableScanRule.java
示例10: onMatch
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final LogicalTableScan scan = call.rel(0);
final RelOptTable table = scan.getTable();
if (BindableTableScan.canHandle(table)) {
call.transformTo(
BindableTableScan.create(scan.getCluster(), table));
}
}
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:Bindables.java
示例11: testAggregateExtractProjectRule
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Test public void testAggregateExtractProjectRule() {
final String sql = "select sum(sal)\n"
+ "from emp";
HepProgram pre = new HepProgramBuilder()
.addRuleInstance(AggregateProjectMergeRule.INSTANCE)
.build();
final AggregateExtractProjectRule rule =
new AggregateExtractProjectRule(Aggregate.class, LogicalTableScan.class,
RelFactories.LOGICAL_BUILDER);
sql(sql).withPre(pre).withRule(rule).check();
}
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelOptRulesTest.java
示例12: testAggregateExtractProjectRuleWithGroupingSets
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
@Test public void testAggregateExtractProjectRuleWithGroupingSets() {
final String sql = "select empno, deptno, sum(sal)\n"
+ "from emp\n"
+ "group by grouping sets ((empno, deptno),(deptno),(empno))";
HepProgram pre = new HepProgramBuilder()
.addRuleInstance(AggregateProjectMergeRule.INSTANCE)
.build();
final AggregateExtractProjectRule rule =
new AggregateExtractProjectRule(Aggregate.class, LogicalTableScan.class,
RelFactories.LOGICAL_BUILDER);
sql(sql).withPre(pre).withRule(rule).check();
}
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:RelOptRulesTest.java
示例13: testAggregateExtractProjectRuleWithGroupingSets2
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
/** Test with column used in both grouping set and argument to aggregate
* function. */
@Test public void testAggregateExtractProjectRuleWithGroupingSets2() {
final String sql = "select empno, deptno, sum(empno)\n"
+ "from emp\n"
+ "group by grouping sets ((empno, deptno),(deptno),(empno))";
HepProgram pre = new HepProgramBuilder()
.addRuleInstance(AggregateProjectMergeRule.INSTANCE)
.build();
final AggregateExtractProjectRule rule =
new AggregateExtractProjectRule(Aggregate.class, LogicalTableScan.class,
RelFactories.LOGICAL_BUILDER);
sql(sql).withPre(pre).withRule(rule).check();
}
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:RelOptRulesTest.java
示例14: testWriter
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
/**
* Unit test for {@link org.apache.calcite.rel.externalize.RelJsonWriter} on
* a simple tree of relational expressions, consisting of a table, a filter
* and an aggregate node.
*/
@Test public void testWriter() {
String s =
Frameworks.withPlanner(
new Frameworks.PlannerAction<String>() {
public String apply(RelOptCluster cluster,
RelOptSchema relOptSchema, SchemaPlus rootSchema) {
rootSchema.add("hr",
new ReflectiveSchema(new JdbcTest.HrSchema()));
LogicalTableScan scan =
LogicalTableScan.create(cluster,
relOptSchema.getTableForMember(
Arrays.asList("hr", "emps")));
final RexBuilder rexBuilder = cluster.getRexBuilder();
LogicalFilter filter =
LogicalFilter.create(scan,
rexBuilder.makeCall(
SqlStdOperatorTable.EQUALS,
rexBuilder.makeFieldAccess(
rexBuilder.makeRangeReference(scan),
"deptno", true),
rexBuilder.makeExactLiteral(BigDecimal.TEN)));
final RelJsonWriter writer = new RelJsonWriter();
final RelDataType bigIntType =
cluster.getTypeFactory().createSqlType(SqlTypeName.BIGINT);
LogicalAggregate aggregate =
LogicalAggregate.create(filter, ImmutableBitSet.of(0), null,
ImmutableList.of(
AggregateCall.create(SqlStdOperatorTable.COUNT,
true, false, ImmutableList.of(1), -1,
bigIntType, "c"),
AggregateCall.create(SqlStdOperatorTable.COUNT,
false, false, ImmutableList.<Integer>of(), -1,
bigIntType, "d")));
aggregate.explain(writer);
return writer.asString();
}
});
assertThat(s, is(XX));
}
开发者ID:apache,项目名称:calcite,代码行数:45,代码来源:RelWriterTest.java
示例15: BeamIOSourceRule
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
private BeamIOSourceRule() {
super(LogicalTableScan.class, Convention.NONE, BeamLogicalConvention.INSTANCE,
"BeamIOSourceRule");
}
开发者ID:apache,项目名称:beam,代码行数:5,代码来源:BeamIOSourceRule.java
示例16: PigTableScanRule
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
private PigTableScanRule() {
super(LogicalTableScan.class, Convention.NONE, PigRel.CONVENTION, "PigTableScanRule");
}
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:PigRules.java
示例17: convert
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
public RelNode convert(RelNode rel) {
final LogicalTableScan scan = (LogicalTableScan) rel;
final RelTraitSet traitSet = scan.getTraitSet().replace(PigRel.CONVENTION);
return new PigTableScan(rel.getCluster(), traitSet, scan.getTable());
}
开发者ID:apache,项目名称:calcite,代码行数:6,代码来源:PigRules.java
示例18: createScan
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
public RelNode createScan(RelOptCluster cluster, RelOptTable table) {
return LogicalTableScan.create(cluster, table);
}
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:RelFactories.java
示例19: translate
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
public RelNode translate(Expression expression) {
if (expression instanceof MethodCallExpression) {
final MethodCallExpression call = (MethodCallExpression) expression;
BuiltInMethod method = BuiltInMethod.MAP.get(call.method);
if (method == null) {
throw new UnsupportedOperationException(
"unknown method " + call.method);
}
RelNode input;
switch (method) {
case SELECT:
input = translate(call.targetExpression);
return LogicalProject.create(input,
toRex(input, (FunctionExpression) call.expressions.get(0)),
(List<String>) null);
case WHERE:
input = translate(call.targetExpression);
return LogicalFilter.create(input,
toRex((FunctionExpression) call.expressions.get(0), input));
case AS_QUERYABLE:
return LogicalTableScan.create(cluster,
RelOptTableImpl.create(null,
typeFactory.createJavaType(
Types.toClass(
Types.getElementType(call.targetExpression.getType()))),
ImmutableList.<String>of(),
call.targetExpression));
case SCHEMA_GET_TABLE:
return LogicalTableScan.create(cluster,
RelOptTableImpl.create(null,
typeFactory.createJavaType((Class)
((ConstantExpression) call.expressions.get(1)).value),
ImmutableList.<String>of(),
call.targetExpression));
default:
throw new UnsupportedOperationException(
"unknown method " + call.method);
}
}
throw new UnsupportedOperationException(
"unknown expression type " + expression.getNodeType());
}
开发者ID:apache,项目名称:calcite,代码行数:47,代码来源:LixToRelTranslator.java
示例20: EnumerableTableScanRule
import org.apache.calcite.rel.logical.LogicalTableScan; //导入依赖的package包/类
/**
* Creates an EnumerableTableScanRule.
*
* @param relBuilderFactory Builder for relational expressions
*/
public EnumerableTableScanRule(RelBuilderFactory relBuilderFactory) {
super(LogicalTableScan.class, Predicates.<RelNode>alwaysTrue(),
Convention.NONE, EnumerableConvention.INSTANCE, relBuilderFactory,
"EnumerableTableScanRule");
}
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:EnumerableTableScanRule.java
注:本文中的org.apache.calcite.rel.logical.LogicalTableScan类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论