MCPcopy Create free account
hub / github.com/acl-dev/acl / load_idx_hosts

Method load_idx_hosts

lib_acl_cpp/app/ndb/ctl_server/db_ctl.cpp:316–359  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316int db_ctl::load_idx_hosts(void)
317{
318 const char* sql = "select id, addr, count from tbl_host_idx";
319 if (ctl_conn_->sql_select(sql) == false)
320 {
321 logger_error("sql(%s) error", sql);
322 return -1;
323 }
324
325 const std::vector<acl::db_row*>* rows = ctl_conn_->get_rows();
326 if (rows == NULL)
327 {
328 logger_warn("tbl_host_idx empty");
329 return 0;
330 }
331
332 unsigned int id;
333 const char* addr;
334 acl_int64 count;
335 size_t i;
336 for (i = 0; i < rows->size(); i++)
337 {
338 const acl::db_row* row = (*rows)[i];
339 if ((id = row->field_int("id", -1)) == (unsigned int) -1)
340 {
341 logger_error("id(-1) invalid");
342 continue;
343 }
344 else if ((addr = row->field_string("addr")) == NULL)
345 {
346 logger_error("name null");
347 continue;
348 }
349 else if ((count = row->field_int64("count", -1)) == -1)
350 {
351 logger_error("count invalid");
352 continue;
353 }
354 idx_host* host = new idx_host(id, addr, count);
355 idx_hosts_.push_back(host);
356 }
357 ctl_conn_->free_result();
358 return (int) i;
359}
360
361int db_ctl::load_dat_hosts(void)
362{

Callers

nothing calls this directly

Calls 8

get_rowsMethod · 0.80
field_intMethod · 0.80
field_stringMethod · 0.80
field_int64Method · 0.80
free_resultMethod · 0.80
sql_selectMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected