Vector

A dense array of numeric values stored in a binary storage efficient for storage and retrieval.

Vectors are effectively used to represent data in artificial intelligence, machine learning, semantic search, computer vision, and natural language processing applications.

All values within the vector must be of the same type.

Comparison with BSON arrays

BSON arrays are serialized as objects, where the keys are integers (but still encoded as UTF8 strings). Arrays have a minimum overhead of 3 bytes per stored element.

Vectors are serialized contiguously, so there is no overhead per element.

However, arrays and vectors are not interchangeable. Most MongoDB operators expect one or the other, but will not work with both.

External resources

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Default serializer for Vector.

Properties

Link copied to clipboard
abstract val padding: Byte

The number of bits in the final byte of raw that are to be ignored.

Link copied to clipboard
abstract val raw: ByteArray

The raw data stored in this vector.

Link copied to clipboard
abstract val type: Byte

The type of the elements in the vector (called dtype in the specification).

Functions

Link copied to clipboard

Converts this Vector into a ByteArray that fits into the content of BsonType.BinaryData.