当前位置: 首页>>代码示例>>Java>>正文


Java Util.first方法代码示例

本文整理汇总了Java中org.apache.calcite.util.Util.first方法的典型用法代码示例。如果您正苦于以下问题:Java Util.first方法的具体用法?Java Util.first怎么用?Java Util.first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.util.Util的用法示例。


在下文中一共展示了Util.first方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPredicates

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
public RelOptPredicateList getPredicates(RelSubset r,
    RelMetadataQuery mq) {
  if (!Bug.CALCITE_1048_FIXED) {
    return RelOptPredicateList.EMPTY;
  }
  final RexBuilder rexBuilder = r.getCluster().getRexBuilder();
  RelOptPredicateList list = null;
  for (RelNode r2 : r.getRels()) {
    RelOptPredicateList list2 = mq.getPulledUpPredicates(r2);
    if (list2 != null) {
      list = list == null ? list2 : list.union(rexBuilder, list2);
    }
  }
  return Util.first(list, RelOptPredicateList.EMPTY);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelMdPredicates.java

示例2: visit

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public void visit(JsonFunction jsonFunction) {
  // "name" is not required - a class can have several functions
  checkRequiredAttributes(jsonFunction, "className");
  try {
    final SchemaPlus schema = currentMutableSchema("function");
    final List<String> path =
        Util.first(jsonFunction.path, currentSchemaPath());
    create(schema,
        jsonFunction.name,
        path,
        jsonFunction.className,
        jsonFunction.methodName);
  } catch (Exception e) {
    throw new RuntimeException("Error instantiating " + jsonFunction, e);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:ModelHandler.java

示例3: columnStrategies

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Helper for {@link #getColumnStrategies()}. */
public static List<ColumnStrategy> columnStrategies(final RelOptTable table) {
  final int fieldCount = table.getRowType().getFieldCount();
  final InitializerExpressionFactory ief =
      Util.first(table.unwrap(InitializerExpressionFactory.class),
          NullInitializerExpressionFactory.INSTANCE);
  return new AbstractList<ColumnStrategy>() {
    public int size() {
      return fieldCount;
    }

    public ColumnStrategy get(int index) {
      return ief.generationStrategy(table, index);
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:RelOptTableImpl.java

示例4: collation

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
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()));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RelBuilder.java

示例5: HepPlanner

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
 * Creates a new HepPlanner with the option to keep the graph a
 * tree(noDAG=true) or allow DAG(noDAG=false).
 *
 * @param program    program controlling rule application
 * @param onCopyHook Function to call when a node is copied
 */
public HepPlanner(
    HepProgram program,
    Context context,
    boolean noDAG,
    Function2<RelNode, RelNode, Void> onCopyHook,
    RelOptCostFactory costFactory) {
  super(costFactory, context);
  this.mainProgram = program;
  this.onCopyHook =
      Util.first(onCopyHook, Functions.<RelNode, RelNode, Void>ignore2());
  mapDigestToVertex = new HashMap<>();
  graph = DefaultDirectedGraph.create();

  // NOTE jvs 24-Apr-2006:  We use LinkedHashSet here and below
  // in order to provide deterministic behavior.
  allRules = new LinkedHashSet<>();
  this.noDAG = noDAG;
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:HepPlanner.java

示例6: create

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public Schema create(SchemaPlus parentSchema, String name,
    Map<String, Object> operand) {
  Map map = (Map) operand;
  double scale = Util.first((Double) map.get("scale"), 1D);
  int part = Util.first((Integer) map.get("part"), 1);
  int partCount = Util.first((Integer) map.get("partCount"), 1);
  boolean columnPrefix = Util.first((Boolean) map.get("columnPrefix"), true);
  return new TpchSchema(scale, part, partCount, columnPrefix);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:TpchSchemaFactory.java

示例7: create

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public Schema create(SchemaPlus parentSchema, String name,
    Map<String, Object> operand) {
  Map map = (Map) operand;
  double scale = Util.first((Double) map.get("scale"), 1D);
  int part = Util.first((Integer) map.get("part"), 1);
  int partCount = Util.first((Integer) map.get("partCount"), 1);
  boolean columnPrefix = Util.first((Boolean) map.get("columnPrefix"), true);
  return new TpcdsSchema(scale, part, partCount);
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:TpcdsSchemaFactory.java

示例8: estimateJoinedRows

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** @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);
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:Join.java

示例9: toRel

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public RelNode toRel(final RelOptTable table) {
  final RelNode scan = table.toRel(createToRelContext());

  final InitializerExpressionFactory ief =
      Util.first(table.unwrap(InitializerExpressionFactory.class),
          NullInitializerExpressionFactory.INSTANCE);

  // Lazily create a blackboard that contains all non-generated columns.
  final Supplier<Blackboard> bb = new Supplier<Blackboard>() {
    public Blackboard get() {
      RexNode sourceRef = rexBuilder.makeRangeReference(scan);
      return createInsertBlackboard(table, sourceRef,
          table.getRowType().getFieldNames());
    }
  };

  int virtualCount = 0;
  final List<RexNode> list = new ArrayList<>();
  for (RelDataTypeField f : table.getRowType().getFieldList()) {
    final ColumnStrategy strategy =
        ief.generationStrategy(table, f.getIndex());
    switch (strategy) {
    case VIRTUAL:
      list.add(ief.newColumnDefaultValue(table, f.getIndex(), bb.get()));
      ++virtualCount;
      break;
    default:
      list.add(
          rexBuilder.makeInputRef(scan,
              RelOptTableImpl.realOrdinal(table, f.getIndex())));
    }
  }
  if (virtualCount > 0) {
    relBuilder.push(scan);
    relBuilder.project(list);
    return relBuilder.build();
  }
  return scan;
}
 
开发者ID:apache,项目名称:calcite,代码行数:40,代码来源:SqlToRelConverter.java

示例10: explain

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override public void explain(RelWriter pw) {
  // Not a typical implementation of "explain". We don't gather terms &
  // values to be printed later. We actually do the work.
  String s = getDescription();
  pw.item("subset", s);
  final AbstractRelNode input =
      (AbstractRelNode) Util.first(getBest(), getOriginal());
  if (input == null) {
    return;
  }
  input.explainTerms(pw);
  pw.done(input);
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelSubset.java

示例11: SubstitutionVisitor

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public SubstitutionVisitor(RelNode target_, RelNode query_,
    ImmutableList<UnifyRule> rules, RelBuilderFactory relBuilderFactory) {
  this.cluster = target_.getCluster();
  final RexExecutor executor =
      Util.first(cluster.getPlanner().getExecutor(), RexUtil.EXECUTOR);
  final RelOptPredicateList predicates = RelOptPredicateList.EMPTY;
  this.simplify =
      new RexSimplify(cluster.getRexBuilder(), predicates, false, executor);
  this.rules = rules;
  this.query = Holder.of(MutableRels.toMutable(query_));
  this.target = MutableRels.toMutable(target_);
  this.relBuilder = relBuilderFactory.create(cluster, null);
  final Set<MutableRel> parents = Sets.newIdentityHashSet();
  final List<MutableRel> allNodes = new ArrayList<>();
  final MutableRelVisitor visitor =
      new MutableRelVisitor() {
        public void visit(MutableRel node) {
          parents.add(node.getParent());
          allNodes.add(node);
          super.visit(node);
        }
      };
  visitor.go(target);

  // Populate the list of leaves in the tree under "target".
  // Leaves are all nodes that are not parents.
  // For determinism, it is important that the list is in scan order.
  allNodes.removeAll(parents);
  targetLeaves = ImmutableList.copyOf(allNodes);

  allNodes.clear();
  parents.clear();
  visitor.go(query);
  allNodes.removeAll(parents);
  queryLeaves = ImmutableList.copyOf(allNodes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:37,代码来源:SubstitutionVisitor.java

示例12: create

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public static MockModifiableViewRelOptTable create(MockModifiableViewTable modifiableViewTable,
    MockCatalogReader catalogReader, String catalogName, String schemaName, String name,
    boolean stream, double rowCount, ColumnResolver resolver) {
  final Table underlying = modifiableViewTable.unwrap(Table.class);
  final InitializerExpressionFactory initializerExpressionFactory =
      underlying != null && underlying instanceof Wrapper
          ? ((Wrapper) underlying).unwrap(InitializerExpressionFactory.class)
          : NullInitializerExpressionFactory.INSTANCE;
  return new MockModifiableViewRelOptTable(modifiableViewTable,
      catalogReader, catalogName, schemaName, name, stream, rowCount,
      resolver, Util.first(initializerExpressionFactory,
      NullInitializerExpressionFactory.INSTANCE));
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:MockCatalogReader.java

示例13: estimateRowCount

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override public double estimateRowCount(RelMetadataQuery mq) {
  return Util.first(RelMdUtil.getJoinRowCount(mq, this, condition), 1D);
}
 
开发者ID:apache,项目名称:calcite,代码行数:4,代码来源:Join.java

示例14: estimateRowCount

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
@Override public double estimateRowCount(RelMetadataQuery mq) {
  return Util.first(
      RelMdUtil.getSemiJoinRowCount(mq, left, right, joinType, condition),
      1D);
}
 
开发者ID:apache,项目名称:calcite,代码行数:6,代码来源:SemiJoin.java

示例15: getUnit

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Returns {@code SECOND} for both {@code HOUR TO SECOND} and
 * {@code SECOND}. */
public TimeUnit getUnit() {
  return Util.first(timeUnitRange.endUnit, timeUnitRange.startUnit);
}
 
开发者ID:apache,项目名称:calcite,代码行数:6,代码来源:SqlIntervalQualifier.java


注:本文中的org.apache.calcite.util.Util.first方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。