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