org.apache.calcite.adapter.enumerable.EnumerableLimit Java Examples
The following examples show how to use
org.apache.calcite.adapter.enumerable.EnumerableLimit.
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: RelMdMaxRowCount.java From calcite with Apache License 2.0 | 6 votes |
public Double getMaxRowCount(EnumerableLimit rel, RelMetadataQuery mq) { Double rowCount = mq.getMaxRowCount(rel.getInput()); if (rowCount == null) { rowCount = Double.POSITIVE_INFINITY; } final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); rowCount = Math.max(rowCount - offset, 0D); if (rel.fetch != null) { final int limit = RexLiteral.intValue(rel.fetch); if (limit < rowCount) { return (double) limit; } } return rowCount; }
Example #2
Source File: RelMdMinRowCount.java From calcite with Apache License 2.0 | 6 votes |
public Double getMinRowCount(EnumerableLimit rel, RelMetadataQuery mq) { Double rowCount = mq.getMinRowCount(rel.getInput()); if (rowCount == null) { rowCount = 0D; } final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset); rowCount = Math.max(rowCount - offset, 0D); if (rel.fetch != null) { final int limit = RexLiteral.intValue(rel.fetch); if (limit < rowCount) { return (double) limit; } } return rowCount; }
Example #3
Source File: OLAPLimitRel.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { EnumerableRel input = sole(inputs); if (input instanceof OLAPRel) { ((OLAPRel) input).replaceTraitSet(EnumerableConvention.INSTANCE); } return EnumerableLimit.create(input, localOffset, localFetch); }
Example #4
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall relOptRuleCall) { EnumerableLimit limit = relOptRuleCall.rel(0); RelNode convert = convert(limit); if(convert != null){ relOptRuleCall.transformTo(convert); } }
Example #5
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 5 votes |
@Override public void onMatch(RelOptRuleCall relOptRuleCall) { EnumerableLimit limit = relOptRuleCall.rel(0); RelNode convert = convert(limit); if(convert != null){ relOptRuleCall.transformTo(convert); } }
Example #6
Source File: CalcitePlanner.java From herddb with Apache License 2.0 | 5 votes |
private PlannerOp planLimit(EnumerableLimit op, RelDataType rowType) { PlannerOp input = convertRelNode(op.getInput(), rowType, false, false); CompiledSQLExpression maxRows = SQLExpressionCompiler.compileExpression(op.fetch); CompiledSQLExpression offset = SQLExpressionCompiler.compileExpression(op.offset); return new LimitOp(input, maxRows, offset); }
Example #7
Source File: OLAPLimitRel.java From kylin with Apache License 2.0 | 5 votes |
@Override public EnumerableRel implementEnumerable(List<EnumerableRel> inputs) { EnumerableRel input = sole(inputs); if (input instanceof OLAPRel) { ((OLAPRel) input).replaceTraitSet(EnumerableConvention.INSTANCE); } return EnumerableLimit.create(input, localOffset, localFetch); }
Example #8
Source File: CassandraRules.java From calcite with Apache License 2.0 | 5 votes |
/** @see org.apache.calcite.rel.convert.ConverterRule */ public void onMatch(RelOptRuleCall call) { final EnumerableLimit limit = call.rel(0); final RelNode converted = convert(limit); if (converted != null) { call.transformTo(converted); } }
Example #9
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 4 votes |
public ElasticsearchLimitRule() { super(operand(EnumerableLimit.class,operand(ElasticsearchToEnumerableConverter.class,any())),"ElasticsearchLimitRule"); }
Example #10
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 4 votes |
public RelNode convert(EnumerableLimit limit){ RelTraitSet traitSet = limit.getTraitSet().replace(ElasticsearchRelNode.CONVENTION); return new ElasticsearchLimit(limit.getCluster(),traitSet,convert(limit.getInput(),ElasticsearchRelNode.CONVENTION),limit.offset,limit.fetch); }
Example #11
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 4 votes |
public ElasticsearchLimitRule() { super(operand(EnumerableLimit.class,operand(ElasticsearchToEnumerableConverter.class,any())),"ElasticsearchLimitRule"); }
Example #12
Source File: ElasticsearchLimitRule.java From dk-fitting with Apache License 2.0 | 4 votes |
public RelNode convert(EnumerableLimit limit){ RelTraitSet traitSet = limit.getTraitSet().replace(ElasticsearchRelNode.CONVENTION); return new ElasticsearchLimit(limit.getCluster(),traitSet,convert(limit.getInput(),ElasticsearchRelNode.CONVENTION),limit.offset,limit.fetch); }
Example #13
Source File: CassandraRules.java From calcite with Apache License 2.0 | 4 votes |
private CassandraLimitRule() { super(operand(EnumerableLimit.class, operand(CassandraToEnumerableConverter.class, any())), "CassandraLimitRule"); }
Example #14
Source File: CassandraRules.java From calcite with Apache License 2.0 | 4 votes |
public RelNode convert(EnumerableLimit limit) { final RelTraitSet traitSet = limit.getTraitSet().replace(CassandraRel.CONVENTION); return new CassandraLimit(limit.getCluster(), traitSet, convert(limit.getInput(), CassandraRel.CONVENTION), limit.offset, limit.fetch); }
Example #15
Source File: RelUtils.java From sql-gremlin with Apache License 2.0 | 2 votes |
/** * Is this a RelNode we can convert into Gremlin? * @param node the node to check * @return true if a convert operation is supported */ public static Boolean isConvertable(RelNode node) { return !(node instanceof EnumerableAggregate || node instanceof EnumerableCalc || node instanceof EnumerableLimit || node instanceof EnumerableSort); }