php8.5
Home/ Manual/ bson / binary/ MongoDB\BSON\Binary::fromVector

MongoDB\BSON\Binary::fromVector

PHP function Edit on GitHub ✎

(mongodb >=2.2.0)

Creates a new binary with subtype MongoDB\BSON\Binary::SUBTYPE_VECTOR from the given array and vector type

Description

MongoDB\BSON\Binary::fromVector(array $vector, MongoDB\BSON\VectorType $vectorType): MongoDB\BSON\Binary

Parameters

vector (array)

An array of values representing the vector data. The type of each value must match the type indicated by the vectorType parameter:

  • for MongoDB\BSON\VectorType::Float32, each value must be a float
  • for MongoDB\BSON\VectorType::Int8, each value must be an 8-bit int, i.e. from -127 to 128
  • for MongoDB\BSON\VectorType::PackedBit, each value must be a bool or 1-bit int, i.e. 0 or 1
vectorType (MongoDB\BSON\VectorType)

The vector data type.

Return Values

Returns a new Binary with subtype MongoDB\BSON\Binary::SUBTYPE_VECTOR.

Errors/Exceptions

See Also

  • MongoDB\BSON\Binary::toArray
  • MongoDB\BSON\Binary::getVectorType
  • MongoDB\BSON\VectorType
  • BSON Types

Source: reference/mongodb/bson/binary/fromvector.xml · from the official PHP manual (php/doc-en)