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

General Writer that provides functions for writing tuples. More...

#include <writer.h>

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

Public Member Functions

virtual ~Writer ()
 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, Mode mode)=0
 Open a file. More...
 
virtual void Close ()=0
 Release resources.
 
virtual bool Write (const std::string &key, const std::string &value)=0
 Write a key-value tuple. More...
 
virtual void Flush ()=0
 Flush writing buffer if it has.
 

Detailed Description

General Writer that provides functions for writing tuples.

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

Constructor & Destructor Documentation

◆ ~Writer()

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

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

Member Function Documentation

◆ Open()

virtual bool singa::io::Writer::Open ( const std::string &  path,
Mode  mode 
)
pure virtual

Open a file.

path is the path to the disk BinFile, it can be

  • a path to local disk file.
  • a path to local directory. This is to be compatible with the older version (DataShard). The KVFile is shard.dat under that directory
  • a hdfs file starting with "hdfs://" mode is open mode(kCreate, kAppend).

Implemented in singa::io::TextFileWriter, and singa::io::BinFileWriter.

◆ Write()

virtual bool singa::io::Writer::Write ( const std::string &  key,
const std::string &  value 
)
pure virtual

Write a key-value tuple.

return true if success, otherwise false.

Implemented in singa::io::TextFileWriter, and singa::io::BinFileWriter.


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