Search in sources :

Example 1 with AbstractIntIterator

use of it.unimi.dsi.fastutil.ints.AbstractIntIterator in project presto by prestodb.

the class InMemoryHashAggregationBuilder method hashSortedGroupIds.

private IntIterator hashSortedGroupIds() {
    IntBigArray groupIds = new IntBigArray();
    groupIds.ensureCapacity(groupByHash.getGroupCount());
    for (int i = 0; i < groupByHash.getGroupCount(); i++) {
        groupIds.set(i, i);
    }
    groupIds.sort(0, groupByHash.getGroupCount(), (leftGroupId, rightGroupId) -> Long.compare(groupByHash.getRawHash(leftGroupId), groupByHash.getRawHash(rightGroupId)));
    return new AbstractIntIterator() {

        private final int totalPositions = groupByHash.getGroupCount();

        private int position;

        @Override
        public boolean hasNext() {
            return position < totalPositions;
        }

        @Override
        public int nextInt() {
            return groupIds.get(position++);
        }
    };
}
Also used : AbstractIntIterator(it.unimi.dsi.fastutil.ints.AbstractIntIterator) IntBigArray(com.facebook.presto.common.array.IntBigArray)

Aggregations

IntBigArray (com.facebook.presto.common.array.IntBigArray)1 AbstractIntIterator (it.unimi.dsi.fastutil.ints.AbstractIntIterator)1