Class: Mongo::Operation::MapReduce::Result Private
- Defined in:
- lib/mongo/operation/map_reduce/result.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defines custom behaviour of results for a map reduce operation.
Constant Summary collapse
- COUNTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The counts field for the map/reduce.
'counts'.freeze
- RESULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The field name for a result without a cursor.
'results'.freeze
- TIME =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The time the operation took constant.
'timeMillis'.freeze
Constants inherited from Result
Result::CURSOR, Result::CURSOR_ID, Result::FIRST_BATCH, Result::N, Result::NAMESPACE, Result::NEXT_BATCH, Result::OK, Result::RESULT
Instance Attribute Summary
Attributes inherited from Result
Instance Method Summary collapse
-
#counts ⇒ Hash
private
Gets the map/reduce counts from the reply.
-
#cursor_id ⇒ Integer
private
Get the cursor id.
-
#documents ⇒ Array<BSON::Document>
private
Get the documents from the map/reduce.
-
#successful? ⇒ true, false
private
If the result was a command then determine if it was considered a success.
-
#time ⇒ Integer
private
Get the execution time of the map/reduce.
-
#validate! ⇒ Result
private
Validate the result by checking for any errors.
Methods inherited from Result
#acknowledged?, #cluster_time, #each, #initialize, #inspect, #multiple?, #namespace, #ok?, #operation_time, #reply, #returned_count, #written_count
Constructor Details
This class inherits a constructor from Mongo::Operation::Result
Instance Method Details
#counts ⇒ Hash
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.
Gets the map/reduce counts from the reply.
47 48 49 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 47 def counts reply.documents[0][COUNTS] end |
#cursor_id ⇒ Integer
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.
Get the cursor id.
117 118 119 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 117 def cursor_id 0 end |
#documents ⇒ Array<BSON::Document>
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.
Get the documents from the map/reduce.
59 60 61 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 59 def documents reply.documents[0][RESULTS] || reply.documents[0][RESULT] end |
#successful? ⇒ true, false
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.
If the write was unacknowledged, then this will always return true.
If the result was a command then determine if it was considered a success.
75 76 77 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 75 def successful? !documents.nil? end |
#time ⇒ Integer
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.
Get the execution time of the map/reduce.
87 88 89 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 87 def time reply.documents[0][TIME] end |
#validate! ⇒ Result
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.
This only checks for errors with writes since authentication is handled at the connection level and any authentication errors would be raised there, before a Result is ever created.
Validate the result by checking for any errors.
105 106 107 |
# File 'lib/mongo/operation/map_reduce/result.rb', line 105 def validate! documents.nil? ? raise_operation_failure : self end |