void SectionAttributeEncoder::DecodeSectionFids()

in aios/storage/indexlib/indexlib/common/field_format/section_attribute/section_attribute_encoder.cpp [374:671]


void SectionAttributeEncoder::DecodeSectionFids(const uint8_t*& srcCursor, uint32_t sectionCount, uint8_t*& destCursor,
                                                uint8_t* destEnd)
{
    int32_t leftCount = (int32_t)sectionCount;
    section_fid_t* fidCursor = (section_fid_t*)destCursor;
    CheckBufferLen(fidCursor, (section_fid_t*)destEnd, sectionCount);

    bool firstFieldFlag = false;

    while (leftCount > 0) {
        const uint32_t* src = (const uint32_t*)srcCursor;
        __builtin_prefetch(src + 8, 0, 3);
        section_fid_t* tmpDestCursor = fidCursor;

        uint32_t k = (*src) >> 28;
        switch (k) {
        case 0:
            *tmpDestCursor = (*src) & 1;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 1) & 1) + *tmpDestCursor;
            *(tmpDestCursor + 2) = ((*src >> 2) & 1) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 3) & 1) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 4) & 1) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 5) & 1) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 6) & 1) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 7) & 1) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 8) & 1) + *(tmpDestCursor + 7);
            *(tmpDestCursor + 9) = ((*src >> 9) & 1) + *(tmpDestCursor + 8);
            *(tmpDestCursor + 10) = ((*src >> 10) & 1) + *(tmpDestCursor + 9);
            *(tmpDestCursor + 11) = ((*src >> 11) & 1) + *(tmpDestCursor + 10);
            *(tmpDestCursor + 12) = ((*src >> 12) & 1) + *(tmpDestCursor + 11);
            *(tmpDestCursor + 13) = ((*src >> 13) & 1) + *(tmpDestCursor + 12);
            *(tmpDestCursor + 14) = ((*src >> 14) & 1) + *(tmpDestCursor + 13);
            *(tmpDestCursor + 15) = ((*src >> 15) & 1) + *(tmpDestCursor + 14);
            *(tmpDestCursor + 16) = ((*src >> 16) & 1) + *(tmpDestCursor + 15);
            *(tmpDestCursor + 17) = ((*src >> 17) & 1) + *(tmpDestCursor + 16);
            *(tmpDestCursor + 18) = ((*src >> 18) & 1) + *(tmpDestCursor + 17);
            *(tmpDestCursor + 19) = ((*src >> 19) & 1) + *(tmpDestCursor + 18);
            *(tmpDestCursor + 20) = ((*src >> 20) & 1) + *(tmpDestCursor + 19);
            *(tmpDestCursor + 21) = ((*src >> 21) & 1) + *(tmpDestCursor + 20);
            *(tmpDestCursor + 22) = ((*src >> 22) & 1) + *(tmpDestCursor + 21);
            *(tmpDestCursor + 23) = ((*src >> 23) & 1) + *(tmpDestCursor + 22);
            *(tmpDestCursor + 24) = ((*src >> 24) & 1) + *(tmpDestCursor + 23);
            *(tmpDestCursor + 25) = ((*src >> 25) & 1) + *(tmpDestCursor + 24);
            *(tmpDestCursor + 26) = ((*src >> 26) & 1) + *(tmpDestCursor + 25);
            *(tmpDestCursor + 27) = ((*src >> 27) & 1) + *(tmpDestCursor + 26);
            tmpDestCursor += 28;
            break;
        case 1:
            *tmpDestCursor = (*src) & 3;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 2) & 3) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 4) & 3) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 6) & 3) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 8) & 3) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 10) & 3) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 12) & 3) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 14) & 1) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 15) & 1) + *(tmpDestCursor + 7);
            *(tmpDestCursor + 9) = ((*src >> 16) & 1) + *(tmpDestCursor + 8);
            *(tmpDestCursor + 10) = ((*src >> 17) & 1) + *(tmpDestCursor + 9);
            *(tmpDestCursor + 11) = ((*src >> 18) & 1) + *(tmpDestCursor + 10);
            *(tmpDestCursor + 12) = ((*src >> 19) & 1) + *(tmpDestCursor + 11);
            *(tmpDestCursor + 13) = ((*src >> 20) & 1) + *(tmpDestCursor + 12);
            *(tmpDestCursor + 14) = ((*src >> 21) & 1) + *(tmpDestCursor + 13);
            *(tmpDestCursor + 15) = ((*src >> 22) & 1) + *(tmpDestCursor + 14);
            *(tmpDestCursor + 16) = ((*src >> 23) & 1) + *(tmpDestCursor + 15);
            *(tmpDestCursor + 17) = ((*src >> 24) & 1) + *(tmpDestCursor + 16);
            *(tmpDestCursor + 18) = ((*src >> 25) & 1) + *(tmpDestCursor + 17);
            *(tmpDestCursor + 19) = ((*src >> 26) & 1) + *(tmpDestCursor + 18);
            *(tmpDestCursor + 20) = ((*src >> 27) & 1) + *(tmpDestCursor + 19);
            tmpDestCursor += 21;
            break;
        case 2:
            *tmpDestCursor = (*src) & 1;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 1) & 1) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 2) & 1) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 3) & 1) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 4) & 1) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 5) & 1) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 6) & 1) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 7) & 3) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 9) & 3) + *(tmpDestCursor + 7);
            *(tmpDestCursor + 9) = ((*src >> 11) & 3) + *(tmpDestCursor + 8);
            *(tmpDestCursor + 10) = ((*src >> 13) & 3) + *(tmpDestCursor + 9);
            *(tmpDestCursor + 11) = ((*src >> 15) & 3) + *(tmpDestCursor + 10);
            *(tmpDestCursor + 12) = ((*src >> 17) & 3) + *(tmpDestCursor + 11);
            *(tmpDestCursor + 13) = ((*src >> 19) & 3) + *(tmpDestCursor + 12);
            *(tmpDestCursor + 14) = ((*src >> 21) & 1) + *(tmpDestCursor + 13);
            *(tmpDestCursor + 15) = ((*src >> 22) & 1) + *(tmpDestCursor + 14);
            *(tmpDestCursor + 16) = ((*src >> 23) & 1) + *(tmpDestCursor + 15);
            *(tmpDestCursor + 17) = ((*src >> 24) & 1) + *(tmpDestCursor + 16);
            *(tmpDestCursor + 18) = ((*src >> 25) & 1) + *(tmpDestCursor + 17);
            *(tmpDestCursor + 19) = ((*src >> 26) & 1) + *(tmpDestCursor + 18);
            *(tmpDestCursor + 20) = ((*src >> 27) & 1) + *(tmpDestCursor + 19);
            tmpDestCursor += 21;
            break;
        case 3:
            *tmpDestCursor = (*src) & 1;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 1) & 1) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 2) & 1) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 3) & 1) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 4) & 1) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 5) & 1) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 6) & 1) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 7) & 1) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 8) & 1) + *(tmpDestCursor + 7);
            *(tmpDestCursor + 9) = ((*src >> 9) & 1) + *(tmpDestCursor + 8);
            *(tmpDestCursor + 10) = ((*src >> 10) & 1) + *(tmpDestCursor + 9);
            *(tmpDestCursor + 11) = ((*src >> 11) & 1) + *(tmpDestCursor + 10);
            *(tmpDestCursor + 12) = ((*src >> 12) & 1) + *(tmpDestCursor + 11);
            *(tmpDestCursor + 13) = ((*src >> 13) & 1) + *(tmpDestCursor + 12);
            *(tmpDestCursor + 14) = ((*src >> 14) & 3) + *(tmpDestCursor + 13);
            *(tmpDestCursor + 15) = ((*src >> 16) & 3) + *(tmpDestCursor + 14);
            *(tmpDestCursor + 16) = ((*src >> 18) & 3) + *(tmpDestCursor + 15);
            *(tmpDestCursor + 17) = ((*src >> 20) & 3) + *(tmpDestCursor + 16);
            *(tmpDestCursor + 18) = ((*src >> 22) & 3) + *(tmpDestCursor + 17);
            *(tmpDestCursor + 19) = ((*src >> 24) & 3) + *(tmpDestCursor + 18);
            *(tmpDestCursor + 20) = ((*src >> 26) & 3) + *(tmpDestCursor + 19);
            tmpDestCursor += 21;
            break;
        case 4:
            *tmpDestCursor = (*src) & 3;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 2) & 3) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 4) & 3) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 6) & 3) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 8) & 3) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 10) & 3) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 12) & 3) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 14) & 3) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 16) & 3) + *(tmpDestCursor + 7);
            *(tmpDestCursor + 9) = ((*src >> 18) & 3) + *(tmpDestCursor + 8);
            *(tmpDestCursor + 10) = ((*src >> 20) & 3) + *(tmpDestCursor + 9);
            *(tmpDestCursor + 11) = ((*src >> 22) & 3) + *(tmpDestCursor + 10);
            *(tmpDestCursor + 12) = ((*src >> 24) & 3) + *(tmpDestCursor + 11);
            *(tmpDestCursor + 13) = ((*src >> 26) & 3) + *(tmpDestCursor + 12);
            tmpDestCursor += 14;
            break;
        case 5:
            *tmpDestCursor = (*src) & 15;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 4) & 7) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 7) & 7) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 10) & 7) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 13) & 7) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 16) & 7) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 19) & 7) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 22) & 7) + *(tmpDestCursor + 6);
            *(tmpDestCursor + 8) = ((*src >> 25) & 7) + *(tmpDestCursor + 7);
            tmpDestCursor += 9;
            break;
        case 6:
            *tmpDestCursor = (*src) & 7;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 3) & 15) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 7) & 15) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 11) & 15) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 15) & 15) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 19) & 7) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 22) & 7) + *(tmpDestCursor + 5);
            *(tmpDestCursor + 7) = ((*src >> 25) & 7) + *(tmpDestCursor + 6);
            tmpDestCursor += 8;
            break;
        case 7:
            *tmpDestCursor = (*src) & 15;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 4) & 15) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 8) & 15) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 12) & 15) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 16) & 15) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 20) & 15) + *(tmpDestCursor + 4);
            *(tmpDestCursor + 6) = ((*src >> 24) & 15) + *(tmpDestCursor + 5);
            tmpDestCursor += 7;
            break;
        case 8:
            *tmpDestCursor = (*src) & 31;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 5) & 31) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 10) & 31) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 15) & 31) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 20) & 15) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 24) & 15) + *(tmpDestCursor + 4);
            tmpDestCursor += 6;
            break;
        case 9:
            *tmpDestCursor = (*src) & 15;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 4) & 15) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 8) & 31) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 13) & 31) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 18) & 31) + *(tmpDestCursor + 3);
            *(tmpDestCursor + 5) = ((*src >> 23) & 31) + *(tmpDestCursor + 4);
            tmpDestCursor += 6;
            break;
        case 10:
            *tmpDestCursor = (*src) & 63;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 6) & 63) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 12) & 63) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 18) & 31) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 23) & 31) + *(tmpDestCursor + 3);
            tmpDestCursor += 5;
            break;
        case 11:
            *tmpDestCursor = (*src) & 31;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 5) & 31) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 10) & 63) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 16) & 63) + *(tmpDestCursor + 2);
            *(tmpDestCursor + 4) = ((*src >> 22) & 63) + *(tmpDestCursor + 3);
            tmpDestCursor += 5;
            break;
        case 12:
            *tmpDestCursor = (*src) & 127;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 7) & 127) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 14) & 127) + *(tmpDestCursor + 1);
            *(tmpDestCursor + 3) = ((*src >> 21) & 127) + *(tmpDestCursor + 2);
            tmpDestCursor += 4;
            break;
        case 13:
            *tmpDestCursor = (*src) & 1023;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 10) & 511) + *(tmpDestCursor);
            *(tmpDestCursor + 2) = ((*src >> 19) & 511) + *(tmpDestCursor + 1);
            tmpDestCursor += 3;
            break;
        case 14:
            *tmpDestCursor = (*src) & 16383;
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            *(tmpDestCursor + 1) = ((*src >> 14) & 16383) + *(tmpDestCursor);
            tmpDestCursor += 2;
            break;
        case 15:
            *tmpDestCursor = (*src) & ((1 << 28) - 1);
            if (firstFieldFlag)
                *tmpDestCursor += *(tmpDestCursor - 1);
            else
                firstFieldFlag = true;
            tmpDestCursor += 1;
            break;
        }

        leftCount -= itemNumPerUnit[k];
        fidCursor += itemNumPerUnit[k];
        srcCursor += sizeof(uint32_t);
    }

    destCursor = (uint8_t*)fidCursor;
}