Class NullableNumericAggregator
- java.lang.Object
-
- org.apache.druid.query.aggregation.NullableNumericAggregator
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Aggregator
public final class NullableNumericAggregator extends Object implements Aggregator
Null-aware numericAggregator. The result of this aggregator will be null if all the values to be aggregated are null values or no values are aggregated at all. If any of the values are non-null, the result will be the aggregated value of the delegate aggregator. When wrapped by this class, the underlying aggregator's required storage space is increased by one byte. The extra byte is a boolean that stores whether or not any non-null values have been seen. The extra byte is placed before the underlying aggregator's normal state. (Buffer layout = [nullability byte] [delegate storage bytes]) Used byNullableNumericAggregatorFactory.factorize(ColumnSelectorFactory)to wrap non-null aware aggregators. This class is only used when SQL compatible null handling is enabled.
-
-
Constructor Summary
Constructors Constructor Description NullableNumericAggregator(Aggregator delegate, BaseNullableColumnValueSelector selector)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaggregate()Performs aggregation.voidclose()Objectget()doublegetDouble()The default implementation castsAggregator.getFloat()to double.floatgetFloat()longgetLong()booleanisNull()returns true if aggregator's output type is primitive long/double/float and aggregated value is null, but when aggregated output type is Object, this method always returns false, and users are advised to check nullability for the object returned byAggregator.get()method.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.druid.query.aggregation.Aggregator
aggregateWithSize
-
-
-
-
Constructor Detail
-
NullableNumericAggregator
public NullableNumericAggregator(Aggregator delegate, BaseNullableColumnValueSelector selector)
-
-
Method Detail
-
aggregate
public void aggregate()
Description copied from interface:AggregatorPerforms aggregation.- Specified by:
aggregatein interfaceAggregator
-
get
@Nullable public Object get()
- Specified by:
getin interfaceAggregator
-
getFloat
public float getFloat()
- Specified by:
getFloatin interfaceAggregator
-
getLong
public long getLong()
- Specified by:
getLongin interfaceAggregator
-
getDouble
public double getDouble()
Description copied from interface:AggregatorThe default implementation castsAggregator.getFloat()to double. This default method is added to enable smooth backward compatibility, please re-implement it if your aggregators work with numeric double columns.- Specified by:
getDoublein interfaceAggregator
-
isNull
public boolean isNull()
Description copied from interface:Aggregatorreturns true if aggregator's output type is primitive long/double/float and aggregated value is null, but when aggregated output type is Object, this method always returns false, and users are advised to check nullability for the object returned byAggregator.get()method. The default implementation always return false to enable smooth backward compatibility, re-implement if your aggregator is nullable.- Specified by:
isNullin interfaceAggregator
-
close
public void close()
- Specified by:
closein interfaceAggregator- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-