@@ -0,0 +1,2289 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.operator.aggregation;%0A%0Aimport com.facebook.presto.spi.block.Block;%0Aimport com.facebook.presto.spi.block.BlockBuilder;%0Aimport com.facebook.presto.spi.block.BlockBuilderStatus;%0Aimport com.facebook.presto.spi.type.SqlVarbinary;%0Aimport com.facebook.presto.spi.type.StandardTypes;%0Aimport com.google.common.collect.ImmutableList;%0Aimport io.airlift.stats.cardinality.HyperLogLog;%0A%0Aimport java.util.List;%0A%0Aimport static com.facebook.presto.spi.type.HyperLogLogType.HYPER_LOG_LOG;%0A%0Apublic class TestMergeHyperLogLogAggregation%0A        extends AbstractTestAggregationFunction%0A%7B%0A    private static final int NUMBER_OF_BUCKETS = 16;%0A%0A    @Override%0A    public Block%5B%5D getSequenceBlocks(int start, int length)%0A    %7B%0A        BlockBuilder blockBuilder = HYPER_LOG_LOG.createBlockBuilder(new BlockBuilderStatus(), length);%0A        for (int i = start; i %3C start + length; i++) %7B%0A            HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);%0A            hll.add(i);%0A            HYPER_LOG_LOG.writeSlice(blockBuilder, hll.serialize());%0A        %7D%0A        return new Block%5B%5D %7BblockBuilder.build()%7D;%0A    %7D%0A%0A    @Override%0A    protected String getFunctionName()%0A    %7B%0A        return %22merge%22;%0A    %7D%0A%0A    @Override%0A    protected List%3CString%3E getFunctionParameterTypes()%0A    %7B%0A        return ImmutableList.of(StandardTypes.HYPER_LOG_LOG);%0A    %7D%0A%0A    @Override%0A    public Object getExpectedValue(int start, int length)%0A    %7B%0A        if (length == 0) %7B%0A            return null;%0A        %7D%0A%0A        HyperLogLog hll = HyperLogLog.newInstance(NUMBER_OF_BUCKETS);%0A        for (int i = start; i %3C start + length; i++) %7B%0A            hll.add(i);%0A        %7D%0A        return new SqlVarbinary(hll.serialize().getBytes());%0A    %7D%0A%7D%0A

Add test for MergeHyperLogLogAggregation