Skip to main content

%Library.Vector

Class %Library.Vector Extends %DataType [ SqlCategory = VECTOR, System = 1 ]

Datatype class for storing vector content, such as embeddings, in the native $vector format. See also the TO_VECTOR() SQL function to convert user input to the VECTOR datatype

Parameters

DATATYPE

Parameter DATATYPE [ Constraint = ",DOUBLE,DECIMAL,FLOAT,INT,INTEGER,TIMESTAMP,VARCHAR," ] = "FLOAT";

The datatype of the elements stored in the vector. Default to FLOAT (SQL type, corresponds to 'xf32' in ObjectScript), a significantly more storage-conscious option for Vector Search.

LEN

Parameter LEN As INTEGER;

The number of elements the vector can contain.

STORAGEDEFAULT

Parameter STORAGEDEFAULT As STRING = "GLOBALNODE";

The number of elements the vector can contain.

Methods

IsValid

ClassMethod IsValid(%val As %Vector) As %Status [ CodeMode = generator, ServerOnly = 1 ]

Normalize

ClassMethod Normalize(%val As %Vector) As %Vector [ CodeMode = generator, ServerOnly = 1 ]

DisplayToLogical

ClassMethod DisplayToLogical(%val As %String) As %Vector [ CodeMode = generator, ServerOnly = 1 ]

DisplayToLogical - If this is passed a dynamic array e.g. 'Set dynArray=[1,2,3,4]' then detect this with $isobject(%val) and then if it is an oref then test if it is a dynamic array and if so then walk this turning it into a vector so we can support JSON and dynamic arrays.

LogicalToDisplay

ClassMethod LogicalToDisplay(%val As %Vector) As %String

LogicalToOdbc

ClassMethod LogicalToOdbc(%val As %Vector) As %String [ ServerOnly = 1 ]

OdbcToLogical

ClassMethod OdbcToLogical(%val As %String) As %Vector [ CodeMode = generator, ServerOnly = 1 ]

HandleConversionError

ClassMethod HandleConversionError(ex As %RawString, conversionInput As %String) [ Internal, PublicList = SQLCODE ]

CalculateODBCLength

ClassMethod CalculateODBCLength(datatype As %String = "FLOAT", len As %Integer = "") [ Internal ]