Module: Mongo::Protocol::Serializers::Sections Private
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Defined in: | lib/mongo/protocol/serializers.rb |
Overview
MongoDB wire protocol serialization strategy for a Section of OP_MSG.
Serializes and de-serializes a list of Sections
.
Class Attribute Summary
-
.size_limited? ⇒ true
readonly
Internal use only
Whether there can be a size limit on this type after serialization.
Class Method Summary
-
.deserialize(buffer, options = {}) ⇒ Array<BSON::Document>
Internal use only
Deserializes a section of an OP_MSG from the IO stream.
-
.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) ⇒ BSON::ByteBuffer
Internal use only
Serializes the sections of an OP_MSG, payload type 0 or 1.
Class Attribute Details
.size_limited? ⇒ true
(readonly)
Whether there can be a size limit on this type after serialization.
# File 'lib/mongo/protocol/serializers.rb', line 240
def self.size_limited? true end
Class Method Details
.deserialize(buffer, options = {}) ⇒ Array
<BSON::Document
>
Deserializes a section of an OP_MSG from the IO stream.
# File 'lib/mongo/protocol/serializers.rb', line 219
def self.deserialize(buffer, = {}) end_length = (@flag_bits & Msg::FLAGS.index(:checksum_present)) == 1 ? 32 : 0 sections = [] until buffer.length == end_length case byte = buffer.get_byte when PayloadZero::TYPE_BYTE sections << PayloadZero.deserialize(buffer, ) when PayloadOne::TYPE_BYTE sections += PayloadOne.deserialize(buffer, ) else raise Error::UnknownPayloadType.new(byte) end end sections end
.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) ⇒ BSON::ByteBuffer
Serializes the sections of an OP_MSG, payload type 0 or 1.
# File 'lib/mongo/protocol/serializers.rb', line 192
def self.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) value.each do |section| case section[:type] when PayloadZero::TYPE PayloadZero.serialize(buffer, section[:payload], max_bson_size) when nil PayloadZero.serialize(buffer, section[:payload], max_bson_size) when PayloadOne::TYPE PayloadOne.serialize(buffer, section[:payload], max_bson_size) else raise Error::UnknownPayloadType.new(section[:type]) end end end