Exemple #1
0
    size_t BitmapEncoding::Bitmap::decompress(void const* src, size_t size, Chunk& chunk)
    {
        size_t chunkSize = chunk.getSize();
        TypeId type = chunk.getAttributeDesc().getType();
        _elementSize = TypeLibrary::getType(type).byteSize();

        /* No more immutable arrays, to keep consistent with old code, always treat data as string
         */
        _bitmapElements = chunkSize;
        _elementSize = 1;

        if(!_bitmapElements) { return chunkSize; }

        uint8_t* dst = (uint8_t*)chunk.getDataForLoad();
        ByteInputItr in((uint8_t *)src, size);
        uint32_t bmLength = ceil(_bitmapElements / 8.0);
        uint32_t individualBMLength = bmLength + _elementSize; // value + bm
        assert(individualBMLength);
        uint32_t bitmaps = size / individualBMLength;

        boost::scoped_array<uint8_t> bitmapArr(new uint8_t[bmLength]);
        boost::scoped_array<uint8_t> baseValueArr(new uint8_t[_elementSize]);

        uint8_t *bitmap = bitmapArr.get();
        uint8_t *baseValue = baseValueArr.get();

        for(uint32_t i = 0; i < bitmaps; ++i)
        {
            if(in.getArray(baseValue, _elementSize) == -1) { return 0; }
            if(in.getArray(bitmap, bmLength)== -1) { return 0; }
            decodeBitmap(baseValue, bitmap, dst);
        }
        return chunkSize;
    }
    size_t BitmapEncoding::Bitmap::decompress(void const* src, size_t size, Chunk& chunk)
    {
        size_t chunkSize = chunk.getSize();
        TypeId type = chunk.getAttributeDesc().getType();        
        _elementSize = TypeLibrary::getType(type).byteSize();

        if(_elementSize == 0 || _elementSize > 8 || chunk.isSparse() || !chunk.getArrayDesc().isImmutable() || chunk.getAttributeDesc().isNullable())
        {
            _bitmapElements = chunkSize;
            _elementSize = 1;
        }
        else
        {
            _bitmapElements = chunkSize / _elementSize;
        }


        if(!_bitmapElements) { return chunkSize; }

        uint8_t* dst = (uint8_t*)chunk.getData();
        ByteInputItr in((uint8_t *)src, size);
        uint32_t bmLength = ceil(_bitmapElements / 8.0);
        uint32_t individualBMLength = bmLength + _elementSize; // value + bm
        assert(individualBMLength);
        uint32_t bitmaps = size / individualBMLength;

        boost::scoped_array<uint8_t> bitmapArr(new uint8_t[bmLength]);
        boost::scoped_array<uint8_t> baseValueArr(new uint8_t[_elementSize]);

        uint8_t *bitmap = bitmapArr.get();
        uint8_t *baseValue = baseValueArr.get();

        for(uint32_t i = 0; i < bitmaps; ++i)
        {
            if(in.getArray(baseValue, _elementSize) == -1) { return 0; }
            if(in.getArray(bitmap, bmLength)== -1) { return 0; } 
            decodeBitmap(baseValue, bitmap, dst);
        }
        return chunkSize;
    }