Class AggregatorImpl<T,R>
- java.lang.Object
-
- de.caluga.morphium.aggregation.AggregatorImpl<T,R>
-
- All Implemented Interfaces:
Aggregator<T,R>
public class AggregatorImpl<T,R> extends Object implements Aggregator<T,R>
User: Stephan Bösebeck Date: 30.08.12 Time: 16:24
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface de.caluga.morphium.aggregation.Aggregator
Aggregator.BucketGranularity, Aggregator.GeoNearFields, Aggregator.MergeActionWhenMatched, Aggregator.MergeActionWhenNotMatched
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Aggregator<T,R>addFields(Map<String,Object> m)voidaddOperator(Map<String,Object> o)List<R>aggregate()voidaggregate(AsyncOperationCallback<R> callback)MorphiumAggregationIterator<T,R>aggregateIterable()List<Map<String,Object>>aggregateMap()voidaggregateMap(AsyncOperationCallback<Map<String,Object>> callback)Aggregator<T,R>bucket(Expr groupBy, List<Expr> boundaries, Expr preset, Map<String,Expr> output)Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries and outputs a document per each bucket.Aggregator<T,R>bucketAuto(Expr groupBy, int numBuckets, Map<String,Expr> output, Aggregator.BucketGranularity granularity)Aggregator<T,R>collation(Collation collation)Aggregator<T,R>collStats(Boolean latencyHistograms, Double scale, boolean count, boolean queryExecStats)Aggregator<T,R>count(Enum fld)Aggregator<T,R>count(String fld)Aggregator<T,R>currentOp(boolean allUsers, boolean idleConnections, boolean idleCursors, boolean idleSessions, boolean localOps)Aggregator<T,R>facet(Map<String,Aggregator> facets)Aggregator<T,R>facetExpr(Map<String,Expr> facets)Aggregator<T,R>genericStage(String stageName, Object param)Aggregator<T,R>geoNear(Map<Aggregator.GeoNearFields,Object> param)AggregateMongoCommandgetAggregateCmd()CollationgetCollation()StringgetCollectionName()longgetCount()MorphiumgetMorphium()List<Map<String,Object>>getPipeline()Class<? extends R>getResultType()Class<? extends T>getSearchType()Aggregator<T,R>graphLookup(Class<?> type, Expr startWith, Enum connectFromField, Enum connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)Aggregator<T,R>graphLookup(Class<?> type, Expr startWith, String connectFromField, String connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)Aggregator<T,R>graphLookup(String fromCollection, Expr startWith, String connectFromField, String connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)Group<T,R>group(Expr id)Group<T,R>group(String id)Group<T,R>group(Map<String,Object> id)Aggregator<T,R>indexStats()booleanisExplain()booleanisUseDisk()Aggregator<T,R>limit(int num)Aggregator<T,R>listLocalSessions()Aggregator<T,R>listLocalSessions(List<String> users, List<String> dbs)Aggregator<T,R>listLocalSessionsAllUsers()Aggregator<T,R>listSessions()Aggregator<T,R>listSessions(List<String> users, List<String> dbs)Aggregator<T,R>listSessionsAllUsers()Aggregator<T,R>lookup(Class fromType, Enum localField, Enum foreignField, String outputArray, List<Expr> pipeline, Map<String,Expr> let)$lookup: { from:, localField: , foreignField: , as: Aggregator<T,R>lookup(String fromCollection, String localField, String foreignField, String outputArray, List<Expr> pipeline, Map<String,Expr> let)Aggregator<T,R>match(Expr q)Aggregator<T,R>match(Query<T> q)Aggregator<T,R>matchSubQuery(Query<?> q)Aggregator<T,R>merge(Class<?> intoCollection)Aggregator<T,R>merge(Class<?> intoCollection, Map<String,Expr> let, List<Map<String,Expr>> machedPipeline, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)Aggregator<T,R>merge(String intoCollection)Aggregator<T,R>merge(String intoCollection, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)Aggregator<T,R>merge(String intoDb, String intoCollection)Aggregator<T,R>merge(String intoDb, String intoCollection, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)Aggregator<T,R>merge(String intoCollection, Map<String,Expr> let, List<Map<String,Expr>> machedPipeline, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)Aggregator<T,R>out(Class<?> type)Aggregator<T,R>out(String collectionName)Aggregator<T,R>out(String db, String collectionName)Aggregator<T,R>planCacheStats(Map<String,Object> param)Aggregator<T,R>project(String... m)Aggregator<T,R>project(String fld, Expr e)Aggregator<T,R>project(Map<String,Object> m)Aggregator<T,R>redact(Expr redact)redact needs to resolve to $$DESCEND, $$PRUNE, or $$KEEPAggregator<T,R>replaceRoot(Expr newRoot)Aggregator<T,R>replaceWith(Expr newDoc)Replaces the input document with the specified document.Aggregator<T,R>sample(int sampleSize)Randomly selects the specified number of documents from its input.Aggregator<T,R>set(Map<String,Expr> param)Adds new fields to documents.voidsetCollectionName(String cn)voidsetExplain(boolean explain)voidsetMorphium(Morphium m)voidsetResultType(Class<? extends R> type)voidsetSearchType(Class<? extends T> type)voidsetUseDisk(boolean useDisk)Aggregator<T,R>skip(int num)Aggregator<T,R>sort(String... prefixed)Aggregator<T,R>sort(Map<String,Integer> sort)Aggregator<T,R>sortByCount(Expr sortby)The $sortByCount stage is equivalent to the following $group + $sort sequence:Aggregator<T,R>unionWith(Aggregator agg)Aggregator<T,R>unionWith(String collection)Aggregator<T,R>unset(Enum... field)Aggregator<T,R>unset(String... param)Aggregator<T,R>unset(List<String> field)Aggregator<T,R>unwind(Expr listField)Aggregator<T,R>unwind(String listField)
-
-
-
Method Detail
-
getCollation
public Collation getCollation()
- Specified by:
getCollationin interfaceAggregator<T,R>
-
isUseDisk
public boolean isUseDisk()
- Specified by:
isUseDiskin interfaceAggregator<T,R>
-
setUseDisk
public void setUseDisk(boolean useDisk)
- Specified by:
setUseDiskin interfaceAggregator<T,R>
-
isExplain
public boolean isExplain()
- Specified by:
isExplainin interfaceAggregator<T,R>
-
setExplain
public void setExplain(boolean explain)
- Specified by:
setExplainin interfaceAggregator<T,R>
-
getMorphium
public Morphium getMorphium()
- Specified by:
getMorphiumin interfaceAggregator<T,R>
-
setMorphium
public void setMorphium(Morphium m)
- Specified by:
setMorphiumin interfaceAggregator<T,R>
-
getSearchType
public Class<? extends T> getSearchType()
- Specified by:
getSearchTypein interfaceAggregator<T,R>
-
setSearchType
public void setSearchType(Class<? extends T> type)
- Specified by:
setSearchTypein interfaceAggregator<T,R>
-
getResultType
public Class<? extends R> getResultType()
- Specified by:
getResultTypein interfaceAggregator<T,R>
-
setResultType
public void setResultType(Class<? extends R> type)
- Specified by:
setResultTypein interfaceAggregator<T,R>
-
project
public Aggregator<T,R> project(Map<String,Object> m)
- Specified by:
projectin interfaceAggregator<T,R>
-
project
public Aggregator<T,R> project(String fld, Expr e)
- Specified by:
projectin interfaceAggregator<T,R>
-
project
public Aggregator<T,R> project(String... m)
- Specified by:
projectin interfaceAggregator<T,R>
-
addFields
public Aggregator<T,R> addFields(Map<String,Object> m)
- Specified by:
addFieldsin interfaceAggregator<T,R>
-
match
public Aggregator<T,R> match(Query<T> q)
- Specified by:
matchin interfaceAggregator<T,R>
-
matchSubQuery
public Aggregator<T,R> matchSubQuery(Query<?> q)
- Specified by:
matchSubQueryin interfaceAggregator<T,R>
-
match
public Aggregator<T,R> match(Expr q)
- Specified by:
matchin interfaceAggregator<T,R>
-
limit
public Aggregator<T,R> limit(int num)
- Specified by:
limitin interfaceAggregator<T,R>
-
skip
public Aggregator<T,R> skip(int num)
- Specified by:
skipin interfaceAggregator<T,R>
-
unwind
public Aggregator<T,R> unwind(Expr listField)
- Specified by:
unwindin interfaceAggregator<T,R>
-
unwind
public Aggregator<T,R> unwind(String listField)
- Specified by:
unwindin interfaceAggregator<T,R>
-
sort
public Aggregator<T,R> sort(String... prefixed)
- Specified by:
sortin interfaceAggregator<T,R>
-
sort
public Aggregator<T,R> sort(Map<String,Integer> sort)
- Specified by:
sortin interfaceAggregator<T,R>
-
getCollectionName
public String getCollectionName()
- Specified by:
getCollectionNamein interfaceAggregator<T,R>
-
setCollectionName
public void setCollectionName(String cn)
- Specified by:
setCollectionNamein interfaceAggregator<T,R>
-
group
public Group<T,R> group(Map<String,Object> id)
- Specified by:
groupin interfaceAggregator<T,R>
-
addOperator
public void addOperator(Map<String,Object> o)
- Specified by:
addOperatorin interfaceAggregator<T,R>
-
getCount
public long getCount()
- Specified by:
getCountin interfaceAggregator<T,R>
-
aggregateIterable
public MorphiumAggregationIterator<T,R> aggregateIterable()
- Specified by:
aggregateIterablein interfaceAggregator<T,R>
-
aggregate
public void aggregate(AsyncOperationCallback<R> callback)
- Specified by:
aggregatein interfaceAggregator<T,R>
-
aggregateMap
public List<Map<String,Object>> aggregateMap()
- Specified by:
aggregateMapin interfaceAggregator<T,R>
-
aggregateMap
public void aggregateMap(AsyncOperationCallback<Map<String,Object>> callback)
- Specified by:
aggregateMapin interfaceAggregator<T,R>
-
getAggregateCmd
public AggregateMongoCommand getAggregateCmd()
- Specified by:
getAggregateCmdin interfaceAggregator<T,R>
-
getPipeline
public List<Map<String,Object>> getPipeline()
- Specified by:
getPipelinein interfaceAggregator<T,R>
-
count
public Aggregator<T,R> count(String fld)
- Specified by:
countin interfaceAggregator<T,R>
-
count
public Aggregator<T,R> count(Enum fld)
- Specified by:
countin interfaceAggregator<T,R>
-
out
public Aggregator<T,R> out(Class<?> type)
- Specified by:
outin interfaceAggregator<T,R>
-
bucket
public Aggregator<T,R> bucket(Expr groupBy, List<Expr> boundaries, Expr preset, Map<String,Expr> output)
Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries and outputs a document per each bucket. Each output document contains an _id field whose value specifies the inclusive lower bound of the bucket. The output option specifies the fields included in each output document.$bucket only produces output documents for buckets that contain at least one input document.
- Specified by:
bucketin interfaceAggregator<T,R>- Parameters:
groupBy- : Expression to group by, usually a field nameboundaries- : Boundaries for the bucketspreset- : the default, needs to be a literaloutput- : definition of output documents and accumulator- Returns:
-
bucketAuto
public Aggregator<T,R> bucketAuto(Expr groupBy, int numBuckets, Map<String,Expr> output, Aggregator.BucketGranularity granularity)
- Specified by:
bucketAutoin interfaceAggregator<T,R>
-
collStats
public Aggregator<T,R> collStats(Boolean latencyHistograms, Double scale, boolean count, boolean queryExecStats)
- Specified by:
collStatsin interfaceAggregator<T,R>- Parameters:
latencyHistograms- : if null, no latency statsscale- : if null, no storageStats- Returns:
-
currentOp
public Aggregator<T,R> currentOp(boolean allUsers, boolean idleConnections, boolean idleCursors, boolean idleSessions, boolean localOps)
- Specified by:
currentOpin interfaceAggregator<T,R>
-
facetExpr
public Aggregator<T,R> facetExpr(Map<String,Expr> facets)
- Specified by:
facetExprin interfaceAggregator<T,R>
-
facet
public Aggregator<T,R> facet(Map<String,Aggregator> facets)
- Specified by:
facetin interfaceAggregator<T,R>
-
geoNear
public Aggregator<T,R> geoNear(Map<Aggregator.GeoNearFields,Object> param)
- Specified by:
geoNearin interfaceAggregator<T,R>
-
graphLookup
public Aggregator<T,R> graphLookup(Class<?> type, Expr startWith, Enum connectFromField, Enum connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)
- Specified by:
graphLookupin interfaceAggregator<T,R>
-
graphLookup
public Aggregator<T,R> graphLookup(Class<?> type, Expr startWith, String connectFromField, String connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)
- Specified by:
graphLookupin interfaceAggregator<T,R>
-
graphLookup
public Aggregator<T,R> graphLookup(String fromCollection, Expr startWith, String connectFromField, String connectToField, String as, Integer maxDepth, String depthField, Query restrictSearchWithMatch)
- Specified by:
graphLookupin interfaceAggregator<T,R>
-
indexStats
public Aggregator<T,R> indexStats()
- Specified by:
indexStatsin interfaceAggregator<T,R>
-
listLocalSessionsAllUsers
public Aggregator<T,R> listLocalSessionsAllUsers()
- Specified by:
listLocalSessionsAllUsersin interfaceAggregator<T,R>
-
listLocalSessions
public Aggregator<T,R> listLocalSessions()
- Specified by:
listLocalSessionsin interfaceAggregator<T,R>
-
listLocalSessions
public Aggregator<T,R> listLocalSessions(List<String> users, List<String> dbs)
- Specified by:
listLocalSessionsin interfaceAggregator<T,R>
-
listSessionsAllUsers
public Aggregator<T,R> listSessionsAllUsers()
- Specified by:
listSessionsAllUsersin interfaceAggregator<T,R>
-
listSessions
public Aggregator<T,R> listSessions()
- Specified by:
listSessionsin interfaceAggregator<T,R>
-
listSessions
public Aggregator<T,R> listSessions(List<String> users, List<String> dbs)
- Specified by:
listSessionsin interfaceAggregator<T,R>
-
lookup
public Aggregator<T,R> lookup(Class fromType, Enum localField, Enum foreignField, String outputArray, List<Expr> pipeline, Map<String,Expr> let)
$lookup: { from:, localField: , foreignField: , as: - Specified by:
lookupin interfaceAggregator<T,R>- Returns:
-
lookup
public Aggregator<T,R> lookup(String fromCollection, String localField, String foreignField, String outputArray, List<Expr> pipeline, Map<String,Expr> let)
- Specified by:
lookupin interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(String intoDb, String intoCollection, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(String intoCollection, Map<String,Expr> let, List<Map<String,Expr>> machedPipeline, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(Class<?> intoCollection, Map<String,Expr> let, List<Map<String,Expr>> machedPipeline, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(String intoDb, String intoCollection)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(Class<?> intoCollection)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(String intoCollection)
- Specified by:
mergein interfaceAggregator<T,R>
-
merge
public Aggregator<T,R> merge(String intoCollection, Aggregator.MergeActionWhenMatched matchAction, Aggregator.MergeActionWhenNotMatched notMatchedAction, String... onFields)
- Specified by:
mergein interfaceAggregator<T,R>
-
out
public Aggregator<T,R> out(String collectionName)
- Specified by:
outin interfaceAggregator<T,R>
-
out
public Aggregator<T,R> out(String db, String collectionName)
- Specified by:
outin interfaceAggregator<T,R>
-
planCacheStats
public Aggregator<T,R> planCacheStats(Map<String,Object> param)
- Specified by:
planCacheStatsin interfaceAggregator<T,R>
-
redact
public Aggregator<T,R> redact(Expr redact)
redact needs to resolve to $$DESCEND, $$PRUNE, or $$KEEPSystem Variable Description $$DESCEND $redact returns the fields at the current document level, excluding embedded documents. To include embedded documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine access for these embedded documents. $$PRUNE $redact excludes all fields at this current document/embedded document level, without further inspection of any of the excluded fields. This applies even if the excluded field contains embedded documents that may have different access levels. $$KEEP $redact returns or keeps all fields at this current document/embedded document level, without further inspection of the fields at this level. This applies even if the included field contains embedded documents that may have different access levels.
- Specified by:
redactin interfaceAggregator<T,R>- Returns:
-
replaceRoot
public Aggregator<T,R> replaceRoot(Expr newRoot)
- Specified by:
replaceRootin interfaceAggregator<T,R>
-
replaceWith
public Aggregator<T,R> replaceWith(Expr newDoc)
Description copied from interface:AggregatorReplaces the input document with the specified document. The operation replaces all existing fields in the input document, including the _id field. With $replaceWith, you can promote an embedded document to the top-level. You can also specify a new document as the replacement.- Specified by:
replaceWithin interfaceAggregator<T,R>- Returns:
-
sample
public Aggregator<T,R> sample(int sampleSize)
Description copied from interface:AggregatorRandomly selects the specified number of documents from its input.- Specified by:
samplein interfaceAggregator<T,R>- Returns:
-
set
public Aggregator<T,R> set(Map<String,Expr> param)
Adds new fields to documents. $set outputs documents that contain all existing fields from the input documents and newly added fields.The $set stage is an alias for $addFields.
- Specified by:
setin interfaceAggregator<T,R>- Parameters:
param-- Returns:
-
sortByCount
public Aggregator<T,R> sortByCount(Expr sortby)
The $sortByCount stage is equivalent to the following $group + $sort sequence:{ $group: { _id:
, count: { $sum: 1 } } }, { $sort: { count: -1 } } - Specified by:
sortByCountin interfaceAggregator<T,R>- Parameters:
sortby-- Returns:
-
unionWith
public Aggregator<T,R> unionWith(String collection)
- Specified by:
unionWithin interfaceAggregator<T,R>
-
unionWith
public Aggregator<T,R> unionWith(Aggregator agg)
- Specified by:
unionWithin interfaceAggregator<T,R>
-
unset
public Aggregator<T,R> unset(List<String> field)
- Specified by:
unsetin interfaceAggregator<T,R>
-
unset
public Aggregator<T,R> unset(String... param)
- Specified by:
unsetin interfaceAggregator<T,R>
-
unset
public Aggregator<T,R> unset(Enum... field)
- Specified by:
unsetin interfaceAggregator<T,R>
-
genericStage
public Aggregator<T,R> genericStage(String stageName, Object param)
- Specified by:
genericStagein interfaceAggregator<T,R>
-
collation
public Aggregator<T,R> collation(Collation collation)
- Specified by:
collationin interfaceAggregator<T,R>
-
-