/** * Count aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> count(MapFunction<T, Object> f) { return new TypedCount<T>(f).toColumnJava(); }
/** * Average aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) { return new TypedAverage<T>(f).toColumnJava(); }
/** * Sum aggregate function for floating point (double) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> sum(MapFunction<T, Double> f) { return new TypedSumDouble<T>(f).toColumnJava(); }
/** * Sum aggregate function for integral (long, i.e. 64 bit integer) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> sumLong(MapFunction<T, Long> f) { return new TypedSumLong<T>(f).toColumnJava(); } }
@Override public UnsafeRow next() { if (hasNext()) { UnsafeRow result = generateOutput.apply( aggregationBufferMapIterator.getKey(), aggregationBufferMapIterator.getValue()); try { // Pre-load next key-value pair form aggregationBufferMapIterator to make hasNext // idempotent. mapIteratorHasNext = aggregationBufferMapIterator.next(); } catch (IOException e) { throw new RuntimeException(e); } if (!mapIteratorHasNext) { // If there is no input from aggregationBufferMapIterator, we copy current result. UnsafeRow resultCopy = result.copy(); // Then, we free the map. hashMap.free(); return resultCopy; } else { return result; } } else { // no more result throw new NoSuchElementException(); } }
} else { TungstenAggregationIterator aggregationIterator = new TungstenAggregationIterator( groupingExpressions, aggregateExpressions, chidlResIter); if (!hasInput && groupingExpressions.isEmpty()) { UnsafeRow singleRowResult = aggregationIterator.outputForEmptyGroupingKeyWithoutInput(); return Iterators.singletonIterator(singleRowResult); } else {
/** * Generate a output row when there is no input and there is no grouping expression. */ public UnsafeRow outputForEmptyGroupingKeyWithoutInput() { if (groupingExpressions.isEmpty()) { // We create a output row and copy it. So, we can free the map. UnsafeRow resultCopy = generateOutput.apply(UnsafeRow.createFromByteArray(0, 0), initialAggregationBuffer).copy(); hashMap.free(); return resultCopy; } else { throw new IllegalStateException("This method should not be called when groupingExpressions is not empty."); } } }
/** * Count aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> count(MapFunction<T, Object> f) { return new TypedCount<T>(f).toColumnJava(); }
/** * Average aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) { return new TypedAverage<T>(f).toColumnJava(); }
/** * Sum aggregate function for floating point (double) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> sum(MapFunction<T, Double> f) { return new TypedSumDouble<T>(f).toColumnJava(); }
/** * Sum aggregate function for integral (long, i.e. 64 bit integer) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> sumLong(MapFunction<T, Long> f) { return new TypedSumLong<T>(f).toColumnJava(); } }
/** * Count aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> count(MapFunction<T, Object> f) { return new TypedCount<T>(f).toColumnJava(); }
/** * Average aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) { return new TypedAverage<T>(f).toColumnJava(); }
/** * Sum aggregate function for floating point (double) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> sum(MapFunction<T, Double> f) { return new TypedSumDouble<T>(f).toColumnJava(); }
/** * Sum aggregate function for integral (long, i.e. 64 bit integer) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> sumLong(MapFunction<T, Long> f) { return new TypedSumLong<T>(f).toColumnJava(); } }
/** * Count aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> count(MapFunction<T, Object> f) { return new TypedCount<T>(f).toColumnJava(); }
/** * Average aggregate function. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> avg(MapFunction<T, Double> f) { return new TypedAverage<T>(f).toColumnJava(); }
/** * Sum aggregate function for floating point (double) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Double> sum(MapFunction<T, Double> f) { return new TypedSumDouble<T>(f).toColumnJava(); }
/** * Sum aggregate function for integral (long, i.e. 64 bit integer) type. * * @since 2.0.0 */ public static <T> TypedColumn<T, Long> sumLong(MapFunction<T, Long> f) { return new TypedSumLong<T>(f).toColumnJava(); } }