@Override
    public final void foreach(int start, int count, BytePieceSetter setter) {
        BytePiece bytes = new BytePiece();
        switch (version) {
            case Version.VERSION_0_ID:
                for (int index = start; index < start + count; index++) {
                    long startAddr, endAddr;

                    if (maxObjLen == 0) {
                        startAddr = 0;
                        endAddr = 0;
                    } else {
                        long indexAddr = dataAddr + (index << 3) + 4;
                        int str_offset = (objCount << 3) + 4;
                        startAddr = MemoryUtil.getInt(indexAddr) + dataAddr + str_offset;
                        endAddr = MemoryUtil.getInt(indexAddr + 4) + dataAddr + str_offset;
                    }

                    bytes.addr = startAddr;
                    bytes.len = (int) (endAddr - startAddr);
                    setter.set(index, bytes);
                }
                break;
            default:
                for (int index = start; index < start + count; index++) {
                    long startAddr, endAddr;

                    long indexAddr = dataAddr + (index << 2);
                    int str_offset = (objCount + 1) << 2;
                    startAddr = MemoryUtil.getInt(indexAddr) + dataAddr + str_offset;
                    endAddr = MemoryUtil.getInt(indexAddr + 4) + dataAddr + str_offset;

                    bytes.addr = startAddr;
                    bytes.len = (int) (endAddr - startAddr);
                    setter.set(index, bytes);
                }
        }
    }
Note that this method could update the content of dpn.
Make sure to call this method before you actually save the dpn instance to storage.
indexr-segment/src/main/java/io/indexr/segment/pack/DataPack.java