Search in sources :

Example 6 with ArrayBucket

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"));
}
Also used : ArrayBucket(io.crate.data.ArrayBucket) Bucket(io.crate.data.Bucket) ArrayBucket(io.crate.data.ArrayBucket) ArrayList(java.util.ArrayList) Row(io.crate.data.Row) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

ArrayBucket (io.crate.data.ArrayBucket)6 Test (org.junit.Test)5 CrateUnitTest (io.crate.test.integration.CrateUnitTest)4 Bucket (io.crate.data.Bucket)3 Row (io.crate.data.Row)3 ArrayList (java.util.ArrayList)2 Streamer (io.crate.Streamer)1 CollectionBucket (io.crate.data.CollectionBucket)1 DistributedResultRequest (io.crate.executor.transport.distributed.DistributedResultRequest)1 FunctionIdent (io.crate.metadata.FunctionIdent)1 PageResultListener (io.crate.operation.PageResultListener)1 InputCollectExpression (io.crate.operation.collect.InputCollectExpression)1 TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)1 DataType (io.crate.types.DataType)1 UUID (java.util.UUID)1 BytesRef (org.apache.lucene.util.BytesRef)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1