@Override public boolean isNull(int position) { checkReadablePosition(position); return valueIsNull[position]; }
@Override public int getInt(int position, int offset) { checkReadablePosition(position); if (offset != 0) { throw new IllegalArgumentException("offset must be zero"); } return values[position]; }
@Override public Block getSingleValueBlock(int position) { checkReadablePosition(position); return new IntArrayBlock( 0, 1, valueIsNull[position] ? new boolean[] {true} : null, new int[] {values[position]}); }
@Override public void writePositionTo(int position, BlockBuilder blockBuilder) { checkReadablePosition(position); blockBuilder.writeInt(values[position]); blockBuilder.closeEntry(); }
@Override public Block copyPositions(int[] positions, int offset, int length) { checkArrayRange(positions, offset, length); if (!hasNonNullValue) { return new RunLengthEncodedBlock(NULL_VALUE_BLOCK, length); } boolean[] newValueIsNull = null; if (hasNullValue) { newValueIsNull = new boolean[length]; } int[] newValues = new int[length]; for (int i = 0; i < length; i++) { int position = positions[offset + i]; checkReadablePosition(position); if (hasNullValue) { newValueIsNull[i] = valueIsNull[position]; } newValues[i] = values[position]; } return new IntArrayBlock(0, length, newValueIsNull, newValues); }
@Override public boolean isNull(int position) { checkReadablePosition(position); return valueIsNull[position]; }
@Override public int getInt(int position, int offset) { checkReadablePosition(position); if (offset != 0) { throw new IllegalArgumentException("offset must be zero"); } return values[position]; }
@Override public Block getSingleValueBlock(int position) { checkReadablePosition(position); return new IntArrayBlock( 0, 1, valueIsNull[position] ? new boolean[] {true} : null, new int[] {values[position]}); }
@Override public void writePositionTo(int position, BlockBuilder blockBuilder) { checkReadablePosition(position); blockBuilder.writeInt(values[position]); blockBuilder.closeEntry(); }
@Override public Block copyPositions(int[] positions, int offset, int length) { checkArrayRange(positions, offset, length); if (!hasNonNullValue) { return new RunLengthEncodedBlock(NULL_VALUE_BLOCK, length); } boolean[] newValueIsNull = null; if (hasNullValue) { newValueIsNull = new boolean[length]; } int[] newValues = new int[length]; for (int i = 0; i < length; i++) { int position = positions[offset + i]; checkReadablePosition(position); if (hasNullValue) { newValueIsNull[i] = valueIsNull[position]; } newValues[i] = values[position]; } return new IntArrayBlock(0, length, newValueIsNull, newValues); }