1021{
1023 printf("ReadIndex [%s]\n", event_name);
1024
1027
1030
1032 printf("ReadIndex: reading index for event [%s]\n", event_name);
1033
1034
1035
1036 char cmd[256];
1037
1038 if (event_name)
1039 sprintf(cmd, "SELECT event_name, table_name, tag_name, column_name, itimestamp FROM _history_index where event_name=\'%s\';", event_name);
1040 else
1041 sprintf(cmd, "SELECT event_name, table_name, tag_name, column_name, itimestamp FROM _history_index;");
1042
1044
1048 }
1049
1051 printf("ReadIndex: event %s, Read status %d, nrows: %d\n",
1052 event_name,
1055 }
1056
1059
1063 }
1064
1067
1068 if (nrows == 0)
1070
1072 printf("ReadIndex: event %s, nrows: %d, ncols: %d\n",
1073 event_name,
1074 nrows, ncols);
1075
1076 if (nrows < 0)
1078
1079 if (ncols < 1)
1081
1082
1083 while (1) {
1086 break;
1087
1088 std::string xevent_name = sql->
GetColumn(1);
1089
1091 if (p) {
1092 std::string xtable_name = p;
1093 std::string xtimestamp = sql->
GetColumn(5);
1094 int timestamp = atoi(xtimestamp.c_str());
1095
1097 if (!ie) {
1101 }
1102
1107 }
1108
1109
1110 continue;
1111 }
1112
1114 if (p) {
1115 std::string xtag_name = p;
1116 std::string xcolumn_name = sql->
GetColumn(4);
1117 std::string xtimestamp = sql->
GetColumn(5);
1118 int timestamp = atoi(xtimestamp.c_str());
1119
1121 if (!ie) {
1126 }
1127
1128 bool found = false;
1129 for (
unsigned j=0;
j<ie->
tags.size();
j++)
1130 if (ie->
tags[
j].tag_name == xtag_name) {
1131 if (timestamp > ie->
tags[
j].timestamp) {
1132 ie->
tags[
j].timestamp = timestamp;
1133 ie->
tags[
j].column_name = xcolumn_name;
1134 }
1135 found = true;
1136 break;
1137 }
1138
1139 if (!found) {
1144 ie->
tags.push_back(it);
1145 }
1146
1147
1148 continue;
1149 }
1150
1151 }
1152
1154
1156
1157 if (event_name == NULL)
1159
1160
1161
1163}
virtual const char * GetColumn(int icol)=0
virtual int Exec(const char *sql)=0
virtual int GetNumColumns()=0
virtual int GetNumRows()=0
static IndexEntry * FindIndexByEventName(const char *event_name)