use of org.apache.hyracks.dataflow.std.sort.RunMergingFrameReader in project asterixdb by apache.
the class RunMergingFrameReaderTest method testNormalRunMergeWithTopK.
@Test
public void testNormalRunMergeWithTopK() throws HyracksDataException {
int pageSize = 128;
int numRuns = 2;
int numFramesPerRun = 2;
int minRecordSize = pageSize / 10;
int maxRecordSize = pageSize / 8;
for (int topK = 1; topK < pageSize * numRuns * numFramesPerRun / maxRecordSize / 2; topK++) {
IHyracksTaskContext ctx = testUtils.create(pageSize);
List<Map<Integer, String>> keyValueMapList = new ArrayList<>(numRuns);
List<TestFrameReader> readerList = new ArrayList<>(numRuns);
List<IFrame> frameList = new ArrayList<>(numRuns);
prepareRandomInputRunList(ctx, pageSize, numRuns, numFramesPerRun, minRecordSize, maxRecordSize, readerList, frameList, keyValueMapList);
RunMergingFrameReader reader = new RunMergingFrameReader(ctx, readerList, frameList, SortFields, Comparators, null, RecordDesc, topK);
int totoalCount = testMergeSucceedInner(ctx, reader, keyValueMapList);
int newCount = 0;
for (Map<Integer, String> x : keyValueMapList) {
newCount += x.size();
}
assertEquals(topK + newCount, totoalCount);
}
}
Aggregations