-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsharding_demo.cpp
More file actions
49 lines (42 loc) · 3.15 KB
/
sharding_demo.cpp
File metadata and controls
49 lines (42 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
╔═════════════════════════════════════════════════════════════════════╗
║ ThemisDB - Hybrid Database System ║
╠═════════════════════════════════════════════════════════════════════╣
File: sharding_demo.cpp ║
Version: 0.0.34 ║
Last Modified: 2026-03-09 03:52:20 ║
Author: unknown ║
╠═════════════════════════════════════════════════════════════════════╣
Quality Metrics: ║
• Maturity Level: 🟢 PRODUCTION-READY ║
• Quality Score: 100.0/100 ║
• Total Lines: 48 ║
• Open Issues: TODOs: 0, Stubs: 0 ║
╠═════════════════════════════════════════════════════════════════════╣
Revision History: ║
• 2a1fb0423 2026-03-03 Merge branch 'develop' into copilot/audit-src-module-docu... ║
• a629043ab 2026-02-22 Audit: document gaps found - benchmarks and stale annotat... ║
╠═════════════════════════════════════════════════════════════════════╣
Status: ✅ Production Ready ║
╚═════════════════════════════════════════════════════════════════════╝
*/
#include "sharding/urn.h"
#include "sharding/consistent_hash.h"
#include "sharding/shard_topology.h"
#include "sharding/urn_resolver.h"
#include <iostream>
#include <memory>
using namespace themis::sharding;
int main() {
std::cout << "=== ThemisDB Horizontal Sharding Demo ===" << std::endl;
// Create URN
auto urn = URN::parse("urn:themis:relational:customers:users:550e8400-e29b-41d4-a716-446655440000");
std::cout << "URN: " << urn->toString() << std::endl;
// Setup hash ring
auto hash_ring = std::make_shared<ConsistentHashRing>();
hash_ring->addShard("shard_001", 150);
hash_ring->addShard("shard_002", 150);
std::cout << "Shards: " << hash_ring->getShardCount() << std::endl;
std::cout << "Target shard: " << hash_ring->getShardForURN(*urn) << std::endl;
return 0;
}