9 #include"schemaparser.h"
14 unsigned int reserved;
19 unsigned long long int TS;
20 unsigned long long int e_RAB_ID;
21 unsigned long long int UE_ID;
23 double measurement_interval;
24 unsigned long long int active_throughput;
25 unsigned long long int average_throughput;
26 unsigned long long int min_throughput;
27 unsigned long long int max_throughput;
32 using namespace mc_schema;
34 int main(int argc, char **argv){
35 // Get the nib.json file
36 string directory = ".";
40 string inflnm = directory + "/" + string("nib.json");
42 ifstream infl(inflnm);
44 cerr << "Error, can't open " << inflnm << endl;
49 while(getline(infl, line)){
55 mc_schemas *mcs = new_mc_schemas(nib_str);
56 if(mcs->has_errors()){
57 fprintf(stderr, "Errors loading the schemas:\n%s\n",mcs->get_errors().c_str());
59 vector<string> streams = mcs->get_streams();
60 printf("Loaded %ld streams:\n", streams.size());
61 for(int i=0;i<streams.size(); ++i){
62 string str_rep = mcs->get_query_rep(streams[i])->to_string();
63 printf("\t%s\n",str_rep.c_str());
67 // Load a sample record
69 thpt *t = (thpt *)buf;
75 t->GNB_ID.offset = sizeof(thpt);
76 string foobar("foobar");
77 strncpy(buf+sizeof(thpt), foobar.c_str(), 6);
79 t->measurement_interval = 10.1;
80 t->active_throughput = 4;
81 t->average_throughput = 5;
82 t->min_throughput = 6;
83 t->max_throughput = 7;
85 int t_len = sizeof(thpt)+6;
87 // Get the throughput_ue schema
88 query_rep *qr = mcs->get_query_rep("throughput_ue");
90 // Extract stuff by various methods
91 int ts_idx = qr->get_index_of_field("TS");
92 int ts_type = qr->get_type(ts_idx);
93 int ts_offset = qr->get_offset(ts_idx);
94 field_handle ts_handle = qr->get_handle(ts_idx);
96 string ts_s = get_field_string(ts_handle, buf, t_len);
97 unsigned long long int ts_lu = get_field_ullong(ts_handle, buf, t_len);
98 unsigned int ts_u = get_field_uint(ts_handle, buf, t_len);
99 printf("ts string=%s, ullong=%lld, uint = %d\n",ts_s.c_str(), ts_lu, ts_u);
101 field_handle erab_handle = qr->get_handle(1);
102 access_result erab_ar = get_field_by_handle(erab_handle, buf, t_len);
103 printf("erab = %lld\n", erab_ar.r.l);
105 access_result ue_ar = get_field_by_index(qr, 2, buf, t_len);
106 printf("ue = %lld\n", ue_ar.r.l);
108 int gnb_idx = qr->get_index_of_field("GNB_ID");
109 field_handle gnb_handle = qr->get_handle(gnb_idx);
110 string gnb = get_field_string(gnb_handle, buf, t_len);
111 printf("gnb=%s\n",gnb.c_str());
113 access_result mt_ar = get_field_by_index(qr, 8, buf, t_len);
114 printf("mt = %lld, type=%d\n", mt_ar.r.l, mt_ar.field_data_type);
116 access_result none_ar = get_field_by_index(qr, 9, buf, t_len);
117 printf("none = %lld, type=%d\n", none_ar.r.l, none_ar.field_data_type);