Class: Google::Apis::DatastoreV1::Aggregation
- Inherits:
-
Object
- Object
- Google::Apis::DatastoreV1::Aggregation
- Includes:
- Core::Hashable, Core::JsonObjectSupport
- Defined in:
- lib/google/apis/datastore_v1/classes.rb,
lib/google/apis/datastore_v1/representations.rb,
lib/google/apis/datastore_v1/representations.rb
Overview
Defines an aggregation that produces a single result.
Instance Attribute Summary collapse
-
#alias ⇒ String
Optional.
-
#avg ⇒ Google::Apis::DatastoreV1::Avg
Average of the values of the requested property.
-
#count ⇒ Google::Apis::DatastoreV1::Count
Count of entities that match the query.
-
#sum ⇒ Google::Apis::DatastoreV1::Sum
Sum of the values of the requested property.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Aggregation
constructor
A new instance of Aggregation.
-
#update!(**args) ⇒ Object
Update properties of this object.
Constructor Details
#initialize(**args) ⇒ Aggregation
Returns a new instance of Aggregation.
71 72 73 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 71 def initialize(**args) update!(**args) end |
Instance Attribute Details
#alias ⇒ String
Optional. Optional name of the property to store the result of the aggregation.
If not provided, Datastore will pick a default name following the format
property_. For example: AGGREGATE COUNT_UP_TO(1) AS count_up_to_1,
COUNT_UP_TO(2), COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) OVER ( ... );
becomes: AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2) AS
property_1, COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) AS property_2 OVER ( ...
); Requires: * Must be unique across all aggregation aliases. * Conform to
entity property name limitations.
Corresponds to the JSON property alias
39 40 41 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 39 def alias @alias end |
#avg ⇒ Google::Apis::DatastoreV1::Avg
Average of the values of the requested property. * Only numeric values will be
aggregated. All non-numeric values including NULL are skipped. * If the
aggregated values contain NaN, returns NaN. * If the aggregated value set
is empty, returns NULL. * Always returns the result as a double.
Corresponds to the JSON property avg
47 48 49 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 47 def avg @avg end |
#count ⇒ Google::Apis::DatastoreV1::Count
Count of entities that match the query. The COUNT(*) aggregation function
operates on the entire entity so it does not require a field reference.
Corresponds to the JSON property count
53 54 55 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 53 def count @count end |
#sum ⇒ Google::Apis::DatastoreV1::Sum
Sum of the values of the requested property. * Only numeric values will be
aggregated. All non-numeric values including NULL are skipped. * If the
aggregated values contain NaN, returns NaN. * If the aggregated value set
is empty, returns 0. * Returns a 64-bit integer if the sum result is an
integer value and does not overflow. Otherwise, the result is returned as a
double. Note that even if all the aggregated values are integers, the result
is returned as a double if it cannot fit within a 64-bit signed integer. When
this occurs, the returned value will lose precision. * When underflow occurs,
floating-point aggregation is non-deterministic. This means that running the
same query repeatedly without any changes to the underlying values could
produce slightly different results each time. In those cases, values should be
stored as integers over floating-point numbers.
Corresponds to the JSON property sum
69 70 71 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 69 def sum @sum end |
Instance Method Details
#update!(**args) ⇒ Object
Update properties of this object
76 77 78 79 80 81 |
# File 'lib/google/apis/datastore_v1/classes.rb', line 76 def update!(**args) @alias = args[:alias] if args.key?(:alias) @avg = args[:avg] if args.key?(:avg) @count = args[:count] if args.key?(:count) @sum = args[:sum] if args.key?(:sum) end |