CernVM-FS
2.12.0
|
#include <file_backed_buffer.h>
Public Member Functions | |
~FileBackedBuffer () | |
void | Append (const void *source, uint64_t len) |
void | Commit () |
int64_t | Data (void **ptr, int64_t len, uint64_t pos) |
int64_t | Read (void *ptr, int64_t len) |
int64_t | ReadP (void *ptr, int64_t len, uint64_t pos) |
void | Rewind () |
uint64_t | GetSize () const |
Static Public Member Functions | |
static FileBackedBuffer * | Create (uint64_t in_memory_threshold, const std::string &tmp_dir="/tmp/") |
Private Types | |
enum | { kWriteState = 0, kReadState } |
enum | { kMemoryMode = 0, kFileMode } |
Private Member Functions | |
FRIEND_TEST (T_FileBackedBuffer, SimpleWriteAndRead) | |
FRIEND_TEST (T_FileBackedBuffer, EmptyBuffer) | |
FRIEND_TEST (T_FileBackedBuffer, EmptyWrite) | |
FRIEND_TEST (T_FileBackedBuffer, StraightToFile) | |
FRIEND_TEST (T_FileBackedBuffer, OnlyInMemory) | |
FileBackedBuffer (uint64_t in_memory_threshold, const std::string &tmp_dir) | |
void | SaveToFile () |
Private Member Functions inherited from SingleCopy | |
SingleCopy () | |
Private Attributes | |
const uint64_t | in_memory_threshold_ |
const std::string | tmp_dir_ |
enum FileBackedBuffer:: { ... } | state_ |
enum FileBackedBuffer:: { ... } | mode_ |
uint64_t | size_ |
unsigned char * | buf_ |
uint64_t | pos_ |
FILE * | fp_ |
std::string | file_path_ |
MemoryMappedFile * | mmapped_ |
This file is part of the CernVM File System. FileBackedBuffer is a class for smart data writing and reading. It represents a buffer that is in a first step filled with data and, once all data has been written, it can be read back out.
It works in 2 modes: memory mode and file mode. It first starts working in memory mode, but as soon as the buffer size reaches a configurable threshold, it writes all data into a temporary file, freeing up the occupied memory. From that point, all further data are written directly into the file.
Reading is done straight from memory or using mmap, depending on the current mode of operation.
Method call timeline:
Definition at line 37 of file file_backed_buffer.h.
|
private |
Enumerator | |
---|---|
kWriteState | |
kReadState |
Definition at line 65 of file file_backed_buffer.h.
|
private |
Enumerator | |
---|---|
kMemoryMode | |
kFileMode |
Definition at line 70 of file file_backed_buffer.h.
FileBackedBuffer::~FileBackedBuffer | ( | ) |
|
private |
Definition at line 22 of file file_backed_buffer.cc.
Referenced by Create().
void FileBackedBuffer::Append | ( | const void * | source, |
uint64_t | len | ||
) |
Definition at line 57 of file file_backed_buffer.cc.
Referenced by upload::S3Uploader::DoUpload().
void FileBackedBuffer::Commit | ( | ) |
Definition at line 98 of file file_backed_buffer.cc.
Referenced by upload::S3Uploader::DoUpload().
|
static |
This file is part of the CernVM File System.
Definition at line 16 of file file_backed_buffer.cc.
Referenced by upload::S3Uploader::CreateJobInfo(), upload::S3Uploader::DoUpload(), and upload::S3StreamHandle::S3StreamHandle().
int64_t FileBackedBuffer::Data | ( | void ** | ptr, |
int64_t | len, | ||
uint64_t | pos | ||
) |
Definition at line 121 of file file_backed_buffer.cc.
Referenced by ReadP().
|
private |
|
private |
|
private |
|
private |
|
private |
uint64_t FileBackedBuffer::GetSize | ( | ) | const |
Definition at line 154 of file file_backed_buffer.cc.
int64_t FileBackedBuffer::Read | ( | void * | ptr, |
int64_t | len | ||
) |
int64_t FileBackedBuffer::ReadP | ( | void * | ptr, |
int64_t | len, | ||
uint64_t | pos | ||
) |
Definition at line 142 of file file_backed_buffer.cc.
Referenced by Read().
void FileBackedBuffer::Rewind | ( | ) |
|
private |
Definition at line 161 of file file_backed_buffer.cc.
Referenced by Append().
|
private |
Definition at line 77 of file file_backed_buffer.h.
Referenced by Append(), Commit(), Data(), SaveToFile(), and ~FileBackedBuffer().
|
private |
Definition at line 83 of file file_backed_buffer.h.
Referenced by Append(), Commit(), SaveToFile(), and ~FileBackedBuffer().
|
private |
Definition at line 81 of file file_backed_buffer.h.
Referenced by Append(), Commit(), SaveToFile(), and ~FileBackedBuffer().
|
private |
Definition at line 62 of file file_backed_buffer.h.
Referenced by Append().
|
private |
Definition at line 85 of file file_backed_buffer.h.
Referenced by Commit(), Data(), and ~FileBackedBuffer().
enum { ... } FileBackedBuffer::mode_ |
Referenced by Append(), Commit(), Data(), GetSize(), SaveToFile(), and ~FileBackedBuffer().
|
private |
Definition at line 79 of file file_backed_buffer.h.
Referenced by Append(), Commit(), GetSize(), Read(), Rewind(), and SaveToFile().
|
private |
Definition at line 75 of file file_backed_buffer.h.
Referenced by Append(), Commit(), Data(), GetSize(), and SaveToFile().
enum { ... } FileBackedBuffer::state_ |
Referenced by Append(), Commit(), Data(), GetSize(), Rewind(), SaveToFile(), and ~FileBackedBuffer().
|
private |
Definition at line 63 of file file_backed_buffer.h.
Referenced by SaveToFile().