public static void inputReal(QuantileDigestState state, long value, long weight, double accuracy) { inputBigint(state, floatToSortableInt(intBitsToFloat((int) value)), weight, accuracy); }
private static InternalAggregationFunction generateAggregation(Type valueType, QuantileDigestType outputType, int arity) { DynamicClassLoader classLoader = new DynamicClassLoader(QuantileDigestAggregationFunction.class.getClassLoader()); List<Type> inputTypes = getInputTypes(valueType, arity); QuantileDigestStateSerializer stateSerializer = new QuantileDigestStateSerializer(valueType); Type intermediateType = stateSerializer.getSerializedType(); AggregationMetadata metadata = new AggregationMetadata( generateAggregationName(NAME, outputType.getTypeSignature(), inputTypes.stream().map(Type::getTypeSignature).collect(toImmutableList())), createInputParameterMetadata(inputTypes), getMethodHandle(valueType, arity), COMBINE_FUNCTION, OUTPUT_FUNCTION.bindTo(stateSerializer), ImmutableList.of(new AccumulatorStateDescriptor( QuantileDigestState.class, stateSerializer, new QuantileDigestStateFactory())), outputType); GenericAccumulatorFactoryBinder factory = AccumulatorCompiler.generateAccumulatorFactoryBinder(metadata, classLoader); return new InternalAggregationFunction(NAME, inputTypes, ImmutableList.of(intermediateType), outputType, true, true, factory); }
@Override public InternalAggregationFunction specialize(BoundVariables boundVariables, int arity, TypeManager typeManager, FunctionRegistry functionRegistry) { Type valueType = boundVariables.getTypeVariable("V"); QuantileDigestType outputType = (QuantileDigestType) typeManager.getParameterizedType( StandardTypes.QDIGEST, ImmutableList.of(TypeSignatureParameter.of(valueType.getTypeSignature()))); return generateAggregation(valueType, outputType, arity); }
public static void inputBigint(QuantileDigestState state, long value, long weight, double accuracy) { QuantileDigest qdigest = getOrCreateQuantileDigest(state, verifyAccuracy(accuracy)); state.addMemoryUsage(-qdigest.estimatedInMemorySizeInBytes()); qdigest.add(value, verifyWeight(weight)); state.addMemoryUsage(qdigest.estimatedInMemorySizeInBytes()); }
public static void inputDouble(QuantileDigestState state, double value, long weight, double accuracy) { inputBigint(state, doubleToSortableLong(value), weight, accuracy); }