|
MASA-Core
|
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>
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. | |
| SpecialRowFile::SpecialRowFile | ( | string * | path, |
| string | filename | ||
| ) |
Creates a new Special Row associated with a given file.
| path | the path to save this file. |
| filename | the 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.
| path | the path to save this file. |
| id | the 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.
| SpecialRowFile::~SpecialRowFile | ( | ) | [virtual] |
Destroys any allocated resource previously allocated by this object.
Definition at line 68 of file SpecialRowFile.cpp.
| void SpecialRowFile::close | ( | ) | [virtual] |
| string SpecialRowFile::getFullFilename | ( | bool | temp | ) | [private] |
Returns the complete filename (with path) of the special row.
| temp | indicates 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.
| readOnly | true if it must be opened for read mode, false otherwise. |
| length | the 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.
| buf | vector containing the cells to be read. The data read will be stored in the first byte of this vector. |
| offset | the position that the data must be read. |
| len | length of the vector. |
Implements SpecialRow.
Definition at line 132 of file SpecialRowFile.cpp.
| void SpecialRowFile::truncateRow | ( | int | size | ) | [virtual] |
Truncates the file.
| size | the 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.
| buf | vector containing the cells to be saved. |
| offset | the position that the vector must be stored. |
| len | length of the vector. |
Implements SpecialRow.
Definition at line 125 of file SpecialRowFile.cpp.
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.
1.7.6.1