Page[] maskedPages = new Page[pages.length];
for (int i = 0; i < pages.length; i++) {
Page page = pages[i];
int positionCount = page.getPositionCount();
int blockSize = SINGLE_BOOLEAN.getFixedSize() * positionCount;
BlockBuilder blockBuilder = new BlockBuilder(SINGLE_BOOLEAN, blockSize, Slices.allocate(blockSize).getOutput());
for (int j = 0; j < page.getPositionCount(); j++) {
blockBuilder.append(maskValue);
}
Block[] sourceBlocks = page.getBlocks();
Block[] outputBlocks = new Block[sourceBlocks.length + 1]; // +1 for the single boolean output channel
System.arraycopy(sourceBlocks, 0, outputBlocks, 0, sourceBlocks.length);
outputBlocks[sourceBlocks.length] = blockBuilder.build();
maskedPages[i] = new Page(outputBlocks);
}
return maskedPages;