@@ -142,7 +142,7 @@ Request Opcodes
142
142
The following are the supported ``opCode``:
143
143
144
144
.. list-table::
145
- :widths: 15 20 65
145
+ :widths: 25 10 65
146
146
:header-rows: 1
147
147
148
148
* - Opcode Name
@@ -178,6 +178,9 @@ The following are the supported ``opCode``:
178
178
* - ``OP_COMMANDREPLY``
179
179
- 2011
180
180
- Cluster internal protocol representing a reply to an ``OP_COMMAND``.
181
+ * - ``OP_COMPRESSED``
182
+ - 2012
183
+ - Wraps other opcodes using compression
181
184
* - ``OP_MSG``
182
185
- 2013
183
186
- 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>`
622
625
or :ref:`OP_GET_MORE <wire-op-get-more>` returns zero
623
626
for the cursor id), there is no need to kill the cursor.
624
627
625
-
626
628
.. _wire-op-command:
627
629
628
630
OP_COMMAND
@@ -693,6 +695,99 @@ as a response to a ``OP_COMMAND``.
693
695
commands that can require a large amount of data sent from the client,
694
696
such as a batch insert.
695
697
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
+
696
791
.. _wire-op-msg:
697
792
698
793
OP_MSG
0 commit comments