Class AggregateField (3.26.5)

public abstract class AggregateField

Represents an aggregation that can be performed by Firestore.

Inheritance

Object > AggregateField

Static Methods

average(FieldPath fieldPath)

public static AggregateField.AverageAggregateField average(FieldPath fieldPath)

Create an AverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

The result of an average operation will always be a double or NaN.

  • Averaging over zero documents or fields will result in a double value representing NaN.
  • Averaging over NaN will result in a double value representing NaN.
Parameter
Name Description
fieldPath FieldPath

Specifies the field to average across the result set.

Returns
Type Description
AggregateField.AverageAggregateField

The AverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

average(String field)

public static AggregateField.AverageAggregateField average(String field)

Create an AverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

The result of an average operation will always be a double or NaN.

  • Averaging over zero documents or fields will result in a double value representing NaN.
  • Averaging over NaN will result in a double value representing NaN.
Parameter
Name Description
field String

Specifies the field to average across the result set.

Returns
Type Description
AggregateField.AverageAggregateField

The AverageAggregateField object that can be used to compute the average of a specified field over a range of documents in the result set of a query.

count()

public static AggregateField.CountAggregateField count()

Create a CountAggregateField object that can be used to compute the count of documents in the result set of a query.

The result of a count operation will always be a 64-bit integer value.

Returns
Type Description
AggregateField.CountAggregateField

The CountAggregateField object that can be used to compute the count of documents in the result set of a query.

sum(FieldPath fieldPath)

public static AggregateField.SumAggregateField sum(FieldPath fieldPath)

Create a SumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

The result of a sum operation will always be a 64-bit integer value, a double, or NaN.

  • Summing over zero documents or fields will result in 0L.
  • Summing over NaN will result in a double value representing NaN.
  • A sum that overflows the maximum representable 64-bit integer value will result in a double return value. This may result in lost precision of the result.
  • A sum that overflows the maximum representable double value will result in a double return value representing infinity.
Parameter
Name Description
fieldPath FieldPath

Specifies the field to sum across the result set.

Returns
Type Description
AggregateField.SumAggregateField

The SumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

sum(String field)

public static AggregateField.SumAggregateField sum(String field)

Create a SumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

The result of a sum operation will always be a 64-bit integer value, a double, or NaN.

  • Summing over zero documents or fields will result in 0L.
  • Summing over NaN will result in a double value representing NaN.
  • A sum that overflows the maximum representable 64-bit integer value will result in a double return value. This may result in lost precision of the result.
  • A sum that overflows the maximum representable double value will result in a double return value representing infinity.
Parameter
Name Description
field String

Specifies the field to sum across the result set.

Returns
Type Description
AggregateField.SumAggregateField

The SumAggregateField object that can be used to compute the sum of a specified field over a range of documents in the result set of a query.

Constructors

AggregateField()

public AggregateField()

Methods

equals(Object other)

public boolean equals(Object other)

Returns true if the given object is equal to this object. Two AggregateField objects are considered equal if they have the same operator and operate on the same field.

Parameter
Name Description
other Object
Returns
Type Description
boolean
Overrides

hashCode()

public int hashCode()

Calculates and returns the hash code for this object.

Returns
Type Description
int
Overrides