Creates and returns a new encrypted index based on the provided configuration.
std::unique_ptr<cyborg::EncryptedIndex>
CreateIndex(const std::string index_name,
const std::array<uint8_t, 32>& index_key,
const IndexConfig& index_config,
const std::optional<size_t>& max_cache_size = 0);
Parameters
Parameter | Type | Description |
---|
index_name | std::string | Name of the index to create (must be unique). |
index_key | std::array<uint8_t, 32> | 32-byte encryption key for the index, used to secure index data. |
index_config | IndexConfig | Configuration for the index type (e.g., IVFFlat, IVFPQ). |
max_cache_size | size_t | (Optional) Maximum size for the local cache (default is 0 ). |
Returns
std::unique_ptr<cyborg::EncryptedIndex>
: A pointer to the newly created index (EncryptedIndex
).
Exceptions
Example Usage
#include "cyborg_vector_search/client.hpp"
#include "cyborg_vector_search/encrypted_index.hpp"
#include <array>
// ... Initialize the client ...
// Create a secure 32-byte key (example: all zeros)
std::array<uint8_t, 32> index_key = {0};
// Example vector dimensionality & number of lists
const size_t vector_dim = 1024;
const size_t num_lists = 128;
// Create an index configuration (e.g., using an IVFFlat configuration)
IndexIVFFlat index_config(vector_dim, num_lists, DistanceMetric::euclidean);
auto index = client.CreateIndex("my_index", index_key, index_config);