Turi Create
4.0
|
#include <core/storage/fileio/general_fstream.hpp>
Public Member Functions | |
general_ofstream (std::string filename) | |
general_ofstream (std::string filename, bool gzip_compress) | |
bool | good () const |
bool | bad () const |
bool | fail () const |
size_t | get_bytes_written () const |
std::string | filename () const |
A generic output file stream interface that provides unified access to local filesystem, HDFS, S3, in memory files, and can automatically perform gzip decoding.
Usage:
file can be:
Unlike standard std::ofstream, random seek is not allowed. In other words, only sequential write is permitted.
If the filename ends with ".gz", gzip compression is automatically performed.
S3 access keys are mediated by having the filename be of the form s3://[access_key_id]:[secret_key]:[endpoint/][bucket]/[object_name]
Endpoint URLs however, are set globally via the global variable S3_ENDPOINT.
Definition at line 130 of file general_fstream.hpp.
turi::general_ofstream::general_ofstream | ( | std::string | filename | ) |
Constructs a general ofstream object when opens the filename specified. The file may be on HDFS. If the filename has the ".gz" suffix, it will be gzip compressed.
Throw an std::io_base::failure exception if failing to contruct the stream.
turi::general_ofstream::general_ofstream | ( | std::string | filename, |
bool | gzip_compress | ||
) |
Constructs a general ofstream object when opens the filename specified. The file may be on HDFS. This overloaded constructor allows you to explicitly specify whether the file is to to be gzip compressed, regardless of the filename.
Throw an std::io_base::failure exception if failing to contruct the stream.
bool turi::general_ofstream::bad | ( | ) | const |
Returns true if the stream is bad. See std::ios_base
bool turi::general_ofstream::fail | ( | ) | const |
Returns true if the last stream operation has failed. See std::ios_base
std::string turi::general_ofstream::filename | ( | ) | const |
Returns the local file name used by the stream.
size_t turi::general_ofstream::get_bytes_written | ( | ) | const |
Returns the number of bytes written to disk so far. Due to file compression and buffering this can be very different from how many bytes were wrtten to the stream.
bool turi::general_ofstream::good | ( | ) | const |
Returns true if the stream is good. See std::ios_base