本文整理了Java中org.apache.calcite.rex.RexLiteral.intValue
方法的一些代码示例,展示了RexLiteral.intValue
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RexLiteral.intValue
方法的具体详情如下:
包路径:org.apache.calcite.rex.RexLiteral
类名称:RexLiteral
方法名:intValue
暂无
代码示例来源:origin: apache/hive
@Override
public Double getRowCount(Sort rel, RelMetadataQuery mq) {
final Double rowCount = mq.getRowCount(rel.getInput());
if (rowCount != null && rel.fetch != null) {
final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset);
final int limit = RexLiteral.intValue(rel.fetch);
final Double offsetLimit = new Double(offset + limit);
// offsetLimit is smaller than rowCount of the input operator
// thus, we return the offsetLimit
if (offsetLimit < rowCount) {
return offsetLimit;
}
}
return rowCount;
}
代码示例来源:origin: apache/drill
@Override
public Double getRowCount(Sort rel, RelMetadataQuery mq) {
final Double rowCount = mq.getRowCount(rel.getInput());
if (rowCount != null && rel.fetch != null) {
final int offset = rel.offset == null ? 0 : RexLiteral.intValue(rel.offset);
final int limit = RexLiteral.intValue(rel.fetch);
final Double offsetLimit = new Double(offset + limit);
// offsetLimit is smaller than rowCount of the input operator
// thus, we return the offsetLimit
if (offsetLimit < rowCount) {
return offsetLimit;
}
}
return rowCount;
}
代码示例来源:origin: apache/hive
@Override
public boolean matches(RelOptRuleCall call) {
final HiveSortLimit sort = call.rel(0);
final HiveUnion union = call.rel(1);
// We only apply this rule if Union.all is true.
// And Sort.fetch is not null and it is more than 0.
return union.all && sort.fetch != null
// Calite bug CALCITE-987
&& RexLiteral.intValue(sort.fetch) > 0;
}
代码示例来源:origin: apache/drill
@Override
public boolean matches(RelOptRuleCall call) {
final HiveSortLimit sort = call.rel(0);
final HiveUnion union = call.rel(1);
// We only apply this rule if Union.all is true.
// And Sort.fetch is not null and it is more than 0.
return union.all && sort.fetch != null
// Calite bug CALCITE-987
&& RexLiteral.intValue(sort.fetch) > 0;
}
代码示例来源:origin: apache/incubator-druid
final int firstOffset = (first.offset != null ? RexLiteral.intValue(first.offset) : 0);
final int secondOffset = (second.offset != null ? RexLiteral.intValue(second.offset) : 0);
} else if (first.fetch == null) {
fetch = RexLiteral.intValue(second.fetch);
} else if (second.fetch == null) {
fetch = Math.max(0, RexLiteral.intValue(first.fetch) - secondOffset);
} else {
fetch = Math.max(
0,
Math.min(
RexLiteral.intValue(first.fetch) - secondOffset,
RexLiteral.intValue(second.fetch)
代码示例来源:origin: apache/incubator-druid
return null;
final int index = RexLiteral.intValue(call.getOperands().get(1)) - 1;
final int length;
if (call.getOperands().size() > 2) {
length = RexLiteral.intValue(call.getOperands().get(2));
} else {
length = -1;
代码示例来源:origin: apache/hive
if (HiveCalciteUtil.limitRelNode(bottomSortLimit)) {
final RexBuilder rexBuilder = topSortLimit.getCluster().getRexBuilder();
int topOffset = topSortLimit.offset == null ? 0 : RexLiteral.intValue(topSortLimit.offset);
int topLimit = RexLiteral.intValue(topSortLimit.fetch);
int bottomOffset = bottomSortLimit.offset == null ? 0 : RexLiteral.intValue(bottomSortLimit.offset);
int bottomLimit = RexLiteral.intValue(bottomSortLimit.fetch);
代码示例来源:origin: apache/drill
if (HiveCalciteUtil.limitRelNode(bottomSortLimit)) {
final RexBuilder rexBuilder = topSortLimit.getCluster().getRexBuilder();
int topOffset = topSortLimit.offset == null ? 0 : RexLiteral.intValue(topSortLimit.offset);
int topLimit = RexLiteral.intValue(topSortLimit.fetch);
int bottomOffset = bottomSortLimit.offset == null ? 0 : RexLiteral.intValue(bottomSortLimit.offset);
int bottomLimit = RexLiteral.intValue(bottomSortLimit.fetch);
代码示例来源:origin: apache/incubator-druid
@Override
public void onMatch(final RelOptRuleCall call)
{
final Sort sort = call.rel(0);
final DruidUnionRel unionRel = call.rel(1);
final int limit = RexLiteral.intValue(sort.fetch);
final int offset = sort.offset != null ? RexLiteral.intValue(sort.offset) : 0;
final DruidUnionRel newUnionRel = DruidUnionRel.create(
unionRel.getQueryMaker(),
unionRel.getRowType(),
unionRel.getInputs(),
unionRel.getLimit() >= 0 ? Math.min(limit + offset, unionRel.getLimit()) : limit + offset
);
if (offset == 0) {
call.transformTo(newUnionRel);
} else {
call.transformTo(
call.builder()
.push(newUnionRel)
.sortLimit(offset, -1, Collections.emptyList())
.build()
);
}
}
}
代码示例来源:origin: apache/hive
@Override
public boolean matches(RelOptRuleCall call) {
final HiveSortLimit sortLimit = call.rel(0);
// If it is not created by HiveSortJoinReduceRule, we cannot remove it
if (!sortLimit.isRuleCreated()) {
return false;
}
// Finally, if we do not reduce the size input enough, we bail out
int limit = RexLiteral.intValue(sortLimit.fetch);
Double rowCount = call.getMetadataQuery().getRowCount(sortLimit.getInput());
if (rowCount != null && limit <= reductionProportion * rowCount &&
rowCount - limit >= reductionTuples) {
return false;
}
return true;
}
代码示例来源:origin: apache/hive
final int index = RexLiteral.intValue(call.getOperands().get(1)) - 1;
indexStart = DruidExpressions.numberLiteral(index);
length = DruidExpressions.numberLiteral(RexLiteral.intValue(call.getOperands().get(2)));
代码示例来源:origin: apache/drill
@Override
public boolean matches(RelOptRuleCall call) {
final HiveSortLimit sortLimit = call.rel(0);
// If it is not created by HiveSortJoinReduceRule, we cannot remove it
if (!sortLimit.isRuleCreated()) {
return false;
}
// Finally, if we do not reduce the size input enough, we bail out
int limit = RexLiteral.intValue(sortLimit.fetch);
Double rowCount = RelMetadataQuery.instance().getRowCount(sortLimit.getInput());
if (rowCount != null && limit <= reductionProportion * rowCount &&
rowCount - limit >= reductionTuples) {
return false;
}
return true;
}
代码示例来源:origin: apache/hive
final int offset = sort.offset == null ? 0 : RexLiteral.intValue(sort.offset);
for (RelNode input : union.getInputs()) {
if (RexLiteral.intValue(sort.fetch) + offset < call.getMetadataQuery().getRowCount(input)) {
finishPushSortPastUnion = false;
.makeExactLiteral(BigDecimal.valueOf(RexLiteral.intValue(sort.fetch) + offset));
HiveSortLimit branchSort = sort.copy(sort.getTraitSet(), input, sort.getCollation(), null,
fetchRN);
代码示例来源:origin: apache/incubator-druid
final Integer limit = sort.fetch != null ? RexLiteral.intValue(sort.fetch) : null;
final List<OrderByColumnSpec> orderBys = new ArrayList<>(sort.getChildExps().size());
代码示例来源:origin: apache/drill
final int offset = sort.offset == null ? 0 : RexLiteral.intValue(sort.offset);
for (RelNode input : union.getInputs()) {
if (RexLiteral.intValue(sort.fetch) + offset < RelMetadataQuery.instance().getRowCount(input)) {
finishPushSortPastUnion = false;
.makeExactLiteral(BigDecimal.valueOf(RexLiteral.intValue(sort.fetch) + offset));
HiveSortLimit branchSort = sort.copy(sort.getTraitSet(), input, sort.getCollation(), null,
fetchRN);
代码示例来源:origin: apache/hive
private BoundarySpec getWindowBound(RexWindowBound wb) {
BoundarySpec boundarySpec;
if (wb.isCurrentRow()) {
boundarySpec = new BoundarySpec(Direction.CURRENT);
} else {
final Direction direction;
final int amt;
if (wb.isPreceding()) {
direction = Direction.PRECEDING;
} else {
direction = Direction.FOLLOWING;
}
if (wb.isUnbounded()) {
amt = BoundarySpec.UNBOUNDED_AMOUNT;
} else {
amt = RexLiteral.intValue(wb.getOffset());
}
boundarySpec = new BoundarySpec(direction, amt);
}
return boundarySpec;
}
代码示例来源:origin: apache/incubator-druid
);
} else if (aggregateCall.getAggregation().getKind() == SqlKind.SUM
&& Calcites.isIntLiteral(arg1) && RexLiteral.intValue(arg1) == 1
&& Calcites.isIntLiteral(arg2) && RexLiteral.intValue(arg2) == 0) {
|| (aggregateCall.getAggregation().getKind() == SqlKind.SUM
&& Calcites.isIntLiteral(arg2)
&& RexLiteral.intValue(arg2) == 0) /* Case A2 */) {
newProjects.add(arg1);
newProjects.add(filter);
代码示例来源:origin: apache/drill
private BoundarySpec getWindowBound(RexWindowBound wb) {
BoundarySpec boundarySpec;
if (wb.isCurrentRow()) {
boundarySpec = new BoundarySpec(Direction.CURRENT);
} else {
final Direction direction;
final int amt;
if (wb.isPreceding()) {
direction = Direction.PRECEDING;
} else {
direction = Direction.FOLLOWING;
}
if (wb.isUnbounded()) {
amt = BoundarySpec.UNBOUNDED_AMOUNT;
} else {
amt = RexLiteral.intValue(wb.getOffset());
}
boundarySpec = new BoundarySpec(direction, amt);
}
return boundarySpec;
}
代码示例来源:origin: apache/drill
private GroupScan getGroupScanWithLimit(GroupScan groupScan, LimitPrel limit) {
final int offset = limit.getOffset() != null ? Math.max(0, RexLiteral.intValue(limit.getOffset())) : 0;
final int fetch = Math.max(0, RexLiteral.intValue(limit.getFetch()));
// Scan Limit uses conservative approach: use offset 0 and fetch = parent limit offset + parent limit fetch.
if (groupScan instanceof JsonTableGroupScan) {
JsonTableGroupScan jsonTableGroupScan = (JsonTableGroupScan) groupScan;
return (jsonTableGroupScan.clone(jsonTableGroupScan.getScanSpec()).applyLimit(offset + fetch));
} else if (groupScan instanceof BinaryTableGroupScan) {
BinaryTableGroupScan binaryTableGroupScan = (BinaryTableGroupScan) groupScan;
final HBaseScanSpec oldScanSpec = binaryTableGroupScan.getHBaseScanSpec();
final HBaseScanSpec newScanSpec = new HBaseScanSpec(oldScanSpec.getTableName(), oldScanSpec.getStartRow(),
oldScanSpec.getStopRow(), oldScanSpec.getFilter());
return new BinaryTableGroupScan(binaryTableGroupScan.getUserName(), binaryTableGroupScan.getStoragePlugin(),
binaryTableGroupScan.getFormatPlugin(), newScanSpec, binaryTableGroupScan.getColumns(),
binaryTableGroupScan.getTableStats()).applyLimit(offset + fetch);
}
return null;
}
代码示例来源:origin: apache/hive
RexLiteral.intValue(sortLimit.fetch) == 0) {
return false;
final int offset = sortLimit.offset == null ? 0 : RexLiteral.intValue(sortLimit.offset);
final RelMetadataQuery mq = call.getMetadataQuery();
if (offset + RexLiteral.intValue(sortLimit.fetch)
>= mq.getRowCount(reducedInput)) {
return false;
内容来源于网络,如有侵权,请联系作者删除!