Java Code Examples for org.apache.calcite.rel.logical.LogicalExchange#create()
The following examples show how to use
org.apache.calcite.rel.logical.LogicalExchange#create() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelDistributionTraitDef.java From Bats with Apache License 2.0 | 6 votes |
public RelNode convert(RelOptPlanner planner, RelNode rel, RelDistribution toDistribution, boolean allowInfiniteCostConverters) { if (toDistribution == RelDistributions.ANY) { return rel; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Exchange exchange = LogicalExchange.create(rel, toDistribution); RelNode newRel = planner.register(exchange, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toDistribution); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
Example 2
Source File: RelDistributionTraitDef.java From calcite with Apache License 2.0 | 6 votes |
public RelNode convert(RelOptPlanner planner, RelNode rel, RelDistribution toDistribution, boolean allowInfiniteCostConverters) { if (toDistribution == RelDistributions.ANY) { return rel; } // Create a logical sort, then ask the planner to convert its remaining // traits (e.g. convert it to an EnumerableSortRel if rel is enumerable // convention) final Exchange exchange = LogicalExchange.create(rel, toDistribution); RelNode newRel = planner.register(exchange, rel); final RelTraitSet newTraitSet = rel.getTraitSet().replace(toDistribution); if (!newRel.getTraitSet().equals(newTraitSet)) { newRel = planner.changeTraits(newRel, newTraitSet); } return newRel; }
Example 3
Source File: RelMetadataTest.java From calcite with Apache License 2.0 | 6 votes |
@Test void testNodeTypeCountExchange() { final RelNode rel = convertSql("select * from emp"); final RelDistribution dist = RelDistributions.hash(ImmutableList.<Integer>of()); final LogicalExchange exchange = LogicalExchange.create(rel, dist); final Map<Class<? extends RelNode>, Integer> expected = new HashMap<>(); expected.put(TableScan.class, 1); expected.put(Exchange.class, 1); expected.put(Project.class, 1); final RelMetadataQuery mq = rel.getCluster().getMetadataQuery(); final Multimap<Class<? extends RelNode>, RelNode> result = mq.getNodeTypes(exchange); assertThat(result, notNullValue()); final Map<Class<? extends RelNode>, Integer> resultCount = new HashMap<>(); for (Entry<Class<? extends RelNode>, Collection<RelNode>> e : result.asMap().entrySet()) { resultCount.put(e.getKey(), e.getValue().size()); } assertThat(expected, equalTo(resultCount)); }
Example 4
Source File: RelMetadataTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testRowCountExchange() { final String sql = "select * from emp order by ename limit 123456"; RelNode rel = convertSql(sql); final RelDistribution dist = RelDistributions.hash(ImmutableList.<Integer>of()); final LogicalExchange exchange = LogicalExchange.create(rel, dist); checkExchangeRowCount(exchange, EMP_SIZE, 0D, 123456D); }
Example 5
Source File: RelMetadataTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testDistributionHash() { final RelNode rel = convertSql("select * from emp"); final RelDistribution dist = RelDistributions.hash(ImmutableList.of(1)); final LogicalExchange exchange = LogicalExchange.create(rel, dist); final RelMetadataQuery mq = rel.getCluster().getMetadataQuery(); RelDistribution d = mq.getDistribution(exchange); assertThat(d, is(dist)); }
Example 6
Source File: RelMetadataTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testDistributionHashEmpty() { final RelNode rel = convertSql("select * from emp"); final RelDistribution dist = RelDistributions.hash(ImmutableList.<Integer>of()); final LogicalExchange exchange = LogicalExchange.create(rel, dist); final RelMetadataQuery mq = rel.getCluster().getMetadataQuery(); RelDistribution d = mq.getDistribution(exchange); assertThat(d, is(dist)); }
Example 7
Source File: RelMetadataTest.java From calcite with Apache License 2.0 | 5 votes |
@Test void testDistributionSingleton() { final RelNode rel = convertSql("select * from emp"); final RelDistribution dist = RelDistributions.SINGLETON; final LogicalExchange exchange = LogicalExchange.create(rel, dist); final RelMetadataQuery mq = rel.getCluster().getMetadataQuery(); RelDistribution d = mq.getDistribution(exchange); assertThat(d, is(dist)); }
Example 8
Source File: RelFactories.java From Bats with Apache License 2.0 | 4 votes |
@Override public RelNode createExchange( RelNode input, RelDistribution distribution) { return LogicalExchange.create(input, distribution); }
Example 9
Source File: RelFactories.java From calcite with Apache License 2.0 | 4 votes |
@Override public RelNode createExchange( RelNode input, RelDistribution distribution) { return LogicalExchange.create(input, distribution); }