STXXL  1.4.0
 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 28 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)
 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 (const request *req) throw (io_error)
 
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)
 
request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl)
 
virtual int get_allocator_id () const
 Returns the file's allocator. More...
 
virtual int get_queue_id () const
 Returns the identifier of the file's queue. More...
 
- Public Member Functions inherited from stxxl::file
virtual ~file ()
 
void add_request_ref ()
 
virtual request_ptr aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl)=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)=0
 Schedules an asynchronous write request to the file. More...
 
virtual void close_remove ()
 close and remove file More...
 
void delete_request_ref ()
 
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)
 
virtual int get_physical_device_id () const
 
int get_request_nref ()
 
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...
 
- Protected Member Functions inherited from stxxl::file
 file ()
 Initializes file object. 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 int DEFAULT_QUEUE = -1
 
static const int NO_ALLOCATOR = -1
 
static const int NO_QUEUE = -2
 

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 
)

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 44 of file fileperblock_file.cpp.

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

Definition at line 58 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 110 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 125 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 68 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

Reimplemented from stxxl::file.

Definition at line 146 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 90 of file fileperblock_file.cpp.

References 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 ( const request req)
throw (io_error
)
virtual

Implements stxxl::file.

Definition at line 77 of file fileperblock_file.cpp.

References stxxl::request_interface::serve().

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 57 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 61 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 33 of file fileperblock_file.h.

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

Definition at line 31 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 35 of file fileperblock_file.h.

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

Definition at line 34 of file fileperblock_file.h.

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

Definition at line 32 of file fileperblock_file.h.


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