|
MASA-Core
|
Abstract class that represents an Special Row.
A Special Row is a row (or column) stored to be used in the further stages. This class permit that subclasses store the special row in any possible area (e.g.: disk, memory, database, etc.).
Definition at line 41 of file SpecialRow.hpp.
#include <SpecialRow.hpp>
Public Member Functions | |
| SpecialRow () | |
| Default Constructor. | |
| virtual | ~SpecialRow () |
| Default Destructor. | |
| void | open (bool readOnly, int length=0) |
| Opens the special rows for read-only or write-only. | |
| virtual int | write (const cell_t *buf, int len) |
| Writes data in the row serially. | |
| virtual int | read (cell_t *buf, int len) |
| Reads data from the row serially. | |
| virtual int | getType () |
| void | seek (int offset) |
| Defines the next position to be read. | |
| int | getOffset () |
| Returns the current reading position. | |
| int | getId () |
| Returns the ID of the row. | |
| virtual void | close ()=0 |
| Closes the special row for writing. | |
| virtual void | truncateRow (int size)=0 |
| Truncate the size of the row. | |
Static Public Member Functions | |
| static int | sortById (SpecialRow *a, SpecialRow *b) |
| Function that sorts the special rows by ID. | |
Protected Member Functions | |
| void | setId (int id) |
| Defines the ID of the row, i.e., the number of the row it represents. | |
Private Member Functions | |
| virtual void | initialize (bool readOnly, int length=0)=0 |
| Initializes the row with specific data. | |
| virtual int | write (const cell_t *buf, int offset, int len)=0 |
| Stores the vector in a given offset. | |
| virtual int | read (cell_t *buf, int offset, int len)=0 |
| Stores the vector in a given offset. | |
Private Attributes | |
| int | id |
| The number of the row that this object represents. | |
| int | offset |
| Current reading position. | |
| bool | readOnly |
| Indicates if the row is in reading or writing mode. | |
Default Constructor.
Definition at line 29 of file SpecialRow.cpp.
| SpecialRow::~SpecialRow | ( | ) | [virtual] |
Default Destructor.
Definition at line 36 of file SpecialRow.cpp.
| virtual void SpecialRow::close | ( | ) | [pure virtual] |
Closes the special row for writing.
Implements CellsWriter.
Implemented in SpecialRowFile, FirstRow, and SpecialRowRAM.
| int SpecialRow::getId | ( | ) |
Returns the ID of the row.
Definition at line 62 of file SpecialRow.cpp.
| int SpecialRow::getOffset | ( | ) | [virtual] |
Returns the current reading position.
Implements SeekableCellsReader.
Definition at line 92 of file SpecialRow.cpp.
| int SpecialRow::getType | ( | ) | [virtual] |
Implements CellsReader.
Definition at line 48 of file SpecialRow.cpp.
| virtual void SpecialRow::initialize | ( | bool | readOnly, |
| int | length = 0 |
||
| ) | [private, pure virtual] |
Initializes the row with specific data.
| readOnly | if true, indicates that the row will be used only for read access. Otherwise, the row will only be used for write access. Each subclass must implement this method with specific code. |
| length | the maximum length of this row. The subclass may consider this as the initial size, for faster allocation. |
Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.
| void SpecialRow::open | ( | bool | readOnly, |
| int | length = 0 |
||
| ) |
Opens the special rows for read-only or write-only.
| readOnly | if true, indicates that the row will be used only for read access. Otherwise, the row will only be used for write access. |
| length | the maximum length of this row. |
Definition at line 43 of file SpecialRow.cpp.
| int SpecialRow::read | ( | cell_t * | buf, |
| int | len | ||
| ) | [virtual] |
Reads data from the row serially.
The read access is done in the reverse direction, from the end to the beginning. Before reading, the SpecialRow::setOffset must defines the start position to be read.
| buf | vector that will receive the cells read from the row. |
| len | length of the vector. |
Implements CellsReader.
Definition at line 119 of file SpecialRow.cpp.
| virtual int SpecialRow::read | ( | cell_t * | buf, |
| int | offset, | ||
| int | len | ||
| ) | [private, pure 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. |
Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.
| void SpecialRow::seek | ( | int | offset | ) | [virtual] |
Defines the next position to be read.
| offset | The reading position. |
Implements SeekableCellsReader.
Definition at line 81 of file SpecialRow.cpp.
| void SpecialRow::setId | ( | int | id | ) | [protected] |
Defines the ID of the row, i.e., the number of the row it represents.
| id | the number of the row (i-coordinate). |
Definition at line 55 of file SpecialRow.cpp.
| int SpecialRow::sortById | ( | SpecialRow * | a, |
| SpecialRow * | b | ||
| ) | [static] |
Function that sorts the special rows by ID.
Definition at line 69 of file SpecialRow.cpp.
| virtual void SpecialRow::truncateRow | ( | int | size | ) | [pure virtual] |
Truncate the size of the row.
If the size is zero, the row must be completely deleted. Each subclass must implement this method with specific code.
| size | the number of cells to keep after truncation. |
Implemented in SpecialRowFile, FirstRow, and SpecialRowRAM.
| int SpecialRow::write | ( | const cell_t * | buf, |
| int | len | ||
| ) | [virtual] |
Writes data in the row serially.
| buf | vector containing the cells to be appended to the row. |
| len | length of the vector. |
Implements CellsWriter.
Definition at line 99 of file SpecialRow.cpp.
| virtual int SpecialRow::write | ( | const cell_t * | buf, |
| int | offset, | ||
| int | len | ||
| ) | [private, pure 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. |
Implemented in FirstRow, SpecialRowFile, and SpecialRowRAM.
int SpecialRow::id [private] |
The number of the row that this object represents.
Definition at line 134 of file SpecialRow.hpp.
int SpecialRow::offset [private] |
Current reading position.
Definition at line 137 of file SpecialRow.hpp.
bool SpecialRow::readOnly [private] |
Indicates if the row is in reading or writing mode.
Definition at line 140 of file SpecialRow.hpp.
1.7.6.1