Class: Google::Apis::DatastoreV1beta3::Aggregation

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/datastore_v1beta3/classes.rb,
lib/google/apis/datastore_v1beta3/representations.rb,
lib/google/apis/datastore_v1beta3/representations.rb

Overview

Defines an aggregation that produces a single result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Aggregation

Returns a new instance of Aggregation.



73
74
75
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 73

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#aliasString

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

Returns:

  • (String)


39
40
41
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 39

def alias
  @alias
end

#avgGoogle::Apis::DatastoreV1beta3::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. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns NULL. * Always returns the result as a double. Corresponds to the JSON property avg



48
49
50
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 48

def avg
  @avg
end

#countGoogle::Apis::DatastoreV1beta3::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



54
55
56
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 54

def count
  @count
end

#sumGoogle::Apis::DatastoreV1beta3::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. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns 0. * Returns a 64- bit integer if all aggregated numbers are integers and the sum result 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



71
72
73
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 71

def sum
  @sum
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



78
79
80
81
82
83
# File 'lib/google/apis/datastore_v1beta3/classes.rb', line 78

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