Compressed — Documentation by YARD 0.9.37 (original) (raw)
Class: Mongo::Protocol::Compressed
Inherits:
Defined in:
lib/mongo/protocol/compressed.rb
Overview
Constant Summarycollapse
NOOP =
The noop compressor identifier.
'noop'.freeze
NOOP_BYTE =
The byte signaling that the message has not been compressed (test mode).
0.chr.force_encoding(BSON::BINARY).freeze
SNAPPY =
The snappy compressor identifier.
'snappy'.freeze
SNAPPY_BYTE =
The byte signaling that the message has been compressed with snappy.
1.chr.force_encoding(BSON::BINARY).freeze
ZLIB_BYTE =
The byte signaling that the message has been compressed with Zlib.
2.chr.force_encoding(BSON::BINARY).freeze
ZLIB =
The Zlib compressor identifier.
'zlib'.freeze
ZSTD =
The zstd compressor identifier.
'zstd'.freeze
ZSTD_BYTE =
The byte signaling that the message has been compressed with zstd.
3.chr.force_encoding(BSON::BINARY).freeze
COMPRESSOR_ID_MAP =
The compressor identifier to byte map.
{ SNAPPY => SNAPPY_BYTE, ZSTD => ZSTD_BYTE, ZLIB => ZLIB_BYTE }.freeze
Constants inherited from Message
Message::BATCH_SIZE, Message::COLLECTION, Message::LIMIT, Message::MAX_MESSAGE_SIZE, Message::ORDERED, Message::Q
Instance Attribute Summary
Attributes inherited from Message
Instance Method Summarycollapse
- #initialize(message, compressor, zlib_compression_level = nil) ⇒ Compressed constructor
Creates a new OP_COMPRESSED message. - #maybe_inflate ⇒ Protocol::Message private
Inflates an OP_COMRESSED message and returns the original message. - #replyable? ⇒ true, false
Whether the message expects a reply from the database.
Methods inherited from Message
#==, deserialize, #hash, #maybe_add_server_api, #maybe_compress, #maybe_decrypt, #maybe_encrypt, #number_returned, #serialize, #set_request_id
Methods included from Id
Constructor Details
#initialize(message, compressor, zlib_compression_level = nil) ⇒ Compressed
Creates a new OP_COMPRESSED message.
79 80 81 82 83 84 85 86 87 | # File 'lib/mongo/protocol/compressed.rb', line 79 def initialize(message, compressor, zlib_compression_level = nil) @original_message = message @original_op_code = message.op_code @uncompressed_size = 0 @compressor_id = COMPRESSOR_ID_MAP[compressor] @compressed_message = '' @zlib_compression_level = zlib_compression_level if zlib_compression_level && zlib_compression_level != -1 @request_id = message.request_id end |
---|
Instance Method Details
#maybe_inflate ⇒ Protocol::Message
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.
Inflates an OP_COMRESSED message and returns the original message.
| 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | # File 'lib/mongo/protocol/compressed.rb', line 95 def maybe_inflate message = Registry.get(@original_op_code).allocate buf = decompress(@compressed_message) message.send(:fields).each do |field| if field[:multi] Message.deserialize_array(message, buf, field) else Message.deserialize_field(message, buf, field) end end if message.is_a?(Msg) message.fix_after_deserialization end message end | | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
#replyable? ⇒ true, false
Whether the message expects a reply from the database.
120 121 122 | # File 'lib/mongo/protocol/compressed.rb', line 120 def replyable? @original_message.replyable? end |
---|