From c36c6b65abd5d183035e3699a7385a0365a253df Mon Sep 17 00:00:00 2001 From: andf-mongodb Date: Wed, 12 May 2021 17:19:54 -0400 Subject: [PATCH] DOCS-14429 add missing opcompressed wire protocol --- source/reference/mongodb-wire-protocol.txt | 99 +++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/source/reference/mongodb-wire-protocol.txt b/source/reference/mongodb-wire-protocol.txt index d2efdc1463e..7c02853afa8 100644 --- a/source/reference/mongodb-wire-protocol.txt +++ b/source/reference/mongodb-wire-protocol.txt @@ -142,7 +142,7 @@ Request Opcodes The following are the supported ``opCode``: .. list-table:: - :widths: 15 20 65 + :widths: 25 10 65 :header-rows: 1 * - Opcode Name @@ -178,6 +178,9 @@ The following are the supported ``opCode``: * - ``OP_COMMANDREPLY`` - 2011 - Cluster internal protocol representing a reply to an ``OP_COMMAND``. + * - ``OP_COMPRESSED`` + - 2012 + - Wraps other opcodes using compression * - ``OP_MSG`` - 2013 - Send a message using the format introduced in MongoDB 3.6. @@ -622,7 +625,6 @@ If a cursor is read until exhausted (read until :ref:`OP_QUERY ` or :ref:`OP_GET_MORE ` returns zero for the cursor id), there is no need to kill the cursor. - .. _wire-op-command: OP_COMMAND @@ -693,6 +695,99 @@ as a response to a ``OP_COMMAND``. commands that can require a large amount of data sent from the client, such as a batch insert. +.. _wire-op-compressed: + +OP_COMPRESSED +~~~~~~~~~~~~~ + +.. versionadded:: MongoDB 3.4 + +Any opcode can be compressed and wrapped in an OP_COMPRESSED header. +The OP_COMPRESSED message contains the original compressed opcode +message alongside the metadata necessary to process and decompress it. + +The format of the OP_COMPRESSED message is: + +.. code-block:: bash + + struct { + MsgHeader header; // standard message header + int32 originalOpcode; // value of wrapped opcode + int32 uncompressedSize; // size of deflated compressedMessage, excluding MsgHeader + uint8 compressorId; // ID of compressor that compressed message + char *compressedMessage; // opcode itself, excluding MsgHeader + } + +.. list-table:: + :widths: 25 75 + :header-rows: 1 + + * - Field + - Description + + * - ``MsgHeader`` + + - Message header, as described in :ref:`wp-message-header`. + + * - ``originalOpcode`` + + - Contains the value of the wrapped opcode. + + * - ``uncompressedSize`` + + - The size of the deflated ``compressedMessage``, which excludes + the ``MsgHeader``. + + * - ``compressorId`` + + - The ID of the compressor that compressed the message. A list of + ``compressorId`` values is provided below. + + * - ``compressedMessage`` + + - The opcode itself, excluding the ``MsgHeader``. + +Each compressor is assigned a predefined compressor ID as follows: + +.. list-table:: + :widths: 15 25 60 + :header-rows: 1 + + * - compressorId + - Handshake Value + - Description + + * - ``0`` + + - noop + + - The content of the message is uncompressed. This is used for + testing. + + * - ``1`` + + - snappy + + - The content of the message is compressed using snappy. + + * - ``2`` + + - zlib + + - The content of the message is compressed using zlib. + + * - ``3`` + + - zstd + + - The content of the message is compressed using zstd. + + * - ``4-255`` + + - reserved + + - Reserved for future use. + .. _wire-op-msg: OP_MSG