use of it.unimi.dsi.fastutil.ints.IntArrayList in project gatk by broadinstitute.
the class ReadLikelihoods method overlappingReadIndicesBySampleIndex.
private int[][] overlappingReadIndicesBySampleIndex(final Locatable overlap) {
if (overlap == null) {
return null;
}
final int sampleCount = samples.numberOfSamples();
final int[][] result = new int[sampleCount][];
final IntArrayList buffer = new IntArrayList(200);
final String contig = overlap.getContig();
final int overlapStart = overlap.getStart();
final int overlapEnd = overlap.getEnd();
for (int s = 0; s < sampleCount; s++) {
buffer.clear();
final GATKRead[] sampleReads = readsBySampleIndex[s];
final int sampleReadCount = sampleReads.length;
buffer.ensureCapacity(sampleReadCount);
for (int r = 0; r < sampleReadCount; r++) {
if (unclippedReadOverlapsRegion(sampleReads[r], contig, overlapStart, overlapEnd)) {
buffer.add(r);
}
}
result[s] = buffer.toIntArray();
}
return result;
}
use of it.unimi.dsi.fastutil.ints.IntArrayList in project druid by druid-io.
the class InDimFilter method getFloatPredicateSupplier.
private Supplier<DruidFloatPredicate> getFloatPredicateSupplier() {
return new Supplier<DruidFloatPredicate>() {
private final Object initLock = new Object();
private DruidFloatPredicate predicate;
private void initFloatValues() {
if (predicate != null) {
return;
}
synchronized (initLock) {
if (predicate != null) {
return;
}
IntArrayList floatBits = new IntArrayList(values.size());
for (String value : values) {
Float floatValue = Floats.tryParse(value);
if (floatValue != null) {
floatBits.add(Float.floatToIntBits(floatValue));
}
}
if (floatBits.size() > NUMERIC_HASHING_THRESHOLD) {
final IntOpenHashSet floatBitsHashSet = new IntOpenHashSet(floatBits);
predicate = new DruidFloatPredicate() {
@Override
public boolean applyFloat(float input) {
return floatBitsHashSet.contains(Float.floatToIntBits(input));
}
};
} else {
final int[] floatBitsArray = floatBits.toIntArray();
Arrays.sort(floatBitsArray);
predicate = new DruidFloatPredicate() {
@Override
public boolean applyFloat(float input) {
return Arrays.binarySearch(floatBitsArray, Float.floatToIntBits(input)) >= 0;
}
};
}
}
}
@Override
public DruidFloatPredicate get() {
initFloatValues();
return predicate;
}
};
}
use of it.unimi.dsi.fastutil.ints.IntArrayList in project druid by druid-io.
the class MergeIntIteratorTest method smokeTest.
@Test
public void smokeTest() {
ThreadLocalRandom r = ThreadLocalRandom.current();
for (int i = 0; i < 1000; i++) {
int numIterators = r.nextInt(1, 11);
List<IntList> lists = new ArrayList<>(numIterators);
for (int j = 0; j < numIterators; j++) {
lists.add(new IntArrayList());
}
for (int j = 0; j < 50; j++) {
lists.get(r.nextInt(numIterators)).add(j);
}
for (int j = 0; j < lists.size() + 1; j++) {
assertAscending(mergeAscending(iteratorsFromLists(lists)));
Collections.rotate(lists, 1);
}
for (int j = 0; j < 10; j++) {
Collections.shuffle(lists);
assertAscending(mergeAscending(iteratorsFromLists(lists)));
}
}
}
use of it.unimi.dsi.fastutil.ints.IntArrayList in project pinot by linkedin.
the class DefaultGroupKeyGenerator method generateKeysForBlock.
/**
* {@inheritDoc}
*
*/
@Override
public void generateKeysForBlock(TransformBlock transformBlock, int[] outGroupKeys) {
int startIndex = 0;
int length = transformBlock.getNumDocs();
// Fetch all dictionary ids according to the document id set for all group-by columns.
for (int i = 0; i < _numGroupByColumns; i++) {
BlockValSet blockValueSet = transformBlock.getBlockValueSet(_groupByColumns[i]);
_reusableSingleDictIds[i] = blockValueSet.getDictionaryIds();
}
// Calculate the group key and store it into the result buffer.
int outIndex = 0;
int endIndex = startIndex + length;
switch(_storageType) {
case ARRAY_BASED:
for (int i = startIndex; i < endIndex; i++) {
int groupKey = 0;
for (int j = _numGroupByColumns - 1; j >= 0; j--) {
groupKey = groupKey * _cardinalities[j] + _reusableSingleDictIds[j][i];
}
outGroupKeys[outIndex++] = groupKey;
_groupKeyFlags[groupKey] = true;
}
break;
case LONG_MAP_BASED:
for (int i = startIndex; i < endIndex; i++) {
long rawKey = 0;
for (int j = _numGroupByColumns - 1; j >= 0; j--) {
rawKey = rawKey * _cardinalities[j] + _reusableSingleDictIds[j][i];
}
outGroupKeys[outIndex++] = updateRawKeyToGroupKeyMapping(rawKey);
}
break;
case ARRAY_MAP_BASED:
for (int i = startIndex; i < endIndex; i++) {
IntArrayList rawKey = new IntArrayList(_numGroupByColumns);
rawKey.size(_numGroupByColumns);
int[] rawKeyArray = rawKey.elements();
for (int j = 0; j < _numGroupByColumns; j++) {
rawKeyArray[j] = _reusableSingleDictIds[j][i];
}
outGroupKeys[outIndex++] = updateRawKeyToGroupKeyMapping(rawKey);
}
break;
default:
throw new RuntimeException("Unsupported storage type.");
}
}
use of it.unimi.dsi.fastutil.ints.IntArrayList in project presto by prestodb.
the class ParquetReader method readStruct.
private Block readStruct(Type type, List<String> path, IntList elementOffsets) throws IOException {
List<TypeSignatureParameter> parameters = type.getTypeSignature().getParameters();
Block[] blocks = new Block[parameters.size()];
for (int i = 0; i < parameters.size(); i++) {
NamedTypeSignature namedTypeSignature = parameters.get(i).getNamedTypeSignature();
Type fieldType = typeManager.getType(namedTypeSignature.getTypeSignature());
String name = namedTypeSignature.getName();
blocks[i] = readBlock(name, fieldType, path, new IntArrayList());
}
InterleavedBlock interleavedBlock = new InterleavedBlock(blocks);
int blockSize = blocks[0].getPositionCount();
int[] offsets = new int[blockSize + 1];
for (int i = 1; i < offsets.length; i++) {
elementOffsets.add(parameters.size());
offsets[i] = i * parameters.size();
}
return new ArrayBlock(blockSize, new boolean[blockSize], offsets, interleavedBlock);
}
Aggregations