public final class Group extends AbstractRecordCompositeOperator
Aggregation
: Aggregation.avg(String)
, Aggregation.count(String)
,
Aggregation.max(String)
, Aggregation.min(String)
,
Aggregation.stddev(String)
, Aggregation.sum(String)
, Aggregation.var(String)
.
The operator uses groups of consecutive equal keys ("key groups") to determine which data values to aggregate. The input data need not be sorted; if it is already sorted, performance will be optimal.
input, output
Constructor and Description |
---|
Group()
Default constructor.
|
Group(List<String> keys,
List<Aggregation> aggregations)
Create a new group plan, specifying keys and aggegations.
|
Modifier and Type | Method and Description |
---|---|
protected void |
compose(CompositionContext ctx)
Compose the body of this operator.
|
Aggregation[] |
getAggregations()
Returns the aggregations to apply to the data.
|
int |
getInitialGroupCapacity()
Returns a hint as to the number of groups that are expected to be processed.
|
RecordPort |
getInput()
Returns the input port
|
String |
getKeyFieldPrefix()
Returns the prefix to add to key fields.
|
String[] |
getKeys()
Returns the names of the key fields.
|
int |
getMaxGroupCapacity()
Returns the max number of groups to fit into internal memory buffers.
|
RecordPort |
getOutput()
Returns the output port
|
boolean |
isFewGroupsHint()
Provides a hint as to whether the number of groups is expected to be small.
|
void |
setAggregations(Aggregation[] aggregations)
Sets the aggregations to apply to the data.
|
void |
setAggregations(String aggregationExpression)
Sets the aggregations to apply to the data.
|
void |
setFewGroupsHint(boolean fewGroupsHint)
Sets a hint as to whether the number of groups is expected to be small.
|
void |
setInitialGroupCapacity(int initialGroupCapacity)
Sets a hint as to the number of groups that are expected to be processed.
|
void |
setKeyFieldPrefix(String keyFieldPrefix)
Sets the prefix to add to key fields.
|
void |
setKeys(String[] keys)
Sets the names of the key fields.
|
void |
setMaxGroupCapacity(int maxGroupCapacity)
Sets the max number of groups to fit into internal memory buffers.
|
disableParallelism, getInputPorts, getOutputPorts, newInput, newInput, newOutput, newRecordInput, newRecordInput, newRecordOutput, notifyError
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
disableParallelism, getInputPorts, getOutputPorts
public Group()
public Group(List<String> keys, List<Aggregation> aggregations)
keys
- the names of the key fields. If empty then all of the rows in the input are treated as one group.aggregations
- the aggregations to apply to the data.public RecordPort getInput()
PipelineOperator
getInput
in interface PipelineOperator<RecordPort>
getInput
in class AbstractRecordCompositeOperator
public RecordPort getOutput()
PipelineOperator
getOutput
in interface PipelineOperator<RecordPort>
getOutput
in class AbstractRecordCompositeOperator
public String[] getKeys()
public void setKeys(String[] keys)
keys
- names of the fields to use as group keys (order is important)public Aggregation[] getAggregations()
public void setAggregations(Aggregation[] aggregations)
aggregations
- the aggregations to apply to the input datapublic void setAggregations(String aggregationExpression)
Each aggregation contains the aggregation function with the aggregation parameters
contained within parentheses. Most aggregations take only one parameter: the name
of the field to aggregate. The distinct
keyword can be used before the
first parameter. Doing so enables a distinct aggregation. Use the as
keyword to specify the field name that should be used for the resultant aggregation.
Examples of aggregation expressions:
count(field) as "count"
sum(field), avg(field), min(field), max(field)
Note that double quotes must be used when a keyword such as an aggregation function
name is used as the resultant field name (the as
clause).
aggregationExpression
- expression containing aggregations to applypublic String getKeyFieldPrefix()
public void setKeyFieldPrefix(String keyFieldPrefix)
keyFieldPrefix
- key field prefix textpublic int getInitialGroupCapacity()
public void setInitialGroupCapacity(int initialGroupCapacity)
initialGroupCapacity
- the initial capacitypublic int getMaxGroupCapacity()
public void setMaxGroupCapacity(int maxGroupCapacity)
maxGroupCapacity
- the max capacity.public boolean isFewGroupsHint()
public void setFewGroupsHint(boolean fewGroupsHint)
fewGroupsHint
- a hint as to whether the number of groups is expected to be smallprotected void compose(CompositionContext ctx)
CompositeOperator
OperatorComposable.add(O)
OperatorComposable.connect(P, P)
. This includes
connections from the composite's input ports to sub-operators, connections between sub-operators, and
connections from sub-operators output ports to the composite's output portscompose
in class CompositeOperator
ctx
- the contextCopyright © 2024 Actian Corporation. All rights reserved.