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

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

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

Util.quotientList介绍

[英]Creates a list that returns every nth element of a list, starting at element k.

It is OK if the list is empty or its size is not a multiple of n.

For instance, quotientList(list, 2, 0) returns the even elements of a list, and quotientList(list, 2, 1) returns the odd elements. Those lists are the same length only if list has even size.
[中]创建一个列表,从元素k开始,返回列表的每n个元素。
如果列表为空或其大小不是n的倍数,则可以。
例如,商列表(list,2,0)返回列表中的偶数元素,商列表(list,2,1)返回奇数元素。只有当列表的大小相等时,这些列表的长度才相同。

代码示例

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

/** Given a list with N elements
 * [e<sub>0</sub>, e<sub>1</sub>, ..., e<sub>N-1</sub>]
 * (where N is even), returns a list of the N / 2 elements
 * [ (e<sub>0</sub>, e<sub>1</sub>),
 * (e<sub>2</sub>, e<sub>3</sub>), ... ]. */
public static <E> List<Pair<E, E>> pairs(final List<E> list) {
 //noinspection unchecked
 return Pair.zip(quotientList(list, 2, 0),
   quotientList(list, 2, 1));
}

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

/** Converts a list of extended columns
 * (of the form [name0, type0, name1, type1, ...])
 * into a list of (name, type) pairs. */
private static List<Pair<SqlIdentifier, SqlDataTypeSpec>> pairs(
  SqlNodeList extendedColumns) {
 final List list = extendedColumns.getList();
 //noinspection unchecked
 return Pair.zip(Util.quotientList(list, 2, 0),
   Util.quotientList(list, 2, 1));
}

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

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)));
 }
}

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

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)));
 }
}

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

/** Creates a list of (name, type) pairs from {@link #columnList}, in which
 * they alternate. */
private List<Pair<SqlIdentifier, SqlDataTypeSpec>> nameTypes() {
 final List list = columnList.getList();
 //noinspection unchecked
 return Pair.zip((List<SqlIdentifier>) Util.quotientList(list, 2, 0),
   Util.quotientList((List<SqlDataTypeSpec>) list, 2, 1));
}

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

/** Creates a list of (name, type) pairs from {@link #columnList}, in which
 * they alternate. */
private List<Pair<SqlIdentifier, SqlDataTypeSpec>> nameTypes() {
 final List list = columnList.getList();
 //noinspection unchecked
 return Pair.zip((List<SqlIdentifier>) Util.quotientList(list, 2, 0),
   Util.quotientList((List<SqlDataTypeSpec>) list, 2, 1));
}

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

final List<SqlNode> identifierList = Util.quotientList(extendList.getList(), 2, 0);
SqlValidatorUtil.checkIdentifierListForDuplicates(
  identifierList, validator.getValidationErrorFunction());

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

final List<SqlNode> identifierList = Util.quotientList(extendList.getList(), 2, 0);
SqlValidatorUtil.checkIdentifierListForDuplicates(
  identifierList, validator.getValidationErrorFunction());

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

final List list0 = Util.quotientList(beatles, 3, 0);
assertEquals(2, list0.size());
assertEquals("john", list0.get(0));
assertEquals("ringo", list0.get(1));
final List list1 = Util.quotientList(beatles, 3, 1);
assertEquals(1, list1.size());
assertEquals("paul", list1.get(0));
final List list2 = Util.quotientList(beatles, 3, 2);
assertEquals(1, list2.size());
assertEquals("george", list2.get(0));
 final List listBad = Util.quotientList(beatles, 3, 4);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
 final List listBad = Util.quotientList(beatles, 3, 3);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
 final List listBad = Util.quotientList(beatles, 0, 0);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
final List<String> list3 = Util.quotientList(empty, 7, 2);
assertEquals(0, list3.size());
final List list4 = Util.quotientList(beatles, 10, 0);

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

final List list0 = Util.quotientList(beatles, 3, 0);
assertEquals(2, list0.size());
assertEquals("john", list0.get(0));
assertEquals("ringo", list0.get(1));
final List list1 = Util.quotientList(beatles, 3, 1);
assertEquals(1, list1.size());
assertEquals("paul", list1.get(0));
final List list2 = Util.quotientList(beatles, 3, 2);
assertEquals(1, list2.size());
assertEquals("george", list2.get(0));
 final List listBad = Util.quotientList(beatles, 3, 4);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
 final List listBad = Util.quotientList(beatles, 3, 3);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
 final List listBad = Util.quotientList(beatles, 0, 0);
 fail("Expected error, got " + listBad);
} catch (IllegalArgumentException e) {
final List<String> list3 = Util.quotientList(empty, 7, 2);
assertEquals(0, list3.size());
final List list4 = Util.quotientList(beatles, 10, 0);

相关文章