SWC-DB  v0.5.12 C++ documentations
SWC-DB© (Super Wide Column Database) - High Performance Scalable Database (https://github.com/kashirin-alex/swc-db)
Schemas.h
Go to the documentation of this file.
1 /*
2  * SWC-DB© Copyright since 2019 Alex Kashirin <kashirin.alex@gmail.com>
3  * License details at <https://github.com/kashirin-alex/swc-db/#license>
4  */
5 
6 #ifndef swcdb_db_client_Schemas_h
7 #define swcdb_db_client_Schemas_h
8 
9 
12 
13 
14 namespace SWC { namespace client {
15 
16 
17 class Schemas final {
18  public:
19 
21  Schemas(Clients* a_clients,
22  const Config::Property::Value_int32_g::Ptr expiry_ms) noexcept
23  : m_mutex(), m_schemas(),
24  _clients(a_clients), m_expiry_ms(expiry_ms),
26  }
27 
28  Schemas(const Schemas&) = delete;
29 
30  Schemas& operator=(const Schemas&) = delete;
31 
32  ~Schemas() noexcept { }
33 
34  void remove(cid_t cid);
35 
36  void remove(const std::string& name);
37 
38  void clear_expired();
39 
40  DB::Schema::Ptr get(int& err, cid_t cid,
41  uint32_t timeout=300000);
42 
43  DB::Schema::Ptr get(int& err, const std::string& name,
44  uint32_t timeout=300000);
45 
47 
48  DB::Schema::Ptr get(const std::string& name);
49 
50  void get(int& err, const DB::Schemas::SelectorPatterns& patterns,
51  DB::SchemasVec& schemas, uint32_t timeout=300000);
52 
53  DB::SchemasVec get(int& err, const DB::Schemas::SelectorPatterns& patterns,
54  uint32_t timeout=300000);
55 
56  void set(const DB::Schema::Ptr& schema);
57 
58  void set(const DB::SchemasVec& schemas);
59 
60  private:
61 
62  class ColumnGetData;
63  struct Pending final {
67  Pending() noexcept : req(nullptr), datap(nullptr) { }
70  noexcept : req(a_req), datap(a_datap) { }
71  Pending(const Pending&) = delete;
72  Pending& operator=(const Pending&) = default;
74  ~Pending() noexcept { }
75  };
76 
77  Pending _request(cid_t cid, uint32_t timeout);
78 
79  Pending _request(const std::string& name, uint32_t timeout);
80 
81  void _request(int& err, const DB::Schemas::SelectorPatterns& patterns,
82  DB::SchemasVec& schemas, uint32_t timeout);
83 
84  struct SchemaData {
85  int64_t ts;
88  SchemaData() noexcept: ts(), schema() { }
90  ~SchemaData() noexcept { }
92  void assign(int64_t _ts, const DB::Schema::Ptr& _schema) {
93  ts = _ts;
94  schema = _schema;
95  }
96  };
98  std::unordered_map<cid_t, SchemaData> m_schemas;
101  std::unordered_map<cid_t, Pending> m_pending_cid;
102  std::unordered_map<std::string, Pending> m_pending_name;
103 
104 };
105 
106 
107 
108 }}
109 
110 #endif // swcdb_db_client_Schemas_h
SWC::client::Schemas::Pending::Pending
SWC_CAN_INLINE Pending(const Comm::DispatchHandler::Ptr &a_req, ColumnGetData *a_datap) noexcept
Definition: Schemas.h:69
SWC::client::Schemas::m_pending_name
std::unordered_map< std::string, Pending > m_pending_name
Definition: Schemas.h:102
SWC::DB::Schema::Ptr
std::shared_ptr< Schema > Ptr
Definition: Schema.h:185
SWC::client::Schemas::Schemas
Schemas(const Schemas &)=delete
SWC::client::Schemas::Pending::Pending
Pending(const Pending &)=delete
SWC::client::Schemas::m_schemas
std::unordered_map< cid_t, SchemaData > m_schemas
Definition: Schemas.h:98
SWC::client::Schemas::SchemaData::assign
SWC_CAN_INLINE void assign(int64_t _ts, const DB::Schema::Ptr &_schema)
Definition: Schemas.h:92
Settings.h
SWC::client::Schemas
Definition: Schemas.h:17
SWC::client::Schemas::set
void set(const DB::Schema::Ptr &schema)
Definition: Schemas.cc:208
SWC::client::Schemas::clear_expired
void clear_expired()
Definition: Schemas.cc:33
SWC::client::Schemas::m_expiry_ms
Config::Property::Value_int32_g::Ptr m_expiry_ms
Definition: Schemas.h:100
SWC::DB::Schemas::SelectorPatterns
Definition: Schemas.h:100
SWC::client::Schemas::SchemaData::SchemaData
SWC_CAN_INLINE SchemaData() noexcept
Definition: Schemas.h:88
SWC::client::Schemas::Pending::datap
ColumnGetData * datap
Definition: Schemas.h:65
SWC::client::Schemas::m_mutex
Core::MutexSptd m_mutex
Definition: Schemas.h:97
SWC::client::Schemas::Pending
Definition: Schemas.h:63
SWC::client::Schemas::Pending::~Pending
SWC_CAN_INLINE ~Pending() noexcept
Definition: Schemas.h:74
SWC_CAN_INLINE
#define SWC_CAN_INLINE
Definition: Compat.h:102
SWC::client::Schemas::SchemaData::ts
int64_t ts
Definition: Schemas.h:85
SWC::client::Schemas::~Schemas
~Schemas() noexcept
Definition: Schemas.h:32
SWC
The SWC-DB C++ namespace 'SWC'.
Definition: main.cc:12
SWC::client::Schemas::ColumnGetData
Definition: Schemas.cc:46
SWC::client::Schemas::SchemaData::~SchemaData
SWC_CAN_INLINE ~SchemaData() noexcept
Definition: Schemas.h:90
SWC::client::Schemas::Pending::req
Comm::DispatchHandler::Ptr req
Definition: Schemas.h:64
SWC::client::Schemas::Pending::Pending
SWC_CAN_INLINE Pending() noexcept
Definition: Schemas.h:67
SWC::client::Clients
Definition: Clients.h:39
SWC::cid_t
uint64_t cid_t
Definition: Identifiers.h:16
SWC::client::Schemas::_request
Pending _request(cid_t cid, uint32_t timeout)
Definition: Schemas.cc:224
SWC::client::Schemas::operator=
Schemas & operator=(const Schemas &)=delete
SWC::Core::Vector
Definition: Vector.h:14
SWC::client::Schemas::remove
void remove(cid_t cid)
Definition: Schemas.cc:16
SWC::client::Schemas::m_pending_cid
std::unordered_map< cid_t, Pending > m_pending_cid
Definition: Schemas.h:101
SWC::client::Schemas::Pending::operator=
Pending & operator=(const Pending &)=default
SWC::client::Schemas::get
DB::Schema::Ptr get(int &err, cid_t cid, uint32_t timeout=300000)
Definition: Schemas.cc:98
SWC::client::Schemas::SchemaData
Definition: Schemas.h:84
SWC::client::Schemas::SchemaData::schema
DB::Schema::Ptr schema
Definition: Schemas.h:86
Schemas.h
SWC::Core::MutexSptd
Definition: MutexSptd.h:16
SWC::client::Schemas::_clients
Clients * _clients
Definition: Schemas.h:99
SWC::client::Schemas::Schemas
SWC_CAN_INLINE Schemas(Clients *a_clients, const Config::Property::Value_int32_g::Ptr expiry_ms) noexcept
Definition: Schemas.h:21
SWC::Comm::DispatchHandler::Ptr
std::shared_ptr< DispatchHandler > Ptr
Definition: DispatchHandler.h:20
SWC::Config::Property::Value_int32_g
Definition: Property.h:586