Represents a vector column for Data API tables.

See DataAPIVectorLike for the types that can be converted into a DataAPIVector.

You may use the vector function as a shorthand for creating a new DataAPIVector.

See the official DataStax documentation for more information.

Implements

Constructors

  • Creates a new DataAPIVector instance from a vector-like value.

    You can set validate to false to bypass any validation if you're confident the value is a valid vector.

    Parameters

    • vector: DataAPIVectorLike

      The vector-like value to convert to a DataAPIVector

    • validate: boolean = true

      Whether to validate the vector-like value (default: true)

    Returns DataAPIVector

    Throws

    TypeError If vector is not a valid vector-like value

Properties

#vector: number[] | {
    $binary: string;
} | Float32Array

Type declaration

  • $binary: string

Accessors

  • get length(): number
  • Returns the length of the vector (# of floats), agnostic of the underlying type.

    Returns number

    The length of the vector

Methods

  • Implementation of $SerializeForCollection for TableCodec

    Parameters

    Returns readonly [0, undefined | number[] | {
        $binary: string;
    }]

  • Implementation of $SerializeForTable for TableCodec

    Parameters

    Returns readonly [0, undefined | number[] | {
        $binary: string;
    }]

  • Returns the vector as a base64 string, converting between types if necessary.

    Returns string

    The vector as a base64 string

  • Returns the vector as a Float32Array, converting between types if necessary.

    Returns Float32Array

    The vector as a Float32Array

  • Gets the raw underlying implementation of the vector.

    Returns number[] | {
        $binary: string;
    } | Float32Array

    The raw vector