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

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

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

Util.transform介绍

[英]Transforms a list, applying a function to each element.
[中]转换列表,对每个元素应用函数。

代码示例

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

List<String> tableAliases() {
  return Util.transform(tableRefs, tableRef -> tableRef.table.alias);
 }
}

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

/** Returns a list, backed by a list of
 * {@link org.apache.calcite.util.PartiallyOrderedSet.Node}s, that strips
 * away the node and returns the element inside.
 *
 * @param <E> Element type
 */
public static <E> List<E> strip(List<Node<E>> list) {
 if (list.size() == 1
   && list.get(0).e == null) {
  // If parent list contains top element, a node whose element is null,
  // officially there are no parents.
  // Similarly child list and bottom element.
  return ImmutableList.of();
 }
 return Util.transform(list, node -> node.e);
}

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

/** Returns a list, backed by a list of
 * {@link org.apache.calcite.util.PartiallyOrderedSet.Node}s, that strips
 * away the node and returns the element inside.
 *
 * @param <E> Element type
 */
public static <E> List<E> strip(List<Node<E>> list) {
 if (list.size() == 1
   && list.get(0).e == null) {
  // If parent list contains top element, a node whose element is null,
  // officially there are no parents.
  // Similarly child list and bottom element.
  return ImmutableList.of();
 }
 return Util.transform(list, node -> node.e);
}

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

/** Copies this measure, mapping its arguments using a given function. */
 Measure copy(Function<Column, Column> mapper) {
  return new Measure(agg, distinct, name, Util.transform(args, mapper));
 }
}

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

public double getRowCount(List<Attribute> attributes) {
 return lattice.getRowCount(
   Util.transform(attributes, input -> ((AttributeImpl) input).column));
}

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

public double getRowCount(List<Attribute> attributes) {
 return lattice.getRowCount(
   Util.transform(attributes, input -> ((AttributeImpl) input).column));
}

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

/** Assigns a table alias to the top entry on the stack. */
public RelBuilder as(final String alias) {
 final Frame pair = stack.pop();
 List<Field> newFields =
   Util.transform(pair.fields, field -> field.addAlias(alias));
 stack.push(new Frame(pair.rel, ImmutableList.copyOf(newFields)));
 return this;
}

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

/** Assigns a table alias to the top entry on the stack. */
public RelBuilder as(final String alias) {
 final Frame pair = stack.pop();
 List<Field> newFields =
   Util.transform(pair.fields, field -> field.addAlias(alias));
 stack.push(new Frame(pair.rel, ImmutableList.copyOf(newFields)));
 return this;
}

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

protected boolean matchesSafely(List<Lattice> lattices) {
  final Lattice lattice = lattices.get(ordinal);
  final List<String> actualNameList =
    Util.transform(lattice.defaultMeasures, measure -> measure.name);
  return actualNameList.equals(nameList);
 }
};

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

static List<Type> internalTypes(List<? extends RexNode> operandList) {
 return Util.transform(operandList, node -> toInternal(node.getType()));
}

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

static List<Type> internalTypes(List<? extends RexNode> operandList) {
 return Util.transform(operandList, node -> toInternal(node.getType()));
}

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

/** Creates a copy of this collation that changes the ordinals of input
 * fields. */
public static RelCollation permute(RelCollation collation,
  Map<Integer, Integer> mapping) {
 return of(
   Util.transform(collation.getFieldCollations(),
     fc -> fc.copy(mapping.get(fc.getFieldIndex()))));
}

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

protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) {
  return new SqlBinaryStringLiteral(
    BitString.concat(
      Util.transform(literals,
        literal -> ((SqlBinaryStringLiteral) literal).getBitString())),
    literals.get(0).getParserPosition());
 }
}

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

protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) {
  return new SqlBinaryStringLiteral(
    BitString.concat(
      Util.transform(literals,
        literal -> ((SqlBinaryStringLiteral) literal).getBitString())),
    literals.get(0).getParserPosition());
 }
}

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

protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) {
  return new SqlCharStringLiteral(
    NlsString.concat(
      Util.transform(literals,
        literal -> ((SqlCharStringLiteral) literal).getNlsString())),
    literals.get(0).getParserPosition());
 }
}

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

protected SqlAbstractStringLiteral concat1(List<SqlLiteral> literals) {
  return new SqlCharStringLiteral(
    NlsString.concat(
      Util.transform(literals,
        literal -> ((SqlCharStringLiteral) literal).getNlsString())),
    literals.get(0).getParserPosition());
 }
}

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

/** Tests {@link Util#transform(List, java.util.function.Function)}. */
@Test public void testTransform() {
 final List<String> beatles =
   Arrays.asList("John", "Paul", "George", "Ringo");
 final List<String> empty = Collections.emptyList();
 assertThat(Util.transform(beatles, s -> s.toUpperCase(Locale.ROOT)),
   is(Arrays.asList("JOHN", "PAUL", "GEORGE", "RINGO")));
 assertThat(Util.transform(empty, s -> s.toUpperCase(Locale.ROOT)), is(empty));
 assertThat(Util.transform(beatles, String::length),
   is(Arrays.asList(4, 4, 6, 5)));
 assertThat(Util.transform(beatles, String::length),
   instanceOf(RandomAccess.class));
 final List<String> beatles2 = new LinkedList<>(beatles);
 assertThat(Util.transform(beatles2, String::length),
   not(instanceOf(RandomAccess.class)));
}

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

public static MutableAggregate permute(MutableAggregate aggregate,
  MutableRel input, Mapping mapping) {
 ImmutableBitSet groupSet = Mappings.apply(mapping, aggregate.groupSet);
 ImmutableList<ImmutableBitSet> groupSets =
   Mappings.apply2(mapping, aggregate.groupSets);
 List<AggregateCall> aggregateCalls =
   Util.transform(aggregate.aggCalls, call -> call.transform(mapping));
 return MutableAggregate.of(input, groupSet, groupSets, aggregateCalls);
}

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

/** Creates a copy of this collation that changes the ordinals of input
  * fields. */
 public static RelCollation permute(RelCollation collation,
   Mappings.TargetMapping mapping) {
  return of(
    Util.transform(collation.getFieldCollations(),
      fc -> fc.copy(mapping.getTarget(fc.getFieldIndex()))));
 }
}

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

private GroupKey groupKey_(ImmutableBitSet groupSet, boolean indicator,
  @Nonnull ImmutableList<ImmutableBitSet> groupSets) {
 if (groupSet.length() > peek().getRowType().getFieldCount()) {
  throw new IllegalArgumentException("out of bounds: " + groupSet);
 }
 Objects.requireNonNull(groupSets);
 final ImmutableList<RexNode> nodes =
   fields(ImmutableIntList.of(groupSet.toArray()));
 final List<ImmutableList<RexNode>> nodeLists =
   Util.transform(groupSets,
     bitSet -> fields(ImmutableIntList.of(bitSet.toArray())));
 return groupKey_(nodes, indicator, nodeLists);
}

相关文章