Search in sources :

Example 1 with SortedDocIdSet

use of com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet in project pinot by linkedin.

the class SortedDocIdSetTest method testTwoPair.

@Test
public void testTwoPair() {
    List<IntPair> pairs = new ArrayList<IntPair>();
    pairs.add(Pairs.intPair(90, 99));
    pairs.add(Pairs.intPair(100, 109));
    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(20, result.size());
}
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) Test(org.testng.annotations.Test)

Example 2 with SortedDocIdSet

use of com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet in project pinot by linkedin.

the class SortedDocIdSetTest method testPairWithSameStartAndEnd.

@Test
public void testPairWithSameStartAndEnd() {
    List<IntPair> pairs = new ArrayList<IntPair>();
    pairs.add(Pairs.intPair(1, 1));
    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(1, result.size());
}
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) Test(org.testng.annotations.Test)

Example 3 with SortedDocIdSet

use of com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet in project pinot by linkedin.

the class SortedDocIdSetTest method testOnePair.

@Test
public void testOnePair() {
    List<IntPair> pairs = new ArrayList<IntPair>();
    pairs.add(Pairs.intPair(0, 9));
    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(10, result.size());
}
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) Test(org.testng.annotations.Test)

Example 4 with SortedDocIdSet

use of com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet in project pinot by linkedin.

the class SortedDocIdSetTest method testEmpty.

@Test
public void testEmpty() {
    List<IntPair> pairs = new ArrayList<IntPair>();
    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.assertTrue(result.isEmpty(), "Expected empty result set but got:" + result);
}
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) Test(org.testng.annotations.Test)

Example 5 with SortedDocIdSet

use of com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet 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)5 BlockDocIdIterator (com.linkedin.pinot.core.common.BlockDocIdIterator)5 SortedDocIdSet (com.linkedin.pinot.core.operator.docidsets.SortedDocIdSet)5 ArrayList (java.util.ArrayList)5 Test (org.testng.annotations.Test)4