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.scalar;
 
 
 
 
 public final class TestingRowConstructor
 {
     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapperProvider().get().registerModule(new SimpleModule().addSerializer(Slice.classnew SliceSerializer()));
 
     private TestingRowConstructor() {}
 
     @ScalarFunction("test_row")
     @SqlType("row<bigint,bigint>('col0','col1')")
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<bigint,double>('col0','col1')")
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<bigint,double,boolean,varchar,timestamp>('col0','col1','col2','col3','col4')")
                                                           @Nullable @SqlType(.Boolean arg3, @Nullable @SqlType(.Slice arg4,
                                                           @Nullable @SqlType(.Long arg5)
     {
         return toStackRepresentation(arg1arg2arg3arg4arg5);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<HyperLogLog>('col0')")
     {
         return toStackRepresentation(arg1);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<double,row<timestamp with time zone,timestamp with time zone>('col0','col1')>('col2','col3')")
                                                                   @Nullable @SqlType("row<timestamp with time zone,timestamp with time zone>('col0','col1')"Slice arg2)
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<timestamp with time zone,timestamp with time zone>('col0','col1')")
                                                                    @Nullable @SqlType(.Long arg2)
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<double,double>('col0','col1')")
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<double,varchar>('col0','col1')")
     {
         return toStackRepresentation(arg1arg2);
     }
 
     @ScalarFunction("test_row")
     @SqlType("row<boolean,boolean>('col0','col1')")
    {
        return toStackRepresentation(arg1arg2);
    }
    @ScalarFunction("test_row")
    @SqlType("row<boolean,boolean,boolean,boolean>('col0','col1','col2','col3')")
                                              @Nullable @SqlType(.Boolean arg3, @Nullable @SqlType(.Boolean arg4)
    {
        return toStackRepresentation(arg1arg2arg3arg4);
    }
    @ScalarFunction("test_row")
    @SqlType("row<boolean,array<bigint>>('col0','col1')")
    public static Slice testRowBooleanArray(@Nullable @SqlType(.Boolean arg1, @Nullable @SqlType("array<bigint>"Slice arg2)
    {
        return toStackRepresentation(arg1arg2);
    }
    @ScalarFunction("test_row")
    @SqlType("row<boolean,array<bigint>,map<bigint,double>>('col0','col1','col2')")
    public static Slice testRowBooleanArrayMap(@Nullable @SqlType(.Boolean arg1, @Nullable @SqlType("array<bigint>"Slice arg2,
                                               @Nullable @SqlType("map<bigint,double>"Slice arg3)
    {
        return toStackRepresentation(arg1arg2arg3);
    }
    @ScalarFunction("test_row")
    @SqlType("row<double,array<bigint>,row<bigint,double>('col0','col1')>('col0','col1','col2')")
    public static Slice testNestedRow(@Nullable @SqlType(.Double arg1, @Nullable @SqlType("array<bigint>"Slice arg2,
                                               @Nullable @SqlType("row<bigint,double>('col0','col1')"Slice arg3)
    {
        return toStackRepresentation(arg1arg2arg3);
    }
    @ScalarFunction("test_row")
    @SqlType("row<timestamp>('col0')")
    {
        return toStackRepresentation(arg1);
    }
    private static Slice toStackRepresentation(Object... values)
    {
        try {
            return Slices.utf8Slice(.writeValueAsString(Arrays.asList(values)));
        }
        catch (JsonProcessingException e) {
            throw Throwables.propagate(e);
        }
    }
New to GrepCode? Check out our FAQ X