Search in sources :

Example 1 with DimensionColumnPage

use of org.apache.carbondata.core.datastore.chunk.DimensionColumnPage in project carbondata by apache.

the class ExcludeFilterExecuterImpl method applyFilter.

@Override
public BitSetGroup applyFilter(RawBlockletColumnChunks rawBlockletColumnChunks, boolean useBitsetPipeLine) throws IOException {
    if (isDimensionPresentInCurrentBlock) {
        int chunkIndex = segmentProperties.getDimensionOrdinalToChunkMapping().get(dimColEvaluatorInfo.getColumnIndex());
        if (null == rawBlockletColumnChunks.getDimensionRawColumnChunks()[chunkIndex]) {
            rawBlockletColumnChunks.getDimensionRawColumnChunks()[chunkIndex] = rawBlockletColumnChunks.getDataBlock().readDimensionChunk(rawBlockletColumnChunks.getFileReader(), chunkIndex);
        }
        DimensionRawColumnChunk dimensionRawColumnChunk = rawBlockletColumnChunks.getDimensionRawColumnChunks()[chunkIndex];
        DimensionColumnPage[] dimensionColumnPages = dimensionRawColumnChunk.decodeAllColumnPages();
        BitSetGroup bitSetGroup = new BitSetGroup(dimensionRawColumnChunk.getPagesCount());
        for (int i = 0; i < dimensionColumnPages.length; i++) {
            BitSet bitSet = getFilteredIndexes(dimensionColumnPages[i], dimensionRawColumnChunk.getRowCount()[i], useBitsetPipeLine, rawBlockletColumnChunks.getBitSetGroup(), i);
            bitSetGroup.setBitSet(bitSet, i);
        }
        return bitSetGroup;
    } else if (isMeasurePresentInCurrentBlock) {
        int chunkIndex = segmentProperties.getMeasuresOrdinalToChunkMapping().get(msrColumnEvaluatorInfo.getColumnIndex());
        if (null == rawBlockletColumnChunks.getMeasureRawColumnChunks()[chunkIndex]) {
            rawBlockletColumnChunks.getMeasureRawColumnChunks()[chunkIndex] = rawBlockletColumnChunks.getDataBlock().readMeasureChunk(rawBlockletColumnChunks.getFileReader(), chunkIndex);
        }
        MeasureRawColumnChunk measureRawColumnChunk = rawBlockletColumnChunks.getMeasureRawColumnChunks()[chunkIndex];
        ColumnPage[] ColumnPages = measureRawColumnChunk.decodeAllColumnPages();
        BitSetGroup bitSetGroup = new BitSetGroup(measureRawColumnChunk.getPagesCount());
        DataType msrType = getMeasureDataType(msrColumnEvaluatorInfo);
        for (int i = 0; i < ColumnPages.length; i++) {
            BitSet bitSet = getFilteredIndexesForMeasure(measureRawColumnChunk.decodeColumnPage(i), measureRawColumnChunk.getRowCount()[i], useBitsetPipeLine, rawBlockletColumnChunks.getBitSetGroup(), i, msrType);
            bitSetGroup.setBitSet(bitSet, i);
        }
        return bitSetGroup;
    }
    return null;
}
Also used : DimensionColumnPage(org.apache.carbondata.core.datastore.chunk.DimensionColumnPage) BitSetGroup(org.apache.carbondata.core.util.BitSetGroup) BitSet(java.util.BitSet) DataType(org.apache.carbondata.core.metadata.datatype.DataType) MeasureRawColumnChunk(org.apache.carbondata.core.datastore.chunk.impl.MeasureRawColumnChunk) DimensionRawColumnChunk(org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk)

Example 2 with DimensionColumnPage

use of org.apache.carbondata.core.datastore.chunk.DimensionColumnPage in project carbondata by apache.

the class RowLevelFilterExecuterImpl method readSurrogatesFromColumnChunk.

/**
 * read the filter member dictionary data from the block corresponding to
 * applied filter column
 *
 * @param blockChunkHolder
 * @param index
 * @param dimColumnEvaluatorInfo
 * @return
 */
private int readSurrogatesFromColumnChunk(RawBlockletColumnChunks blockChunkHolder, int index, int page, DimColumnResolvedFilterInfo dimColumnEvaluatorInfo, int chunkIndex) {
    DimensionColumnPage dataChunk = blockChunkHolder.getDimensionRawColumnChunks()[chunkIndex].decodeColumnPage(page);
    if (dimColumnEvaluatorInfo.getDimension().isColumnar()) {
        byte[] rawData = dataChunk.getChunkData(index);
        ByteBuffer byteBuffer = ByteBuffer.allocate(CarbonCommonConstants.INT_SIZE_IN_BYTE);
        return CarbonUtil.getSurrogateKey(rawData, byteBuffer);
    } else {
        return readSurrogatesFromColumnGroupBlock(dataChunk, index, dimColumnEvaluatorInfo);
    }
}
Also used : VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) DimensionColumnPage(org.apache.carbondata.core.datastore.chunk.DimensionColumnPage) ByteBuffer(java.nio.ByteBuffer)

Example 3 with DimensionColumnPage

use of org.apache.carbondata.core.datastore.chunk.DimensionColumnPage in project carbondata by apache.

the class CompressedDimensionChunkFileBasedReaderV1 method decodeColumnPage.

@Override
public DimensionColumnPage decodeColumnPage(DimensionRawColumnChunk dimensionRawColumnChunk, int pageNumber) throws IOException {
    int blockIndex = dimensionRawColumnChunk.getColumnIndex();
    byte[] dataPage = null;
    int[] invertedIndexes = null;
    int[] invertedIndexesReverse = null;
    int[] rlePage = null;
    FileReader fileReader = dimensionRawColumnChunk.getFileReader();
    ByteBuffer rawData = dimensionRawColumnChunk.getRawData();
    dataPage = COMPRESSOR.unCompressByte(rawData.array(), (int) dimensionRawColumnChunk.getOffSet(), dimensionRawColumnChunk.getLength());
    // if row id block is present then read the row id chunk and uncompress it
    DataChunk dataChunk = dimensionColumnChunk.get(blockIndex);
    if (CarbonUtil.hasEncoding(dataChunk.getEncodingList(), Encoding.INVERTED_INDEX)) {
        byte[] columnIndexData;
        synchronized (fileReader) {
            columnIndexData = fileReader.readByteArray(filePath, dataChunk.getRowIdPageOffset(), dataChunk.getRowIdPageLength());
        }
        invertedIndexes = CarbonUtil.getUnCompressColumnIndex(dataChunk.getRowIdPageLength(), columnIndexData, numberComressor, 0);
        // get the reverse index
        invertedIndexesReverse = getInvertedReverseIndex(invertedIndexes);
    }
    // then actual data based on rle block
    if (CarbonUtil.hasEncoding(dataChunk.getEncodingList(), Encoding.RLE)) {
        // read and uncompress the rle block
        byte[] key;
        synchronized (fileReader) {
            key = fileReader.readByteArray(filePath, dataChunk.getRlePageOffset(), dataChunk.getRlePageLength());
        }
        rlePage = numberComressor.unCompress(key, 0, dataChunk.getRlePageLength());
        // uncompress the data with rle indexes
        dataPage = UnBlockIndexer.uncompressData(dataPage, rlePage, eachColumnValueSize[blockIndex]);
        rlePage = null;
    }
    // fill chunk attributes
    DimensionColumnPage columnDataChunk = null;
    if (dataChunk.isRowMajor()) {
        // to store fixed length column chunk values
        columnDataChunk = new ColumnGroupDimensionColumnPage(dataPage, eachColumnValueSize[blockIndex], numberOfRows);
    } else // and set to data chunk instance
    if (!CarbonUtil.hasEncoding(dataChunk.getEncodingList(), Encoding.DICTIONARY)) {
        columnDataChunk = new VariableLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, numberOfRows);
    } else {
        // to store fixed length column chunk values
        columnDataChunk = new FixedLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, numberOfRows, eachColumnValueSize[blockIndex]);
    }
    return columnDataChunk;
}
Also used : FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) DimensionColumnPage(org.apache.carbondata.core.datastore.chunk.DimensionColumnPage) ColumnGroupDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.ColumnGroupDimensionColumnPage) FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) FileReader(org.apache.carbondata.core.datastore.FileReader) DataChunk(org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) ByteBuffer(java.nio.ByteBuffer) ColumnGroupDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.ColumnGroupDimensionColumnPage)

Example 4 with DimensionColumnPage

use of org.apache.carbondata.core.datastore.chunk.DimensionColumnPage in project carbondata by apache.

the class CompressedDimensionChunkFileBasedReaderV3 method decodeDimensionLegacy.

private DimensionColumnPage decodeDimensionLegacy(DimensionRawColumnChunk rawColumnPage, ByteBuffer pageData, DataChunk2 pageMetadata, int offset) {
    byte[] dataPage;
    int[] rlePage;
    int[] invertedIndexes = null;
    int[] invertedIndexesReverse = null;
    dataPage = COMPRESSOR.unCompressByte(pageData.array(), offset, pageMetadata.data_page_length);
    offset += pageMetadata.data_page_length;
    // if row id block is present then read the row id chunk and uncompress it
    if (hasEncoding(pageMetadata.encoders, Encoding.INVERTED_INDEX)) {
        invertedIndexes = CarbonUtil.getUnCompressColumnIndex(pageMetadata.rowid_page_length, pageData, offset);
        offset += pageMetadata.rowid_page_length;
        // get the reverse index
        invertedIndexesReverse = getInvertedReverseIndex(invertedIndexes);
    }
    // then actual data based on rle block
    if (hasEncoding(pageMetadata.encoders, Encoding.RLE)) {
        rlePage = CarbonUtil.getIntArray(pageData, offset, pageMetadata.rle_page_length);
        // uncompress the data with rle indexes
        dataPage = UnBlockIndexer.uncompressData(dataPage, rlePage, eachColumnValueSize[rawColumnPage.getColumnIndex()]);
    }
    DimensionColumnPage columnDataChunk = null;
    // and set to data chunk instance
    if (!hasEncoding(pageMetadata.encoders, Encoding.DICTIONARY)) {
        columnDataChunk = new VariableLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, pageMetadata.getNumberOfRowsInpage());
    } else {
        // to store fixed length column chunk values
        columnDataChunk = new FixedLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, pageMetadata.getNumberOfRowsInpage(), eachColumnValueSize[rawColumnPage.getColumnIndex()]);
    }
    return columnDataChunk;
}
Also used : FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) DimensionColumnPage(org.apache.carbondata.core.datastore.chunk.DimensionColumnPage) FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage)

Example 5 with DimensionColumnPage

use of org.apache.carbondata.core.datastore.chunk.DimensionColumnPage in project carbondata by apache.

the class CompressedDimensionChunkFileBasedReaderV2 method decodeColumnPage.

public DimensionColumnPage decodeColumnPage(DimensionRawColumnChunk dimensionRawColumnChunk, int pageNumber) throws IOException {
    byte[] dataPage = null;
    int[] invertedIndexes = null;
    int[] invertedIndexesReverse = null;
    int[] rlePage = null;
    DataChunk2 dimensionColumnChunk = null;
    int copySourcePoint = (int) dimensionRawColumnChunk.getOffSet();
    int blockIndex = dimensionRawColumnChunk.getColumnIndex();
    ByteBuffer rawData = dimensionRawColumnChunk.getRawData();
    if (dimensionChunksOffset.size() - 1 == blockIndex) {
        dimensionColumnChunk = CarbonUtil.readDataChunk(rawData, copySourcePoint, dimensionRawColumnChunk.getLength());
        int totalDimensionDataLength = dimensionColumnChunk.data_page_length + dimensionColumnChunk.rle_page_length + dimensionColumnChunk.rowid_page_length;
        synchronized (dimensionRawColumnChunk.getFileReader()) {
            rawData = dimensionRawColumnChunk.getFileReader().readByteBuffer(filePath, dimensionChunksOffset.get(blockIndex) + dimensionChunksLength.get(blockIndex), totalDimensionDataLength);
        }
    } else {
        dimensionColumnChunk = CarbonUtil.readDataChunk(rawData, copySourcePoint, dimensionChunksLength.get(blockIndex));
        copySourcePoint += dimensionChunksLength.get(blockIndex);
    }
    // first read the data and uncompressed it
    dataPage = COMPRESSOR.unCompressByte(rawData.array(), copySourcePoint, dimensionColumnChunk.data_page_length);
    copySourcePoint += dimensionColumnChunk.data_page_length;
    // if row id block is present then read the row id chunk and uncompress it
    if (hasEncoding(dimensionColumnChunk.encoders, Encoding.INVERTED_INDEX)) {
        byte[] dataInv = new byte[dimensionColumnChunk.rowid_page_length];
        rawData.position(copySourcePoint);
        rawData.get(dataInv);
        invertedIndexes = CarbonUtil.getUnCompressColumnIndex(dimensionColumnChunk.rowid_page_length, dataInv, numberComressor, 0);
        copySourcePoint += dimensionColumnChunk.rowid_page_length;
        // get the reverse index
        invertedIndexesReverse = getInvertedReverseIndex(invertedIndexes);
    }
    // then actual data based on rle block
    if (hasEncoding(dimensionColumnChunk.encoders, Encoding.RLE)) {
        byte[] dataRle = new byte[dimensionColumnChunk.rle_page_length];
        rawData.position(copySourcePoint);
        rawData.get(dataRle);
        rlePage = numberComressor.unCompress(dataRle, 0, dimensionColumnChunk.rle_page_length);
        // uncompress the data with rle indexes
        dataPage = UnBlockIndexer.uncompressData(dataPage, rlePage, eachColumnValueSize[blockIndex]);
    }
    // fill chunk attributes
    DimensionColumnPage columnDataChunk = null;
    if (dimensionColumnChunk.isRowMajor()) {
        // to store fixed length column chunk values
        columnDataChunk = new ColumnGroupDimensionColumnPage(dataPage, eachColumnValueSize[blockIndex], numberOfRows);
    } else // and set to data chunk instance
    if (!hasEncoding(dimensionColumnChunk.encoders, Encoding.DICTIONARY)) {
        columnDataChunk = new VariableLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, numberOfRows);
    } else {
        // to store fixed length column chunk values
        columnDataChunk = new FixedLengthDimensionColumnPage(dataPage, invertedIndexes, invertedIndexesReverse, numberOfRows, eachColumnValueSize[blockIndex]);
    }
    return columnDataChunk;
}
Also used : FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) DimensionColumnPage(org.apache.carbondata.core.datastore.chunk.DimensionColumnPage) ColumnGroupDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.ColumnGroupDimensionColumnPage) FixedLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage) DataChunk2(org.apache.carbondata.format.DataChunk2) VariableLengthDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage) ByteBuffer(java.nio.ByteBuffer) ColumnGroupDimensionColumnPage(org.apache.carbondata.core.datastore.chunk.impl.ColumnGroupDimensionColumnPage)

Aggregations

DimensionColumnPage (org.apache.carbondata.core.datastore.chunk.DimensionColumnPage)8 VariableLengthDimensionColumnPage (org.apache.carbondata.core.datastore.chunk.impl.VariableLengthDimensionColumnPage)5 ByteBuffer (java.nio.ByteBuffer)3 DimensionRawColumnChunk (org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk)3 FixedLengthDimensionColumnPage (org.apache.carbondata.core.datastore.chunk.impl.FixedLengthDimensionColumnPage)3 MeasureRawColumnChunk (org.apache.carbondata.core.datastore.chunk.impl.MeasureRawColumnChunk)3 ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)3 BitSet (java.util.BitSet)2 FileReader (org.apache.carbondata.core.datastore.FileReader)2 ColumnGroupDimensionColumnPage (org.apache.carbondata.core.datastore.chunk.impl.ColumnGroupDimensionColumnPage)2 DataType (org.apache.carbondata.core.metadata.datatype.DataType)2 BlockletScannedResult (org.apache.carbondata.core.scan.result.BlockletScannedResult)2 QueryStatistic (org.apache.carbondata.core.stats.QueryStatistic)2 BitSetGroup (org.apache.carbondata.core.util.BitSetGroup)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 DataOutputStream (java.io.DataOutputStream)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 DataChunk (org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk)1 GenericQueryType (org.apache.carbondata.core.scan.filter.GenericQueryType)1