Line data Source code
1 : /* 2 : * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved. 3 : * Copyright Contributors to the OpenSDN project 4 : */ 5 : 6 : /* 7 : * This file has utility functions for handling StatsOracle queries 8 : * 9 : */ 10 : 11 : #ifndef STATS_QUERY_H_ 12 : #define STATS_QUERY_H_ 13 : 14 : #include <vector> 15 : #include <string> 16 : #include <map> 17 : #include <set> 18 : #include <utility> 19 : #include "query.h" 20 : 21 : class AnalyticsQuery; 22 : 23 : 24 : class StatsQuery { 25 : public: 26 : static bool is_stat_table_query(const std::string& table); 27 : 28 : struct column_t { 29 : QEOpServerProxy::VarType datatype; 30 : bool index; 31 : bool output; 32 : std::set<std::string> suffixes; 33 : }; 34 : std::string type(void) const { return type_; } 35 : std::string attr(void) const { return attr_; } 36 1973 : bool is_stat_table_static(void) const { return is_static_; } 37 : 38 1363 : column_t get_column_desc(const std::string& colname) const { 39 : std::map<std::string,column_t>::const_iterator st = 40 1363 : schema_.find(colname); 41 1363 : if (st!=schema_.end()) { 42 1362 : return st->second; 43 : } else { 44 0 : column_t ct; 45 0 : ct.datatype = QEOpServerProxy::BLANK; 46 0 : ct.index = false; 47 0 : ct.output = false; 48 0 : return ct; 49 0 : } 50 : } 51 : static QEOpServerProxy::AggOper ParseAgg(const std::string&, std::string&); 52 : StatsQuery(const std::string& table); 53 : private: 54 : std::string type_; 55 : std::string attr_; 56 : bool is_static_; 57 : std::map<std::string,column_t> schema_; 58 : }; 59 : 60 : 61 : #endif