Class AggregationSet
- All Implemented Interfaces:
SmartExternalizable, Externalizable, Serializable
- Since:
- 10.0
- Author:
- Niv Ingberg
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(SpaceEntriesAggregator aggregator) Calculates average of path values of matching entries, infers the return type of the path.booleancount()Counts matching entries.Counts matching entries whose path is not null.distinct(DistinctAggregator aggregator) longgroupBy(GroupByAggregator aggregator) Returns entry with maximum value of path of matching entries.Returns maximum value of path of matching entries.Returns entry with minimum value of path of matching entries.Returns minimum value of path of matching entries.orderBy(OrderByAggregator aggregator) voidSums values of paths of matching entries, infers the return type of the path.withExecutionTimeout(long timeout, TimeUnit unit) Limits how long the aggregation may run.voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SmartExternalizable
enabledSmartExternalizableWithReference
-
Constructor Details
-
AggregationSet
public AggregationSet()
-
-
Method Details
-
withExecutionTimeout
Limits how long the aggregation may run. A partition that is still scanning when the timeout expires stops and fails the aggregation with anAggregationTimeoutException; the caller stops waiting shortly after the timeout even if a partition does not answer. Without this setting the space's default applies ("com.gs.aggregation.default-timeout-ms"), which is no limit unless configured. A value set here replaces the default, whether it is shorter or longer.This bounds the execution of the aggregation. It is unrelated to the timeout of read and take operations, which is how long to wait for a matching entry to appear.
A partition checks the timeout between the entries it scans or the index entries it walks. What it hands to tiered storage as one SQL statement, and a single call to a custom aggregator's
aggregate(), are checked when they return: until then they keep their partition busy. The caller is still released on time, except from a space it reaches directly in its own JVM, where the aggregation runs on the caller's thread.Unless it runs on the caller's thread, the aggregation runs on copies of the aggregators, so that a partition that answers after the caller stopped waiting does not write into the caller's ones. The copies are made with
SpaceEntriesAggregator.clone(), which copies an aggregator's fields but not the objects they refer to: a custom aggregator therefore creates its mutable state lazily, inaggregate()andaggregateIntermediateResult()as the built-in ones do, or overridesclone()to copy it. State it creates up front, such as a list assigned where the field is declared, is shared with the copies.The caller's wait covers the aggregation, not finding a partition to send it to. When the proxy knows no active member of a partition - for instance when it reaches the space for the first time while that partition is down - the call first waits for one, as any space operation does, for up to the proxy's
space-config.proxy.router.active-server-lookup-timeout, 20 seconds by default.- Parameters:
timeout- the maximum execution time, greater than zerounit- the unit oftimeout- Returns:
- this aggregation set
- Since:
- 18.0.1
-
getExecutionTimeout
public long getExecutionTimeout()- Returns:
- the execution timeout set by
withExecutionTimeout(long, TimeUnit), in milliseconds, or 0 if none was set - Since:
- 18.0.1
-
add
-
count
Counts matching entries. -
count
Counts matching entries whose path is not null.- Parameters:
path- Path to inspect
-
sum
Sums values of paths of matching entries, infers the return type of the path.- Parameters:
path- Path to sum (must be a numeric type)
-
average
Calculates average of path values of matching entries, infers the return type of the path.- Parameters:
path- Path to average (must be a numeric type)
-
maxValue
Returns maximum value of path of matching entries.- Parameters:
path- Path to inspect (must be a comparable type)- See Also:
-
maxEntry
Returns entry with maximum value of path of matching entries.- Parameters:
path- Path to inspect (must be a comparable type)- See Also:
-
minValue
Returns minimum value of path of matching entries.- Parameters:
path- Path to inspect (must be a comparable type)- See Also:
-
minEntry
Returns entry with minimum value of path of matching entries.- Parameters:
path- Path to inspect (must be a comparable type)- See Also:
-
groupBy
-
orderBy
-
distinct
-
getAggregators
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
containsOrderByAggregator
public boolean containsOrderByAggregator()
-