Stxxl  1.3.2
Public Member Functions | Protected Member Functions | List of all members
fileperblock_file< base_file_type > Class Template Reference

Implementation of file based on other files, dynamically allocate one file per block. Allows for dynamic disk space consumption. More...

#include <fileperblock_file.h>

Inheritance diagram for fileperblock_file< base_file_type >:
Inheritance graph
[legend]
Collaboration diagram for fileperblock_file< base_file_type >:
Collaboration graph
[legend]

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 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...
 
virtual void lock ()
 Locks file for reading and writing (acquires a lock in the file system) More...
 
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...
 
- 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_cmpl)
 Schedules an asynchronous read request to the file. More...
 
request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_cmpl)
 Schedules an asynchronous write request to the file. More...
 
virtual int get_queue_id () const
 Returns the identifier of the file's queue. More...
 
virtual int get_allocator_id () const
 Returns the file's allocator. More...
 
- Public Member Functions inherited from file
void add_request_ref ()
 
void delete_request_ref ()
 
int get_request_nref ()
 
virtual int get_physical_device_id () const
 
virtual void remove ()
 

Protected Member Functions

std::string filename_for_block (unsigned_type offset)
 Constructs a file name for a given block. More...
 
- Protected Member Functions inherited from file
 file ()
 Initializes file object. More...
 

Additional Inherited Members

- Public Types inherited from file
enum  open_mode {
  RDONLY = 1, WRONLY = 2, RDWR = 4, CREAT = 8,
  DIRECT = 16, TRUNC = 32, SYNC = 64, NO_LOCK = 128
}
 Definition of acceptable file open modes. More...
 
typedef request::offset_type offset_type
 
typedef request::size_type size_type
 
- Static Public Attributes inherited from file
static const int DEFAULT_QUEUE = -1
 
static const int NO_QUEUE = -2
 
static const int NO_ALLOCATOR = -1
 

Detailed Description

template<class base_file_type>
class fileperblock_file< base_file_type >

Implementation of file based on other files, dynamically allocate one file per block. Allows for dynamic disk space consumption.

Constructor & Destructor Documentation

template<class base_file_type >
__STXXL_BEGIN_NAMESPACE 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

Parameters
filename_prefixfilename prefix, numbering will be appended to it
modeopen mode, see file::open_modes
diskdisk(file) identifier

Member Function Documentation

template<class base_file_type >
void 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.

Reimplemented from file.

template<class base_file_type >
void 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.

Reimplemented from file.

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

Constructs a file name for a given block.

template<class base_file_type >
const char * 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 file.

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

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

Implements file.

References request_interface::wait().

template<class base_file_type>
virtual void 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

Implements file.

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

Returns size of the file.

Returns
file size in length

Implements file.


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