Skip to content

Commit 953a13c

Browse files
committed
DR + RM PR comments
1 parent d8c5113 commit 953a13c

File tree

2 files changed

+32
-17
lines changed

2 files changed

+32
-17
lines changed

source/data-formats/bson.txt

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ In addition to the core {+language+} objects, BSON also provides some special ty
294294
specific to the specification. The following sections describe other
295295
types that are supported in the driver.
296296

297+
.. _ruby-bson-binary:
298+
297299
BSON::Binary
298300
~~~~~~~~~~~~
299301

@@ -314,8 +316,19 @@ the bytes encode a particular type of data:
314316
BSON::Binary.new("binary_string", :user)
315317
# => <BSON::Binary:0x47113101225420 type=user data=0x62696e6172795f73...>
316318

317-
The valid subtype specifications are ``:generic``, ``:function``,
318-
``:old``, ``:uuid_old``, ``:uuid``, ``:md5``, and ``:user``.
319+
The following list provides the valid subtype specifications:
320+
321+
- ``:generic``
322+
- ``:function``
323+
- ``:old``
324+
- ``:uuid_old``
325+
- ``:uuid``
326+
- ``:md5``
327+
- ``:ciphertext``
328+
- ``:column``
329+
- ``:sensitive``
330+
- ``:vector``
331+
- ``:user``
319332

320333
You can use the ``data`` and ``type`` attributes to retrieve a
321334
``Binary`` object's data and the subtype, as shown in the following code:
@@ -455,20 +468,20 @@ BSON::Vector
455468
Starting in ``bson`` v5.1, you can use the
456469
``BSON::Vector`` type to represent vectors of numeric values.
457470

458-
You can create a ``Vector`` object to store values of the following
471+
You can create a ``BSON::Vector`` object to store values of the following
459472
types:
460473

461474
- ``int8``
462475
- ``float32``
463476
- ``packed_bit``
464477

465-
You can use the optional ``dtype`` and ``padding`` atrributes to specify
478+
You can use the optional ``dtype`` and ``padding`` attributes to specify
466479
the data type of the vector and the bit padding, respectively.
467-
``Vector`` itself is a container to hold your array values, type
468-
information, and padding specification. ``Vector`` objects are
480+
``BSON::Vector`` itself is a container to hold your array values, type
481+
information, and padding specification. ``BSON::Vector`` objects are
469482
serialized as normal arrays in MongoDB.
470483

471-
The following example demonstrates how to create a ``Vector`` object:
484+
The following example demonstrates how to create a ``BSON::Vector`` object:
472485

473486
.. code-block:: ruby
474487

@@ -477,23 +490,25 @@ The following example demonstrates how to create a ``Vector`` object:
477490
Convert Vectors to Binary
478491
`````````````````````````
479492

480-
You can convert ``Vector`` and array objects to ``BSON::Binary`` objects
481-
so they are serialized as BSON binary vector (subtype 9) instances. Use
482-
the ``Binary.from_vector`` method, as shown in the following code:
493+
You can convert ``BSON::Vector`` and array objects to
494+
:ref:`ruby-bson-binary` objects so they are serialized as BSON binary
495+
vector (subtype 9) instances. Use the ``BSON::Binary.from_vector``
496+
method, as shown in the following code:
483497

484498
.. code-block:: ruby
499+
500+
vector = BSON::Vector.new([ -0.0016261312, -0.028070757, -0.011342932 ], :float32)
501+
BSON::Binary.from_vector(vector)
485502

486-
BSON::Binary.from_vector([ -0.0016261312, -0.028070757, -0.011342932 ], :float32)
487-
488-
Using the ``Binary`` type improves storage efficiency. To learn
503+
Using the ``BSON::Binary`` type improves storage efficiency. To learn
489504
more, see the `BSON specification <https://bsonspec.org/spec.html>`__.
490505

491-
You can convert a ``Binary`` to a ``Vector`` by using the
492-
``Binary.as_vector`` method.
506+
You can convert a ``BSON::Binary`` to a ``BSON::Vector`` by using the
507+
``BSON::Binary.as_vector`` method.
493508

494509
.. tip:: {+avs+}
495510

496-
To view an example that leverages the ``Binary`` type
511+
To view an example that leverages the ``BSON::Binary`` type
497512
to perform efficient {+avs+} queries, see the :ref:`ruby-avs-examples`.
498513

499514
BSON::Code

source/vector-search.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ embedding of the phrase "time travel":
132132
``BSON::Binary`` type's vector subtype, introduced in ``bson`` gem v5.1,
133133
to serve as the query vector. You can also use an array of
134134
numbers as a query vector, but we recommend that you use the
135-
``Binary`` vector type to improve storage efficiency. To learn more about
135+
``BSON::Binary`` vector type to improve storage efficiency. To learn more about
136136
this type, see the :ref:`ruby-bson-vector` section of the BSON guide.
137137

138138
Vector Search Score

0 commit comments

Comments
 (0)