Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
50
51
52
53
54
#ifndef DGRIDD_DATASTORE_SIMPLE_H
#define DGRIDD_DATASTORE_SIMPLE_H
 
#include <mutex>
#include "dgrid.h"
#include "dgrid_req_structs.h"
 
namespace DGrid {
 
class DGriddNodeArbiter;
 
class DGriddDataStoreSimple
{
public:
    DGriddDataStoreSimple(std::string session = "", DGriddNodeArbiter* a = nullptr);
    virtual ~DGriddDataStoreSimple();
    void setNodeArbiter(DGriddNodeArbiter*);
    void showStats();
 
    uint32_t getThemesCount();
    uint64_t getKeysCount();
 
/*
client-controlled methods: stats
*/
    DGridResult get_stats(const std::string& theme, std::vector<std::string>& data, std::string& error_string);
 
/*
client-controlled methods
*/
    DGridResult set_value(const std::string& theme, const std::string& key, /*const*/ SimpleValueData& value, std::string& error_string);
    DGridResult get_value(const std::string& theme, const std::string& key, SimpleValueData& value, std::string& error_string);
    DGridResult del_value(const std::string& theme, const std::string& key, std::string& error_string);
 
/*
node interaction methods
*/
    // ответ на запрос темы (в data можно указать ключи, если нужна не вся тема)
    DGridResult get_theme_simple(const std::string& name, SimpleValueMap& data);
    // сохраняем копию в локальное хранилище, для единичной записи возвращаем прошлый источник
    DGridResult append_theme_simple(const std::string& name, const SimpleValueMap& data, NodeID& source_node);
    // дописываем в локальное хранилище и возвращаем разницу
    DGridResult sync_theme_simple(const std::string& name, SimpleValueMap& data);
 
private:
    DGriddNodeArbiter* _node_arbiter;
    std::string        _session;
    std::mutex io_mutex;
    std::unordered_map<std::string, SimpleValueMap > internal_data;
};
 
} // namespace DGrid
 
#endif // DGRIDD_DATASTORE_SIMPLE_H