| 375 | } |
| 376 | |
| 377 | std::string csv_reader::fetch_raw_line(int data_id) |
| 378 | { |
| 379 | static int n = 0; |
| 380 | std::ifstream& ifs = *m_ifstreams[m_io_thread_pool->get_local_thread_id()]; |
| 381 | // Seek to the start of this datum's line. |
| 382 | ifs.seekg(m_index[data_id], std::ios::beg); |
| 383 | // Compute the length of the line to read, excluding newline. |
| 384 | std::streamsize cnt = m_index[data_id + 1] - m_index[data_id] - 1; |
| 385 | // Read directly into a string buffer. |
| 386 | std::string line; |
| 387 | line.resize(cnt); |
| 388 | if (!ifs.read(&line[0], cnt)) { |
| 389 | std::stringstream err; |
| 390 | err << __FILE__ << " " << __LINE__ << " :: " |
| 391 | << "csv_reader: error on reading data_id: " << data_id << "\n" |
| 392 | << "index.size(): " << m_index.size() << " m_index[" << data_id |
| 393 | << ")=" << m_index[data_id] << "; index[" << data_id + 1 |
| 394 | << ")= " << m_index[data_id + 1] << "\ncnt: " << cnt |
| 395 | << " role: " << get_role() << " gcount: " << ifs.gcount() |
| 396 | << " n: " << n; |
| 397 | throw lbann_exception(err.str()); |
| 398 | } |
| 399 | ++n; |
| 400 | return line; |
| 401 | } |
| 402 | |
| 403 | void csv_reader::skip_rows(std::ifstream& s, int rows) |
| 404 | { |
nothing calls this directly
no test coverage detected