Documentation Index Fetch the complete documentation index at: https://docs.cyborg.co/llms.txt
Use this file to discover all available pages before exploring further.
The cyborg::Client class manages storage configurations and acts as a factory for creating or loading encrypted indexes.
Constructor
cyborg :: Client ( const std ::string & api_key,
const DBConfig & index_location,
const DBConfig & config_location,
const DBConfig & contents_location,
const int cpu_threads,
const GPUConfig gpu_config);
Initializes a new instance of Client.
Parameters
Parameter Type Description api_keystd::stringAPI key for your CyborgDB account. index_locationDBConfigConfiguration for index storage location. config_locationDBConfigConfiguration for index metadata storage. contents_locationDBConfigConfiguration for encrypted item contents storage. Used by upsert and get operations. cpu_threadsintNumber of CPU threads to use (e.g., 0 to use all available cores). gpu_configGPUConfigGPU operations configuration (requires CUDA). Use bitflags: kNone (no GPU), kUpsert (GPU for upsert), kTrain (GPU for training), kQuery (GPU for query), or kAll (GPU for all operations). Combine with | operator.
Exceptions
Throws if the cpu_threads parameter is less than 0.
Throws if any DBConfig is invalid.
Throws if the GPU is not available when gpu_accelerate is true.
Throws if the backing store is not available.
Throws if the Client could not be initialized.
Example Usage
#include "cyborgdb_core/client.hpp"
std ::string api_key = "your_api_key_here" ;
cyborg :: DBConfig index_location ( Location :: kThreadSafeMemory );
cyborg :: DBConfig config_location ( Location :: kRedis , "index_metadata" , "redis://localhost" );
cyborg :: DBConfig contents_location ( Location :: kRocksDB ); // Where encrypted item contents are stored
int cpu_threads = 4 ;
// Example 1: Enable GPU for all operations
cyborg ::GPUConfig gpu_config_all = cyborg ::kAll;
cyborg :: Client client1 ( api_key , index_location , config_location , contents_location , cpu_threads , gpu_config_all );
// Example 2: Enable GPU for specific operations (upsert, train, and query)
cyborg ::GPUConfig gpu_config_selective = cyborg ::kUpsert | cyborg ::kTrain | cyborg ::kQuery;
cyborg :: Client client2 ( api_key , index_location , config_location , contents_location , cpu_threads , gpu_config_selective );
// Example 3: Enable GPU only for training and query
cyborg ::GPUConfig gpu_config_train_query = cyborg ::kTrain | cyborg ::kQuery;
cyborg :: Client client3 ( api_key , index_location , config_location , contents_location , cpu_threads , gpu_config_train_query );
// Example 4: Disable GPU completely
cyborg ::GPUConfig gpu_config_none = cyborg ::kNone;
cyborg :: Client client4 ( api_key , index_location , config_location , contents_location , cpu_threads , gpu_config_none );
Methods
cpu_threads()
Returns the number of CPU threads configured for this client.
Returns: int - The number of CPU threads.
Example:
int threads = client . cpu_threads ();
std ::cout << "Using " << threads << " CPU threads" << std ::endl;
gpu_accelerate()
bool gpu_accelerate () const ;
Checks if GPU acceleration is enabled for any operations.
Returns: bool - true if GPU is enabled for any operation, false otherwise.
Example:
if ( client . gpu_accelerate ()) {
std ::cout << "GPU acceleration is enabled" << std ::endl;
}
gpu_config()
GPUConfig gpu_config () const ;
Returns the GPU operations configuration for this client.
Returns: GPUConfig - The GPU operations configuration.
Example:
cyborg ::GPUConfig config = client . gpu_config ();
if (config & cyborg ::kTrain) {
std ::cout << "GPU is enabled for training" << std ::endl;
}