private static ByteSlice doCompressIndexedStr(ByteSlice data, int itemSize) {
        if (itemSize == 0 || data.getInt(0) == 0) {
            return ByteSlice.empty();
        }
        long native_p = BhcompressLibrary.INSTANCE.JavaCompress_IndexedString_NP(data.address(), itemSize);
        int err = MemoryUtil.getByte(native_p);
        if (err != BhcompressLibrary.CprsErr_J.CPRS_SUCCESS_J) {
            MemoryUtil.free(native_p);
            throw new RuntimeException(String.format("compress string err[%d]", err));
        }
        int max_len = MemoryUtil.getShort(native_p + 1) & 0xFFFF;
        if (max_len == 0) {
            return ByteSlice.fromAddress(native_p, 1 + 2, true);
        }
        int index_cmp_data_size = MemoryUtil.getInt(native_p + 3);
        int str_cmp_data_size = MemoryUtil.getInt(native_p + 7);
        return ByteSlice.fromAddress(native_p, 1 + 2 + 4 + 4 + index_cmp_data_size + str_cmp_data_size, true);
    }
Wrapper of brighthouse compression.
This class is closely linked to cpp code and native data structure, don't touch it unless you know what you are doing.

Note that all values here are in unsigned form, including max_val.
indexr-segment/src/main/java/io/indexr/compress/bh/BHCompressor.java