本文整理汇总了Java中org.apache.calcite.util.Util.skip方法的典型用法代码示例。如果您正苦于以下问题:Java Util.skip方法的具体用法?Java Util.skip怎么用?Java Util.skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.util.Util
的用法示例。
在下文中一共展示了Util.skip方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAggregateCalls
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
* Presents a view of the {@link RexWinAggCall} list as a list of
* {@link AggregateCall}.
*/
public List<AggregateCall> getAggregateCalls(Window windowRel) {
final List<String> fieldNames =
Util.skip(windowRel.getRowType().getFieldNames(),
windowRel.getInput().getRowType().getFieldCount());
return new AbstractList<AggregateCall>() {
public int size() {
return aggCalls.size();
}
public AggregateCall get(int index) {
final RexWinAggCall aggCall = aggCalls.get(index);
final SqlAggFunction op = (SqlAggFunction) aggCall.getOperator();
return AggregateCall.create(op, aggCall.distinct,
false, getProjectOrdinals(aggCall.getOperands()), -1,
aggCall.getType(), fieldNames.get(aggCall.ordinal));
}
};
}
示例2: validateImpl
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
protected RelDataType validateImpl(RelDataType targetRowType) {
final List<String> nameList = new ArrayList<String>();
final List<SqlNode> operands = call.getOperandList();
final SqlValidatorNamespace childNs =
validator.getNamespace(operands.get(0));
final RelDataType rowType = childNs.getRowTypeSansSystemColumns();
final List<SqlNode> columnNames = Util.skip(operands, 2);
for (final SqlNode operand : columnNames) {
String name = ((SqlIdentifier) operand).getSimple();
if (nameList.contains(name)) {
throw validator.newValidationError(operand,
RESOURCE.aliasListDuplicate(name));
}
nameList.add(name);
}
if (nameList.size() != rowType.getFieldCount()) {
// Position error over all column names
final SqlNode node = operands.size() == 3
? operands.get(2)
: new SqlNodeList(columnNames, SqlParserPos.sum(columnNames));
throw validator.newValidationError(node,
RESOURCE.aliasListDegree(rowType.getFieldCount(), getString(rowType),
nameList.size()));
}
final List<RelDataType> typeList = new ArrayList<RelDataType>();
for (RelDataTypeField field : rowType.getFieldList()) {
typeList.add(field.getType());
}
return validator.getTypeFactory().createStructType(
typeList,
nameList);
}
示例3: leafToRanges
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
protected static List<Range<TimestampString>> leafToRanges(RexCall call,
TimeZone timeZone, boolean withNot) {
switch (call.getKind()) {
case EQUALS:
case LESS_THAN:
case LESS_THAN_OR_EQUAL:
case GREATER_THAN:
case GREATER_THAN_OR_EQUAL:
{
final TimestampString value;
if (call.getOperands().get(0) instanceof RexInputRef
&& literalValue(call.getOperands().get(1), timeZone) != null) {
value = literalValue(call.getOperands().get(1), timeZone);
} else if (call.getOperands().get(1) instanceof RexInputRef
&& literalValue(call.getOperands().get(0), timeZone) != null) {
value = literalValue(call.getOperands().get(0), timeZone);
} else {
return null;
}
switch (call.getKind()) {
case LESS_THAN:
return ImmutableList.of(withNot ? Range.atLeast(value) : Range.lessThan(value));
case LESS_THAN_OR_EQUAL:
return ImmutableList.of(withNot ? Range.greaterThan(value) : Range.atMost(value));
case GREATER_THAN:
return ImmutableList.of(withNot ? Range.atMost(value) : Range.greaterThan(value));
case GREATER_THAN_OR_EQUAL:
return ImmutableList.of(withNot ? Range.lessThan(value) : Range.atLeast(value));
default:
if (!withNot) {
return ImmutableList.of(Range.closed(value, value));
}
return ImmutableList.of(Range.lessThan(value), Range.greaterThan(value));
}
}
case BETWEEN:
{
final TimestampString value1;
final TimestampString value2;
if (literalValue(call.getOperands().get(2), timeZone) != null
&& literalValue(call.getOperands().get(3), timeZone) != null) {
value1 = literalValue(call.getOperands().get(2), timeZone);
value2 = literalValue(call.getOperands().get(3), timeZone);
} else {
return null;
}
boolean inverted = value1.compareTo(value2) > 0;
if (!withNot) {
return ImmutableList.of(
inverted ? Range.closed(value2, value1) : Range.closed(value1, value2));
}
return ImmutableList.of(Range.lessThan(inverted ? value2 : value1),
Range.greaterThan(inverted ? value1 : value2));
}
case IN:
{
ImmutableList.Builder<Range<TimestampString>> ranges =
ImmutableList.builder();
for (RexNode operand : Util.skip(call.operands)) {
final TimestampString element = literalValue(operand, timeZone);
if (element == null) {
return null;
}
if (withNot) {
ranges.add(Range.lessThan(element));
ranges.add(Range.greaterThan(element));
} else {
ranges.add(Range.closed(element, element));
}
}
return ranges.build();
}
default:
return null;
}
}
示例4: suffix
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public final List<String> suffix() {
return Util.skip(identifier.names, prefixLength);
}
示例5: resolve_
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
private void resolve_(final CalciteSchema rootSchema, List<String> names,
List<String> schemaNames, SqlNameMatcher nameMatcher, Path path,
Resolved resolved) {
final List<String> concat = ImmutableList.<String>builder()
.addAll(schemaNames).addAll(names).build();
CalciteSchema schema = rootSchema;
SqlValidatorNamespace namespace = null;
List<String> remainingNames = concat;
for (String schemaName : concat) {
if (schema == rootSchema
&& nameMatcher.matches(schemaName, schema.name)) {
remainingNames = Util.skip(remainingNames);
continue;
}
final CalciteSchema subSchema =
schema.getSubSchema(schemaName, nameMatcher.isCaseSensitive());
if (subSchema != null) {
path = path.plus(null, -1, subSchema.name, StructKind.NONE);
remainingNames = Util.skip(remainingNames);
schema = subSchema;
namespace = new SchemaNamespace(validator,
ImmutableList.copyOf(path.stepNames()));
continue;
}
CalciteSchema.TableEntry entry =
schema.getTable(schemaName, nameMatcher.isCaseSensitive());
if (entry == null) {
entry = schema.getTableBasedOnNullaryFunction(schemaName,
nameMatcher.isCaseSensitive());
}
if (entry != null) {
path = path.plus(null, -1, entry.name, StructKind.NONE);
remainingNames = Util.skip(remainingNames);
final Table table = entry.getTable();
SqlValidatorTable table2 = null;
if (table instanceof Wrapper) {
table2 = ((Wrapper) table).unwrap(Prepare.PreparingTable.class);
}
if (table2 == null) {
final RelOptSchema relOptSchema =
validator.catalogReader.unwrap(RelOptSchema.class);
final RelDataType rowType = table.getRowType(validator.typeFactory);
table2 = RelOptTableImpl.create(relOptSchema, rowType, entry, null);
}
namespace = new TableNamespace(validator, table2);
resolved.found(namespace, false, this, path, remainingNames);
return;
}
// neither sub-schema nor table
if (namespace != null
&& !remainingNames.equals(names)) {
resolved.found(namespace, false, this, path, remainingNames);
}
return;
}
}
示例6: numeric
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
private static SqlTypeExplicitPrecedenceList numeric(SqlTypeName typeName) {
int i = getListPosition(typeName, COMPACT_NUMERIC_TYPES);
return new SqlTypeExplicitPrecedenceList(
Util.skip(COMPACT_NUMERIC_TYPES, i));
}
示例7: pushDownEqualJoinConditions
import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
* Pushes down parts of a join condition.
*
* <p>For example, given
* "emp JOIN dept ON emp.deptno + 1 = dept.deptno", adds a project above
* "emp" that computes the expression
* "emp.deptno + 1". The resulting join condition is a simple combination
* of AND, equals, and input fields.
*/
private static RexNode pushDownEqualJoinConditions(
RexNode node,
int leftCount,
int rightCount,
List<RexNode> extraLeftExprs,
List<RexNode> extraRightExprs) {
switch (node.getKind()) {
case AND:
case EQUALS:
final RexCall call = (RexCall) node;
final List<RexNode> list = new ArrayList<>();
List<RexNode> operands = Lists.newArrayList(call.getOperands());
for (int i = 0; i < operands.size(); i++) {
RexNode operand = operands.get(i);
final int left2 = leftCount + extraLeftExprs.size();
final int right2 = rightCount + extraRightExprs.size();
final RexNode e =
pushDownEqualJoinConditions(
operand,
leftCount,
rightCount,
extraLeftExprs,
extraRightExprs);
final List<RexNode> remainingOperands = Util.skip(operands, i + 1);
final int left3 = leftCount + extraLeftExprs.size();
fix(remainingOperands, left2, left3);
fix(list, left2, left3);
list.add(e);
}
if (!list.equals(call.getOperands())) {
return call.clone(call.getType(), list);
}
return call;
case OR:
case INPUT_REF:
case LITERAL:
return node;
default:
final ImmutableBitSet bits = RelOptUtil.InputFinder.bits(node);
final int mid = leftCount + extraLeftExprs.size();
switch (Side.of(bits, mid)) {
case LEFT:
fix(extraRightExprs, mid, mid + 1);
extraLeftExprs.add(node);
return new RexInputRef(mid, node.getType());
case RIGHT:
final int index2 = mid + rightCount + extraRightExprs.size();
extraRightExprs.add(node);
return new RexInputRef(index2, node.getType());
case BOTH:
case EMPTY:
default:
return node;
}
}
}