本文整理汇总了Java中org.apache.calcite.util.Pair.of方法的典型用法代码示例。如果您正苦于以下问题:Java Pair.of方法的具体用法?Java Pair.of怎么用?Java Pair.of使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.util.Pair
的用法示例。
在下文中一共展示了Pair.of方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDS
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private Pair<String, Long> createDS(DatasetVersionMutator service, String path, String name, String table, DatasetVersion version,
Pair<String, Long> idVersionPair)
throws NamespaceException, DatasetNotFoundException {
DatasetPath path1 = new DatasetPath(path);
VirtualDatasetUI ds1 = new VirtualDatasetUI();
ds1.setFullPathList(path1.toPathList());
ds1.setVersion(version);
ds1.setSavedVersion(idVersionPair == null ? null : idVersionPair.getValue());
ds1.setName(name);
ds1.setState(new VirtualDatasetState(new FromTable(path1.toPathString()).wrap()));
ds1.getState().setColumnsList(asList(new Column("foo", new ExpColumnReference("bar").wrap())));
ds1.setSql("select * from " + table);
ds1.setId(idVersionPair == null ? null : idVersionPair.getKey());
ViewFieldType type = new ViewFieldType("hello", "float");
ds1.setSqlFieldsList(Collections.singletonList(type));
ds1.setCalciteFieldsList(Collections.singletonList(type));
service.put(ds1);
service.putVersion(ds1);
VirtualDatasetUI dsOut = service.get(path1);
return Pair.of(dsOut.getId(), dsOut.getSavedVersion());
}
示例2: register
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private SyntheticRecordType register(
final SyntheticRecordType syntheticType) {
final List<Pair<Type, Boolean>> key =
new AbstractList<Pair<Type, Boolean>>() {
public Pair<Type, Boolean> get(int index) {
final Types.RecordField field =
syntheticType.getRecordFields().get(index);
return Pair.of(field.getType(), field.nullable());
}
public int size() {
return syntheticType.getRecordFields().size();
}
};
SyntheticRecordType syntheticType2 = syntheticTypes.get(key);
if (syntheticType2 == null) {
syntheticTypes.put(key, syntheticType);
return syntheticType;
} else {
return syntheticType2;
}
}
示例3: implement
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
public void implement(Implementor implementor) {
implementor.visitChild(0, getInput());
final MongoRules.RexToMongoTranslator translator =
new MongoRules.RexToMongoTranslator(
(JavaTypeFactory) getCluster().getTypeFactory(),
MongoRules.mongoFieldNames(getInput().getRowType()));
final List<String> items = new ArrayList<String>();
for (Pair<RexNode, String> pair : getNamedProjects()) {
final String name = pair.right;
final String expr = pair.left.accept(translator);
items.add(expr.equals("'$" + name + "'")
? MongoRules.maybeQuote(name) + ": 1"
: MongoRules.maybeQuote(name) + ": " + expr);
}
final String findString = Util.toString(items, "{", ", ", "}");
final String aggregateString = "{$project: " + findString + "}";
final Pair<String, String> op = Pair.of(findString, aggregateString);
implementor.add(op.left, op.right);
}
示例4: register
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private SyntheticRecordType register(
final SyntheticRecordType syntheticType) {
final List<Pair<Type, Boolean>> key =
new AbstractList<Pair<Type, Boolean>>() {
public Pair<Type, Boolean> get(int index) {
final Types.RecordField field =
syntheticType.getRecordFields().get(index);
return Pair.of(field.getType(), field.nullable());
}
public int size() {
return syntheticType.getRecordFields().size();
}
};
SyntheticRecordType syntheticType2 = syntheticTypes.get(key);
if (syntheticType2 == null) {
syntheticTypes.put(key, syntheticType);
return syntheticType;
} else {
return syntheticType2;
}
}
示例5: selector
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
public Pair<Type, List<Expression>> selector(
ParameterExpression parameter,
List<Integer> fields,
JavaRowFormat targetFormat) {
// Optimize target format
switch (fields.size()) {
case 0:
targetFormat = JavaRowFormat.LIST;
break;
case 1:
targetFormat = JavaRowFormat.SCALAR;
break;
}
final PhysType targetPhysType =
project(fields, targetFormat);
switch (format) {
case SCALAR:
return Pair.of(parameter.getType(),
Collections.<Expression>singletonList(parameter));
default:
return Pair.of(targetPhysType.getJavaRowType(),
fieldReferences(parameter, fields));
}
}
示例6: convertOverlapsOperand
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private Pair<RexNode, RexNode> convertOverlapsOperand(SqlRexContext cx,
SqlParserPos pos, SqlNode operand) {
final SqlNode a0;
final SqlNode a1;
switch (operand.getKind()) {
case ROW:
a0 = ((SqlCall) operand).operand(0);
final SqlNode a10 = ((SqlCall) operand).operand(1);
final RelDataType t1 = cx.getValidator().getValidatedNodeType(a10);
if (SqlTypeUtil.isInterval(t1)) {
// make t1 = t0 + t1 when t1 is an interval.
a1 = plus(pos, a0, a10);
} else {
a1 = a10;
}
break;
default:
a0 = operand;
a1 = operand;
}
final RexNode r0 = cx.convertExpression(a0);
final RexNode r1 = cx.convertExpression(a1);
return Pair.of(r0, r1);
}
示例7: applicableRules
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private List<UnifyRule> applicableRules(MutableRel query,
MutableRel target) {
final Class queryClass = query.getClass();
final Class targetClass = target.getClass();
final Pair<Class, Class> key = Pair.of(queryClass, targetClass);
List<UnifyRule> list = ruleMap.get(key);
if (list == null) {
final ImmutableList.Builder<UnifyRule> builder =
ImmutableList.builder();
for (UnifyRule rule : rules) {
//noinspection unchecked
if (mightMatch(rule, queryClass, targetClass)) {
builder.add(rule);
}
}
list = builder.build();
ruleMap.put(key, list);
}
return list;
}
示例8: findQualifyingTableName
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override public Pair<String, SqlValidatorNamespace>
findQualifyingTableName(final String columnName, SqlNode ctx) {
final SqlNameMatcher nameMatcher = validator.catalogReader.nameMatcher();
final Map<String, ScopeChild> map =
findQualifyingTableNames(columnName, ctx, nameMatcher);
switch (map.size()) {
case 0:
throw validator.newValidationError(ctx,
RESOURCE.columnNotFound(columnName));
case 1:
final Map.Entry<String, ScopeChild> entry =
map.entrySet().iterator().next();
return Pair.of(entry.getKey(), entry.getValue().namespace);
default:
throw validator.newValidationError(ctx,
RESOURCE.columnAmbiguous(columnName));
}
}
示例9: options
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private static List<Pair<SqlIdentifier, SqlNode>> options(
final SqlNodeList optionList) {
return new AbstractList<Pair<SqlIdentifier, SqlNode>>() {
public Pair<SqlIdentifier, SqlNode> get(int index) {
return Pair.of((SqlIdentifier) optionList.get(index * 2),
optionList.get(index * 2 + 1));
}
public int size() {
return optionList.size() / 2;
}
};
}
示例10: split
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
/** Splits this program into a list of project expressions and a list of
* filter expressions.
*
* <p>Neither list is null.
* The filters are evaluated first. */
public Pair<ImmutableList<RexNode>, ImmutableList<RexNode>> split() {
final List<RexNode> filters = Lists.newArrayList();
if (condition != null) {
RelOptUtil.decomposeConjunction(expandLocalRef(condition), filters);
}
final ImmutableList.Builder<RexNode> projects = ImmutableList.builder();
for (RexLocalRef project : this.projects) {
projects.add(expandLocalRef(project));
}
return Pair.of(projects.build(), ImmutableList.copyOf(filters));
}
示例11: splitLeftAndRightColumns
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
/** Splits a column set between left and right sets. */
private static Pair<ImmutableBitSet, ImmutableBitSet>
splitLeftAndRightColumns(int leftCount, final ImmutableBitSet columns) {
ImmutableBitSet.Builder leftBuilder = ImmutableBitSet.builder();
ImmutableBitSet.Builder rightBuilder = ImmutableBitSet.builder();
for (int bit : columns) {
if (bit < leftCount) {
leftBuilder.set(bit);
} else {
rightBuilder.set(bit - leftCount);
}
}
return Pair.of(leftBuilder.build(), rightBuilder.build());
}
示例12: validateAndGetType
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
public Pair<SqlNode, RelDataType> validateAndGetType(SqlNode sqlNode)
throws ValidationException {
final SqlNode validatedNode = this.validate(sqlNode);
final RelDataType type =
this.validator.getValidatedNodeType(validatedNode);
return Pair.of(validatedNode, type);
}
示例13: of2
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
/**
* Creates a reference to a given field in a list of fields.
*/
public static Pair<RexNode, String> of2(
int index,
List<RelDataTypeField> fields) {
final RelDataTypeField field = fields.get(index);
return Pair.of(
(RexNode) new RexInputRef(index, field.getType()),
field.getName());
}
示例14: getComponentTypes
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
private Pair<RelDataType, RelDataType> getComponentTypes(
RelDataTypeFactory typeFactory,
List<RelDataType> argTypes) {
return Pair.of(
typeFactory.leastRestrictive(Util.quotientList(argTypes, 2, 0)),
typeFactory.leastRestrictive(Util.quotientList(argTypes, 2, 1)));
}
示例15: getNamedProjects
import org.apache.calcite.util.Pair; //导入方法依赖的package包/类
/**
* Returns a list of project expressions and their field names.
*/
public List<Pair<RexLocalRef, String>> getNamedProjects() {
return new AbstractList<Pair<RexLocalRef, String>>() {
public int size() {
return projects.size();
}
public Pair<RexLocalRef, String> get(int index) {
return Pair.of(
projects.get(index),
outputRowType.getFieldList().get(index).getName());
}
};
}