Search in sources :

Example 6 with ColumnPage

use of org.apache.carbondata.core.datastore.page.ColumnPage in project carbondata by apache.

the class AdaptiveIntegralCodec method createEncoder.

@Override
public ColumnPageEncoder createEncoder(Map<String, String> parameter) {
    final Compressor compressor = CompressorFactory.getInstance().getCompressor();
    return new ColumnPageEncoder() {

        @Override
        protected byte[] encodeData(ColumnPage input) throws MemoryException, IOException {
            if (encodedPage != null) {
                throw new IllegalStateException("already encoded");
            }
            encodedPage = ColumnPage.newPage(input.getColumnSpec(), targetDataType, input.getPageSize());
            input.convertValue(converter);
            byte[] result = encodedPage.compress(compressor);
            encodedPage.freeMemory();
            return result;
        }

        @Override
        protected List<Encoding> getEncodingList() {
            List<Encoding> encodings = new ArrayList<Encoding>();
            encodings.add(Encoding.ADAPTIVE_INTEGRAL);
            return encodings;
        }

        @Override
        protected ColumnPageEncoderMeta getEncoderMeta(ColumnPage inputPage) {
            return new ColumnPageEncoderMeta(inputPage.getColumnSpec(), targetDataType, stats, compressor.getName());
        }
    };
}
Also used : ColumnPageEncoder(org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoder) LazyColumnPage(org.apache.carbondata.core.datastore.page.LazyColumnPage) ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) ColumnPageEncoderMeta(org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoderMeta) ArrayList(java.util.ArrayList) Compressor(org.apache.carbondata.core.datastore.compression.Compressor) Encoding(org.apache.carbondata.format.Encoding)

Example 7 with ColumnPage

use of org.apache.carbondata.core.datastore.page.ColumnPage in project carbondata by apache.

the class ComplexDimensionIndexCodec method createEncoder.

@Override
public ColumnPageEncoder createEncoder(Map<String, String> parameter) {
    return new IndexStorageEncoder() {

        @Override
        void encodeIndexStorage(ColumnPage inputPage) {
            IndexStorage indexStorage = new BlockIndexerStorageForShort(inputPage.getByteArrayPage(), false, false, false);
            byte[] flattened = ByteUtil.flatten(indexStorage.getDataPage());
            byte[] compressed = compressor.compressByte(flattened);
            super.indexStorage = indexStorage;
            super.compressedDataPage = compressed;
        }

        @Override
        protected List<Encoding> getEncodingList() {
            List<Encoding> encodings = new ArrayList<>();
            encodings.add(Encoding.DICTIONARY);
            encodings.add(Encoding.INVERTED_INDEX);
            return encodings;
        }
    };
}
Also used : ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) ArrayList(java.util.ArrayList) BlockIndexerStorageForShort(org.apache.carbondata.core.datastore.columnar.BlockIndexerStorageForShort) Encoding(org.apache.carbondata.format.Encoding) IndexStorage(org.apache.carbondata.core.datastore.columnar.IndexStorage)

Example 8 with ColumnPage

use of org.apache.carbondata.core.datastore.page.ColumnPage in project carbondata by apache.

the class DictDimensionIndexCodec method createEncoder.

@Override
public ColumnPageEncoder createEncoder(Map<String, String> parameter) {
    return new IndexStorageEncoder() {

        @Override
        void encodeIndexStorage(ColumnPage inputPage) {
            IndexStorage indexStorage;
            byte[][] data = inputPage.getByteArrayPage();
            if (isInvertedIndex) {
                indexStorage = new BlockIndexerStorageForShort(data, true, false, isSort);
            } else {
                indexStorage = new BlockIndexerStorageForNoInvertedIndexForShort(data, false);
            }
            byte[] flattened = ByteUtil.flatten(indexStorage.getDataPage());
            super.compressedDataPage = compressor.compressByte(flattened);
            super.indexStorage = indexStorage;
        }

        @Override
        protected List<Encoding> getEncodingList() {
            List<Encoding> encodings = new ArrayList<>();
            encodings.add(Encoding.DICTIONARY);
            encodings.add(Encoding.RLE);
            if (isInvertedIndex) {
                encodings.add(Encoding.INVERTED_INDEX);
            }
            return encodings;
        }
    };
}
Also used : ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) BlockIndexerStorageForNoInvertedIndexForShort(org.apache.carbondata.core.datastore.columnar.BlockIndexerStorageForNoInvertedIndexForShort) ArrayList(java.util.ArrayList) BlockIndexerStorageForShort(org.apache.carbondata.core.datastore.columnar.BlockIndexerStorageForShort) Encoding(org.apache.carbondata.format.Encoding) IndexStorage(org.apache.carbondata.core.datastore.columnar.IndexStorage)

Example 9 with ColumnPage

use of org.apache.carbondata.core.datastore.page.ColumnPage in project carbondata by apache.

the class CompressedMeasureChunkFileBasedReaderV1 method decodeColumnPage.

@Override
public ColumnPage decodeColumnPage(MeasureRawColumnChunk measureRawColumnChunk, int pageNumber) throws IOException, MemoryException {
    int blockIndex = measureRawColumnChunk.getColumnIndex();
    DataChunk dataChunk = measureColumnChunks.get(blockIndex);
    ValueEncoderMeta meta = dataChunk.getValueEncoderMeta().get(0);
    ColumnPageDecoder codec = encodingFactory.createDecoderLegacy(meta);
    ColumnPage decodedPage = codec.decode(measureRawColumnChunk.getRawData().array(), (int) measureRawColumnChunk.getOffSet(), dataChunk.getDataPageLength());
    decodedPage.setNullBits(dataChunk.getNullValueIndexForColumn());
    return decodedPage;
}
Also used : ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) DataChunk(org.apache.carbondata.core.metadata.blocklet.datachunk.DataChunk) ColumnPageDecoder(org.apache.carbondata.core.datastore.page.encoding.ColumnPageDecoder) ValueEncoderMeta(org.apache.carbondata.core.metadata.ValueEncoderMeta)

Example 10 with ColumnPage

use of org.apache.carbondata.core.datastore.page.ColumnPage in project carbondata by apache.

the class CompressedMeasureChunkFileBasedReaderV2 method decodeColumnPage.

public ColumnPage decodeColumnPage(MeasureRawColumnChunk measureRawColumnChunk, int pageNumber) throws IOException, MemoryException {
    int copyPoint = (int) measureRawColumnChunk.getOffSet();
    int blockIndex = measureRawColumnChunk.getColumnIndex();
    ByteBuffer rawData = measureRawColumnChunk.getRawData();
    DataChunk2 measureColumnChunk = CarbonUtil.readDataChunk(rawData, copyPoint, measureColumnChunkLength.get(blockIndex));
    copyPoint += measureColumnChunkLength.get(blockIndex);
    ColumnPage page = decodeMeasure(measureRawColumnChunk, measureColumnChunk, copyPoint);
    page.setNullBits(getNullBitSet(measureColumnChunk.presence));
    return page;
}
Also used : ColumnPage(org.apache.carbondata.core.datastore.page.ColumnPage) DataChunk2(org.apache.carbondata.format.DataChunk2) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ColumnPage (org.apache.carbondata.core.datastore.page.ColumnPage)20 ArrayList (java.util.ArrayList)8 Encoding (org.apache.carbondata.format.Encoding)7 DimensionColumnPage (org.apache.carbondata.core.datastore.chunk.DimensionColumnPage)5 DimensionRawColumnChunk (org.apache.carbondata.core.datastore.chunk.impl.DimensionRawColumnChunk)4 MeasureRawColumnChunk (org.apache.carbondata.core.datastore.chunk.impl.MeasureRawColumnChunk)4 BlockIndexerStorageForShort (org.apache.carbondata.core.datastore.columnar.BlockIndexerStorageForShort)4 IndexStorage (org.apache.carbondata.core.datastore.columnar.IndexStorage)4 BitSet (java.util.BitSet)3 BlockIndexerStorageForNoInvertedIndexForShort (org.apache.carbondata.core.datastore.columnar.BlockIndexerStorageForNoInvertedIndexForShort)3 Compressor (org.apache.carbondata.core.datastore.compression.Compressor)3 LazyColumnPage (org.apache.carbondata.core.datastore.page.LazyColumnPage)3 ColumnPageEncoder (org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoder)3 ColumnPageEncoderMeta (org.apache.carbondata.core.datastore.page.encoding.ColumnPageEncoderMeta)3 DataChunk2 (org.apache.carbondata.format.DataChunk2)3 ByteBuffer (java.nio.ByteBuffer)2 TableSpec (org.apache.carbondata.core.datastore.TableSpec)2 ComplexColumnPage (org.apache.carbondata.core.datastore.page.ComplexColumnPage)2 BlockletScannedResult (org.apache.carbondata.core.scan.result.BlockletScannedResult)2 QueryStatistic (org.apache.carbondata.core.stats.QueryStatistic)2