Loads an existing encrypted index and returns an instance of EncryptedIndex
.
std::unique_ptr<cyborg::EncryptedIndex>
LoadIndex(const std::string index_name,
const std::array<uint8_t, 32>& index_key,
const std::optional<size_t>& max_cache_size = 0,
cyborg::Logger* logger = nullptr);
Parameters
Parameter | Type | Description |
---|
index_name | std::string | Name of the index to load. |
index_key | std::array<uint8_t, 32> | 32-byte encryption key for the index, used to secure index data. |
max_cache_size | std::optional<size_t> | (Optional) Maximum size for the local cache (default is 0 ). |
logger | cyborg::Logger* | (Optional) Pointer to a logger instance for capturing operation logs (default is nullptr ). |
Returns
std::unique_ptr<cyborg::EncryptedIndex>
: A pointer to the loaded index (EncryptedIndex
).
Exceptions
Example Usage
#include "cyborgdb_core/client.hpp"
#include "cyborgdb_core/encrypted_index.hpp"
#include "cyborgdb_core/logger.hpp"
#include <array>
// ... Initialize the client ...
// Create a secure 32-byte key (example: all zeros)
std::array<uint8_t, 32> index_key = {0};
// Optional: Create and configure a logger
cyborg::Logger logger;
logger.Configure(LogLevel::Debug, true, "index_loading.log");
auto index = client.LoadIndex("my_index", index_key, 1000, &logger);