From 3ac954922108b07fb3f7a7ce1c727bfcfad8b263 Mon Sep 17 00:00:00 2001 From: Ferenc Szontágh <szf@fsociety.hu> Date: Thu, 27 Jun 2024 18:51:54 +0000 Subject: [PATCH] readme and some test --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 100 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 378061c..430be0e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,102 @@ -## RocksDBWrapper +# RocksDBWrapper -A simple wrapper for rocksdb +RocksDBWrapper is a C++ library that provides a convenient interface for storing, retrieving, and indexing data using RocksDB. This library supports serialization of complex data structures and indexing for efficient queries. +## Features + +* **Store and Retrieve Data:** Easily store and retrieve complex data structures. +* **Key Existence Check:** Check if a specific key exists in the database. +* **Member Indexing:** Index struct members for efficient search queries. +* **Text Search:** Perform text-based searches on indexed members. +* **Conditional Search:** Perform conditional searches on the data. + +## Installation + +### Dependencies + +* [RocksDB](https://github.com/facebook/rocksdb) +* [tser](https://github.com/StefanoDacchille/tser) +* [GoogleTest](https://github.com/google/googletest) (for testing) + +### Build + +```sh +mkdir build +cd build +cmake .. -DBUILD_TESTS=ON # Add -DBUILD_TESTS=OFF if you do not want to build tests +make +``` + +## Public Methods Documentation + +### Constructor and Destructor + +#### `RocksDBWrapper(const std::string &db_path, const std::string &index_path)` + +* **Description:** Constructs a `RocksDBWrapper` instance and opens the specified database and index paths. +* **Parameters:** + + * `db_path`: The path to the main RocksDB database. + * `index_path`: The path to the index RocksDB database. + +#### `~RocksDBWrapper()` + +* **Description:** Destructor that cleans up the database and index database resources. + +### Data Storage and Retrieval + +#### `template <typename T> void store(const std::string &key, const T &value)` + +* **Description:** Stores a value associated with the specified key. +* **Parameters:** + + * `key`: The key to associate with the value. + * `value`: The value to store. + +#### `template <typename T> bool get(const std::string &key, T &value)` + +* **Description:** Retrieves the value associated with the specified key. +* **Parameters:** + + * `key`: The key to retrieve the value for. + * `value`: The variable to store the retrieved value. +* **Returns:** `true` if the key was found and the value was retrieved; `false` otherwise. + +### Key Existence + +#### `bool keyExists(const std::string &key)` + +* **Description:** Checks if a key exists in the database. +* **Parameters:** + + * `key`: The key to check for existence. +* **Returns:** `true` if the key exists; `false` otherwise. + +### Searching + +#### `template <typename T> std::vector<std::string> search(const std::string &member_name, const std::string &member_value)` + +* **Description:** Searches for keys by a member's value. +* **Parameters:** + + * `member_name`: The name of the member to search by. + * `member_value`: The value of the member to search for. +* **Returns:** A vector of keys that match the search criteria. + +#### `template <typename T> void search_text(const std::string &search_value, std::vector<T> &res)` + +* **Description:** Performs a text-based search on indexed members. +* **Parameters:** + + * `search_value`: The text to search for. + * `res`: A vector to store the results. + +#### `template <typename T> void search_conditional(std::vector<T> &res, std::function<bool(const T &)> condition)` + +* **Description:** Performs a conditional search on the data. +* **Parameters:** + + * `res`: A vector to store the results. + * `condition`: A function to define the search condition. + +This `README.md` provides a comprehensive overview of the `RocksDBWrapper` library, including installation instructions, usage examples, and documentation of public methods. -- Gitblit v1.9.3