Module: Mongo::Collection::View::Aggregation::Behavior
- Extended by:
- Forwardable
- Includes:
- Enumerable, Explainable, Immutable, Iterable, Loggable, Retryable
- Included in:
- Mongo::Collection::View::Aggregation, ChangeStream
- Defined in:
- lib/mongo/collection/view/aggregation/behavior.rb
Overview
Distills the behavior common to aggregator classes, like View::Aggregator and View::ChangeStream.
Constant Summary
Constants included from Loggable
Constants included from Explainable
Explainable::ALL_PLANS_EXECUTION, Explainable::EXECUTION_STATS, Explainable::QUERY_PLANNER
Instance Attribute Summary collapse
-
#view ⇒ View
readonly
View The collection view.
Attributes included from Mongo::CursorHost
Attributes included from Immutable
Instance Method Summary collapse
-
#allow_disk_use(value = nil) ⇒ true, ...
Set to true if disk usage is allowed during the aggregation.
-
#explain ⇒ Hash
Get the explain plan for the aggregation.
-
#timeout_ms ⇒ Integer | nil
private
The timeout_ms value that was passed as an option to this object, or which was inherited from the view.
-
#write? ⇒ Boolean
private
Whether this aggregation will write its result to a database collection.
Methods included from Retryable
#read_worker, #select_server, #write_worker
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Methods included from Iterable
Methods included from Mongo::CursorHost
Instance Attribute Details
#view ⇒ View (readonly)
Returns view The collection view.
19 20 21 |
# File 'lib/mongo/collection/view/aggregation/behavior.rb', line 19 def view @view end |
Instance Method Details
#allow_disk_use(value = nil) ⇒ true, ...
Set to true if disk usage is allowed during the aggregation.
38 39 40 |
# File 'lib/mongo/collection/view/aggregation/behavior.rb', line 38 def allow_disk_use(value = nil) configure(:allow_disk_use, value) end |
#explain ⇒ Hash
Get the explain plan for the aggregation.
50 51 52 |
# File 'lib/mongo/collection/view/aggregation/behavior.rb', line 50 def explain self.class.new(view, pipeline, .merge(explain: true)).first end |
#timeout_ms ⇒ Integer | nil
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the timeout_ms value that was passed as an option to this object, or which was inherited from the view.
68 69 70 |
# File 'lib/mongo/collection/view/aggregation/behavior.rb', line 68 def timeout_ms @timeout_ms || view.timeout_ms end |
#write? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether this aggregation will write its result to a database collection.
60 61 62 |
# File 'lib/mongo/collection/view/aggregation/behavior.rb', line 60 def write? pipeline.any? { |op| op.key?('$out') || op.key?(:$out) || op.key?('$merge') || op.key?(:$merge) } end |