@Override public Block copyPositions(List<Integer> positions) { int finalLength = positions.stream().mapToInt(this::getLength).sum(); SliceOutput newSlice = Slices.allocate(finalLength).getOutput(); int[] newOffsets = new int[positions.size() + 1]; boolean[] newValueIsNull = new boolean[positions.size()]; for (int i = 0; i < positions.size(); i++) { int position = positions.get(i); if (isEntryNull(position)) { newValueIsNull[i] = true; } else { newSlice.appendBytes( sliceOutput .getUnderlyingSlice() .getBytes(getPositionOffset(position), getLength(position))); } newOffsets[i + 1] = newSlice.size(); } return new VariableWidthBlock(positions.size(), newSlice.slice(), newOffsets, newValueIsNull); }
@Override protected Slice getRawSlice() { return sliceOutput.getUnderlyingSlice(); }