本文整理汇总了Java中org.apache.calcite.rex.RexLiteral.intValue方法的典型用法代码示例。如果您正苦于以下问题:Java RexLiteral.intValue方法的具体用法?Java RexLiteral.intValue怎么用?Java RexLiteral.intValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rex.RexLiteral
的用法示例。
在下文中一共展示了RexLiteral.intValue方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matches
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
@Override
public boolean matches(RelOptRuleCall call) {
final LimitPrel limit = call.rel(0);
final ElasticsearchIntermediatePrel intermediatePrel = call.rel(1);
if (intermediatePrel.hasTerminalPrel()) {
return false;
}
// TODO: this can probably be supported in many cases.
if (limit.getOffset() != null && RexLiteral.intValue(limit.getOffset()) != 0) {
return false;
}
final PlannerSettings plannerSettings = PrelUtil.getPlannerSettings(limit.getCluster().getPlanner());
if (intermediatePrel.contains(ElasticsearchSample.class)
&& limit.getFetch() != null
&& RexLiteral.intValue(limit.getFetch()) >= SampleCrel.getSampleSizeAndSetMinSampleSize(plannerSettings, ElasticSampleRule.SAMPLE_SIZE_DENOMINATOR)) {
return false;
}
return true;
}
示例2: checkInputForCollationAndLimit
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
/** Returns whether a relational expression is already sorted and has fewer
* rows than the sum of offset and limit.
*
* <p>If this is the case, it is safe to push down a
* {@link org.apache.calcite.rel.core.Sort} with limit and optional offset. */
public static boolean checkInputForCollationAndLimit(RelMetadataQuery mq,
RelNode input, RelCollation collation, RexNode offset, RexNode fetch) {
// Check if the input is already sorted
boolean alreadySorted = collation.getFieldCollations().isEmpty();
for (RelCollation inputCollation : mq.collations(input)) {
if (inputCollation.satisfies(collation)) {
alreadySorted = true;
break;
}
}
// Check if we are not reducing the number of tuples
boolean alreadySmaller = true;
final Double rowCount = mq.getMaxRowCount(input);
if (rowCount != null && fetch != null) {
final int offsetVal = offset == null ? 0 : RexLiteral.intValue(offset);
final int limit = RexLiteral.intValue(fetch);
if ((double) offsetVal + (double) limit < rowCount) {
alreadySmaller = false;
}
}
return alreadySorted && alreadySmaller;
}
示例3: getMaxRowCount
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
public Double getMaxRowCount(Sort 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;
}
示例4: getMinRowCount
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
public Double getMinRowCount(Sort 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;
}
示例5: convertLiteral
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private PathSegment convertLiteral(RexLiteral literal) {
switch (literal.getType().getSqlTypeName()) {
case CHAR:
return new NameSegment(RexLiteral.stringValue(literal));
case INTEGER:
return new ArraySegment(RexLiteral.intValue(literal));
default:
return null;
}
}
示例6: getRows
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
@Override
public double getRows() {
int off = offset != null ? RexLiteral.intValue(offset) : 0 ;
if (fetch == null) {
return getInput().getRows() - off;
} else {
int f = RexLiteral.intValue(fetch);
return off + f;
}
}
示例7: estimateRowCount
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
@Override
public double estimateRowCount(RelMetadataQuery mq) {
int off = offset != null ? RexLiteral.intValue(offset) : 0 ;
if (fetch == null) {
return getInput().estimateRowCount(DefaultRelMetadataProvider.INSTANCE.getRelMetadataQuery()) - off;
} else {
int f = RexLiteral.intValue(fetch);
return off + f;
}
}
示例8: merge
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
/**
* Merges this limit with an ElasticsearchSample operator.
* @param sample
* @param treeWithoutLimit
* @return
*/
public ElasticsearchLimit merge(ElasticsearchSample sample, RelNode treeWithoutLimit){
if(sample == null){
return this;
}
long sampleSize = SampleCrel.getSampleSizeAndSetMinSampleSize(PrelUtil.getPlannerSettings(getCluster().getPlanner()), ElasticSampleRule.SAMPLE_SIZE_DENOMINATOR);
int limitAmount = RexLiteral.intValue(getFetch());
int finalLimit = Math.min((int) sampleSize, limitAmount);
RexNode offset = getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(0), getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER));
RexNode fetch = getCluster().getRexBuilder().makeExactLiteral(BigDecimal.valueOf(finalLimit), getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER));
return new ElasticsearchLimit(getCluster(), treeWithoutLimit.getTraitSet(), treeWithoutLimit, offset, fetch, isPushDown(), getPluginId());
}
示例9: getWindowParameterAsMillis
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
private long getWindowParameterAsMillis(RexNode parameterNode) {
if (parameterNode instanceof RexLiteral) {
return RexLiteral.intValue(parameterNode);
} else {
throw new IllegalArgumentException(String.format("[%s] is not valid.", parameterNode));
}
}
示例10: estimateRowCount
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
@Override
public double estimateRowCount(RelMetadataQuery mq) {
int off = offset != null ? RexLiteral.intValue(offset) : 0 ;
if (fetch == null) {
return getInput().estimateRowCount(mq) - off;
} else {
int f = RexLiteral.intValue(fetch);
return off + f;
}
}
示例11: implement
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
public void implement(Implementor implementor) {
implementor.visitChild(0, getInput());
if (offset != null) {
implementor.offset = RexLiteral.intValue(offset);
}
if (fetch != null) {
implementor.fetch = RexLiteral.intValue(fetch);
}
}
示例12: isValid
import org.apache.calcite.rex.RexLiteral; //导入方法依赖的package包/类
@Override public boolean isValid(Litmus litmus, Context context) {
if (!super.isValid(litmus, context)) {
return false;
}
final String signature = signature();
if (!isValidSignature(signature)) {
return litmus.fail("invalid signature [{}]", signature);
}
if (rels.isEmpty()) {
return litmus.fail("must have at least one rel");
}
for (int i = 0; i < rels.size(); i++) {
final RelNode r = rels.get(i);
if (i == 0) {
if (!(r instanceof TableScan)) {
return litmus.fail("first rel must be TableScan, was ", r);
}
if (r.getTable() != table) {
return litmus.fail("first rel must be based on table table");
}
} else {
final List<RelNode> inputs = r.getInputs();
if (inputs.size() != 1 || inputs.get(0) != rels.get(i - 1)) {
return litmus.fail("each rel must have a single input");
}
if (r instanceof Aggregate) {
final Aggregate aggregate = (Aggregate) r;
if (aggregate.getGroupSets().size() != 1
|| aggregate.indicator) {
return litmus.fail("no grouping sets");
}
}
if (r instanceof Filter) {
final Filter filter = (Filter) r;
if (!isValidFilter(filter.getCondition())) {
return litmus.fail("invalid filter [{}]", filter.getCondition());
}
}
if (r instanceof Sort) {
final Sort sort = (Sort) r;
if (sort.offset != null && RexLiteral.intValue(sort.offset) != 0) {
return litmus.fail("offset not supported");
}
}
}
}
return true;
}