private final static byte[] B = Bytes.toBytes("b");
@Test
public void testAggregatingMergeSort() throws Throwable {
Tuple[] results1 = new Tuple[] {
new SingleKeyValueTuple(new KeyValue(A, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(1L))),
};
Tuple[] results2 = new Tuple[] {
new SingleKeyValueTuple(new KeyValue(B, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(1L)))
};
Tuple[] results3 = new Tuple[] {
new SingleKeyValueTuple(new KeyValue(A, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(1L))),
new SingleKeyValueTuple(new KeyValue(B, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(1L))),
};
Tuple[] results4 = new Tuple[] {
new SingleKeyValueTuple(new KeyValue(A, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(1L))),
};
final List<PeekingResultIterator>results = new ArrayList<PeekingResultIterator>(Arrays.asList(new PeekingResultIterator[] {
new MaterializedResultIterator(Arrays.asList(results1)),
new MaterializedResultIterator(Arrays.asList(results2)),
new MaterializedResultIterator(Arrays.asList(results3)),
new MaterializedResultIterator(Arrays.asList(results4))}));
Tuple[] expectedResults = new Tuple[] {
new SingleKeyValueTuple(new KeyValue(A, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(3L))),
new SingleKeyValueTuple(new KeyValue(B, SINGLE_COLUMN_FAMILY, SINGLE_COLUMN, PDataType.LONG.toBytes(2L))),
};
PhoenixConnection pconn = DriverManager.getConnection(getUrl(), TEST_PROPERTIES).unwrap(PhoenixConnection.class);
StatementContext context = new StatementContext(new PhoenixStatement(pconn), null, Collections.emptyList(), new Scan());
AggregationManager aggregationManager = context.getAggregationManager();