Add fetchSublist method to BinaryTable for improved data retrieval

This commit is contained in:
ImBenji
2025-10-10 12:37:34 +01:00
parent cf983c8d96
commit b15d11a5a4
11 changed files with 2362 additions and 611 deletions

View File

@@ -0,0 +1,47 @@
#include <iostream>
#include <filesystem>
#include "../binary_table.h"
int main() {
using namespace bt;
const std::string filename = "debug_simple.bin";
if (std::filesystem::exists(filename)) {
std::filesystem::remove(filename);
}
BinaryTable table(filename);
table.initialize();
std::cout << "1. Storing key1..." << std::endl;
table.set<int32_t>("key1", 100);
std::cout << "2. Reading key1..." << std::endl;
try {
int32_t val = table.get<int32_t>("key1");
std::cout << " ✅ key1 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key1 failed: " << e.what() << std::endl;
}
std::cout << "3. Storing key2..." << std::endl;
table.set<int32_t>("key2", 200);
std::cout << "4. Reading key2..." << std::endl;
try {
int32_t val = table.get<int32_t>("key2");
std::cout << " ✅ key2 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key2 failed: " << e.what() << std::endl;
}
std::cout << "5. Re-reading key1..." << std::endl;
try {
int32_t val = table.get<int32_t>("key1");
std::cout << " ✅ key1 = " << val << std::endl;
} catch (const std::exception& e) {
std::cout << " ❌ key1 failed: " << e.what() << std::endl;
}
return 0;
}