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