Apache Singa
A General Distributed Deep Learning Library
Public Member Functions | List of all members
singa::io::Reader Class Referenceabstract

General Reader that provides functions for reading tuples. More...

#include <reader.h>

Inheritance diagram for singa::io::Reader:
Inheritance graph
[legend]

Public Member Functions

virtual ~Reader ()
 In case that users forget to call Close() to release resources, e.g., memory, you can release them here. More...
 
virtual bool Open (const std::string &path)=0
 path is the path to the storage, could be a file path, database connection, or hdfs path. More...
 
virtual void Close ()=0
 Release resources.
 
virtual bool Read (std::string *key, std::string *value)=0
 Read a tuple. More...
 
virtual int Count ()=0
 Iterate through all tuples to get the num of all tuples. More...
 
virtual void SeekToFirst ()=0
 Seek to the first tuple when the cursor arrives to the end of the file.
 

Detailed Description

General Reader that provides functions for reading tuples.

Subclasses implement the functions for a specific data storage, e.g., CSV file, HDFS, kvfile, leveldb, lmdb, etc.

Constructor & Destructor Documentation

◆ ~Reader()

virtual singa::io::Reader::~Reader ( )
inlinevirtual

In case that users forget to call Close() to release resources, e.g., memory, you can release them here.

Member Function Documentation

◆ Count()

virtual int singa::io::Reader::Count ( )
pure virtual

Iterate through all tuples to get the num of all tuples.

return num of tuples

Implemented in singa::io::TextFileReader, and singa::io::BinFileReader.

◆ Open()

virtual bool singa::io::Reader::Open ( const std::string &  path)
pure virtual

path is the path to the storage, could be a file path, database connection, or hdfs path.

return true if open successfully, otherwise false.

Implemented in singa::io::TextFileReader, and singa::io::BinFileReader.

◆ Read()

virtual bool singa::io::Reader::Read ( std::string *  key,
std::string *  value 
)
pure virtual

Read a tuple.

return true if read successfully; return flase if coming to the end of the file; LOG(FATAL) if error happens.

Implemented in singa::io::TextFileReader, and singa::io::BinFileReader.


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