Thrill
0.1
|
Implementation of file based on other files, dynamically allocate one file per block. Allows for dynamic disk space consumption.
Definition at line 28 of file fileperblock_file.hpp.
#include <fileperblock_file.hpp>
Public Member Functions | |
fileperblock_file (const std::string &filename_prefix, int mode, int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR, unsigned int device_id=DEFAULT_DEVICE_ID) | |
virtual | ~fileperblock_file () |
virtual void | discard (offset_type offset, offset_type length) |
virtual void | export_files (offset_type offset, offset_type length, std::string filename) |
Rename the file corresponding to the offset such that it is out of reach for deleting. More... | |
const char * | io_type () const final |
virtual void | lock () |
Locks file for reading and writing (acquires a lock in the file system). More... | |
void | serve (void *buffer, offset_type offset, size_type bytes, request::read_or_write op) final |
virtual void | set_size (offset_type new_size) |
virtual offset_type | size () |
Public Member Functions inherited from disk_queued_file | |
disk_queued_file (int queue_id, int allocator_id) | |
request_ptr | aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler()) override |
request_ptr | awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler()) override |
int | get_allocator_id () const override |
Returns the file's parallel disk block allocator number. More... | |
int | get_queue_id () const override |
Public Member Functions inherited from file | |
file (unsigned int device_id=DEFAULT_DEVICE_ID, file_stats *file_stats=nullptr) | |
Construct a new file, usually called by a subclass. More... | |
file (const file &)=delete | |
non-copyable: delete copy-constructor More... | |
file (file &&)=default | |
move-constructor: default More... | |
virtual | ~file () |
void | add_request_ref () |
increment referenced requests More... | |
virtual void | close_remove () |
close and remove file More... | |
void | delete_request_ref () |
decrement referenced requests More... | |
virtual void | discard (offset_type offset, offset_type size) |
virtual void | export_files (offset_type offset, offset_type length, std::string prefix) |
unsigned int | get_device_id () const |
Returns the file's physical device id. More... | |
file_stats * | get_file_stats () const |
size_t | get_request_nref () |
return number of referenced requests More... | |
bool | need_alignment () const |
Returns need_alignment_. More... | |
file & | operator= (const file &)=delete |
non-copyable: delete assignment operator More... | |
file & | operator= (file &&)=default |
move-assignment operator: default More... | |
virtual void | serve (void *buffer, offset_type offset, size_type bytes, request::read_or_write op)=0 |
virtual void | set_size (offset_type newsize)=0 |
Public Member Functions inherited from ReferenceCounter | |
ReferenceCounter () noexcept | |
new objects have zero reference count More... | |
ReferenceCounter (const ReferenceCounter &) noexcept | |
coping still creates a new object with zero reference count More... | |
~ReferenceCounter () | |
bool | dec_reference () const noexcept |
Call whenever resetting (i.e. More... | |
void | inc_reference () const noexcept |
Call whenever setting a pointer to the object. More... | |
ReferenceCounter & | operator= (const ReferenceCounter &) noexcept |
assignment operator, leaves pointers unchanged More... | |
size_t | reference_count () const noexcept |
Return the number of references to this object (for debugging) More... | |
bool | unique () const noexcept |
Test if the ReferenceCounter is referenced by only one CountingPtr. More... | |
Protected Member Functions | |
std::string | filename_for_block (offset_type offset) |
Constructs a file name for a given block. More... | |
Private Attributes | |
offset_type | current_size_ |
std::string | filename_prefix_ |
tlx::counting_ptr< base_file_type > | lock_file_ |
int | mode_ |
Static Private Attributes | |
static constexpr bool | debug = false |
Additional Inherited Members | |
Public Types inherited from file | |
using | offset_type = request::offset_type |
the offset of a request, also the size of the file More... | |
enum | open_mode { RDONLY = 1, WRONLY = 2, RDWR = 4, CREAT = 8, DIRECT = 16, TRUNC = 32, SYNC = 64, NO_LOCK = 128, REQUIRE_DIRECT = 256 } |
using | size_type = request::size_type |
the size of a request More... | |
Static Public Member Functions inherited from file | |
static int | unlink (const char *path) |
unlink path from filesystem More... | |
static int | truncate (const char *path, external_size_type length) |
Static Public Attributes inherited from file | |
static const unsigned int | DEFAULT_DEVICE_ID = std::numeric_limits<unsigned int>::max() |
static const int | DEFAULT_LINUXAIO_QUEUE = -2 |
static const int | DEFAULT_QUEUE = -1 |
static const int | NO_ALLOCATOR = -1 |
Protected Attributes inherited from file | |
unsigned int | device_id_ |
file_stats * | file_stats_ |
bool | need_alignment_ = false |
Flag whether read/write operations REQUIRE alignment. More... | |
tlx::reference_counter | request_ref_ |
count the number of requests referencing this file More... | |
fileperblock_file | ( | const std::string & | filename_prefix, |
int | mode, | ||
int | queue_id = DEFAULT_QUEUE , |
||
int | allocator_id = NO_ALLOCATOR , |
||
unsigned int | device_id = DEFAULT_DEVICE_ID |
||
) |
Constructs file object. param filename_prefix_ filename prefix, numbering will be appended to it param mode_ open mode_, see file::open_modes
Definition at line 41 of file fileperblock_file.cpp.
|
virtual |
Definition at line 55 of file fileperblock_file.cpp.
References fileperblock_file< base_file_type >::lock_file_.
|
virtual |
Frees the specified region. Actually deletes the corresponding file if the whole thing is deleted.
Definition at line 105 of file fileperblock_file.cpp.
References fileperblock_file< base_file_type >::filename_for_block(), TLX_LOG, TLX_LOG1, file::truncate(), and tlx::unused().
Referenced by fileperblock_file< base_file_type >::size().
|
virtual |
Rename the file corresponding to the offset such that it is out of reach for deleting.
Definition at line 122 of file fileperblock_file.cpp.
References foxxll::as_signed(), fileperblock_file< base_file_type >::filename_for_block(), FOXXLL_THROW_ERRNO, TLX_LOG1, file::truncate(), and tlx::unused().
Referenced by fileperblock_file< base_file_type >::size().
|
protected |
Constructs a file name for a given block.
Definition at line 62 of file fileperblock_file.cpp.
References fileperblock_file< base_file_type >::filename_prefix_.
Referenced by fileperblock_file< base_file_type >::discard(), fileperblock_file< base_file_type >::export_files(), and fileperblock_file< base_file_type >::serve().
|
finalvirtual |
Identifies the type of I/O implementation.
Implements file.
Definition at line 145 of file fileperblock_file.cpp.
Referenced by fileperblock_file< base_file_type >::size().
|
virtual |
Locks file for reading and writing (acquires a lock in the file system).
Implements file.
Definition at line 82 of file fileperblock_file.cpp.
References foxxll::BlockAlignment, fileperblock_file< base_file_type >::filename_prefix_, disk_queued_file::get_queue_id(), fileperblock_file< base_file_type >::lock_file_, and fileperblock_file< base_file_type >::mode_.
Referenced by fileperblock_file< base_file_type >::size().
|
final |
Definition at line 71 of file fileperblock_file.cpp.
References file::DEFAULT_DEVICE_ID, file::file_stats_, fileperblock_file< base_file_type >::filename_for_block(), disk_queued_file::get_queue_id(), fileperblock_file< base_file_type >::mode_, and file::NO_ALLOCATOR.
|
inlinevirtual |
Changes the size of the file.
new_size | value of the new file size |
Definition at line 60 of file fileperblock_file.hpp.
|
inlinevirtual |
Returns size of the file.
Implements file.
Definition at line 64 of file fileperblock_file.hpp.
References fileperblock_file< base_file_type >::current_size_, fileperblock_file< base_file_type >::discard(), fileperblock_file< base_file_type >::export_files(), fileperblock_file< base_file_type >::io_type(), and fileperblock_file< base_file_type >::lock().
|
private |
Definition at line 35 of file fileperblock_file.hpp.
Referenced by fileperblock_file< base_file_type >::size().
|
staticprivate |
Definition at line 30 of file fileperblock_file.hpp.
|
private |
Definition at line 33 of file fileperblock_file.hpp.
Referenced by fileperblock_file< base_file_type >::filename_for_block(), and fileperblock_file< base_file_type >::lock().
|
private |
Definition at line 36 of file fileperblock_file.hpp.
Referenced by fileperblock_file< base_file_type >::lock(), and fileperblock_file< base_file_type >::~fileperblock_file().
|
private |
Definition at line 34 of file fileperblock_file.hpp.
Referenced by fileperblock_file< base_file_type >::lock(), and fileperblock_file< base_file_type >::serve().