use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class HashVectorGrouper method iterator.
@Override
public CloseableIterator<Grouper.Entry<Memory>> iterator() {
if (!initialized) {
// a nested groupBy's subquery has an empty result set (see testEmptySubquery() in GroupByQueryRunnerTest)
return CloseableIterators.withEmptyBaggage(Collections.emptyIterator());
}
final IntIterator baseIterator = hashTable.bucketIterator();
return new CloseableIterator<Grouper.Entry<Memory>>() {
@Override
public boolean hasNext() {
return baseIterator.hasNext();
}
@Override
public Grouper.Entry<Memory> next() {
final int bucket = baseIterator.nextInt();
final int bucketPosition = hashTable.bucketMemoryPosition(bucket);
final Memory keyMemory = hashTable.memory().region(bucketPosition + hashTable.bucketKeyOffset(), hashTable.keySize());
final Object[] values = new Object[aggregators.size()];
final int aggregatorsOffset = bucketPosition + hashTable.bucketValueOffset();
for (int i = 0; i < aggregators.size(); i++) {
values[i] = aggregators.get(hashTable.memory().getByteBuffer(), aggregatorsOffset, i);
}
return new Grouper.Entry<>(keyMemory, values);
}
@Override
public void close() {
// Do nothing.
}
};
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class IndexedTableJoinMatcher method matchCondition.
@Override
public void matchCondition() {
reset();
if (singleRowMatching) {
if (conditionMatchers.size() == 1) {
currentRow = conditionMatchers.get(0).matchSingleRow();
} else {
currentRow = conditionMatchers.get(0).matchSingleRow();
for (int i = 1; i < conditionMatchers.size(); i++) {
if (currentRow != conditionMatchers.get(i).matchSingleRow()) {
currentRow = UNINITIALIZED_CURRENT_ROW;
break;
}
}
}
} else {
if (conditionMatchers.size() == 1) {
currentIterator = conditionMatchers.get(0).match();
} else {
for (int i = 0; i < conditionMatchers.size(); i++) {
final IntIterator rows = conditionMatchers.get(i).match();
if (rows.hasNext()) {
currentMatchedRows[i] = rows;
} else {
return;
}
}
currentIterator = new SortedIntIntersectionIterator(currentMatchedRows);
}
advanceCurrentRow();
}
addCurrentRowToMatchedRows();
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class IndexedTableJoinMatcher method matchRemainder.
@Override
public void matchRemainder() {
Preconditions.checkState(matchedRows != null, "matchedRows != null");
currentIterator = new IntIterator() {
int current = -1;
{
advanceRemainderIterator();
}
@Override
public int nextInt() {
if (current >= table.numRows()) {
throw new NoSuchElementException();
}
final int retVal = current;
advanceRemainderIterator();
return retVal;
}
@Override
public boolean hasNext() {
return current < table.numRows();
}
private void advanceRemainderIterator() {
do {
current++;
} while (current < table.numRows() && matchedRows.contains(current));
}
};
matchingRemainder = true;
advanceCurrentRow();
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class IndexMergerTestBase method checkBitmapIndex.
private void checkBitmapIndex(List<Integer> expected, BitmapValues real) {
Assert.assertEquals("bitmap size", expected.size(), real.size());
int i = 0;
for (IntIterator iterator = real.iterator(); iterator.hasNext(); ) {
int index = iterator.nextInt();
Assert.assertEquals(expected.get(i++), (Integer) index);
}
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class MergeIntIteratorTest method testNoIterators.
@Test(expected = NoSuchElementException.class)
public void testNoIterators() {
IntIterator it = IntIteratorUtils.mergeAscending(Collections.emptyList());
assertEmpty(it);
}
Aggregations