Repository: calcite Updated Branches: refs/heads/master 0a330e79f -> 2817bda61
[CALCITE-2512] Move StreamTest#ROW_GENERATOR to Table.scan().iterator to make it not shared between threads (Sergey Nuyanzin) fixes #813 Project: http://git-wip-us.apache.org/repos/asf/calcite/repo Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/2817bda6 Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/2817bda6 Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/2817bda6 Branch: refs/heads/master Commit: 2817bda61dc8d7dd4249f32f250228f5f0797e24 Parents: 0a330e7 Author: snuyanzin <[email protected]> Authored: Fri Aug 31 12:05:35 2018 +0300 Committer: Vladimir Sitnikov <[email protected]> Committed: Sat Sep 1 04:52:17 2018 +0300 ---------------------------------------------------------------------- .../org/apache/calcite/test/StreamTest.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/calcite/blob/2817bda6/core/src/test/java/org/apache/calcite/test/StreamTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/calcite/test/StreamTest.java b/core/src/test/java/org/apache/calcite/test/StreamTest.java index 502fd61..efa4e8a 100644 --- a/core/src/test/java/org/apache/calcite/test/StreamTest.java +++ b/core/src/test/java/org/apache/calcite/test/StreamTest.java @@ -21,7 +21,6 @@ import org.apache.calcite.avatica.util.DateTimeUtils; import org.apache.calcite.config.CalciteConnectionConfig; import org.apache.calcite.linq4j.Enumerable; import org.apache.calcite.linq4j.Linq4j; -import org.apache.calcite.linq4j.function.Function0; import org.apache.calcite.rel.RelCollations; import org.apache.calcite.rel.type.RelDataType; import org.apache.calcite.rel.type.RelDataTypeFactory; @@ -39,7 +38,6 @@ import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.type.SqlTypeName; import com.google.common.collect.ImmutableList; -import com.google.common.collect.Iterables; import org.junit.Ignore; import org.junit.Test; @@ -449,17 +447,6 @@ public class StreamTest { } } - public static final Function0<Object[]> ROW_GENERATOR = - new Function0<Object[]>() { - private int counter = 0; - private Iterator<String> items = - Iterables.cycle("paint", "paper", "brush").iterator(); - - @Override public Object[] apply() { - return new Object[]{System.currentTimeMillis(), counter++, items.next(), 10}; - } - }; - /** * Table representing an infinitely larger ORDERS stream. */ @@ -467,12 +454,17 @@ public class StreamTest { implements StreamableTable { public Enumerable<Object[]> scan(DataContext root) { return Linq4j.asEnumerable(() -> new Iterator<Object[]>() { + private final String[] items = new String[]{"paint", "paper", "brush"}; + private int counter = 0; + public boolean hasNext() { return true; } public Object[] next() { - return ROW_GENERATOR.apply(); + final int index = counter++; + return new Object[]{ + System.currentTimeMillis(), index, items[index % items.length], 10}; } public void remove() {
