Search in sources :

Example 71 with BitSet

use of java.util.BitSet in project lucene-solr by apache.

the class BaseDocIdSetTestCase method testRamBytesUsed.

/** Test ram usage estimation. */
public void testRamBytesUsed() throws IOException {
    final int iters = 100;
    for (int i = 0; i < iters; ++i) {
        final int pow = random().nextInt(20);
        final int maxDoc = TestUtil.nextInt(random(), 1, 1 << pow);
        final int numDocs = TestUtil.nextInt(random(), 0, Math.min(maxDoc, 1 << TestUtil.nextInt(random(), 0, pow)));
        final BitSet set = randomSet(maxDoc, numDocs);
        final DocIdSet copy = copyOf(set, maxDoc);
        final long actualBytes = ramBytesUsed(copy, maxDoc);
        final long expectedBytes = copy.ramBytesUsed();
        assertEquals(expectedBytes, actualBytes);
    }
}
Also used : BitSet(java.util.BitSet) DocIdSet(org.apache.lucene.search.DocIdSet)

Example 72 with BitSet

use of java.util.BitSet in project carbondata by apache.

the class OrFilterExecuterImpl method isScanRequired.

@Override
public BitSet isScanRequired(byte[][] blockMaxValue, byte[][] blockMinValue) {
    BitSet leftFilters = leftExecuter.isScanRequired(blockMaxValue, blockMinValue);
    BitSet rightFilters = rightExecuter.isScanRequired(blockMaxValue, blockMinValue);
    leftFilters.or(rightFilters);
    return leftFilters;
}
Also used : BitSet(java.util.BitSet)

Example 73 with BitSet

use of java.util.BitSet in project carbondata by apache.

the class RangeValueFilterExecuterImpl method applyNoAndDirectFilter.

/**
   * Method to apply the Range Filter.
   * @param blockChunkHolder
   * @return
   * @throws FilterUnsupportedException
   * @throws IOException
   */
public BitSetGroup applyNoAndDirectFilter(BlocksChunkHolder blockChunkHolder) throws FilterUnsupportedException, IOException {
    // select all rows if dimension does not exists in the current block
    if (!isDimensionPresentInCurrentBlock) {
        int numberOfRows = blockChunkHolder.getDataBlock().nodeSize();
        return FilterUtil.createBitSetGroupWithDefaultValue(blockChunkHolder.getDataBlock().numberOfPages(), numberOfRows, true);
    }
    int blockIndex = segmentProperties.getDimensionOrdinalToBlockMapping().get(dimColEvaluatorInfo.getColumnIndex());
    if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) {
        blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock().getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex);
    }
    DimensionRawColumnChunk rawColumnChunk = blockChunkHolder.getDimensionRawDataChunk()[blockIndex];
    BitSetGroup bitSetGroup = new BitSetGroup(rawColumnChunk.getPagesCount());
    for (int i = 0; i < rawColumnChunk.getPagesCount(); i++) {
        if (rawColumnChunk.getMaxValues() != null) {
            if (isScanRequired(rawColumnChunk.getMinValues()[i], rawColumnChunk.getMaxValues()[i], this.filterRangesValues)) {
                if (isRangeFullyCoverBlock == true) {
                    // Set all the bits in this case as filter Min Max values cover the whole block.
                    BitSet bitSet = new BitSet(rawColumnChunk.getRowCount()[i]);
                    bitSet.flip(0, rawColumnChunk.getRowCount()[i]);
                    bitSetGroup.setBitSet(bitSet, i);
                } else {
                    BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), rawColumnChunk.getRowCount()[i]);
                    bitSetGroup.setBitSet(bitSet, i);
                }
            }
        } else {
            BitSet bitSet = getFilteredIndexes(rawColumnChunk.convertToDimColDataChunk(i), rawColumnChunk.getRowCount()[i]);
            bitSetGroup.setBitSet(bitSet, i);
        }
    }
    return bitSetGroup;
}
Also used : BitSetGroup(org.apache.carbondata.core.util.BitSetGroup) BitSet(java.util.BitSet) DimensionRawColumnChunk(org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk)

Example 74 with BitSet

use of java.util.BitSet in project carbondata by apache.

the class AndFilterExecuterImpl method isScanRequired.

@Override
public BitSet isScanRequired(byte[][] blockMaxValue, byte[][] blockMinValue) {
    BitSet leftFilters = leftExecuter.isScanRequired(blockMaxValue, blockMinValue);
    if (leftFilters.isEmpty()) {
        return leftFilters;
    }
    BitSet rightFilter = rightExecuter.isScanRequired(blockMaxValue, blockMinValue);
    if (rightFilter.isEmpty()) {
        return rightFilter;
    }
    leftFilters.and(rightFilter);
    return leftFilters;
}
Also used : BitSet(java.util.BitSet)

Example 75 with BitSet

use of java.util.BitSet in project carbondata by apache.

the class ExcludeFilterExecuterImpl method applyFilter.

@Override
public BitSetGroup applyFilter(BlocksChunkHolder blockChunkHolder) throws IOException {
    int blockIndex = segmentProperties.getDimensionOrdinalToBlockMapping().get(dimColEvaluatorInfo.getColumnIndex());
    if (null == blockChunkHolder.getDimensionRawDataChunk()[blockIndex]) {
        blockChunkHolder.getDimensionRawDataChunk()[blockIndex] = blockChunkHolder.getDataBlock().getDimensionChunk(blockChunkHolder.getFileReader(), blockIndex);
    }
    DimensionRawColumnChunk dimensionRawColumnChunk = blockChunkHolder.getDimensionRawDataChunk()[blockIndex];
    DimensionColumnDataChunk[] dimensionColumnDataChunks = dimensionRawColumnChunk.convertToDimColDataChunks();
    BitSetGroup bitSetGroup = new BitSetGroup(dimensionRawColumnChunk.getPagesCount());
    for (int i = 0; i < dimensionColumnDataChunks.length; i++) {
        BitSet bitSet = getFilteredIndexes(dimensionColumnDataChunks[i], dimensionRawColumnChunk.getRowCount()[i]);
        bitSetGroup.setBitSet(bitSet, i);
    }
    return bitSetGroup;
}
Also used : BitSetGroup(org.apache.carbondata.core.util.BitSetGroup) DimensionColumnDataChunk(org.apache.carbondata.core.datastore.chunk.DimensionColumnDataChunk) BitSet(java.util.BitSet) DimensionRawColumnChunk(org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk)

Aggregations

BitSet (java.util.BitSet)2037 Test (org.junit.Test)294 ArrayList (java.util.ArrayList)224 List (java.util.List)83 HashMap (java.util.HashMap)76 Map (java.util.Map)70 IOException (java.io.IOException)60 HashSet (java.util.HashSet)52 Test (org.junit.jupiter.api.Test)47 RegisterSpecList (com.android.dx.rop.code.RegisterSpecList)45 Random (java.util.Random)42 Configuration (org.apache.hadoop.conf.Configuration)40 Path (org.apache.hadoop.fs.Path)39 ValidReadTxnList (org.apache.hadoop.hive.common.ValidReadTxnList)33 BlockNode (jadx.core.dex.nodes.BlockNode)29 File (java.io.File)27 LinkedList (java.util.LinkedList)27 RexNode (org.apache.calcite.rex.RexNode)27 ByteBuffer (java.nio.ByteBuffer)25 ValidReaderWriteIdList (org.apache.hadoop.hive.common.ValidReaderWriteIdList)25