#include <rocksdb/db.h>
|
#include <rocksdb/options.h>
|
#include <iostream>
|
#include <string>
|
#include <unordered_map>
|
#include <vector>
|
#include <regex>
|
#include "tser/tser.hpp"
|
#include "RocksDBWrapper.h"
|
|
// Define a sample struct with tser serialization
|
struct Book
|
{
|
std::string title;
|
int pages;
|
|
// Define the members for serialization
|
DEFINE_SERIALIZABLE(Book, title, pages)
|
};
|
|
int main()
|
{
|
RocksDBWrapper db("testdb", "indexdb");
|
|
// Create some sample books
|
Book book1{"Book One", 30};
|
Book book2{"Book Two", 15};
|
Book book3{"Book Three", 50};
|
|
// Store the books in the database
|
db.store("book_1", book1);
|
db.store("book_2", book2);
|
db.store("book_3", book3);
|
|
std::vector<Book> res;
|
db.search_text("*One", res);
|
|
for (const auto &_l : res)
|
{
|
std::cout << _l << std::endl;
|
}
|
|
Book _res;
|
db.get("book_1", _res);
|
|
std::cout << _res << std::endl;
|
}
|