Akumuli
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
seriesparser.h
1 
17 #pragma once
18 #include "akumuli_def.h"
19 //#include "queryprocessor_framework.h"
20 #include "stringpool.h"
21 
22 #include <deque>
23 #include <map>
24 #include <memory>
25 #include <mutex>
26 #include <stdint.h>
27 #include <tuple>
28 #include <unordered_map>
29 #include <unordered_set>
30 #include <vector>
31 
32 namespace Akumuli {
33 
34 
38 struct SeriesMatcher {
39  // TODO: add LRU cache
43  typedef std::tuple<const char*, int, uint64_t> SeriesNameT;
44 
45  typedef StringTools::TableT TableT;
46  typedef StringTools::InvT InvT;
47 
48  // Variables
49  StringPool pool;
50  TableT table;
51  InvT inv_table;
52  uint64_t series_id;
53  std::vector<SeriesNameT> names;
54  std::mutex mutex;
55 
56  SeriesMatcher(uint64_t starting_id);
57 
60  uint64_t add(const char* begin, const char* end);
61 
66  void _add(std::string series, uint64_t id);
67 
70  uint64_t match(const char* begin, const char* end);
71 
73  StringT id2str(uint64_t tokenid) const;
74 
78  void pull_new_names(std::vector<SeriesNameT>* buffer);
79 
80  std::vector<uint64_t> get_all_ids() const;
81 };
82 
85 struct SeriesParser {
97  static aku_Status to_normal_form(const char* begin, const char* end, char* out_begin,
98  char* out_end, const char** keystr_begin,
99  const char** keystr_end);
100 
101  typedef StringTools::StringT StringT;
102 
105  static std::tuple<aku_Status, StringT> filter_tags(StringT const& input,
106  StringTools::SetT const& tags, char* out);
107 };
108 }
std::mutex mutex
List of recently added names.
Definition: seriesparser.h:54
void _add(std::string series, uint64_t id)
Definition: seriesparser.cpp:59
std::pair< const char *, int > StringT
Pooled string.
Definition: stringpool.h:68
std::tuple< const char *, int, uint64_t > SeriesNameT
Series name descriptor - pointer to string, length, series id.
Definition: seriesparser.h:43
std::unordered_map< uint64_t, StringT > InvT
Inverted table type (id to string mapping)
Definition: stringpool.h:81
uint64_t series_id
Ids table (id to name mapping)
Definition: seriesparser.h:52
static std::tuple< aku_Status, StringT > filter_tags(StringT const &input, StringTools::SetT const &tags, char *out)
Definition: seriesparser.cpp:258
static aku_Status to_normal_form(const char *begin, const char *end, char *out_begin, char *out_end, const char **keystr_begin, const char **keystr_end)
Definition: seriesparser.cpp:159
TableT table
String pool that stores time-series.
Definition: seriesparser.h:50
StringT id2str(uint64_t tokenid) const
Convert id to string.
Definition: seriesparser.cpp:82
Definition: seriesparser.h:85
uint64_t match(const char *begin, const char *end)
Definition: seriesparser.cpp:70
StringTools::StringT StringT
Pooled string.
Definition: seriesparser.h:41
void pull_new_names(std::vector< SeriesNameT > *buffer)
Definition: seriesparser.cpp:90
std::vector< SeriesNameT > names
Series ID counter.
Definition: seriesparser.h:53
InvT inv_table
Series table (name to id mapping)
Definition: seriesparser.h:51
uint64_t add(const char *begin, const char *end)
Definition: seriesparser.cpp:49
Definition: seriesparser.h:38
Definition: stringpool.h:39
SeriesMatcher(uint64_t starting_id)
Mutex for shared data.
Definition: seriesparser.cpp:40