Search in sources :

Example 16 with IntPair

use of com.linkedin.pinot.common.utils.Pairs.IntPair in project pinot by linkedin.

the class SortedDocIdSetTest method testCustomRange.

private void testCustomRange(String rangeString) {
    String trim = rangeString.replace('[', ' ').replace(']', ' ').replace('(', ' ').replace(')', ' ').replaceAll("[\\s]+", "");
    String[] splits = trim.split(",");
    Assert.assertTrue(splits.length % 2 == 0);
    List<Integer> expectedList = new ArrayList<Integer>();
    List<IntPair> pairs = new ArrayList<IntPair>();
    for (int i = 0; i < splits.length; i += 2) {
        int start = Integer.parseInt(splits[i]);
        int end = Integer.parseInt(splits[i + 1]);
        for (int val = start; val <= end; val++) {
            expectedList.add(val);
        }
        pairs.add(Pairs.intPair(start, end));
    }
    SortedDocIdSet sortedDocIdSet = new SortedDocIdSet("Datasource-testCol", pairs);
    BlockDocIdIterator iterator = sortedDocIdSet.iterator();
    List<Integer> result = new ArrayList<Integer>();
    int docId;
    while ((docId = iterator.next()) != Constants.EOF) {
        result.add(docId);
    }
    Assert.assertEquals(result.size(), expectedList.size());
    Assert.assertEquals(result, expectedList);
}
Also used : ArrayList(java.util.ArrayList) SortedDocIdSet(com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet) IntPair(com.linkedin.pinot.common.utils.Pairs.IntPair) BlockDocIdIterator(com.linkedin.pinot.core.common.BlockDocIdIterator)

Aggregations

IntPair (com.linkedin.pinot.common.utils.Pairs.IntPair)16 ArrayList (java.util.ArrayList)10 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)7 SortedDocIdSet (com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet)5 Test (org.testng.annotations.Test)5 BlockDocIdSet (com.linkedin.pinot.core.common.BlockDocIdSet)2 AndDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.AndDocIdIterator)2 RangelessBitmapDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.RangelessBitmapDocIdIterator)2 List (java.util.List)2 ImmutableRoaringBitmap (org.roaringbitmap.buffer.ImmutableRoaringBitmap)2 MutableRoaringBitmap (org.roaringbitmap.buffer.MutableRoaringBitmap)2 BitmapDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.BitmapDocIdIterator)1 ScanBasedDocIdIterator (com.linkedin.pinot.core.operator.dociditerators.ScanBasedDocIdIterator)1 SortedInvertedIndexReader (com.linkedin.pinot.core.segment.index.readers.SortedInvertedIndexReader)1 Int2ObjectLinkedOpenHashMap (it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1