Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
metadatastorage.h
1 
17 #pragma once
18 #include <cstddef>
19 #include <memory>
20 #include <vector>
21 
22 #include <apr.h>
23 #include <apr_dbd.h>
24 
25 #include "akumuli.h"
26 #include "akumuli_def.h"
27 #include "seriesparser.h"
28 
29 namespace Akumuli {
30 
32 void delete_apr_pool(apr_pool_t* p);
33 
36  const apr_dbd_driver_t* driver;
37  AprHandleDeleter(const apr_dbd_driver_t* driver);
38  void operator()(apr_dbd_t* handle);
39 };
40 
41 
49  // Typedefs
50  typedef std::unique_ptr<apr_pool_t, decltype(&delete_apr_pool)> PoolT;
51  typedef const apr_dbd_driver_t* DriverT;
52  typedef std::unique_ptr<apr_dbd_t, AprHandleDeleter> HandleT;
53  typedef std::pair<int, std::string> VolumeDesc;
54  typedef apr_dbd_prepared_t* PreparedT;
55 
56  // Members
57  PoolT pool_;
58  DriverT driver_;
59  HandleT handle_;
60  PreparedT insert_;
61  aku_logger_cb_t logger_;
62 
66  MetadataStorage(const char* db, aku_logger_cb_t logger);
67 
68  // Creation //
69 
73  void create_tables();
74 
78  void init_volumes(std::vector<VolumeDesc> volumes);
79 
80  void init_config(const char* creation_datetime);
81 
82  // Retreival //
83 
87  std::vector<VolumeDesc> get_volumes() const;
88 
89  void get_configs(std::string* creation_datetime);
90 
92  uint64_t get_prev_largest_id();
93 
94  aku_Status load_matcher_data(SeriesMatcher& matcher);
95 
96  // Writing //
97 
98  typedef std::tuple<const char*, int, uint64_t> SeriesT;
99 
102  void insert_new_names(std::vector<SeriesT> items);
103 
104 private:
109  int execute_query(std::string query);
110 
111  typedef std::vector<std::string> UntypedTuple;
112 
117  std::vector<UntypedTuple> select_query(const char* query) const;
118 };
119 }
void insert_new_names(std::vector< SeriesT > items)
Definition: metadatastorage.cpp:272
APR DBD handle deleter.
Definition: metadatastorage.h:35
void init_volumes(std::vector< VolumeDesc > volumes)
Definition: metadatastorage.cpp:169
uint64_t get_prev_largest_id()
Definition: metadatastorage.cpp:314
void delete_apr_pool(apr_pool_t *p)
Delete apr pool.
Definition: metadatastorage.cpp:30
std::vector< VolumeDesc > get_volumes() const
Definition: metadatastorage.cpp:218
MetadataStorage(const char *db, aku_logger_cb_t logger)
Definition: metadatastorage.cpp:57
void create_tables()
Definition: metadatastorage.cpp:110
Definition: metadatastorage.h:48
Definition: seriesparser.h:38