Aggregator

class Aggregator[source]

Bases: object

Marker base class for all aggregators.

Aggregators allow computing a value of some function (e.g sum or max) over the stored map entries. The computation is performed in a fully distributed manner, so no data other than the computed value is transferred to the client, making the computation fast.

count(attribute_path=None)[source]

Creates an aggregator that counts the input values.

Accepts None input values and None extracted values.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that counts the input values.

Return type

Aggregator[int]

distinct(attribute_path=None)[source]

Creates an aggregator that calculates the distinct set of input values.

Accepts None input values and None extracted values.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the distinct set of input values.

Return type

Aggregator[set]

double_avg(attribute_path=None)[source]

Creates an aggregator that calculates the average of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type double (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with float or int values sent from the Python client unless they are out of range for double type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the average of the input values.

Return type

Aggregator[float]

double_sum(attribute_path=None)[source]

Creates an aggregator that calculates the sum of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type double (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with float or int values sent from the Python client unless they are out of range for double type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the sum of the input values.

Return type

Aggregator[float]

fixed_point_sum(attribute_path=None)[source]

Creates an aggregator that calculates the sum of the input values.

Does NOT accept None input values or None extracted values.

Accepts generic number input values. That means, one should be able to use this aggregator with float or int value sent from the Python client unless they are out of range for long type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the sum of the input values.

Return type

Aggregator[int]

floating_point_sum(attribute_path=None)[source]

Creates an aggregator that calculates the sum of the input values.

Does NOT accept None input values or None extracted values.

Accepts generic number input values. That means, one should be able to use this aggregator with float or int value sent from the Python client unless they are out of range for double type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the sum of the input values.

Return type

Aggregator[float]

int_avg(attribute_path=None)[source]

Creates an aggregator that calculates the average of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type int (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with int values sent from the Python client unless they are out of range for int type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the average of the input values.

Return type

Aggregator[int]

int_sum(attribute_path=None)[source]

Creates an aggregator that calculates the sum of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type int (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with int values sent from the Python client unless they are out of range for int type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the sum of the input values.

Return type

Aggregator[int]

long_avg(attribute_path=None)[source]

Creates an aggregator that calculates the average of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type long (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with int values sent from the Python client unless they are out of range for long type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the average of the input values.

Return type

Aggregator[int]

long_sum(attribute_path=None)[source]

Creates an aggregator that calculates the sum of the input values.

Does NOT accept None input values or None extracted values.

Since the server-side implementation is in Java, values stored in the Map must be of type long (primitive or boxed) in Java or of a type that can be converted to that. That means, one should be able to use this aggregator with int values sent from the Python client unless they are out of range for long type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the sum of the input values.

Return type

Aggregator[int]

max_(attribute_path=None)[source]

Creates an aggregator that calculates the max of the input values.

Accepts None input values and None extracted values.

Since the server-side implementation is in Java, values stored in the Map must implement the Comparable interface in Java. That means, one should be able to use this aggregator with most of the primitive values sent from the Python client, as Java implements this interface for the equivalents of types like int, str, and float.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the max of the input values.

Return type

Aggregator[any]

min_(attribute_path=None)[source]

Creates an aggregator that calculates the min of the input values.

Accepts None input values and None extracted values.

Since the server-side implementation is in Java, values stored in the Map must implement the Comparable interface in Java. That means, one should be able to use this aggregator with most of the primitive values sent from the Python client, as Java implements this interface for the equivalents of types like int, str, and float.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the min of the input values.

Return type

Aggregator[any]

number_avg(attribute_path=None)[source]

Creates an aggregator that calculates the average of the input values.

Does NOT accept None input values or None extracted values.

Accepts generic number input values. That means, one should be able to use this aggregator with float or int value sent from the Python client unless they are out of range for double type in Java.

Parameters

attribute_path (str) – Extracts values from this path, if given.

Returns

An aggregator that calculates the average of the input values.

Return type

Aggregator[float]

max_by(attribute_path=None)[source]

Creates an aggregator that calculates the max of the input values extracted from the given attribute_path and returns the input item containing the maximum value. If multiple items contain the maximum value, any of them is returned.

Accepts None input values and None extracted values.

Since the server-side implementation is in Java, values stored in the Map must implement the Comparable interface in Java. That means, one should be able to use this aggregator with most of the primitive values sent from the Python client, as Java implements this interface for the equivalents of types like int, str, and float.

Parameters

attribute_path (str) – Path to extract values from.

Returns

An aggregator that calculates the input value containing the maximum value extracted from the path.

Return type

Aggregator[hazelcast.core.MapEntry]

min_by(attribute_path)[source]

Creates an aggregator that calculates the min of the input values extracted from the given attribute_path and returns the input item containing the minimum value. If multiple items contain the minimum value, any of them is returned.

Accepts None input values and None extracted values.

Since the server-side implementation is in Java, values stored in the Map must implement the Comparable interface in Java. That means, one should be able to use this aggregator with most of the primitive values sent from the Python client, as Java implements this interface for the equivalents of types like int, str, and float.

Parameters

attribute_path (str) – Path to extract values from.

Returns

An aggregator that calculates the input value containing the minimum value extracted from the path.

Return type

Aggregator[hazelcast.core.MapEntry]