MCPcopy Create free account
hub / github.com/LBANN/lbann / fetch_raw_line

Method fetch_raw_line

src/data_readers/data_reader_csv.cpp:377–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377std::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
403void csv_reader::skip_rows(std::ifstream& s, int rows)
404{

Callers

nothing calls this directly

Calls 4

lbann_exceptionClass · 0.85
get_local_thread_idMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected