Source:
<code>public Block copyPositions(int[] positions, int offset, int length) { checkValidPositionsArray(positions, offset, length); int[] newOffsets = new int[length + 1]; boolean[] newMapIsNull = new boolean[length]; IntArrayList entriesPositions = new IntArrayList(); int newPosition = 0; for (int i = offset; i < offset + length; ++i) { int position = positions[i]; if (isNull(position)) { newMapIsNull[newPosition] = true; newOffsets[newPosition + 1] = newOffsets[newPosition]; } else { int entriesStartOffset = getOffset(position); int entriesEndOffset = getOffset(position + 1); int entryCount = entriesEndOffset - entriesStartOffset; newOffsets[newPosition + 1] = newOffsets[newPosition] + entryCount; for (int elementIndex = entriesStartOffset; elementIndex < entriesEndOffset; elementIndex++) { entriesPositions.add(elementIndex); } } newPosition++; } int[] hashTable = getHashTables(); int[] newHashTable = new int[newOffsets[newOffsets.length - 1] * HASH_MULTIPLIER]; int newHashIndex = 0; <START> for (int i = 0; i < length; ++i) { <END> int position = positions[offset + i]; int entriesStartOffset = getOffset(position); int entriesEndOffset = getOffset(position + 1); for (int hashIndex = entriesStartOffset * HASH_MULTIPLIER; hashIndex < entriesEndOffset * HASH_MULTIPLIER; hashIndex++) { newHashTable[newHashIndex] = hashTable[hashIndex]; newHashIndex++; } } Block newKeys = getKeys().copyPositions(entriesPositions.elements(), 0, entriesPositions.size()); Block newValues = getValues().copyPositions(entriesPositions.elements(), 0, entriesPositions.size()); return new MapBlock(0, length, newMapIsNull, newOffsets, newKeys, newValues, newHashTable, keyType, keyBlockNativeEquals, keyNativeHashCode); }</code><technical_language>nit: iterate offset offset + length done in other loops in this PR. similar loops if want update all</technical_language>

Target:
public Block copyPositions(int[] positions, int offset, int length) { checkValidPositionsArray(positions, offset, length); int[] newOffsets = new int[length + 1]; boolean[] newMapIsNull = new boolean[length]; IntArrayList entriesPositions = new IntArrayList(); int newPosition = 0; for (int i = offset; i < offset + length; ++i) { int position = positions[i]; if (isNull(position)) { newMapIsNull[newPosition] = true; newOffsets[newPosition + 1] = newOffsets[newPosition]; } else { int entriesStartOffset = getOffset(position); int entriesEndOffset = getOffset(position + 1); int entryCount = entriesEndOffset - entriesStartOffset; newOffsets[newPosition + 1] = newOffsets[newPosition] + entryCount; for (int elementIndex = entriesStartOffset; elementIndex < entriesEndOffset; elementIndex++) { entriesPositions.add(elementIndex); } } newPosition++; } int[] hashTable = getHashTables(); int[] newHashTable = new int[newOffsets[newOffsets.length - 1] * HASH_MULTIPLIER]; int newHashIndex = 0; for (int i = offset; i < offset + length; ++i) { int position = positions[i]; int entriesStartOffset = getOffset(position); int entriesEndOffset = getOffset(position + 1); for (int hashIndex = entriesStartOffset * HASH_MULTIPLIER; hashIndex < entriesEndOffset * HASH_MULTIPLIER; hashIndex++) { newHashTable[newHashIndex] = hashTable[hashIndex]; newHashIndex++; } } Block newKeys = getKeys().copyPositions(entriesPositions.elements(), 0, entriesPositions.size()); Block newValues = getValues().copyPositions(entriesPositions.elements(), 0, entriesPositions.size()); return new MapBlock(0, length, newMapIsNull, newOffsets, newKeys, newValues, newHashTable, keyType, keyBlockNativeEquals, keyNativeHashCode); }