Skip to content

Commit 299eee0

Browse files
committed
DOCS-14429 add missing opcompressed wire protocol
1 parent db864b9 commit 299eee0

File tree

1 file changed

+97
-2
lines changed

1 file changed

+97
-2
lines changed

source/reference/mongodb-wire-protocol.txt

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Request Opcodes
142142
The following are the supported ``opCode``:
143143

144144
.. list-table::
145-
:widths: 15 20 65
145+
:widths: 25 10 65
146146
:header-rows: 1
147147

148148
* - Opcode Name
@@ -178,6 +178,9 @@ The following are the supported ``opCode``:
178178
* - ``OP_COMMANDREPLY``
179179
- 2011
180180
- Cluster internal protocol representing a reply to an ``OP_COMMAND``.
181+
* - ``OP_COMPRESSED``
182+
- 2012
183+
- Wraps other opcodes using compression
181184
* - ``OP_MSG``
182185
- 2013
183186
- 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 <wire-op-query>`
622625
or :ref:`OP_GET_MORE <wire-op-get-more>` returns zero
623626
for the cursor id), there is no need to kill the cursor.
624627

625-
626628
.. _wire-op-command:
627629

628630
OP_COMMAND
@@ -693,6 +695,99 @@ as a response to a ``OP_COMMAND``.
693695
commands that can require a large amount of data sent from the client,
694696
such as a batch insert.
695697

698+
.. _wire-op-compressed:
699+
700+
OP_COMPRESSED
701+
~~~~~~~~~~~~~
702+
703+
.. versionadded:: MongoDB 3.4
704+
705+
Any opcode can be compressed and wrapped in an OP_COMPRESSED header.
706+
The OP_COMPRESSED message contains the original compressed opcode
707+
message alongside the metadata necessary to process and decompress it.
708+
709+
The format of the OP_COMPRESSED message is:
710+
711+
.. code-block:: bash
712+
713+
struct {
714+
MsgHeader header; // standard message header
715+
int32 originalOpcode; // value of wrapped opcode
716+
int32 uncompressedSize; // size of deflated compressedMessage, excluding MsgHeader
717+
uint8 compressorId; // ID of compressor that compressed message
718+
char *compressedMessage; // opcode itself, excluding MsgHeader
719+
}
720+
721+
.. list-table::
722+
:widths: 25 75
723+
:header-rows: 1
724+
725+
* - Field
726+
- Description
727+
728+
* - ``MsgHeader``
729+
730+
- Message header, as described in :ref:`wp-message-header`.
731+
732+
* - ``originalOpcode``
733+
734+
- Contains the value of the wrapped opcode.
735+
736+
* - ``uncompressedSize``
737+
738+
- The size of the deflated ``compressedMessage``, which excludes
739+
the ``MsgHeader``.
740+
741+
* - ``compressorId``
742+
743+
- The ID of the compressor that compressed the message. A list of
744+
``compressorId`` values is provided below.
745+
746+
* - ``compressedMessage``
747+
748+
- The opcode itself, excluding the ``MsgHeader``.
749+
750+
Each compressor is assigned a predefined compressor ID as follows:
751+
752+
.. list-table::
753+
:widths: 15 25 60
754+
:header-rows: 1
755+
756+
* - compressorId
757+
- Handshake Value
758+
- Description
759+
760+
* - ``0``
761+
762+
- noop
763+
764+
- The content of the message is uncompressed. This is used for
765+
testing.
766+
767+
* - ``1``
768+
769+
- snappy
770+
771+
- The content of the message is compressed using snappy.
772+
773+
* - ``2``
774+
775+
- zlib
776+
777+
- The content of the message is compressed using zlib.
778+
779+
* - ``3``
780+
781+
- zstd
782+
783+
- The content of the message is compressed using zstd.
784+
785+
* - ``4-255``
786+
787+
- reserved
788+
789+
- Reserved for future use.
790+
696791
.. _wire-op-msg:
697792

698793
OP_MSG

0 commit comments

Comments
 (0)