| 154 | } |
| 155 | |
| 156 | void PrintTableIndex(std::ostream &stream, |
| 157 | const ::hybridse::vm::IndexList &index_list) { |
| 158 | ::hybridse::base::TextTable t('-', ' ', ' '); |
| 159 | t.add("#"); |
| 160 | t.add("name"); |
| 161 | t.add("keys"); |
| 162 | t.add("ts"); |
| 163 | t.add("ttl"); |
| 164 | t.add("ttl_type"); |
| 165 | t.end_of_row(); |
| 166 | for (int i = 0; i < index_list.size(); i++) { |
| 167 | const ::hybridse::type::IndexDef &index = index_list.Get(i); |
| 168 | t.add(std::to_string(i + 1)); |
| 169 | t.add(index.name()); |
| 170 | t.add(index.first_keys(0)); |
| 171 | std::string ts_name = index.second_key(); |
| 172 | if (ts_name.empty()) { |
| 173 | t.add("-"); |
| 174 | } else { |
| 175 | t.add(index.second_key()); |
| 176 | } |
| 177 | std::ostringstream oss; |
| 178 | for (int i = 0; i < index.ttl_size(); i++) { |
| 179 | oss << index.ttl(i); |
| 180 | if (i != index.ttl_size() - 1) { |
| 181 | oss << "m" << ","; |
| 182 | } |
| 183 | } |
| 184 | t.add(oss.str()); |
| 185 | if (index.ttl_type() == ::hybridse::type::kTTLTimeLive) { |
| 186 | t.add("kAbsolute"); |
| 187 | } else if (index.ttl_type() == ::hybridse::type::kTTLCountLive) { |
| 188 | t.add("kLatest"); |
| 189 | } else if (index.ttl_type() == ::hybridse::type::kTTLTimeLiveAndCountLive) { |
| 190 | t.add("kAbsAndLat"); |
| 191 | } else { |
| 192 | t.add("kAbsOrLat"); |
| 193 | } |
| 194 | t.end_of_row(); |
| 195 | } |
| 196 | stream << t; |
| 197 | } |
| 198 | |
| 199 | void PrintTableSchema(std::ostream &stream, const ::hybridse::vm::Schema &schema) { |
| 200 | if (schema.empty()) { |