Java Code Examples for org.apache.flink.runtime.operators.testutils.TestData#getIntIntTupleReader()
The following examples show how to use
org.apache.flink.runtime.operators.testutils.TestData#getIntIntTupleReader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CombiningUnilateralSortMergerITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCombine() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.25, 64, 0.7f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 2
Source File: CombiningUnilateralSortMergerITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCombineSpilling() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 64, 0.005f, true /* use large record handler */, true); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 3
Source File: CombiningUnilateralSortMergerITCase.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testCombineSpillingDisableObjectReuse() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); MaterializedCountCombiner comb = new MaterializedCountCombiner(); // set maxNumFileHandles = 2 to trigger multiple channel merging Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 2, 0.005f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); for (int i = 0; i < noKeyCnt; i++) { rec.setField(i, 0); for (int j = 0; j < noKeys; j++) { rec.setField(j, 1); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(4950, result.next().intValue()); } merger.close(); }
Example 4
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombine() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.25, 64, 0.7f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 5
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombineSpilling() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 64, 0.005f, true /* use large record handler */, true); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 6
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombineSpillingDisableObjectReuse() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); MaterializedCountCombiner comb = new MaterializedCountCombiner(); // set maxNumFileHandles = 2 to trigger multiple channel merging Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 2, 0.005f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); for (int i = 0; i < noKeyCnt; i++) { rec.setField(i, 0); for (int j = 0; j < noKeys; j++) { rec.setField(j, 1); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(4950, result.next().intValue()); } merger.close(); }
Example 7
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombine() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.25, 64, 0.7f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 8
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombineSpilling() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); TestCountCombiner comb = new TestCountCombiner(); Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 64, 0.005f, true /* use large record handler */, true); final Tuple2<Integer, Integer> rec = new Tuple2<>(); rec.setField(1, 1); for (int i = 0; i < noKeyCnt; i++) { for (int j = 0; j < noKeys; j++) { rec.setField(j, 0); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(noKeyCnt, result.next().intValue()); } merger.close(); // if the combiner was opened, it must have been closed Assert.assertTrue(comb.opened == comb.closed); }
Example 9
Source File: CombiningUnilateralSortMergerITCase.java From flink with Apache License 2.0 | 5 votes |
@Test public void testCombineSpillingDisableObjectReuse() throws Exception { int noKeys = 100; int noKeyCnt = 10000; TestData.MockTuple2Reader<Tuple2<Integer, Integer>> reader = TestData.getIntIntTupleReader(); LOG.debug("initializing sortmerger"); MaterializedCountCombiner comb = new MaterializedCountCombiner(); // set maxNumFileHandles = 2 to trigger multiple channel merging Sorter<Tuple2<Integer, Integer>> merger = new CombiningUnilateralSortMerger<>(comb, this.memoryManager, this.ioManager, reader, this.parentTask, this.serializerFactory2, this.comparator2, 0.01, 2, 0.005f, true /* use large record handler */, false); final Tuple2<Integer, Integer> rec = new Tuple2<>(); for (int i = 0; i < noKeyCnt; i++) { rec.setField(i, 0); for (int j = 0; j < noKeys; j++) { rec.setField(j, 1); reader.emit(rec); } } reader.close(); MutableObjectIterator<Tuple2<Integer, Integer>> iterator = merger.getIterator(); Iterator<Integer> result = getReducingIterator(iterator, serializerFactory2.getSerializer(), comparator2.duplicate()); while (result.hasNext()) { Assert.assertEquals(4950, result.next().intValue()); } merger.close(); }