Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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 java.util.Set;
 
 import static com.facebook.presto.block.BlockAssertions.createBooleansBlock;
 import static com.facebook.presto.block.BlockAssertions.createDoublesBlock;
 import static com.facebook.presto.block.BlockAssertions.createLongsBlock;
 import static com.facebook.presto.block.BlockAssertions.createStringsBlock;
 import static com.facebook.presto.operator.aggregation.AggregationTestUtils.assertAggregation;
 import static org.testng.Assert.assertNotNull;
 
 {
     private static final MetadataManager metadata = new MetadataManager();
 
     @Test
     public void testAllRegistered()
     {
         Set<TypeallTypes = FluentIterable.from(.getTypeManager().getTypes()).toSet();
 
         for (Type valueType : allTypes) {
             assertNotNull(.getExactFunction(new Signature("arbitrary"valueType.getTypeSignature(), valueType.getTypeSignature())));
         }
     }
 
     @Test
     public void testNullBoolean()
         throws Exception
     {
         assertAggregation(
                 booleanAgg,
                 1.0,
                 null,
                 createPage(
                         new Boolean[] {null}));
     }
 
     @Test
     public void testValidBoolean()
             throws Exception
     {
         assertAggregation(
                 booleanAgg,
                 1.0,
                 true,
                 createPage(
                         new Boolean[] {truetrue}));
     }
 
     @Test
     public void testNullLong()
             throws Exception
     {
         assertAggregation(
                 longAgg,
                 1.0,
                 null,
                 createPage(
                         new Long[] {nullnull}));
     }
 
     @Test
     public void testValidLong()
             throws Exception
     {
         assertAggregation(
                 longAgg,
                 1.0,
                 1L,
                 createPage(
                         new Long[] {1L , null}));
     }
 
     @Test
    public void testNullDouble()
            throws Exception
    {
        assertAggregation(
                doubleAgg,
                1.0,
                null,
                createPage(
                        new Double[] {nullnull}));
    }
    @Test
    public void testValidDouble()
            throws Exception
    {
        assertAggregation(
                doubleAgg,
                1.0,
                2.0,
                createPage(
                        new Double[] {null, 2.0}));
    }
    @Test
    public void testNullString()
            throws Exception
    {
        assertAggregation(
                stringAgg,
                1.0,
                null,
                createPage(
                        new String[] {nullnull}));
    }
    @Test
    public void testValidString()
            throws Exception
    {
        assertAggregation(
                stringAgg,
                1.0,
                "a",
                createPage(
                        new String[] {"a""a"}));
    }
    private static Page createPage(Boolean[] values)
    {
        return new Page(createBooleansBlock(values));
    }
    private static Page createPage(Long[] values)
    {
        return new Page(createLongsBlock(values));
    }
    private static Page createPage(Double[] values)
    {
        return new Page(createDoublesBlock(values));
    }
    private static Page createPage(String[] values)
    {
        return new Page(createStringsBlock(values));
    }
New to GrepCode? Check out our FAQ X