use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class StringCardinalityAggregatorColumnSelectorStrategy method hashValues.
@Override
public void hashValues(DimensionSelector dimSelector, HyperLogLogCollector collector) {
for (IntIterator rowIt = dimSelector.getRow().iterator(); rowIt.hasNext(); ) {
int index = rowIt.nextInt();
final String value = dimSelector.lookupName(index);
collector.add(CardinalityAggregator.hashFn.hashUnencodedChars(nullToSpecial(value)).asBytes());
}
}
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 = mergeAscending(Collections.<IntIterator>emptyList());
assertEmpty(it);
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project druid by druid-io.
the class MergeIntIteratorTest method testMergeEmptyIterators.
@Test(expected = NoSuchElementException.class)
public void testMergeEmptyIterators() {
IntIterator it = mergeAscending(Arrays.<IntIterator>asList(EMPTY_ITERATOR, EMPTY_ITERATOR));
assertEmpty(it);
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project angel by Tencent.
the class TaskManager method combineUpdateIndex.
/**
* Combine update index.
*/
@SuppressWarnings("rawtypes")
public void combineUpdateIndex() {
IntOpenHashSet indexSet = null;
MatrixMeta meta = null;
for (Entry<TaskId, Task> entry : runningTask.entrySet()) {
LabeledUpdateIndexBaseTask task = (LabeledUpdateIndexBaseTask) entry.getValue().getUserTask();
IntOpenHashSet taskIndexSet = task.getIndexSet();
if (taskIndexSet != null) {
if (indexSet == null) {
indexSet = taskIndexSet;
meta = task.getMatrixMeta();
} else {
indexSet.addAll(taskIndexSet);
task.setIndexSet(null);
}
}
}
if (indexSet != null && meta != null) {
int size = indexSet.size();
int[] indexArray = new int[size];
int index = 0;
IntIterator iter = indexSet.iterator();
while (iter.hasNext()) {
indexArray[index++] = iter.nextInt();
}
Arrays.sort(indexArray);
List<PartitionKey> partKeyList = WorkerContext.get().getPSAgent().getMatrixMetaManager().getPartitions(meta.getId());
Collections.sort(partKeyList);
int partNum = partKeyList.size();
int lastPos = 0;
for (int i = 0; i < partNum; i++) {
PartitionKey partKey = partKeyList.get(i);
long endCol = partKey.getEndCol();
for (int j = lastPos; j < size; j++) {
if (indexArray[j] >= endCol) {
lastPos = j;
break;
}
}
}
// Bitmap bitmap = new Bitmap();
// int max = indexArray[size - 1];
// byte [] bitIndexArray = new byte[max / 8 + 1];
// for(int i = 0; i < size; i++){
// int bitIndex = indexArray[i] >> 3;
// int bitOffset = indexArray[i] - (bitIndex << 3);
// switch(bitOffset){
// case 0:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x01);break;
// case 1:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x02);break;
// case 2:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x04);break;
// case 3:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x08);break;
// case 4:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x10);break;
// case 5:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x20);break;
// case 6:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x40);break;
// case 7:bitIndexArray[bitIndex] = (byte) (bitIndexArray[bitIndex] & 0x80);break;
// }
// }
}
}
use of it.unimi.dsi.fastutil.ints.IntIterator in project ignite by apache.
the class SparseLocalOnHeapMatrix method nonZeroElements.
/**
* {@inheritDoc}
*/
@Override
public int nonZeroElements() {
int res = 0;
IntIterator rowIter = indexesMap().keySet().iterator();
while (rowIter.hasNext()) {
int row = rowIter.nextInt();
res += indexesMap().get(row).size();
}
return res;
}
Aggregations