MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _op_msg_no_header

Function _op_msg_no_header

pymongo/message.py:331–360  ·  view source on GitHub ↗

Get a OP_MSG message. Note: this method handles multiple documents in a type one payload but it does not perform batch splitting and the total message size is only checked *after* generating the entire message.

(
    flags: int,
    command: Mapping[str, Any],
    identifier: str,
    docs: Optional[list[Mapping[str, Any]]],
    opts: CodecOptions[Any],
)

Source from the content-addressed store, hash-verified

329
330
331def _op_msg_no_header(
332 flags: int,
333 command: Mapping[str, Any],
334 identifier: str,
335 docs: Optional[list[Mapping[str, Any]]],
336 opts: CodecOptions[Any],
337) -> tuple[bytes, int, int]:
338 """Get a OP_MSG message.
339
340 Note: this method handles multiple documents in a type one payload but
341 it does not perform batch splitting and the total message size is
342 only checked *after* generating the entire message.
343 """
344 # Encode the command document in payload 0 without checking keys.
345 encoded = _dict_to_bson(command, False, opts)
346 flags_type = _pack_op_msg_flags_type(flags, 0)
347 total_size = len(encoded)
348 max_doc_size = 0
349 if identifier and docs is not None:
350 type_one = _pack_byte(1)
351 cstring = _make_c_string(identifier)
352 encoded_docs = [_dict_to_bson(doc, False, opts) for doc in docs]
353 size = len(cstring) + sum(len(doc) for doc in encoded_docs) + 4
354 encoded_size = _pack_int(size)
355 total_size += size
356 max_doc_size = max(len(doc) for doc in encoded_docs)
357 data = [flags_type, encoded, type_one, encoded_size, cstring, *encoded_docs]
358 else:
359 data = [flags_type, encoded]
360 return b"".join(data), total_size, max_doc_size
361
362
363def _op_msg_compressed(

Callers 2

_op_msg_compressedFunction · 0.85
_op_msg_uncompressedFunction · 0.85

Calls 3

_dict_to_bsonFunction · 0.90
_make_c_stringFunction · 0.90
joinMethod · 0.45

Tested by

no test coverage detected