org.apache.calcite.util.Util.first()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中org.apache.calcite.util.Util.first()方法的一些代码示例,展示了Util.first()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.first()方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:first

Util.first介绍

[英]Unboxes a Boolean value, using a given default value if it is null.
[中]取消绑定布尔值,如果为空,则使用给定的默认值。

代码示例

代码示例来源:origin: apache/hive

Util.first(context.unwrap(RelFactories.AggregateFactory.class),
    HiveRelFactories.HIVE_AGGREGATE_FACTORY);
this.filterFactory =
  Util.first(context.unwrap(RelFactories.FilterFactory.class),
    HiveRelFactories.HIVE_FILTER_FACTORY);
this.projectFactory =
  Util.first(context.unwrap(RelFactories.ProjectFactory.class),
    HiveRelFactories.HIVE_PROJECT_FACTORY);
this.sortFactory =
  Util.first(context.unwrap(RelFactories.SortFactory.class),
    HiveRelFactories.HIVE_SORT_FACTORY);
this.setOpFactory =
  Util.first(context.unwrap(RelFactories.SetOpFactory.class),
    HiveRelFactories.HIVE_SET_OP_FACTORY);
this.joinFactory =
  Util.first(context.unwrap(RelFactories.JoinFactory.class),
    HiveRelFactories.HIVE_JOIN_FACTORY);
this.semiJoinFactory =
  Util.first(context.unwrap(RelFactories.SemiJoinFactory.class),
    HiveRelFactories.HIVE_SEMI_JOIN_FACTORY);
this.correlateFactory =
  Util.first(context.unwrap(RelFactories.CorrelateFactory.class),
    RelFactories.DEFAULT_CORRELATE_FACTORY);
this.valuesFactory =
  Util.first(context.unwrap(RelFactories.ValuesFactory.class),
    RelFactories.DEFAULT_VALUES_FACTORY);
this.scanFactory =
  Util.first(context.unwrap(RelFactories.TableScanFactory.class),
    RelFactories.DEFAULT_TABLE_SCAN_FACTORY);

代码示例来源:origin: apache/hive

private void setCurrent(RelNode root, LogicalCorrelate corRel) {
 currentRel = corRel;
 if (corRel != null) {
  cm = new CorelMapBuilder().build(Util.first(root, corRel));
 }
}

代码示例来源:origin: apache/drill

private void setCurrent(RelNode root, LogicalCorrelate corRel) {
 currentRel = corRel;
 if (corRel != null) {
  cm = new CorelMapBuilder().build(Util.first(root, corRel));
 }
}

代码示例来源:origin: apache/drill

Util.first(context.unwrap(RelFactories.AggregateFactory.class),
        HiveRelFactories.HIVE_AGGREGATE_FACTORY);
this.filterFactory =
    Util.first(context.unwrap(RelFactories.FilterFactory.class),
        HiveRelFactories.HIVE_FILTER_FACTORY);
this.projectFactory =
    Util.first(context.unwrap(RelFactories.ProjectFactory.class),
        HiveRelFactories.HIVE_PROJECT_FACTORY);
this.sortFactory =
    Util.first(context.unwrap(RelFactories.SortFactory.class),
        HiveRelFactories.HIVE_SORT_FACTORY);
this.setOpFactory =
    Util.first(context.unwrap(RelFactories.SetOpFactory.class),
        HiveRelFactories.HIVE_SET_OP_FACTORY);
this.joinFactory =
    Util.first(context.unwrap(RelFactories.JoinFactory.class),
        HiveRelFactories.HIVE_JOIN_FACTORY);
this.semiJoinFactory =
    Util.first(context.unwrap(RelFactories.SemiJoinFactory.class),
        HiveRelFactories.HIVE_SEMI_JOIN_FACTORY);
this.correlateFactory =
    Util.first(context.unwrap(RelFactories.CorrelateFactory.class),
        RelFactories.DEFAULT_CORRELATE_FACTORY);
this.valuesFactory =
    Util.first(context.unwrap(RelFactories.ValuesFactory.class),
        RelFactories.DEFAULT_VALUES_FACTORY);
this.scanFactory =
    Util.first(context.unwrap(RelFactories.TableScanFactory.class),
        RelFactories.DEFAULT_TABLE_SCAN_FACTORY);

代码示例来源:origin: apache/hive

private static RelNode getRelNode(RelNode rel) {
 if (rel != null && rel instanceof HepRelVertex) {
  rel = ((HepRelVertex) rel).getCurrentRel();
 } else if (rel != null && rel instanceof RelSubset) {
  rel = Util.first(((RelSubset)rel).getBest(), ((RelSubset) rel).getOriginal());
 }
 return rel;
}

代码示例来源:origin: apache/hive

private static CalciteUDFInfo getUDFInfo(String hiveUdfName,
  ImmutableList<RelDataType> calciteArgTypes, RelDataType calciteRetType) {
 CalciteUDFInfo udfInfo = new CalciteUDFInfo();
 udfInfo.udfName = hiveUdfName;
 udfInfo.returnTypeInference = ReturnTypes.explicit(calciteRetType);
 udfInfo.operandTypeInference = InferTypes.explicit(calciteArgTypes);
 ImmutableList.Builder<SqlTypeFamily> typeFamilyBuilder = new ImmutableList.Builder<SqlTypeFamily>();
 for (RelDataType at : calciteArgTypes) {
  typeFamilyBuilder.add(Util.first(at.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
 }
 udfInfo.operandTypeChecker = OperandTypes.family(typeFamilyBuilder.build());
 return udfInfo;
}

代码示例来源:origin: apache/hive

@Override
 public void onMatch(RelOptRuleCall call) {
  final RelSubset rel = call.rel(0);
  call.transformTo(Util.first(rel.getBest(), rel.getOriginal()));
 }
}

代码示例来源:origin: apache/hive

private static RelFieldCollation collation(RexNode node,
                      RelFieldCollation.Direction direction,
                      RelFieldCollation.NullDirection nullDirection,
                      List<RexNode> extraNodes) {
 switch (node.getKind()) {
 case INPUT_REF:
  return new RelFieldCollation(((RexInputRef) node).getIndex(), direction,
    Util.first(nullDirection, direction.defaultNullDirection()));
 case DESCENDING:
  return collation(((RexCall) node).getOperands().get(0),
    RelFieldCollation.Direction.DESCENDING,
    nullDirection, extraNodes);
 case NULLS_FIRST:
  return collation(((RexCall) node).getOperands().get(0), direction,
    RelFieldCollation.NullDirection.FIRST, extraNodes);
 case NULLS_LAST:
  return collation(((RexCall) node).getOperands().get(0), direction,
    RelFieldCollation.NullDirection.LAST, extraNodes);
 default:
  final int fieldIndex = extraNodes.size();
  extraNodes.add(node);
  return new RelFieldCollation(fieldIndex, direction,
    Util.first(nullDirection, direction.defaultNullDirection()));
 }
}

代码示例来源:origin: apache/flink

public SqlNodeList expandStar(
  SqlNodeList selectList,
  SqlSelect select,
  boolean includeSystemVars) {
  final List<SqlNode> list = new ArrayList<>();
  final List<Map.Entry<String, RelDataType>> types = new ArrayList<>();
  for (int i = 0; i < selectList.size(); i++) {
    final SqlNode selectItem = selectList.get(i);
    final RelDataType originalType = getValidatedNodeTypeIfKnown(selectItem);
    expandSelectItem(
      selectItem,
      select,
      Util.first(originalType, unknownType),
      list,
      catalogReader.nameMatcher().createSet(),
      types,
      includeSystemVars);
  }
  getRawSelectScope(select).setExpandedSelectList(list);
  return new SqlNodeList(list, SqlParserPos.ZERO);
}

代码示例来源:origin: apache/hive

final String name = nameIterator.hasNext() ? nameIterator.next() : null;
final String name2 = inferAlias(exprList, node);
names.add(Util.first(name, name2));

代码示例来源:origin: apache/drill

private static RelFieldCollation collation(RexNode node,
                      RelFieldCollation.Direction direction,
                      RelFieldCollation.NullDirection nullDirection, List<RexNode> extraNodes) {
 switch (node.getKind()) {
  case INPUT_REF:
   return new RelFieldCollation(((RexInputRef) node).getIndex(), direction,
       Util.first(nullDirection, direction.defaultNullDirection()));
  case DESCENDING:
   return collation(((RexCall) node).getOperands().get(0),
       RelFieldCollation.Direction.DESCENDING,
       nullDirection, extraNodes);
  case NULLS_FIRST:
   return collation(((RexCall) node).getOperands().get(0), direction,
       RelFieldCollation.NullDirection.FIRST, extraNodes);
  case NULLS_LAST:
   return collation(((RexCall) node).getOperands().get(0), direction,
       RelFieldCollation.NullDirection.LAST, extraNodes);
  default:
   final int fieldIndex = extraNodes.size();
   extraNodes.add(node);
   return new RelFieldCollation(fieldIndex, direction,
       Util.first(nullDirection, direction.defaultNullDirection()));
 }
}

代码示例来源:origin: apache/kylin

SqlAggFunction createCustomAggFunction(String funcName, RelDataType returnType, Class<?> customAggFuncClz) {
  RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
  SqlIdentifier sqlIdentifier = new SqlIdentifier(funcName, new SqlParserPos(1, 1));
  AggregateFunction aggFunction = AggregateFunctionImpl.create(customAggFuncClz);
  List<RelDataType> argTypes = new ArrayList<RelDataType>();
  List<SqlTypeFamily> typeFamilies = new ArrayList<SqlTypeFamily>();
  for (FunctionParameter o : aggFunction.getParameters()) {
    final RelDataType type = o.getType(typeFactory);
    argTypes.add(type);
    typeFamilies.add(Util.first(type.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
  }
  return new SqlUserDefinedAggFunction(sqlIdentifier, ReturnTypes.explicit(returnType),
      InferTypes.explicit(argTypes), OperandTypes.family(typeFamilies), aggFunction, false, false,
      typeFactory);
}

代码示例来源:origin: apache/drill

final String name = nameIterator.hasNext() ? nameIterator.next() : null;
final String name2 = inferAlias(exprList, node);
names.add(Util.first(name, name2));

代码示例来源:origin: apache/drill

private static CalciteUDFInfo getUDFInfo(String hiveUdfName,
  ImmutableList<RelDataType> calciteArgTypes, RelDataType calciteRetType) {
 CalciteUDFInfo udfInfo = new CalciteUDFInfo();
 udfInfo.udfName = hiveUdfName;
 udfInfo.returnTypeInference = ReturnTypes.explicit(calciteRetType);
 udfInfo.operandTypeInference = InferTypes.explicit(calciteArgTypes);
 ImmutableList.Builder<SqlTypeFamily> typeFamilyBuilder = new ImmutableList.Builder<SqlTypeFamily>();
 for (RelDataType at : calciteArgTypes) {
  typeFamilyBuilder.add(Util.first(at.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
 }
 udfInfo.operandTypeChecker = OperandTypes.family(typeFamilyBuilder.build());
 return udfInfo;
}

代码示例来源:origin: apache/hive

listBuilder.add(newCondition);
RexExecutor executor =
  Util.first(filterRel.getCluster().getPlanner().getExecutor(), RexUtil.EXECUTOR);
final RexSimplify simplify =
  new RexSimplify(rexBuilder, true, executor);

代码示例来源:origin: org.apache.calcite/calcite-core

/** Returns {@code SECOND} for both {@code HOUR TO SECOND} and
 * {@code SECOND}. */
public TimeUnit getUnit() {
 return Util.first(timeUnitRange.endUnit, timeUnitRange.startUnit);
}

代码示例来源:origin: org.apache.calcite/calcite-core

/** @deprecated Use {@link RelMdUtil#getJoinRowCount(RelMetadataQuery, Join, RexNode)}. */
@Deprecated // to be removed before 2.0
public static double estimateJoinedRows(
  Join joinRel,
  RexNode condition) {
 final RelMetadataQuery mq = RelMetadataQuery.instance();
 return Util.first(RelMdUtil.getJoinRowCount(mq, joinRel, condition), 1D);
}

代码示例来源:origin: org.apache.calcite/calcite-core

public R apply(RelOptCluster cluster, RelOptSchema relOptSchema,
   SchemaPlus rootSchema, CalciteServerStatement statement) {
  final CalciteSchema schema =
    CalciteSchema.from(
      Util.first(config.getDefaultSchema(), rootSchema));
  return action.apply(cluster, relOptSchema, schema.root().plus());
 }
});

代码示例来源:origin: Qihoo360/Quicksql

Enumerable<MetaSchema> schemas(final String catalog) {
 return Linq4j.asEnumerable(
   getConnection().rootSchema.getSubSchemaMap().values())
   .select((Function1<CalciteSchema, MetaSchema>) calciteSchema ->
     new CalciteMetaSchema(calciteSchema, catalog,
       calciteSchema.getName()))
   .orderBy((Function1<MetaSchema, Comparable>) metaSchema ->
     (Comparable) FlatLists.of(Util.first(metaSchema.tableCatalog, ""),
       metaSchema.tableSchem));
}

代码示例来源:origin: Qihoo360/Quicksql

private List<Pair<ColumnMetaData.Rep, Integer>> fieldClasses(
  final JavaTypeFactory typeFactory) {
 final RelDataType rowType = protoRowType.apply(typeFactory);
 return Lists.transform(rowType.getFieldList(), f -> {
  final RelDataType type = f.getType();
  final Class clazz = (Class) typeFactory.getJavaClass(type);
  final ColumnMetaData.Rep rep =
    Util.first(ColumnMetaData.Rep.of(clazz),
      ColumnMetaData.Rep.OBJECT);
  return Pair.of(rep, type.getSqlTypeName().getJdbcOrdinal());
 });
}

相关文章