本文整理汇总了Java中org.apache.calcite.linq4j.Linq4j.product方法的典型用法代码示例。如果您正苦于以下问题:Java Linq4j.product方法的具体用法?Java Linq4j.product怎么用?Java Linq4j.product使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.linq4j.Linq4j
的用法示例。
在下文中一共展示了Linq4j.product方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cube
import org.apache.calcite.linq4j.Linq4j; //导入方法依赖的package包/类
/** Computes the cube of bit sets.
*
* <p>For example, <code>rollup({0}, {1})</code>
* returns <code>({0, 1}, {0}, {})</code>.
*
* <p>Bit sets are not necessarily singletons:
* <code>rollup({0, 2}, {3, 5})</code>
* returns <code>({0, 2, 3, 5}, {0, 2}, {})</code>. */
@VisibleForTesting
public static ImmutableList<ImmutableBitSet> cube(
List<ImmutableBitSet> bitSets) {
// Given the bit sets [{1}, {2, 3}, {5}],
// form the lists [[{1}, {}], [{2, 3}, {}], [{5}, {}]].
final Set<List<ImmutableBitSet>> builder = Sets.newLinkedHashSet();
for (ImmutableBitSet bitSet : bitSets) {
builder.add(Arrays.asList(bitSet, ImmutableBitSet.of()));
}
Set<ImmutableBitSet> flattenedBitSets = Sets.newLinkedHashSet();
for (List<ImmutableBitSet> o : Linq4j.product(builder)) {
flattenedBitSets.add(ImmutableBitSet.union(o));
}
return ImmutableList.copyOf(flattenedBitSets);
}
示例2: testUnnestItemsInMapWithNoAliasAndAdditionalArgument
import org.apache.calcite.linq4j.Linq4j; //导入方法依赖的package包/类
@Test public void testUnnestItemsInMapWithNoAliasAndAdditionalArgument()
throws SQLException {
Connection connection = DriverManager.getConnection("jdbc:calcite:");
final String sql =
"select * from unnest(MAP['a', 1, 'b', 2], array[5, 6, 7])";
ResultSet resultSet = connection.createStatement().executeQuery(sql);
List<String> map = FlatLists.of("KEY=a; VALUE=1", "KEY=b; VALUE=2");
List<String> array = FlatLists.of(" EXPR$1=5", " EXPR$1=6", " EXPR$1=7");
final StringBuilder b = new StringBuilder();
for (List<String> row : Linq4j.product(FlatLists.of(map, array))) {
b.append(row.get(0)).append(";").append(row.get(1)).append("\n");
}
final String expected = b.toString();
assertThat(CalciteAssert.toString(resultSet), is(expected));
connection.close();
}
示例3: resolve
import org.apache.calcite.linq4j.Linq4j; //导入方法依赖的package包/类
private Resolved resolve() {
final ImmutableList.Builder<ImmutableList<ImmutableBitSet>> builder =
ImmutableList.builder();
List<SqlNode> extraExprs = ImmutableList.of();
Map<Integer, Integer> groupExprProjection = ImmutableMap.of();
if (select.getGroup() != null) {
final SqlNodeList groupList = select.getGroup();
final SqlValidatorUtil.GroupAnalyzer groupAnalyzer =
new SqlValidatorUtil.GroupAnalyzer(temporaryGroupExprList);
for (SqlNode groupExpr : groupList) {
SqlValidatorUtil.analyzeGroupItem(this, groupAnalyzer, builder,
groupExpr);
}
extraExprs = groupAnalyzer.extraExprs;
groupExprProjection = groupAnalyzer.groupExprProjection;
}
final Set<ImmutableBitSet> flatGroupSets =
Sets.newTreeSet(ImmutableBitSet.COMPARATOR);
for (List<ImmutableBitSet> groupSet : Linq4j.product(builder.build())) {
flatGroupSets.add(ImmutableBitSet.union(groupSet));
}
// For GROUP BY (), we need a singleton grouping set.
if (flatGroupSets.isEmpty()) {
flatGroupSets.add(ImmutableBitSet.of());
}
return new Resolved(extraExprs, temporaryGroupExprList, flatGroupSets,
groupExprProjection);
}
示例4: testCartesianProductEnumerator
import org.apache.calcite.linq4j.Linq4j; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test public void testCartesianProductEnumerator() {
final Enumerable<String> abc =
Linq4j.asEnumerable(Arrays.asList("a", "b", "c"));
final Enumerable<String> xy =
Linq4j.asEnumerable(Arrays.asList("x", "y"));
final Enumerator<List<String>> productEmpty =
Linq4j.product(Arrays.<Enumerator<String>>asList());
assertTrue(productEmpty.moveNext());
assertEquals(Arrays.<String>asList(), productEmpty.current());
assertFalse(productEmpty.moveNext());
final Enumerator<List<String>> product0 =
Linq4j.product(
Arrays.asList(Linq4j.<String>emptyEnumerator()));
assertFalse(product0.moveNext());
final Enumerator<List<String>> productFullEmpty =
Linq4j.product(
Arrays.asList(
abc.enumerator(), Linq4j.<String>emptyEnumerator()));
assertFalse(productFullEmpty.moveNext());
final Enumerator<List<String>> productEmptyFull =
Linq4j.product(
Arrays.asList(
abc.enumerator(), Linq4j.<String>emptyEnumerator()));
assertFalse(productEmptyFull.moveNext());
final Enumerator<List<String>> productAbcXy =
Linq4j.product(
Arrays.asList(abc.enumerator(), xy.enumerator()));
assertTrue(productAbcXy.moveNext());
assertEquals(Arrays.asList("a", "x"), productAbcXy.current());
assertTrue(productAbcXy.moveNext());
assertEquals(Arrays.asList("a", "y"), productAbcXy.current());
assertTrue(productAbcXy.moveNext());
assertEquals(Arrays.asList("b", "x"), productAbcXy.current());
assertTrue(productAbcXy.moveNext());
assertTrue(productAbcXy.moveNext());
assertTrue(productAbcXy.moveNext());
assertFalse(productAbcXy.moveNext());
}