T
- input valuepublic final class LastDatedValueFunction<T> extends AggregateFunction<Row,LastDatedValueFunction.Accumulator<T>>
AggregateFunction
that returns a row containing the latest non-null
value with its corresponding date.
The function uses a custom TypeInference
and thus disables any of the default
reflection-based logic. It has a generic parameter T
which will result in Object
(due to type erasure) during runtime. The TypeInference
will provide the necessary
information how to call accumulate(...)
for the given call in the query.
For code readability, we might use some internal utility methods that should rarely change. Implementers can copy those if they don't want to rely on non-official API.
Modifier and Type | Class and Description |
---|---|
static class |
LastDatedValueFunction.Accumulator<T>
Generic accumulator for representing state.
|
Constructor and Description |
---|
LastDatedValueFunction() |
Modifier and Type | Method and Description |
---|---|
void |
accumulate(LastDatedValueFunction.Accumulator<T> acc,
T input,
java.time.LocalDate date)
Generic runtime function that will be called with different kind of instances for
input depending on actual call in the query. |
LastDatedValueFunction.Accumulator<T> |
createAccumulator()
Creates and initializes the accumulator for this
ImperativeAggregateFunction . |
TypeInference |
getTypeInference(DataTypeFactory typeFactory)
Declares the
TypeInference of this function. |
Row |
getValue(LastDatedValueFunction.Accumulator<T> acc)
Called every time when an aggregation result should be materialized.
|
getKind
getAccumulatorType, getResultType
close, functionIdentifier, open, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRequirements, isDeterministic
public TypeInference getTypeInference(DataTypeFactory typeFactory)
TypeInference
of this function. It specifies:
DataType.getConversionClass()
should be used when calling the JVM method
accumulate(Accumulator, Object, LocalDate)
during runtime,
getTypeInference
in interface FunctionDefinition
getTypeInference
in class AggregateFunction<Row,LastDatedValueFunction.Accumulator<T>>
public LastDatedValueFunction.Accumulator<T> createAccumulator()
ImperativeAggregateFunction
ImperativeAggregateFunction
.
The accumulator is an intermediate data structure that stores the aggregated values until a final aggregation result is computed.
createAccumulator
in class ImperativeAggregateFunction<Row,LastDatedValueFunction.Accumulator<T>>
public void accumulate(LastDatedValueFunction.Accumulator<T> acc, T input, java.time.LocalDate date)
input
depending on actual call in the query.public Row getValue(LastDatedValueFunction.Accumulator<T> acc)
AggregateFunction
getValue
in class AggregateFunction<Row,LastDatedValueFunction.Accumulator<T>>
acc
- the accumulator which contains the current intermediate resultsCopyright © 2014–2024 The Apache Software Foundation. All rights reserved.