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());
}
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());
}
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());
}
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);
}
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);
}
Aggregations