Search in sources :

Example 6 with RunMergingFrameReader

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);
    }
}
Also used : IFrame(org.apache.hyracks.api.comm.IFrame) ArrayList(java.util.ArrayList) RunMergingFrameReader(org.apache.hyracks.dataflow.std.sort.RunMergingFrameReader) IHyracksTaskContext(org.apache.hyracks.api.context.IHyracksTaskContext) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)6 IFrame (org.apache.hyracks.api.comm.IFrame)6 RunMergingFrameReader (org.apache.hyracks.dataflow.std.sort.RunMergingFrameReader)6 HashMap (java.util.HashMap)5 IHyracksTaskContext (org.apache.hyracks.api.context.IHyracksTaskContext)5 Test (org.junit.Test)5 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 IFrameReader (org.apache.hyracks.api.comm.IFrameReader)2 VSizeFrame (org.apache.hyracks.api.comm.VSizeFrame)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)1 GeneratedRunFileReader (org.apache.hyracks.dataflow.common.io.GeneratedRunFileReader)1 ExternalSortRunGenerator (org.apache.hyracks.dataflow.std.sort.ExternalSortRunGenerator)1 GroupVSizeFrame (org.apache.hyracks.dataflow.std.sort.util.GroupVSizeFrame)1