Thrill  0.1

Detailed Description

template<class base_file_type>
class foxxll::fileperblock_file< base_file_type >

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.

+ Inheritance diagram for fileperblock_file< base_file_type >:
+ Collaboration diagram for fileperblock_file< base_file_type >:

#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_statsget_file_stats () const
 
size_t get_request_nref ()
 return number of referenced requests More...
 
bool need_alignment () const
 Returns need_alignment_. More...
 
fileoperator= (const file &)=delete
 non-copyable: delete assignment operator More...
 
fileoperator= (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...
 
ReferenceCounteroperator= (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_statsfile_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...
 

Constructor & Destructor Documentation

◆ fileperblock_file()

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.

◆ ~fileperblock_file()

~fileperblock_file ( )
virtual

Member Function Documentation

◆ discard()

void discard ( offset_type  offset,
offset_type  length 
)
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().

◆ export_files()

void export_files ( offset_type  offset,
offset_type  length,
std::string  filename 
)
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().

◆ filename_for_block()

std::string filename_for_block ( offset_type  offset)
protected

◆ io_type()

const char * io_type ( ) const
finalvirtual

Identifies the type of I/O implementation.

Returns
pointer to null terminated string of characters, containing the name of I/O implementation

Implements file.

Definition at line 145 of file fileperblock_file.cpp.

Referenced by fileperblock_file< base_file_type >::size().

◆ lock()

void lock ( )
virtual

◆ serve()

◆ set_size()

virtual void set_size ( offset_type  new_size)
inlinevirtual

Changes the size of the file.

Parameters
new_sizevalue of the new file size

Definition at line 60 of file fileperblock_file.hpp.

◆ size()

Member Data Documentation

◆ current_size_

offset_type current_size_
private

Definition at line 35 of file fileperblock_file.hpp.

Referenced by fileperblock_file< base_file_type >::size().

◆ debug

constexpr bool debug = false
staticprivate

Definition at line 30 of file fileperblock_file.hpp.

◆ filename_prefix_

std::string filename_prefix_
private

◆ lock_file_

◆ mode_


The documentation for this class was generated from the following files: