本文整理汇总了Java中org.apache.calcite.linq4j.Enumerable.enumerator方法的典型用法代码示例。如果您正苦于以下问题:Java Enumerable.enumerator方法的具体用法?Java Enumerable.enumerator怎么用?Java Enumerable.enumerator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.linq4j.Enumerable
的用法示例。
在下文中一共展示了Enumerable.enumerator方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
示例2: testDefaultIfEmpty
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
@Test public void testDefaultIfEmpty() {
final List<String> experience = Arrays.asList("jimi", "mitch", "noel");
final Enumerable<String> notEmptyEnumerable = Linq4j.asEnumerable(experience).defaultIfEmpty();
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();
final Enumerator<String> emptyEnumerator = emptyEnumerable.enumerator();
assertTrue(emptyEnumerator.moveNext());
assertNull(emptyEnumerator.current());
assertFalse(emptyEnumerator.moveNext());
}
示例3: 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());
}
示例4: testJoin
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public void testJoin(CorrelateJoinType joinType, Integer[][] expected) {
Enumerable<Integer[]> join =
Linq4j.asEnumerable(ImmutableList.of(1, 2, 3, 10, 20, 30))
.correlateJoin(joinType,
new Function1<Integer, Enumerable<Integer>>() {
public Enumerable<Integer> apply(Integer a0) {
if (a0 == 1 || a0 == 10) {
return Linq4j.emptyEnumerable();
}
if (a0 == 2 || a0 == 20) {
return Linq4j.singletonEnumerable(a0 * 10);
}
if (a0 == 3 || a0 == 30) {
return Linq4j.asEnumerable(
ImmutableList.of(-a0 * 10, -a0 * 20));
}
throw new IllegalArgumentException(
"Unexpected input " + a0);
}
}, SELECT_BOTH);
for (int i = 0; i < 2; i++) {
Enumerator<Integer[]> e = join.enumerator();
checkResults(e, expected);
e.close();
}
}
示例5: EnumerableDataScanner
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public EnumerableDataScanner(
long transactionId, String[] fieldNames, Column[] schema,
Enumerable<DataAccessor> wrapped) {
super(transactionId, fieldNames, schema);
this.wrapped = wrapped.enumerator();
fetchNext();
}
示例6: enumerator
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public Enumerator<T> enumerator() {
final JavaTypeFactory typeFactory =
((CalciteConnection) queryProvider).getTypeFactory();
final SqlString sql = generateSql();
//noinspection unchecked
final Enumerable<T> enumerable = (Enumerable<T>) ResultSetEnumerable.of(
dataSource.getDataSource(), sql.getSql(),
JdbcUtils.ObjectArrayRowBuilder.factory(fieldClasses(typeFactory)));
return enumerable.enumerator();
}
示例7: testEmptyEnumerable
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
@Test public void testEmptyEnumerable() {
final Enumerable<Object> enumerable = Linq4j.emptyEnumerable();
assertThat(enumerable.any(), is(false));
assertThat(enumerable.longCount(), equalTo(0L));
final Enumerator<Object> enumerator = enumerable.enumerator();
assertThat(enumerator.moveNext(), is(false));
}
示例8: testSingletonEnumerable
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
@Test public void testSingletonEnumerable() {
final Enumerable<String> enumerable = Linq4j.singletonEnumerable("foo");
assertThat(enumerable.any(), is(true));
assertThat(enumerable.longCount(), equalTo(1L));
final Enumerator<String> enumerator = enumerable.enumerator();
assertThat(enumerator.moveNext(), is(true));
assertThat(enumerator.current(), equalTo("foo"));
assertThat(enumerator.moveNext(), is(false));
}
示例9: enumerator
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public Enumerator<T> enumerator() {
final JavaTypeFactory typeFactory =
((CalciteConnection) queryProvider).getTypeFactory();
final SqlString sql = generateSql();
//noinspection unchecked
final Enumerable<T> enumerable = (Enumerable<T>) ResultSetEnumerable.of(
jdbcSchema.getDataSource(),
sql.getSql(),
JdbcUtils.ObjectArrayRowBuilder.factory(fieldClasses(typeFactory)));
return enumerable.enumerator();
}
示例10: implement
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public Node implement(final InterpreterImplementor implementor) {
return new Node() {
public void run() throws InterruptedException {
final Sink sink =
implementor.relSinks.get(EnumerableBindable.this).get(0);
final Enumerable<Object[]> enumerable = bind(implementor.dataContext);
final Enumerator<Object[]> enumerator = enumerable.enumerator();
while (enumerator.moveNext()) {
sink.send(Row.asCopy(enumerator.current()));
}
}
};
}
示例11: setSourceEnumerable
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override public void setSourceEnumerable(Enumerable<Row> enumerable)
throws InterruptedException {
// just copy over the source into the local list
final Enumerator<Row> enumerator = enumerable.enumerator();
while (enumerator.moveNext()) {
this.send(enumerator.current());
}
enumerator.close();
}
示例12: enumerator
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
@Override
public Enumerator<T> enumerator() {
final Enumerable<T> enumerable =
(Enumerable<T>) getTable().project();
return enumerable.enumerator();
}
示例13: enumerator
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public Enumerator<T> enumerator() {
//noinspection unchecked
final Enumerable<T> enumerable =
(Enumerable<T>) getTable().query(getSession());
return enumerable.enumerator();
}
示例14: enumerator
import org.apache.calcite.linq4j.Enumerable; //导入方法依赖的package包/类
public Enumerator<T> enumerator() {
//noinspection unchecked
final Enumerable<T> enumerable =
(Enumerable<T>) getTable().find(getMongoDb(), null, null, null);
return enumerable.enumerator();
}