Class AggregationOptions
- java.lang.Object
-
- dev.morphia.aggregation.experimental.AggregationOptions
-
- All Implemented Interfaces:
dev.morphia.internal.ReadConfigurable<AggregationOptions>
,dev.morphia.internal.SessionConfigurable<AggregationOptions>
,dev.morphia.internal.WriteConfigurable<AggregationOptions>
public class AggregationOptions extends Object implements dev.morphia.internal.SessionConfigurable<AggregationOptions>, dev.morphia.internal.ReadConfigurable<AggregationOptions>, dev.morphia.internal.WriteConfigurable<AggregationOptions>
Defines options to be applied to an aggregation pipeline.
-
-
Constructor Summary
Constructors Constructor Description AggregationOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowDiskUse()
AggregationOptions
allowDiskUse(boolean allowDiskUse)
Enables writing to temporary files.<S,T>
com.mongodb.client.AggregateIterable<S>apply(List<org.bson.Document> documents, com.mongodb.client.MongoCollection<T> collection, Class<S> resultType)
Applies the configured options to the collection.int
batchSize()
AggregationOptions
batchSize(int batchSize)
Sets the batch size for fetching results.boolean
bypassDocumentValidation()
AggregationOptions
bypassDocumentValidation(boolean bypassDocumentValidation)
Enables the aggregation to bypass document validation during the operation.com.mongodb.client.ClientSession
clientSession()
The client session to use for the insertion.AggregationOptions
clientSession(com.mongodb.client.ClientSession clientSession)
Set the client session to use for the insert.com.mongodb.client.model.Collation
collation()
AggregationOptions
collation(com.mongodb.client.model.Collation collation)
Specifies the collation to use for the operation.boolean
getAllowDiskUse()
int
getBatchSize()
boolean
getBypassDocumentValidation()
com.mongodb.client.model.Collation
getCollation()
long
getMaxTime(TimeUnit unit)
long
getMaxTimeMS()
com.mongodb.ReadConcern
getReadConcern()
Gets the read concerncom.mongodb.ReadPreference
getReadPreference()
org.bson.Document
hint()
AggregationOptions
hint(String hint)
Sets the hint for which index to use.long
maxTimeMS()
AggregationOptions
maxTimeMS(long maxTimeMS)
Specifies a time limit in milliseconds for processing operations on a cursor.<C> com.mongodb.client.MongoCollection<C>
prepare(com.mongodb.client.MongoCollection<C> collection)
Applies the options to the collectioncom.mongodb.ReadConcern
readConcern()
AggregationOptions
readConcern(com.mongodb.ReadConcern readConcern)
Specifies the read concern.com.mongodb.ReadPreference
readPreference()
AggregationOptions
readPreference(com.mongodb.ReadPreference readPreference)
Sets the read preference to usecom.mongodb.WriteConcern
writeConcern()
The write concern to use.AggregationOptions
writeConcern(com.mongodb.WriteConcern writeConcern)
Sets the write concern to use
-
-
-
Method Detail
-
allowDiskUse
public boolean allowDiskUse()
- Returns:
- the configuration value
-
allowDiskUse
public AggregationOptions allowDiskUse(boolean allowDiskUse)
Enables writing to temporary files.- Parameters:
allowDiskUse
- true to enable- Returns:
- this
-
apply
public <S,T> com.mongodb.client.AggregateIterable<S> apply(List<org.bson.Document> documents, com.mongodb.client.MongoCollection<T> collection, Class<S> resultType)
Applies the configured options to the collection.- Type Parameters:
T
- the collection typeS
- the result type- Parameters:
documents
- the stage documentscollection
- the collection to configureresultType
- the result type- Returns:
- the updated collection
Developer note.This is an internal item. Its function and presence are subject to change without warning. Its use is highly discouraged.
-
batchSize
public int batchSize()
- Returns:
- the configuration value
-
batchSize
public AggregationOptions batchSize(int batchSize)
Sets the batch size for fetching results.- Parameters:
batchSize
- the size- Returns:
- this
-
bypassDocumentValidation
public boolean bypassDocumentValidation()
- Returns:
- the configuration value
-
bypassDocumentValidation
public AggregationOptions bypassDocumentValidation(boolean bypassDocumentValidation)
Enables the aggregation to bypass document validation during the operation. This lets you insert documents that do not meet the validation requirements.Applicable only if you specify the $out or $merge aggregation stages.
- Parameters:
bypassDocumentValidation
- true to enable the bypass- Returns:
- this
-
clientSession
public AggregationOptions clientSession(com.mongodb.client.ClientSession clientSession)
Description copied from interface:dev.morphia.internal.SessionConfigurable
Set the client session to use for the insert.- Specified by:
clientSession
in interfacedev.morphia.internal.SessionConfigurable<AggregationOptions>
- Parameters:
clientSession
- the client session- Returns:
- this
-
clientSession
public com.mongodb.client.ClientSession clientSession()
Description copied from interface:dev.morphia.internal.SessionConfigurable
The client session to use for the insertion.- Specified by:
clientSession
in interfacedev.morphia.internal.SessionConfigurable<AggregationOptions>
- Returns:
- the client session
-
collation
public com.mongodb.client.model.Collation collation()
- Returns:
- the configuration value
-
collation
public AggregationOptions collation(com.mongodb.client.model.Collation collation)
Specifies the collation to use for the operation.Collation allows users to specify language-specific rules for string comparison, such as rules for letter case and accent marks.
- Parameters:
collation
- the collation to use- Returns:
- this
-
getAllowDiskUse
public boolean getAllowDiskUse()
- Returns:
- the configuration value
-
getBatchSize
public int getBatchSize()
- Returns:
- the configuration value
-
getBypassDocumentValidation
public boolean getBypassDocumentValidation()
- Returns:
- the configuration value
-
getCollation
public com.mongodb.client.model.Collation getCollation()
- Returns:
- the configuration value
-
getMaxTime
public long getMaxTime(TimeUnit unit)
- Parameters:
unit
- the target unit type- Returns:
- the configuration value
-
getMaxTimeMS
public long getMaxTimeMS()
- Returns:
- the configuration value
-
getReadConcern
public com.mongodb.ReadConcern getReadConcern()
Description copied from interface:dev.morphia.internal.ReadConfigurable
Gets the read concern- Specified by:
getReadConcern
in interfacedev.morphia.internal.ReadConfigurable<AggregationOptions>
- Returns:
- the configuration value
-
getReadPreference
public com.mongodb.ReadPreference getReadPreference()
- Specified by:
getReadPreference
in interfacedev.morphia.internal.ReadConfigurable<AggregationOptions>
- Returns:
- the configuration value
-
hint
public org.bson.Document hint()
- Returns:
- the hint for which index to use. A null value means no hint is set.
- Since:
- 2.0
- Since server release
- 3.6
-
hint
public AggregationOptions hint(String hint)
Sets the hint for which index to use. A null value means no hint is set.- Parameters:
hint
- the hint- Returns:
- this
- Since:
- 3.6
- Since server release
- 3.6
-
prepare
public <C> com.mongodb.client.MongoCollection<C> prepare(com.mongodb.client.MongoCollection<C> collection)
Description copied from interface:dev.morphia.internal.WriteConfigurable
Applies the options to the collection- Specified by:
prepare
in interfacedev.morphia.internal.ReadConfigurable<AggregationOptions>
- Specified by:
prepare
in interfacedev.morphia.internal.WriteConfigurable<AggregationOptions>
- Type Parameters:
C
- the collection type- Parameters:
collection
- the collection to prepare- Returns:
- either the passed collection or the updated collection
-
readConcern
public AggregationOptions readConcern(com.mongodb.ReadConcern readConcern)
Specifies the read concern.- Specified by:
readConcern
in interfacedev.morphia.internal.ReadConfigurable<AggregationOptions>
- Parameters:
readConcern
- the read concern to use- Returns:
- this
-
readPreference
public AggregationOptions readPreference(com.mongodb.ReadPreference readPreference)
Sets the read preference to use- Specified by:
readPreference
in interfacedev.morphia.internal.ReadConfigurable<AggregationOptions>
- Parameters:
readPreference
- the read preference- Returns:
- this
-
maxTimeMS
public long maxTimeMS()
- Returns:
- the configuration value
-
maxTimeMS
public AggregationOptions maxTimeMS(long maxTimeMS)
Specifies a time limit in milliseconds for processing operations on a cursor. If you do not specify a value for maxTimeMS, operations will not time out. A value of 0 explicitly specifies the default unbounded behavior.- Parameters:
maxTimeMS
- the max time in milliseconds- Returns:
- this
-
readConcern
public com.mongodb.ReadConcern readConcern()
- Returns:
- the configuration value
-
readPreference
public com.mongodb.ReadPreference readPreference()
- Returns:
- the configuration value
-
writeConcern
public AggregationOptions writeConcern(com.mongodb.WriteConcern writeConcern)
Sets the write concern to use- Specified by:
writeConcern
in interfacedev.morphia.internal.WriteConfigurable<AggregationOptions>
- Parameters:
writeConcern
- the write concern- Returns:
- this
-
writeConcern
public com.mongodb.WriteConcern writeConcern()
Description copied from interface:dev.morphia.internal.WriteConfigurable
The write concern to use. By default the write concern configured for the MongoCollection instance will be used.- Specified by:
writeConcern
in interfacedev.morphia.internal.WriteConfigurable<AggregationOptions>
- Returns:
- the configuration value
-
-