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


Java Enumerable类代码示例

本文整理汇总了Java中org.apache.calcite.linq4j.Enumerable的典型用法代码示例。如果您正苦于以下问题:Java Enumerable类的具体用法?Java Enumerable怎么用?Java Enumerable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Override
public StatementExecutionResult execute(TableSpaceManager tableSpaceManager,
        TransactionContext transactionContext,
        StatementEvaluationContext context, boolean lockRequired, boolean forWrite) throws StatementExecutionException {
    ScanResult resLeft = (ScanResult) left.execute(tableSpaceManager, transactionContext,
            context, lockRequired, forWrite);
    transactionContext = new TransactionContext(resLeft.transactionId);
    ScanResult resRight = (ScanResult) right.execute(tableSpaceManager, transactionContext,
            context, lockRequired, forWrite);
    final long resTransactionId = resRight.transactionId;
    final String[] fieldNamesFromLeft = resLeft.dataScanner.getFieldNames();
    final String[] fieldNamesFromRight = resRight.dataScanner.getFieldNames();
    final Function2<DataAccessor, DataAccessor, DataAccessor> resultProjection = resultProjection(fieldNamesFromLeft, fieldNamesFromRight);

    Enumerable<DataAccessor> result = EnumerableDefaults.thetaJoin(resLeft.dataScanner.createEnumerable(),
            resRight.dataScanner.createEnumerable(),
            predicate(resultProjection, context), resultProjection,
            generateNullsOnLeft,
            generateNullsOnRight
    );
    EnumerableDataScanner joinedScanner = new EnumerableDataScanner(resTransactionId, fieldNames, columns, result);
    return new ScanResult(resTransactionId, joinedScanner);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:25,代码来源:ThetaJoinOp.java

示例2: execute

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Override
public StatementExecutionResult execute(TableSpaceManager tableSpaceManager,
        TransactionContext transactionContext, StatementEvaluationContext context, boolean lockRequired, boolean forWrite) throws StatementExecutionException {
    ScanResult resLeft = (ScanResult) left.execute(tableSpaceManager, transactionContext, context, lockRequired, forWrite);
    transactionContext = new TransactionContext(resLeft.transactionId);
    ScanResult resRight = (ScanResult) right.execute(tableSpaceManager, transactionContext, context, lockRequired, forWrite);
    final long resTransactionId = resRight.transactionId;
    Enumerable<DataAccessor> result = EnumerableDefaults.semiJoin(
            resLeft.dataScanner.createEnumerable(),
            resRight.dataScanner.createEnumerable(),
            JoinKey.keyExtractor(leftKeys),
            JoinKey.keyExtractor(rightKeys)
    );
    EnumerableDataScanner joinedScanner = new EnumerableDataScanner(resTransactionId, fieldNames, columns, result);
    return new ScanResult(resTransactionId, joinedScanner);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:SemiJoinOp.java

示例3: createResultSet

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
private <E> MetaResultSet createResultSet(Enumerable<E> enumerable,
                                          Class clazz, String... names) {
    final List<ColumnMetaData> columns = new ArrayList<>();
    final List<Field> fields = new ArrayList<>();
    final List<String> fieldNames = new ArrayList<>();
    for (String name : names) {
        final int index = fields.size();
        final String fieldName = AvaticaUtils.toCamelCase(name);
        final Field field;
        try {
            field = clazz.getField(fieldName);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
        columns.add(columnMetaData(name, index, field.getType()));
        fields.add(field);
        fieldNames.add(fieldName);
    }
    //noinspection unchecked
    final Iterable<Object> iterable = (Iterable<Object>) (Iterable) enumerable;
    return createResultSet(Collections.<String, Object>emptyMap(),
            columns, CursorFactory.record(clazz, fields, fieldNames),
            new Frame(0, true, iterable));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:25,代码来源:CalciteMetaImpl.java

示例4: schemas

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
Enumerable<MetaSchema> schemas(String catalog) {
    return Linq4j.asEnumerable(
            getConnection().getCalciteRootSchema().getSubSchemaMap().values())
            .select(
                    new Function1<CalciteSchema, MetaSchema>() {
                        public MetaSchema apply(CalciteSchema calciteSchema) {
                            return new CalciteMetaSchema(
                                    calciteSchema,
                                    connection.getCatalog(),
                                    calciteSchema.getName());
                        }
                    })
            .orderBy(
                    new Function1<MetaSchema, Comparable>() {
                        public Comparable apply(MetaSchema metaSchema) {
                            return (Comparable) FlatLists.of(
                                    Util.first(metaSchema.tableCatalog, ""),
                                    metaSchema.tableSchem);
                        }
                    });
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:CalciteMetaImpl.java

示例5: enumerable

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
public <T> Enumerable<T> enumerable(Meta.StatementHandle handle,
                                    CalcitePrepare.CalciteSignature<T> signature) throws SQLException {
    Map<String, Object> map = Maps.newLinkedHashMap();
    AvaticaStatement statement = lookupStatement(handle);
    final List<TypedValue> parameterValues =
            TROJAN.getParameterValues(statement);

    if (MetaImpl.checkParameterValueHasNull(parameterValues)) {
        throw new SQLException("exception while executing query: unbound parameter");
    }

    for (Ord<TypedValue> o : Ord.zip(parameterValues)) {
        map.put("?" + o.i, o.e.toLocal());
    }
    map.putAll(signature.internalParameters);
    final DataContext dataContext = createDataContext(map);
    return signature.enumerable(dataContext);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:19,代码来源:CalciteConnectionImpl.java

示例6: createResultSet

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
private <E> MetaResultSet createResultSet(Enumerable<E> enumerable,
    Class clazz, String... names) {
  final List<ColumnMetaData> columns = new ArrayList<>();
  final List<Field> fields = new ArrayList<>();
  final List<String> fieldNames = new ArrayList<>();
  for (String name : names) {
    final int index = fields.size();
    final String fieldName = AvaticaUtils.toCamelCase(name);
    final Field field;
    try {
      field = clazz.getField(fieldName);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    columns.add(columnMetaData(name, index, field.getType(), false));
    fields.add(field);
    fieldNames.add(fieldName);
  }
  //noinspection unchecked
  final Iterable<Object> iterable = (Iterable<Object>) (Iterable) enumerable;
  return createResultSet(Collections.<String, Object>emptyMap(),
      columns, CursorFactory.record(clazz, fields, fieldNames),
      new Frame(0, true, iterable));
}
 
开发者ID:qubole,项目名称:quark,代码行数:25,代码来源:QuarkMetaImpl.java

示例7: scan

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
public Enumerable<Object[]> scan(DataContext root) {
  final Random random = seed >= 0 ? new Random(seed) : new Random();
  final Maze maze = new Maze(width, height);
  final PrintWriter pw = Util.printWriter(System.out);
  maze.layout(random, pw);
  if (Maze.DEBUG) {
    maze.print(pw, true);
  }
  return new AbstractEnumerable<Object[]>() {
    public Enumerator<Object[]> enumerator() {
      final Set<Integer> solutionSet;
      if (solution) {
        solutionSet = maze.solve(0, 0);
      } else {
        solutionSet = null;
      }
      return Linq4j.transform(maze.enumerator(solutionSet),
          new Function1<String, Object[]>() {
            public Object[] apply(String s) {
              return new Object[] {s};
            }
          });
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:MazeTable.java

示例8: flatProduct

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
public static Function1<Object, Enumerable<ComparableList<Comparable>>> flatProduct(
  final int[] fieldCounts, final boolean withOrdinality,
  final FlatProductInputType[] inputTypes) {
if (fieldCounts.length == 1) {
  if (!withOrdinality && inputTypes[0] == FlatProductInputType.SCALAR) {
    //noinspection unchecked
    return (Function1) LIST_AS_ENUMERABLE;
  } else {
    return new Function1<Object, Enumerable<ComparableList<Comparable>>>() {
      public Enumerable<ComparableList<Comparable>> apply(Object row) {
        return p2(new Object[] { row }, fieldCounts, withOrdinality,
              inputTypes);
      }
    };
  }
}
return new Function1<Object, Enumerable<FlatLists.ComparableList<Comparable>>>() {
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:SqlFunctions.java

示例9: createFilterable

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
private static TableScanNode createFilterable(Compiler compiler,
    TableScan rel, ImmutableList<RexNode> filters, ImmutableIntList projects,
    FilterableTable filterableTable) {
  final DataContext root = compiler.getDataContext();
  final List<RexNode> mutableFilters = Lists.newArrayList(filters);
  final Enumerable<Object[]> enumerable =
      filterableTable.scan(root, mutableFilters);
  for (RexNode filter : mutableFilters) {
    if (!filters.contains(filter)) {
      throw RESOURCE.filterableTableInventedFilter(filter.toString()).ex();
    }
  }
  final Enumerable<Row> rowEnumerable = Enumerables.toRow(enumerable);
  return createEnumerable(compiler, rel, rowEnumerable, null,
      mutableFilters, projects);
}
 
开发者ID:apache,项目名称:calcite,代码行数:17,代码来源:TableScanNode.java

示例10: myEnumerable

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
private Enumerable<String> myEnumerable(final int[] closes, final int size) {
  return new AbstractEnumerable<String>() {
    public Enumerator<String> enumerator() {
      return new Enumerator<String>() {
        int i = 0;

        public String current() {
          return "x";
        }

        public boolean moveNext() {
          return i++ < size;
        }

        public void reset() {
        }

        public void close() {
          ++closes[0];
        }
      };
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:Linq4jTest.java

示例11: testTakeWhileEnumerableFunction

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Test public void testTakeWhileEnumerableFunction() {
  final Enumerable<Department> enumerableDepts =
      Linq4j.asEnumerable(depts);
  final List<Department> deptList =
      EnumerableDefaults.takeWhile(
          enumerableDepts,
          new Predicate2<Department, Integer>() {
            int index = 0;

            public boolean apply(Department v1, Integer v2) {
              // Make sure we're passed the correct indices
              assertEquals(
                  "Invalid index passed to function", index++, (int) v2);
              return 20 != v1.deptno;
            }
          }).toList();

  assertEquals(1, deptList.size());
  assertEquals(depts[0], deptList.get(0));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:Linq4jTest.java

示例12: testList2

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Test public void testList2() {
  final List<String> experience = Arrays.asList("jimi", "mitch", "noel");
  final Enumerator<String> enumerator = Linq4j.enumerator(experience);
  assertThat(enumerator.getClass().getName(), endsWith("ListEnumerator"));
  assertThat(count(enumerator), equalTo(3));

  final Enumerable<String> listEnumerable = Linq4j.asEnumerable(experience);
  final Enumerator<String> listEnumerator = listEnumerable.enumerator();
  assertThat(listEnumerator.getClass().getName(),
      endsWith("ListEnumerator"));
  assertThat(count(listEnumerator), equalTo(3));

  final Enumerable<String> linkedListEnumerable =
      Linq4j.asEnumerable(Lists.newLinkedList(experience));
  final Enumerator<String> iterableEnumerator =
      linkedListEnumerable.enumerator();
  assertThat(iterableEnumerator.getClass().getName(),
      endsWith("IterableEnumerator"));
  assertThat(count(iterableEnumerator), equalTo(3));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:Linq4jTest.java

示例13: bindable

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
/** Creates a {@link org.apache.calcite.runtime.Bindable} that interprets a
 * given relational expression. */
public static ArrayBindable bindable(final RelNode rel) {
  if (rel instanceof ArrayBindable) {
    // E.g. if rel instanceof BindableRel
    return (ArrayBindable) rel;
  }
  return new ArrayBindable() {
    public Enumerable<Object[]> bind(DataContext dataContext) {
      return new Interpreter(dataContext, rel);
    }

    public Class<Object[]> getElementType() {
      return Object[].class;
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:Interpreters.java

示例14: testDefaultIfEmpty2

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Test public void testDefaultIfEmpty2() {
  final List<String> experience = Arrays.asList("jimi", "mitch", "noel");
  final Enumerable<String> notEmptyEnumerable =
      Linq4j.asEnumerable(experience).defaultIfEmpty("dummy");
  final Enumerator<String> notEmptyEnumerator = notEmptyEnumerable.enumerator();
  notEmptyEnumerator.moveNext();
  assertEquals("jimi", notEmptyEnumerator.current());
  notEmptyEnumerator.moveNext();
  assertEquals("mitch", notEmptyEnumerator.current());
  notEmptyEnumerator.moveNext();
  assertEquals("noel", notEmptyEnumerator.current());

  final Enumerable<String> emptyEnumerable =
      Linq4j.asEnumerable(Linq4j.<String>emptyEnumerable()).defaultIfEmpty("N/A");
  final Enumerator<String> emptyEnumerator = emptyEnumerable.enumerator();
  assertTrue(emptyEnumerator.moveNext());
  assertEquals("N/A", emptyEnumerator.current());
  assertFalse(emptyEnumerator.moveNext());
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:Linq4jTest.java

示例15: testGroupByWithKeySelectorAndResultSelectorAndComparer

import org.apache.calcite.linq4j.Enumerable; //导入依赖的package包/类
@Test public void testGroupByWithKeySelectorAndResultSelectorAndComparer() {
  String s =
      Linq4j.asEnumerable(emps)
          .groupBy(EMP_DEPTNO_SELECTOR, new Function2<Integer, Enumerable<Employee>, String>() {
            public String apply(Integer key, Enumerable<Employee> group) {
              return String.format(Locale.ROOT, "%s: %s", key,
                  stringJoin("+", group.select(new Function1<Employee, String>() {
                    public String apply(Employee element) {
                      return element.name;
                    }
                  })));
            }
          }, new EqualityComparer<Integer>() {
            public boolean equal(Integer v1, Integer v2) {
              return true;
            }
            public int hashCode(Integer integer) {
              return 0;
            }
          })
          .toList()
          .toString();
  assertEquals(
      "[10: Fred+Bill+Eric+Janet]",
      s);
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:Linq4jTest.java


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