Source:
<code>private static void writeNewOffsets(byte[] arrayBytes, byte[] newArray, boolean useShortNew, boolean useShortPrevious, int newOffsetArrayPosition, int arrayLength, int offsetArrayPosition, int offset, int offsetShift, int length) { int currentPosition = newOffsetArrayPosition; int offsetArrayElementSize = useShortNew ? Bytes.SIZEOF_SHORT : Bytes.SIZEOF_INT; if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (0 - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, 0); } currentPosition += offsetArrayElementSize; <START> boolean isFirstNullGroup = true; <END> for (int arrayIndex = 0; arrayIndex < arrayLength - 1; arrayIndex++) { int oldOffset = getOffset(arrayBytes, arrayIndex, useShortPrevious, offsetArrayPosition + offset); if (arrayBytes[offset + oldOffset] == QueryConstants.SEPARATOR_BYTE && isFirstNullGroup) { if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (oldOffset - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, oldOffset); } } else { if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (oldOffset + offsetShift - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, oldOffset + offsetShift); } isFirstNullGroup = false; } currentPosition += offsetArrayElementSize; } Bytes.putInt(newArray, currentPosition, newOffsetArrayPosition); currentPosition += Bytes.SIZEOF_INT; Bytes.putInt(newArray, currentPosition, useShortNew ? arrayLength : -arrayLength); currentPosition += Bytes.SIZEOF_INT; Bytes.putByte(newArray, currentPosition, arrayBytes[offset + length - 1]); }</code><technical_language>name for this? 'nullsAtBeginning' (may better)</technical_language>

Target:
private static void writeNewOffsets(byte[] arrayBytes, byte[] newArray, boolean useShortNew, boolean useShortPrevious, int newOffsetArrayPosition, int arrayLength, int offsetArrayPosition, int offset, int offsetShift, int length) { int currentPosition = newOffsetArrayPosition; int offsetArrayElementSize = useShortNew ? Bytes.SIZEOF_SHORT : Bytes.SIZEOF_INT; if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (0 - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, 0); } currentPosition += offsetArrayElementSize; boolean nullsAtBeginning = true; for (int arrayIndex = 0; arrayIndex < arrayLength - 1; arrayIndex++) { int oldOffset = getOffset(arrayBytes, arrayIndex, useShortPrevious, offsetArrayPosition + offset); if (arrayBytes[offset + oldOffset] == QueryConstants.SEPARATOR_BYTE && nullsAtBeginning) { if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (oldOffset - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, oldOffset); } } else { if (useShortNew) { Bytes.putShort(newArray, currentPosition, (short) (oldOffset + offsetShift - Short.MAX_VALUE)); } else { Bytes.putInt(newArray, currentPosition, oldOffset + offsetShift); } nullsAtBeginning = false; } currentPosition += offsetArrayElementSize; } Bytes.putInt(newArray, currentPosition, newOffsetArrayPosition); currentPosition += Bytes.SIZEOF_INT; Bytes.putInt(newArray, currentPosition, useShortNew ? arrayLength : -arrayLength); currentPosition += Bytes.SIZEOF_INT; Bytes.putByte(newArray, currentPosition, arrayBytes[offset + length - 1]); }