use of io.crate.data.ArrayBucket in project crate by crate.
the class SortedPagingIteratorTest method testTwoBucketsAndTwoPagesAreSortedCorrectly.
@Test
public void testTwoBucketsAndTwoPagesAreSortedCorrectly() throws Exception {
SortedPagingIterator<Void, Row> pagingIterator = new SortedPagingIterator<>(ORDERING, randomBoolean());
pagingIterator.merge(numberedBuckets(Arrays.<Bucket>asList(new ArrayBucket(new Object[][] { new Object[] { "a" }, new Object[] { "b" }, new Object[] { "c" } }), new ArrayBucket(new Object[][] { new Object[] { "x" }, new Object[] { "y" } }))));
List<Object[]> rows = new ArrayList<>();
consumeRows(pagingIterator, rows);
assertThat(rows.size(), is(3));
assertThat(TestingHelpers.printRows(rows), is("a\nb\nc\n"));
pagingIterator.merge(numberedBuckets(Arrays.<Bucket>asList(new ArrayBucket(new Object[][] { new Object[] { "d" }, new Object[] { "e" } }), new ArrayBucket(new Object[][] { new Object[] { "y" }, new Object[] { "z" } }))));
consumeRows(pagingIterator, rows);
assertThat(rows.size(), is(5));
assertThat(TestingHelpers.printRows(rows), is("a\nb\nc\nd\ne\n"));
pagingIterator.finish();
consumeRows(pagingIterator, rows);
assertThat(rows.size(), is(9));
assertThat(TestingHelpers.printRows(rows), is("a\nb\nc\nd\ne\nx\ny\ny\nz\n"));
}
Aggregations