STXXL  1.4-dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
stxxl::fileperblock_file< base_file_type > Class Template Reference

Detailed Description

template<class base_file_type>
class stxxl::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 27 of file fileperblock_file.h.

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

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)
 Constructs file object. param filename_prefix filename prefix, numbering will be appended to it param mode open mode, see file::open_modes. More...
 
virtual ~fileperblock_file ()
 
virtual void discard (offset_type offset, offset_type length)
 Frees the specified region. Actually deletes the corresponding file if the whole thing is deleted. More...
 
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
 Identifies the type of I/O implementation. More...
 
virtual void lock ()
 Locks file for reading and writing (acquires a lock in the file system). More...
 
virtual void serve (void *buffer, offset_type offset, size_type bytes, request::request_type type)
 
virtual void set_size (offset_type new_size)
 Changes the size of the file. More...
 
virtual offset_type size ()
 Returns size of the file. More...
 
- Public Member Functions inherited from stxxl::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_cmpl=completion_handler())
 
request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl=completion_handler())
 
virtual int get_allocator_id () const
 Returns the file's disk allocator number. More...
 
virtual int get_queue_id () const
 Returns the identifier of the file's queue number. More...
 
- Public Member Functions inherited from stxxl::file
 file (unsigned int device_id=DEFAULT_DEVICE_ID)
 Construct a new file, usually called by a subclass. More...
 
virtual ~file ()
 
void add_request_ref ()
 increment referenced requests More...
 
virtual request_ptr aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl=completion_handler())=0
 Schedules an asynchronous read request to the file. More...
 
virtual request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl=completion_handler())=0
 Schedules an asynchronous write request to the file. 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)
 Discard a region of the file (mark it unused). Some specialized file types may need to know freed regions. More...
 
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...
 
unsigned_type get_request_nref ()
 return number of referenced requests More...
 
virtual void serve (void *buffer, offset_type offset, size_type bytes, request::request_type type)=0
 
virtual void set_size (offset_type newsize)=0
 Changes the size of the file. 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
 
base_file_type lock_file
 
bool lock_file_created
 
int mode
 

Additional Inherited Members

- Public Types inherited from stxxl::file
typedef request::offset_type 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
}
 Definition of acceptable file open modes. More...
 
typedef request::size_type size_type
 the size of a request More...
 
- Static Public Member Functions inherited from stxxl::file
static int unlink (const char *path)
 unlink path from filesystem More...
 
static int truncate (const char *path, external_size_type length)
 truncate a path to given length. Use this only if you dont have a fileio-specific object, which provides truncate(). More...
 
- Static Public Attributes inherited from stxxl::file
static const unsigned int DEFAULT_DEVICE_ID = (unsigned int)(-1)
 
static const int DEFAULT_LINUXAIO_QUEUE = -2
 
static const int DEFAULT_QUEUE = -1
 
static const int NO_ALLOCATOR = -1
 
- Protected Attributes inherited from stxxl::file
unsigned int m_device_id
 The file's physical device id (e.g. used for prefetching sequence calculation) More...
 
atomic_counted_object m_request_ref
 count the number of requests referencing this file More...
 

Constructor & Destructor Documentation

template<class base_file_type >
stxxl::fileperblock_file< base_file_type >::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 45 of file fileperblock_file.cpp.

template<class base_file_type >
stxxl::fileperblock_file< base_file_type >::~fileperblock_file ( )
virtual

Definition at line 61 of file fileperblock_file.cpp.

References STXXL_ERRMSG.

Member Function Documentation

template<class base_file_type >
void stxxl::fileperblock_file< base_file_type >::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 109 of file fileperblock_file.cpp.

References STXXL_ERRMSG, stxxl::STXXL_UNUSED(), and STXXL_VERBOSE2.

template<class base_file_type >
void stxxl::fileperblock_file< base_file_type >::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 124 of file fileperblock_file.cpp.

References STXXL_ERRMSG, STXXL_THROW_ERRNO, and stxxl::STXXL_UNUSED().

template<class base_file_type >
std::string stxxl::fileperblock_file< base_file_type >::filename_for_block ( offset_type  offset)
protected

Constructs a file name for a given block.

Definition at line 71 of file fileperblock_file.cpp.

template<class base_file_type >
const char * stxxl::fileperblock_file< base_file_type >::io_type ( ) const
virtual

Identifies the type of I/O implementation.

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

Implements stxxl::file.

Definition at line 145 of file fileperblock_file.cpp.

template<class base_file_type >
void stxxl::fileperblock_file< base_file_type >::lock ( )
virtual

Locks file for reading and writing (acquires a lock in the file system).

Implements stxxl::file.

Definition at line 89 of file fileperblock_file.cpp.

References STXXL_BLOCK_ALIGN, and stxxl::request_interface::wait().

Referenced by stxxl::create_file().

template<class base_file_type >
void stxxl::fileperblock_file< base_file_type >::serve ( void *  buffer,
offset_type  offset,
size_type  bytes,
request::request_type  type 
)
virtual

Definition at line 80 of file fileperblock_file.cpp.

template<class base_file_type>
virtual void stxxl::fileperblock_file< base_file_type >::set_size ( offset_type  new_size)
inlinevirtual

Changes the size of the file.

Parameters
new_sizevalue of the new file size

Definition at line 58 of file fileperblock_file.h.

template<class base_file_type>
virtual offset_type stxxl::fileperblock_file< base_file_type >::size ( )
inlinevirtual

Returns size of the file.

Returns
file size in length

Implements stxxl::file.

Definition at line 62 of file fileperblock_file.h.

Member Data Documentation

template<class base_file_type>
offset_type stxxl::fileperblock_file< base_file_type >::current_size
private

Definition at line 32 of file fileperblock_file.h.

template<class base_file_type>
std::string stxxl::fileperblock_file< base_file_type >::filename_prefix
private

Definition at line 30 of file fileperblock_file.h.

template<class base_file_type>
base_file_type stxxl::fileperblock_file< base_file_type >::lock_file
private

Definition at line 34 of file fileperblock_file.h.

template<class base_file_type>
bool stxxl::fileperblock_file< base_file_type >::lock_file_created
private

Definition at line 33 of file fileperblock_file.h.

template<class base_file_type>
int stxxl::fileperblock_file< base_file_type >::mode
private

Definition at line 31 of file fileperblock_file.h.


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