Package org.geotools.feature.visitor
Class GroupByVisitor
- Object
-
- GroupByVisitor
-
- All Implemented Interfaces:
FeatureVisitor
,FeatureAttributeVisitor
,FeatureCalc
public class GroupByVisitor extends Object implements FeatureCalc, FeatureAttributeVisitor
Group features by one or several attributes and applies an aggregator visitor to each group.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GroupByVisitor.GroupByRawResult
Helper class that should be used by optimizations to set the results.static class
GroupByVisitor.GroupByResult
This class implements the feature calculation result of the group by visitor.
-
Constructor Summary
Constructors Constructor Description GroupByVisitor(Aggregate aggregateVisitor, Expression expression, List<Expression> groupByAttributes, ProgressListener progressListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FeatureVisitor
getAggregateVisitor()
Expression
getExpression()
List<Expression>
getExpressions()
List of expressions used by visitor.List<Expression>
getGroupByAttributes()
CalcResult
getResult()
This method computes and returns the group by visitor result.Optional<List<Class>>
getResultType(List<Class> inputTypes)
Returns the expected output type given the input type.void
setValue(List<GroupByVisitor.GroupByRawResult> value)
Methods that allow optimizations to directly set the group by visitor result instead of computing it visiting all the features.void
visit(Feature feature)
Visit the provided feature.boolean
wasOptimized()
boolean
wasVisited()
-
-
-
Constructor Detail
-
GroupByVisitor
public GroupByVisitor(Aggregate aggregateVisitor, Expression expression, List<Expression> groupByAttributes, ProgressListener progressListener)
-
-
Method Detail
-
wasOptimized
public boolean wasOptimized()
-
wasVisited
public boolean wasVisited()
-
getResult
public CalcResult getResult()
This method computes and returns the group by visitor result. If the computation was optimized the optimization result is returned otherwise the result is computed in memory. If for some reason an optimization result exists and there are visited features, an in memory computation is performed and is merged with the existing optimization results.- Specified by:
getResult
in interfaceFeatureCalc
- Returns:
- group by visitor result
-
visit
public void visit(Feature feature)
Description copied from interface:FeatureVisitor
Visit the provided feature.Please consult the documentation for the FeatureCollection you are visiting to learn more - the provided feature may be invalid, or read only.
- Specified by:
visit
in interfaceFeatureVisitor
-
getExpression
public Expression getExpression()
-
getAggregateVisitor
public FeatureVisitor getAggregateVisitor()
-
getGroupByAttributes
public List<Expression> getGroupByAttributes()
-
setValue
public void setValue(List<GroupByVisitor.GroupByRawResult> value)
Methods that allow optimizations to directly set the group by visitor result instead of computing it visiting all the features. Aggregate visitor results are wrapped with the appropriate feature calculation type.- Parameters:
value
- the group by visitor result
-
getExpressions
public List<Expression> getExpressions()
Description copied from interface:FeatureAttributeVisitor
List of expressions used by visitor.- Specified by:
getExpressions
in interfaceFeatureAttributeVisitor
-
getResultType
public Optional<List<Class>> getResultType(List<Class> inputTypes)
Description copied from interface:FeatureAttributeVisitor
Returns the expected output type given the input type.- Specified by:
getResultType
in interfaceFeatureAttributeVisitor
- Parameters:
inputTypes
- The type of the input expressions
-
-