use of io.crate.analyze.OrderBy in project crate by crate.
the class NodeStatsIteratorTest method testNodeStatsIteratorContrat.
@Test
public void testNodeStatsIteratorContrat() throws Exception {
List<Symbol> toCollect = new ArrayList<>();
toCollect.add(idRef);
when(collectPhase.toCollect()).thenReturn(toCollect);
when(collectPhase.whereClause()).thenReturn(WhereClause.MATCH_ALL);
when(collectPhase.orderBy()).thenReturn(new OrderBy(Collections.singletonList(idRef), new boolean[] { false }, new Boolean[] { true }));
List<Object[]> expectedResult = Arrays.asList(new Object[] { new BytesRef("nodeOne") }, new Object[] { new BytesRef("nodeTwo") });
BatchIteratorTester tester = new BatchIteratorTester(() -> NodeStatsIterator.newInstance(transportNodeStatsAction, collectPhase, nodes, new InputFactory(getFunctions())));
tester.verifyResultAndEdgeCaseBehaviour(expectedResult);
}
use of io.crate.analyze.OrderBy in project crate by crate.
the class OrderedLuceneBatchIteratorFactoryTest method prepareSearchers.
@Before
public void prepareSearchers() throws Exception {
IndexWriter iw1 = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
IndexWriter iw2 = new IndexWriter(new RAMDirectory(), new IndexWriterConfig(new StandardAnalyzer()));
expectedResult = LongStream.range(0, 20).mapToObj(i -> new Object[] { i }).collect(Collectors.toList());
// expect descending order to differentiate between insert order
expectedResult.sort(Comparator.comparingLong((Object[] o) -> ((long) o[0])).reversed());
for (int i = 0; i < 20; i++) {
Document doc = new Document();
doc.add(new NumericDocValuesField(columnName, i));
if (i % 2 == 0) {
iw1.addDocument(doc);
} else {
iw2.addDocument(doc);
}
}
iw1.commit();
iw2.commit();
searcher1 = new IndexSearcher(DirectoryReader.open(iw1, true));
searcher2 = new IndexSearcher(DirectoryReader.open(iw2, true));
fieldTypeLookup = columnName -> {
LongFieldMapper.LongFieldType longFieldType = new LongFieldMapper.LongFieldType();
longFieldType.setNames(new MappedFieldType.Names(columnName));
return longFieldType;
};
orderBy = new OrderBy(Collections.singletonList(reference), reverseFlags, nullsFirst);
}
Aggregations