Skip to main content

Location

The Location enum contains the supported index backing store locations for CyborgDB. These are:
kMemory is deprecated and will be removed in a future release. Please use kThreadSafeMemory instead.

DBConfig

DBConfig defines the storage location for various index components.

Constructor

Parameters

Example Usage

For more info, you can read about supported backing stores here.

GPUConfig

GPUConfig is an enum that specifies which operations should use GPU acceleration. It uses bitflags that can be combined using the | (OR) operator.

Enum Values

Example Usage


DeviceConfig

DeviceConfig class holds the configuration details for the device used in vector search operations, such as the number of CPU threads and GPU acceleration settings.

Constructor

Parameters

Methods

Example Usage


DistanceMetric

The DistanceMetric enum contains the supported distance metrics for CyborgDB. These are:

IndexConfig

IndexConfig is an abstract base class for configuring index types. The three derived classes can be used to configure indexes:

IndexIVF

Ideal for large-scale datasets where fast retrieval is prioritized over high recall:

Constructor

Parameters

Methods

IndexIVFFlat

Suitable for applications requiring high recall with less concern for memory usage:

Constructor

Parameters

Methods

IndexIVFPQ

Product Quantization compresses embeddings, making it suitable for balancing memory use and recall:

Constructor

Parameters

Methods

IndexIVFSQ

Scalar Quantization compresses embeddings, providing a good balance of speed, recall, and index size:

Constructor

Parameters

Methods

Example Usage


Array2D

Array2D class provides a 2D container for data, which can be initialized with a specific number of rows and columns, or from an existing vector.

Constructors

  • Array2D(size_t rows, size_t cols, const T& initial_value = T()): Creates a 2D array with specified dimensions, initialized with the given value.
  • Array2D(std::vector<T>&& data, size_t cols): Initializes the 2D array from a 1D vector (move semantics).
  • Array2D(const std::vector<T>& data, size_t cols): Initializes the 2D array from a 1D vector (copy).
  • Array2D(std::initializer_list<std::initializer_list<T>> init_list): Initializes from a nested initializer list (e.g., {{1, 2}, {3, 4}}).
  • Array2D(Array2D&& other) noexcept: Move constructor - transfers ownership without copying.
  • Array2D(): Default constructor - creates an empty array (0 rows, 0 columns).
The copy constructor is deleted. Use Clone() or move semantics to copy an Array2D.

Access Methods

  • operator()(size_t row, size_t col) const: Access an element at the specified row and column (read-only).
  • operator()(size_t row, size_t col): Access an element at the specified row and column (read-write).
  • size_t rows() const: Returns the number of rows.
  • size_t cols() const: Returns the number of columns.
  • size_t size() const: Returns the total number of elements.

Example Usage


TrainingConfig

The TrainingConfig struct defines parameters for training an index, allowing control over convergence and memory usage.

Constructor

Parameters

Struct Members

Note: The struct members are stored in this order (different from constructor parameter order):

QueryParams

The QueryParams struct defines parameters for querying the index, controlling the number of results and probing behavior.

Constructor

Parameters

Higher n_probes values may improve recall but could slow down query time, so select a value based on desired recall and performance trade-offs.
filters use a subset of the MongoDB Query and Projection Operators. For instance: filters: { "$and": [ { "label": "cat" }, { "confidence": { "$gte": 0.9 } } ] } means that only vectors where label == "cat" and confidence >= 0.9 will be considered for encrypted vector search. For more info on metadata, see Metadata Filtering.

QueryResults

QueryResults class holds the results from a Query operation, including IDs, distances, and metadata for the nearest neighbors of each query. Results are vector-based and immutable after construction.

Getter Methods

Methods

ResultView

The ResultView struct provides read-only access to results for a single query:

Example Usage


ItemID

ItemID is a type alias for unique identifiers used throughout CyborgDB.
ItemID is used to uniquely identify vectors and items within an encrypted index. Currently implemented as std::string for flexibility and human-readable identifiers.

IndexType

The IndexType enum defines the supported index types in CyborgDB:
All four index types are available:
  • IVF: Fastest retrieval, lowest recall, smallest index size
  • IVFPQ: Balanced memory usage and recall with product quantization
  • IVFFLAT: Highest recall, largest index size, no compression
  • IVFSQ: Good balance of recall, speed, and index size with scalar quantization (default)
The IVF type is deprecated and will be removed in a future release.

Item

Item struct holds the individual results from a Get operation, including the requested fields.

ResultFields

ResultFields enum specifies which fields to include in query results.

ItemFields

ItemFields enum defines the fields that can be requested for an Item object.
By default, ids are always included in the returned items.