class to handle writing tracks to file, with RAM buffer More...
#include "dwi/tractography/file.h"
Public Types | |
using | vector_type = typename WriterUnbuffered< ValueType >::vector_type |
Public Types inherited from MR::DWI::Tractography::WriterUnbuffered< float > | |
using | vector_type = Eigen::Matrix< float, 3, 1 > |
Public Member Functions | |
Writer (const std::string &file, const Properties &properties, size_t default_buffer_capacity=16777216) | |
create new RAM-buffered track file with specified properties More... | |
Writer (const Writer &W)=delete | |
~Writer () | |
commits any remaining data to file More... | |
bool | operator() (const Streamline< ValueType > &tck) |
append track to file More... | |
Public Member Functions inherited from MR::DWI::Tractography::WriterUnbuffered< float > | |
WriterUnbuffered (const std::string &file, const Properties &properties) | |
create a new track file with the specified properties More... | |
bool | operator() (const Streamline< float > &tck) |
append track to file More... | |
void | set_weights_path (const std::string &path) |
set the path to the track weights More... | |
Public Member Functions inherited from MR::DWI::Tractography::WriterInterface< float > | |
virtual bool | operator() (const Streamline< float > &)=0 |
virtual | ~WriterInterface () |
Protected Member Functions | |
void | add_point (const vector_type &p) |
add point to buffer and increment buffer_size accordingly More... | |
void | commit () |
Protected Member Functions inherited from MR::DWI::Tractography::WriterUnbuffered< float > | |
WriterUnbuffered (const WriterUnbuffered &)=delete | |
copy construction explicitly disabled More... | |
vector_type | delimiter () const |
indicates end of track and start of new track More... | |
vector_type | barrier () const |
indicates end of data More... | |
void | format_point (const vector_type &src, vector_type &dest) |
perform per-point byte-swapping if required More... | |
void | write_weights (const std::string &contents) |
write track weights data to file More... | |
void | commit (vector_type *data, size_t num_points) |
write track point data to file More... | |
Protected Attributes | |
const size_t | buffer_capacity |
std::unique_ptr< vector_type[]> | buffer |
size_t | buffer_size |
std::string | weights_buffer |
Protected Attributes inherited from MR::DWI::Tractography::WriterUnbuffered< float > | |
std::string | weights_name |
int64_t | barrier_addr |
class to handle writing tracks to file, with RAM buffer
writes track header as specified in properties and individual tracks to the file specified in file. Writing individual tracks is done using the append() method.
This class implements a large write-back RAM buffer to hold the track data in RAM, and only commits to file when the buffer capacity is reached. This minimises the number of write() calls, which can otherwise become a bottleneck on distributed or network filesystems. It also helps reduce file fragmentation when multiple processes write to file concurrently. The size of the write-back buffer defaults to 16MB, and can be set in the config file using the TrackWriterBufferSize field (in bytes).
using MR::DWI::Tractography::Writer< ValueType >::vector_type = typename WriterUnbuffered<ValueType>::vector_type |
|
inline |
|
delete |
|
inline |
|
inlineprotected |
|
inlineprotected |
|
inline |
|
protected |
|
protected |
|
protected |
|
protected |