Search in sources :

Example 6 with IntArrayList

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;
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList)

Example 7 with IntArrayList

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;
        }
    };
}
Also used : IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) Supplier(com.google.common.base.Supplier) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList)

Example 8 with IntArrayList

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)));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) IntList(it.unimi.dsi.fastutil.ints.IntList) Test(org.junit.Test)

Example 9 with IntArrayList

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.");
    }
}
Also used : BlockValSet(com.linkedin.pinot.core.common.BlockValSet) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList)

Example 10 with IntArrayList

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);
}
Also used : Type(com.facebook.presto.spi.type.Type) MessageType(parquet.schema.MessageType) ArrayBlock(com.facebook.presto.spi.block.ArrayBlock) TypeSignatureParameter(com.facebook.presto.spi.type.TypeSignatureParameter) Block(com.facebook.presto.spi.block.Block) RunLengthEncodedBlock(com.facebook.presto.spi.block.RunLengthEncodedBlock) ArrayBlock(com.facebook.presto.spi.block.ArrayBlock) InterleavedBlock(com.facebook.presto.spi.block.InterleavedBlock) NamedTypeSignature(com.facebook.presto.spi.type.NamedTypeSignature) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) InterleavedBlock(com.facebook.presto.spi.block.InterleavedBlock)

Aggregations

IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)10 ArrayBlock (com.facebook.presto.spi.block.ArrayBlock)3 Block (com.facebook.presto.spi.block.Block)3 InterleavedBlock (com.facebook.presto.spi.block.InterleavedBlock)3 IntList (it.unimi.dsi.fastutil.ints.IntList)3 RunLengthEncodedBlock (com.facebook.presto.spi.block.RunLengthEncodedBlock)2 Type (com.facebook.presto.spi.type.Type)2 MessageType (parquet.schema.MessageType)2 NamedTypeSignature (com.facebook.presto.spi.type.NamedTypeSignature)1 TypeSignatureParameter (com.facebook.presto.spi.type.TypeSignatureParameter)1 Supplier (com.google.common.base.Supplier)1 BlockValSet (com.linkedin.pinot.core.common.BlockValSet)1 IntOpenHashSet (it.unimi.dsi.fastutil.ints.IntOpenHashSet)1 ArrayList (java.util.ArrayList)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 VariableValueArray (net.glowstone.util.VariableValueArray)1 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)1 Test (org.junit.Test)1