Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *    http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 package org.apache.spark.sql.expressions.javalang;
0019 
0020 import org.apache.spark.api.java.function.MapFunction;
0021 import org.apache.spark.sql.TypedColumn;
0022 import org.apache.spark.sql.execution.aggregate.TypedAverage;
0023 import org.apache.spark.sql.execution.aggregate.TypedCount;
0024 import org.apache.spark.sql.execution.aggregate.TypedSumDouble;
0025 import org.apache.spark.sql.execution.aggregate.TypedSumLong;
0026 
0027 /**
0028  * Type-safe functions available for {@link org.apache.spark.sql.Dataset} operations in Java.
0029  *
0030  * Scala users should use {@link org.apache.spark.sql.expressions.scalalang.typed}.
0031  *
0032  * @since 2.0.0
0033  * @deprecated As of release 3.0.0, please use the untyped builtin aggregate functions.
0034  */
0035 @Deprecated
0036 public class typed {
0037   // Note: make sure to keep in sync with typed.scala
0038 
0039   /**
0040    * Average aggregate function.
0041    *
0042    * @since 2.0.0
0043    */
0044   public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) {
0045     return new TypedAverage<T>(f).toColumnJava();
0046   }
0047 
0048   /**
0049    * Count aggregate function.
0050    *
0051    * @since 2.0.0
0052    */
0053   public static <T> TypedColumn<T, Long> count(MapFunction<T, Object> f) {
0054     return new TypedCount<T>(f).toColumnJava();
0055   }
0056 
0057   /**
0058    * Sum aggregate function for floating point (double) type.
0059    *
0060    * @since 2.0.0
0061    */
0062   public static <T> TypedColumn<T, Double> sum(MapFunction<T, Double> f) {
0063     return new TypedSumDouble<T>(f).toColumnJava();
0064   }
0065 
0066   /**
0067    * Sum aggregate function for integral (long, i.e. 64 bit integer) type.
0068    *
0069    * @since 2.0.0
0070    */
0071   public static <T> TypedColumn<T, Long> sumLong(MapFunction<T, Long> f) {
0072     return new TypedSumLong<T>(f).toColumnJava();
0073   }
0074 }