public int foreach(BitMap position, LongSetter setter) {
        if (position == BitMap.ALL) {
            foreach(0, objCount, setter);
            return objCount;
        }
        DirectBitMapIterator posIterator = position.iterator();
        int count = 0;
        switch (version) {
            case Version.VERSION_0_ID: {
                int index;
                while ((index = posIterator.nextSetBit()) != BitSetIterator.NO_MORE) {
                    if (index >= objCount) {
                        break;
                    }
                    setter.set(index, NumOp.getVal(numType, dataAddr, index, minVal));
                    count++;
                }
                break;
            }
            default: {
                int index;
                while ((index = posIterator.nextSetBit()) != BitSetIterator.NO_MORE) {
                    if (index >= objCount) {
                        break;
                    }
                    setter.set(index, NumOp.getLong(dataAddr, index));
                    count++;
                }
                break;
            }
        }
        return count;
    }
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