Medial Code Documentation
|
interface of stream I/O for serialization More...
#include <io.h>
Public Member Functions | |
virtual size_t | Read (void *ptr, size_t size)=0 |
reads data from a stream | |
virtual void | Write (const void *ptr, size_t size)=0 |
writes data to a stream | |
virtual | ~Stream (void) |
virtual destructor | |
template<typename T > | |
void | Write (const T &data) |
writes a data to stream. | |
template<typename T > | |
bool | Read (T *out_data) |
loads a data from stream. | |
template<typename T > | |
void | WriteArray (const T *data, size_t num_elems) |
Endian aware write array of data. | |
template<typename T > | |
bool | ReadArray (T *data, size_t num_elems) |
Endian aware read array of data. | |
Static Public Member Functions | |
static Stream * | Create (const char *uri, const char *const flag, bool allow_null=false) |
generic factory function create an stream, the stream will close the underlying files upon deletion | |
interface of stream I/O for serialization
|
static |
generic factory function create an stream, the stream will close the underlying files upon deletion
uri | the uri of the input currently we support hdfs://, s3://, and file:// by default file:// will be used |
flag | can be "w", "r", "a" |
allow_null | whether NULL can be returned, or directly report error |
|
inline |
loads a data from stream.
dmlc::Stream support Write/Read of most STL composites and base types. If the data type is not supported, a compile time error will be issued.
This function is endian-aware, the input endian defined by DMLC_IO_USE_LITTLE_ENDIAN
out_data | place holder of data to be deserialized |
|
pure virtual |
reads data from a stream
ptr | pointer to a memory buffer |
size | block size |
Implemented in xgboost::common::PeekableInStream, xgboost::common::FixedSizeStream, dmlc::MemoryFixedSizeStream, dmlc::MemoryStringStream, dmlc::io::HDFSStream, dmlc::io::FileStream, dmlc::io::s3::CURLReadStreamBase, dmlc::io::s3::WriteStream, xgboost::common::Base64InStream, xgboost::common::Base64OutStream, and rabit::utils::MemoryBufferStream.
|
inline |
Endian aware read array of data.
data | The data pointer |
num_elems | Number of elements |
T | the data type. |
|
inline |
writes a data to stream.
dmlc::Stream support Write/Read of most STL composites and base types. If the data type is not supported, a compile time error will be issued.
This function is endian-aware, the output endian defined by DMLC_IO_USE_LITTLE_ENDIAN
data | data to be written |
T | the data type to be written |
|
pure virtual |
writes data to a stream
ptr | pointer to a memory buffer |
size | block size |
Implemented in xgboost::common::PeekableInStream, xgboost::common::FixedSizeStream, dmlc::MemoryFixedSizeStream, dmlc::MemoryStringStream, dmlc::io::HDFSStream, dmlc::io::FileStream, dmlc::io::s3::CURLReadStreamBase, dmlc::io::s3::WriteStream, xgboost::common::Base64InStream, xgboost::common::Base64OutStream, and rabit::utils::MemoryBufferStream.
|
inline |
Endian aware write array of data.
data | The data pointer |
num_elems | Number of elements |
T | the data type. |