QNANO
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Random_Access_Reader Class Reference

#include <Random_Access_Reader.h>

Public Member Functions

std::string get_line (int local_line_nr)
 
void setup (const std::string &filename, std::streampos spos)
 
 Random_Access_Reader (const std::string &filename, std::streampos spos)
 

Public Attributes

std::ifstream ifs
 input stream: only closed on destruction:
 
std::streampos startpos
 position in stream corresponding to starting point for the present thread
 
int lastline
 Number of last processed line; check if we have to seek position or not.
 
std::string lastline_string
 String value of last line; good for reading IA files.
 

Protected Attributes

bool was_setup
 

Detailed Description

Reader that will we used for diagonalizing sparse matrices from files.

Solves the problem: Sparse_Matrix_Generator requires a function that allows random access to the rows of a sparse matrix. However, a naive implementation would stress the file system, because the files have to be read many times and always from the beginning.

Idea: Assume that one typically goes through the files sequentially, i.e. line by line, and make the access efficient in this case. -> Keep stream open and keep track of which line was the last in the stream.

Also: Distribute between threads -> First step: communicate position in stream where data for each thread starts. For CSR sparse matrices, we need to open 3 different files. So, let initial distribution of stream line positions handled somewhere else.


The documentation for this class was generated from the following files: