class NumericAverageStateType extends DataType<NumericAverageState> implements Streamer<NumericAverageState> {

    public static final int ID = 1026;
    public static final long INIT_SIZE = NumericType.size(BigDecimal.ZERO) + 8; // Nominator and primitive long denominator.
    public static final NumericAverageStateType INSTANCE = new NumericAverageStateType();

    @Override
    public int id() {
        return ID;
    }

    @Override
    public Precedence precedence() {
        return Precedence.CUSTOM;
    }

    @Override
    public String getName() {
        return "numeric_average_state";
    }

    @Override
    public Streamer<NumericAverageState> streamer() {
        return this;
    }

    @Override
    public NumericAverageState sanitizeValue(Object value) {
        return (NumericAverageState) value;
    }

    @Override
    public int compare(NumericAverageState val1, NumericAverageState val2) {
        if (val1 == null) return -1;
        return val1.compareTo(val2);
    }

    @Override
    public NumericAverageState readValueFrom(StreamInput in) throws IOException {
        // Cannot use NumericType.INSTANCE as it has default precision and scale values
        // which might not be equal to written BigDecimal's precision and scale.
        return new NumericAverageState<>(
            new BigDecimalValueWrapper(NumericType.of(in.readInt(), in.readInt()).readValueFrom(in)),
            in.readVLong()
        );
    }

    @Override
    public void writeValueTo(StreamOutput out, NumericAverageState v) throws IOException {<FILL_FUNCTION_BODY>}

    @Override
    public long valueBytes(NumericAverageState value) {
        throw new UnsupportedOperationException("valueSize is not implemented on NumericAverageStateType");
    }
}

        // We want to preserve the scale and precision
        // from the numeric argument type for the return type.
        out.writeInt(v.sum.value().precision());
        out.writeInt(v.sum.value().scale());
        NumericType.INSTANCE.writeValueTo(out, v.sum.value()); // NumericType.INSTANCE writes unscaled value
        out.writeVLong(v.count);
    
<methods>public non-sealed void <init>() ,public void addMappingOptions(Map<java.lang.String,java.lang.Object>) ,public java.lang.Integer characterMaximumLength() ,public ColumnStatsSupport<NumericAverageState#RAW> columnStatsSupport() ,public int compareTo(DataType<?>) ,public boolean equals(java.lang.Object) ,public NumericAverageState#RAW explicitCast(java.lang.Object, io.crate.metadata.settings.SessionSettings) throws java.lang.IllegalArgumentException, java.lang.ClassCastException,public abstract java.lang.String getName() ,public List<DataType<?>> getTypeParameters() ,public io.crate.types.TypeSignature getTypeSignature() ,public int hashCode() ,public abstract int id() ,public NumericAverageState#RAW implicitCast(java.lang.Object) throws java.lang.IllegalArgumentException, java.lang.ClassCastException,public boolean isConvertableTo(DataType<?>, boolean) ,public java.lang.Integer numericPrecision() ,public abstract io.crate.types.DataType.Precedence precedence() ,public boolean precedes(DataType<?>) ,public long ramBytesUsed() ,public abstract NumericAverageState#RAW sanitizeValue(java.lang.Object) ,public StorageSupport<? super NumericAverageState#RAW> storageSupport() ,public final StorageSupport<? super NumericAverageState#RAW> storageSupportSafe() ,public abstract Streamer<NumericAverageState#RAW> streamer() ,public ColumnType<io.crate.sql.tree.Expression> toColumnType(io.crate.sql.tree.ColumnPolicy, Supplier<List<ColumnDefinition<io.crate.sql.tree.Expression>>>) ,public java.lang.String toString() ,public abstract long valueBytes(NumericAverageState#RAW) ,public NumericAverageState#RAW valueForInsert(NumericAverageState#RAW) ,public final ValueIndexer<? super NumericAverageState#RAW> valueIndexer(io.crate.metadata.RelationName, io.crate.metadata.Reference, Function<java.lang.String,FieldType>, Function<io.crate.metadata.ColumnIdent,io.crate.metadata.Reference>) ,public void writeTo(org.elasticsearch.common.io.stream.StreamOutput) throws java.io.IOException<variables>