proxygen
|
#include <RecordIO.h>
Public Member Functions | |
RecordIOWriter (File file, uint32_t fileId=1) | |
void | write (std::unique_ptr< IOBuf > buf) |
off_t | filePos () const |
Private Attributes | |
File | file_ |
uint32_t | fileId_ |
std::unique_lock< File > | writeLock_ |
std::atomic< off_t > | filePos_ |
Class to write a stream of RecordIO records to a file.
RecordIOWriter is thread-safe
Definition at line 45 of file RecordIO.h.
Create a RecordIOWriter around a file; will append to the end of file if it exists.
Each file must have a non-zero file id, which is embedded in all record headers. Readers will only return records with the requested file id (or, if the reader is created with fileId=0 in the constructor, the reader will return all records). File ids are only used to allow resynchronization if you store RecordIO records (with headers) inside other RecordIO records (for example, if a record consists of a fragment from another RecordIO file). If you're not planning to do that, the defaults are fine.
Definition at line 33 of file RecordIO.cpp.
References folly::checkUnixError(), folly::File::fd(), file_, filePos_, and writeLock_.
|
inline |
Return the position in the file where the next byte will be written. Conservative, as stuff can be written at any time from another thread.
Definition at line 72 of file RecordIO.h.
References filePos_.
Referenced by folly::test::TEST().
void folly::RecordIOWriter::write | ( | std::unique_ptr< IOBuf > | buf | ) |
Write a record. We will use at most headerSize() bytes of headroom, you might want to arrange that before copying your data into it.
Definition at line 48 of file RecordIO.cpp.
References folly::checkUnixError(), folly::File::fd(), file_, fileId_, filePos_, folly::recordio_helpers::prependHeader(), folly::pwriteFull(), and folly::pwritevFull().
Referenced by folly::test::TEST().
|
private |
Definition at line 77 of file RecordIO.h.
Referenced by RecordIOWriter(), and write().
|
private |
Definition at line 78 of file RecordIO.h.
Referenced by write().
|
private |
Definition at line 80 of file RecordIO.h.
Referenced by filePos(), RecordIOWriter(), and write().
|
private |
Definition at line 79 of file RecordIO.h.
Referenced by RecordIOWriter().