Search in sources :

Example 26 with IntIterator

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.
        }
    };
}
Also used : CloseableIterator(org.apache.druid.java.util.common.parsers.CloseableIterator) IntIterator(it.unimi.dsi.fastutil.ints.IntIterator) Memory(org.apache.datasketches.memory.Memory) WritableMemory(org.apache.datasketches.memory.WritableMemory)

Example 27 with IntIterator

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();
}
Also used : IntIterator(it.unimi.dsi.fastutil.ints.IntIterator)

Example 28 with IntIterator

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();
}
Also used : IntIterator(it.unimi.dsi.fastutil.ints.IntIterator) NoSuchElementException(java.util.NoSuchElementException)

Example 29 with IntIterator

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);
    }
}
Also used : IntIterator(it.unimi.dsi.fastutil.ints.IntIterator)

Example 30 with IntIterator

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);
}
Also used : IntIterator(it.unimi.dsi.fastutil.ints.IntIterator) Test(org.junit.Test)

Aggregations

IntIterator (it.unimi.dsi.fastutil.ints.IntIterator)31 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)4 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)3 Centroid (de.lmu.ifi.dbs.elki.math.linearalgebra.Centroid)2 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)2 BitmapBackedSelection (tech.tablesaw.selection.BitmapBackedSelection)2 Selection (tech.tablesaw.selection.Selection)2 PartitionKey (com.tencent.angel.PartitionKey)1 MatrixMeta (com.tencent.angel.ml.matrix.MatrixMeta)1 ClassLabel (de.lmu.ifi.dbs.elki.data.ClassLabel)1 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)1 Model (de.lmu.ifi.dbs.elki.data.model.Model)1 GeneratorSingleCluster (de.lmu.ifi.dbs.elki.data.synthetic.bymodel.GeneratorSingleCluster)1 LeafEntry (de.lmu.ifi.dbs.elki.index.tree.LeafEntry)1 XTreeDirectoryEntry (de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.xtree.XTreeDirectoryEntry)1 FiniteProgress (de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress)1 LongStatistic (de.lmu.ifi.dbs.elki.logging.statistics.LongStatistic)1 CovarianceMatrix (de.lmu.ifi.dbs.elki.math.linearalgebra.CovarianceMatrix)1 EigenvalueDecomposition (de.lmu.ifi.dbs.elki.math.linearalgebra.EigenvalueDecomposition)1