Skip to content

Commit ba756ad

Browse files
committed
DOCS-14429 add missing opcompressed wire protocol
1 parent 54ff22f commit ba756ad

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

source/reference/mongodb-wire-protocol.txt

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Request Opcodes
135135
The following are the supported ``opCode``:
136136

137137
.. list-table::
138-
:widths: 15 20 65
138+
:widths: 25 10 65
139139
:header-rows: 1
140140

141141
* - Opcode Name
@@ -165,6 +165,9 @@ The following are the supported ``opCode``:
165165
* - ``OP_KILL_CURSORS``
166166
- 2007
167167
- Notify database that the client has finished with the cursor.
168+
* - ``OP_COMPRESSED``
169+
- 2012
170+
- Wraps other opcodes using compression
168171
* - ``OP_MSG``
169172
- 2013
170173
- Send a message using the format introduced in MongoDB 3.6.
@@ -611,6 +614,98 @@ If a cursor is read until exhausted (read until :ref:`OP_QUERY <wire-op-query>`
611614
or :ref:`OP_GET_MORE <wire-op-get-more>` returns zero
612615
for the cursor id), there is no need to kill the cursor.
613616

617+
.. _wire-op-compressed:
618+
619+
OP_COMPRESSED
620+
~~~~~~~~~~~~~
621+
622+
.. versionadded:: MongoDB 3.4
623+
624+
Any opcode can be compressed and wrapped in an OP_COMPRESSED header.
625+
The OP_COMPRESSED message contains the original compressed opcode
626+
message alongside the metadata necessary to process and decompress it.
627+
628+
The format of the OP_COMPRESSED message is:
629+
630+
.. code-block:: bash
631+
632+
struct {
633+
MsgHeader header; // standard message header
634+
int32 originalOpcode; // value of wrapped opcode
635+
int32 uncompressedSize; // size of deflated compressedMessage, excluding MsgHeader
636+
uint8 compressorId; // ID of compressor that compressed message
637+
char *compressedMessage; // opcode itself, excluding MsgHeader
638+
}
639+
640+
.. list-table::
641+
:widths: 25 75
642+
:header-rows: 1
643+
644+
* - Field
645+
- Description
646+
647+
* - ``MsgHeader``
648+
649+
- Message header, as described in :ref:`wp-message-header`.
650+
651+
* - ``originalOpcode``
652+
653+
- Contains the value of the wrapped opcode.
654+
655+
* - ``uncompressedSize``
656+
657+
- The size of the deflated ``compressedMessage``, which excludes
658+
the ``MsgHeader``.
659+
660+
* - ``compressorId``
661+
662+
- The ID of the compressor that compressed the message. A list of
663+
``compressorId`` values is provided below.
664+
665+
* - ``compressedMessage``
666+
667+
- The opcode itself, excluding the ``MsgHeader``.
668+
669+
Each compressor is assigned a predefined compressor ID as follows:
670+
671+
.. list-table::
672+
:widths: 15 25 60
673+
:header-rows: 1
674+
675+
* - compressorId
676+
- Handshake Value
677+
- Description
678+
679+
* - ``0``
680+
681+
- noop
682+
683+
- The content of the message is uncompressed. This is used for
684+
testing.
685+
686+
* - ``1``
687+
688+
- snappy
689+
690+
- The content of the message is compressed using snappy.
691+
692+
* - ``2``
693+
694+
- zlib
695+
696+
- The content of the message is compressed using zlib.
697+
698+
* - ``3``
699+
700+
- zstd
701+
702+
- The content of the message is compressed using zstd.
703+
704+
* - ``4-255``
705+
706+
- reserved
707+
708+
- Reserved for future use.
614709

615710
.. _wire-op-msg:
616711

0 commit comments

Comments
 (0)