/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.operator.aggregation;

import com.facebook.presto.spi.block.Block;
import com.facebook.presto.spi.block.BlockBuilder;
import com.facebook.presto.spi.block.BlockBuilderStatus;
import com.facebook.presto.type.ArrayType;
import com.google.common.collect.ImmutableList;

import java.util.List;

import static com.facebook.presto.spi.type.VarbinaryType.VARBINARY;

public class TestArrayMinAggregation
        extends AbstractTestAggregationFunction
{
    @Override
    public Block getSequenceBlock(int start, int length)
    {
        BlockBuilder blockBuilder = VARBINARY.createBlockBuilder(new BlockBuilderStatus());
        for (int i = start; i < start + length; i++) {
            //VARBINARY.writeSlice(blockBuilder, Slices.wrappedBuffer(Ints.toByteArray(i)));
            VARBINARY.writeSlice(blockBuilder, ArrayType.toStackRepresentation(ImmutableList.of(i)));
        }
        return blockBuilder.build();
    }

    @Override
    public List<Long> getExpectedValue(int start, int length)
    {
        if (length == 0) {
            return null;
        }
        return ImmutableList.of((long) start);
    }

    @Override
    protected String getFunctionName()
    {
        return "min";
    }

    @Override
    protected List<String> getFunctionParameterTypes()
    {
        return ImmutableList.of("array<bigint>");
    }
}

@@ -758,16 +758,64 @@
 Status;%0A
+import com.facebook.presto.spi.type.BigintType;%0A
 import c
@@ -845,24 +845,24 @@
 .ArrayType;%0A
-
 import com.g
@@ -989,16 +989,88 @@
 RBINARY;
+%0Aimport static com.facebook.presto.type.ArrayType.toStackRepresentation;
 %0A%0Apublic
@@ -1386,18 +1386,16 @@
         
-//
 VARBINAR
@@ -1425,109 +1425,8 @@
 er, 
-Slices.wrappedBuffer(Ints.toByteArray(i)));%0A            VARBINARY.writeSlice(blockBuilder, ArrayType.
 toSt
@@ -1462,16 +1462,35 @@
 st.of(i)
+, BigintType.BIGINT
 ));%0A    

Fix build broken by 9dab649