public Page replaceColumn(int channelIndex, Block column)
    {
        if (column.getPositionCount() != positionCount) {
            throw new IllegalArgumentException("New column does not have same number of rows as old column");
        }

        Block[] newBlocks = Arrays.copyOf(blocks, blocks.length);
        newBlocks[channelIndex] = column;
        return Page.wrapBlocksWithoutCopy(newBlocks.length, newBlocks);
    }
@Test
    public void testReplaceColumn()
    {
        int entries = 10;
        BlockBuilder blockBuilder = BIGINT.createBlockBuilder(null, entries);
        for (int i = 0; i < entries; i++) {
            BIGINT.writeLong(blockBuilder, i);
        }
        Block block = blockBuilder.build();
        Page page = new Page(block, block, block);
        assertEquals(page.getBlock(1).getLong(0), 0);

        BlockBuilder newBlockBuilder = BIGINT.createBlockBuilder(null, entries);
        for (int i = 0; i < entries; i++) {
            BIGINT.writeLong(newBlockBuilder, -i);
        }
        Block newBlock = newBlockBuilder.build();
        Page newPage = page.replaceColumn(1, newBlock);

        assertEquals(newPage.getChannelCount(), 3);
        assertEquals(newPage.getBlock(1).getLong(0), 0);
        assertEquals(newPage.getBlock(1).getLong(1), -1);
    }