@@ -135,7 +135,7 @@ Request Opcodes
135
135
The following are the supported ``opCode``:
136
136
137
137
.. list-table::
138
- :widths: 15 20 65
138
+ :widths: 25 10 65
139
139
:header-rows: 1
140
140
141
141
* - Opcode Name
@@ -165,6 +165,9 @@ The following are the supported ``opCode``:
165
165
* - ``OP_KILL_CURSORS``
166
166
- 2007
167
167
- Notify database that the client has finished with the cursor.
168
+ * - ``OP_COMPRESSED``
169
+ - 2012
170
+ - Wraps other opcodes using compression
168
171
* - ``OP_MSG``
169
172
- 2013
170
173
- Send a message using the format introduced in MongoDB 3.6.
@@ -609,6 +612,98 @@ If a cursor is read until exhausted (read until :ref:`OP_QUERY <wire-op-query>`
609
612
or :ref:`OP_GET_MORE <wire-op-get-more>` returns zero
610
613
for the cursor id), there is no need to kill the cursor.
611
614
615
+ .. _wire-op-compressed:
616
+
617
+ OP_COMPRESSED
618
+ ~~~~~~~~~~~~~
619
+
620
+ .. versionadded:: MongoDB 3.4
621
+
622
+ Any opcode can be compressed and wrapped in an OP_COMPRESSED header.
623
+ The OP_COMPRESSED message contains the original compressed opcode
624
+ message alongside the metadata necessary to process and decompress it.
625
+
626
+ The format of the OP_COMPRESSED message is:
627
+
628
+ .. code-block:: bash
629
+
630
+ struct {
631
+ MsgHeader header; // standard message header
632
+ int32 originalOpcode; // value of wrapped opcode
633
+ int32 uncompressedSize; // size of deflated compressedMessage, excluding MsgHeader
634
+ uint8 compressorId; // ID of compressor that compressed message
635
+ char *compressedMessage; // opcode itself, excluding MsgHeader
636
+ }
637
+
638
+ .. list-table::
639
+ :widths: 25 75
640
+ :header-rows: 1
641
+
642
+ * - Field
643
+ - Description
644
+
645
+ * - ``MsgHeader``
646
+
647
+ - Message header, as described in :ref:`wp-message-header`.
648
+
649
+ * - ``originalOpcode``
650
+
651
+ - Contains the value of the wrapped opcode.
652
+
653
+ * - ``uncompressedSize``
654
+
655
+ - The size of the deflated ``compressedMessage``, which excludes
656
+ the ``MsgHeader``.
657
+
658
+ * - ``compressorId``
659
+
660
+ - The ID of the compressor that compressed the message. A list of
661
+ ``compressorId`` values is provided below.
662
+
663
+ * - ``compressedMessage``
664
+
665
+ - The opcode itself, excluding the ``MsgHeader``.
666
+
667
+ Each compressor is assigned a predefined compressor ID as follows:
668
+
669
+ .. list-table::
670
+ :widths: 15 25 60
671
+ :header-rows: 1
672
+
673
+ * - compressorId
674
+ - Handshake Value
675
+ - Description
676
+
677
+ * - ``0``
678
+
679
+ - noop
680
+
681
+ - The content of the message is uncompressed. This is used for
682
+ testing.
683
+
684
+ * - ``1``
685
+
686
+ - snappy
687
+
688
+ - The content of the message is compressed using snappy.
689
+
690
+ * - ``2``
691
+
692
+ - zlib
693
+
694
+ - The content of the message is compressed using zlib.
695
+
696
+ * - ``3``
697
+
698
+ - zstd
699
+
700
+ - The content of the message is compressed using zstd.
701
+
702
+ * - ``4-255``
703
+
704
+ - reserved
705
+
706
+ - Reserved for future use.
612
707
613
708
.. _wire-op-msg:
614
709
0 commit comments