/*
 * Copyright 2004-present Facebook. All Rights Reserved.
 */
package com.facebook.presto.operator;

import com.facebook.presto.block.Block;
import com.google.common.base.Preconditions;

public class Page
{
    private final Block[] blocks;

    public Page(Block... blocks)
    {
        Preconditions.checkNotNull(blocks, "blocks is null");
        Preconditions.checkArgument(blocks.length > 0, "blocks is empty");
        this.blocks = blocks;
    }

    public int getChannelCount()
    {
        return blocks.length;
    }

    public int getPositionCount()
    {
        return blocks[0].getPositionCount();
    }

    public Block[] getBlocks()
    {
        return blocks.clone();
    }

    public Block getBlock(int channel)
    {
        return blocks[channel];
    }
}

@@ -182,16 +182,42 @@
 tions;%0A%0A
+import java.util.Arrays;%0A%0A
 public c
@@ -461,22 +461,52 @@
 locks = 
-blocks
+Arrays.copyOf(blocks, blocks.length)
 ;%0A    %7D%0A

Create copy of input array