MASA-Core
Public Member Functions | Private Member Functions | Private Attributes
SpecialRowFile Class Reference

Detailed Description

Class that reads and stores an Special Row in the disk.

This class is the implementation of a SpecialRow that stores the cells in a file saved in the disk.

While the special row is in write mode, a temporary file (*.tmp) store the cells. As soon as the row turn to read mode, the temporary file is closed and renamed to the definitive name.

Definition at line 36 of file SpecialRowFile.hpp.

#include <SpecialRowFile.hpp>

Inheritance diagram for SpecialRowFile:
SpecialRow SeekableCellsReader CellsWriter CellsReader

List of all members.

Public Member Functions

 SpecialRowFile (string *path, string filename)
 Creates a new Special Row associated with a given file.
 SpecialRowFile (string *path, int id)
 Creates a new Special Row associated with a given rowId.
virtual ~SpecialRowFile ()
 Destroys any allocated resource previously allocated by this object.
virtual void close ()
 Closes the file.
virtual void truncateRow (int size)
 Truncates the file.

Private Member Functions

virtual void initialize (bool readOnly, int length)
 Opens the file for read or write mode.
virtual int write (const cell_t *buf, int offset, int len)
 Stores the vector in a given offset.
virtual int read (cell_t *buf, int offset, int len)
 Stores the vector in a given offset.
string getFullFilename (bool temp)
 Returns the complete filename (with path) of the special row.

Private Attributes

string * path
 Dynamic path name of the partition.
string filename
 File name basic prefix.
FILE * file
 Opened file descriptor.

Constructor & Destructor Documentation

SpecialRowFile::SpecialRowFile ( string *  path,
string  filename 
)

Creates a new Special Row associated with a given file.

Parameters:
paththe path to save this file.
filenamethe name of this file. The rowId is extracted from this name. If the filename is not a valid row name, rowId is set to -1.

Definition at line 34 of file SpecialRowFile.cpp.

SpecialRowFile::SpecialRowFile ( string *  path,
int  id 
)

Creates a new Special Row associated with a given rowId.

Parameters:
paththe path to save this file.
idthe rowId of this file. The filename is associated to this id. The rowId must be relative to the partition, so the rowId 0 is the first row of the partition.

Definition at line 53 of file SpecialRowFile.cpp.

Destroys any allocated resource previously allocated by this object.

Definition at line 68 of file SpecialRowFile.cpp.


Member Function Documentation

void SpecialRowFile::close ( ) [virtual]

Closes the file.

Implements SpecialRow.

Definition at line 93 of file SpecialRowFile.cpp.

string SpecialRowFile::getFullFilename ( bool  temp) [private]

Returns the complete filename (with path) of the special row.

Parameters:
tempindicates if the filename is temporary or definitive.

Definition at line 146 of file SpecialRowFile.cpp.

void SpecialRowFile::initialize ( bool  readOnly,
int  length 
) [private, virtual]

Opens the file for read or write mode.

Parameters:
readOnlytrue if it must be opened for read mode, false otherwise.
lengththe initial size of the file.

Implements SpecialRow.

Definition at line 76 of file SpecialRowFile.cpp.

int SpecialRowFile::read ( cell_t buf,
int  offset,
int  len 
) [private, virtual]

Stores the vector in a given offset.

It is guaranteed that the offset is serially decremented. Each subclass must implement this method with specific code.

Parameters:
bufvector containing the cells to be read. The data read will be stored in the first byte of this vector.
offsetthe position that the data must be read.
lenlength of the vector.
Returns:
The number of cells read.

Implements SpecialRow.

Definition at line 132 of file SpecialRowFile.cpp.

void SpecialRowFile::truncateRow ( int  size) [virtual]

Truncates the file.

Parameters:
sizethe number of cells to keep in the file.

Implements SpecialRow.

Definition at line 107 of file SpecialRowFile.cpp.

int SpecialRowFile::write ( const cell_t buf,
int  offset,
int  len 
) [private, virtual]

Stores the vector in a given offset.

It is guaranteed that the offset is serially incremented. Each subclass must implement this method with specific code.

Parameters:
bufvector containing the cells to be saved.
offsetthe position that the vector must be stored.
lenlength of the vector.
Returns:
The number of cells stored.

Implements SpecialRow.

Definition at line 125 of file SpecialRowFile.cpp.


Member Data Documentation

FILE* SpecialRowFile::file [private]

Opened file descriptor.

Definition at line 82 of file SpecialRowFile.hpp.

string SpecialRowFile::filename [private]

File name basic prefix.

Definition at line 79 of file SpecialRowFile.hpp.

string* SpecialRowFile::path [private]

Dynamic path name of the partition.

Definition at line 76 of file SpecialRowFile.hpp.


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