#include <IntVecFile.h>
Collaboration diagram for PLearn::IntVecFile:
Public Member Functions | |
IntVecFile () | |
Default constructor, you must then call open. | |
IntVecFile (const string &the_filename, bool readwrite=false) | |
IntVecFile (const IntVecFile &other) | |
The copy constructor opens the file a second time in readonly mode only. | |
void | open (const string &the_filename, bool readwrite=false) |
void | close () |
int | get (int i) const |
void | put (int i, int value) |
TVec< int > | getVec () const |
int | length () const |
int | operator[] (int i) const |
void | append (int value) |
void | append (const TVec< int > &vec) |
~IntVecFile () | |
Protected Member Functions | |
void | writeFileSignature () |
write magic signature | |
void | getVersionAndSize () |
store in data members | |
void | seek_to_index (int index) const |
seek depending on version | |
Protected Attributes | |
string | filename |
FILE * | f |
int | length_ |
int | version_number_ |
0 if old version, 1 if < current version | |
char | endianness_ |
either 'L' or 'B' | |
Static Protected Attributes | |
const char | signature [] |
magic signature | |
const int | header_size [] |
index array by version number |
There are two versions of the on-disk file format. The "old" version 0, where integers are stored in the file in plain little-endian binary representation, with no header at all. The "length" of the vector is inferred directly from the size of the file.
The version 1 has the following layout. The file starts with the magic header {0xDE, 0xAD, 0xBE, 0xEF}. Following is a single character: 'L' for little-endian, and 'B' for big-endian file. Finally, three bytes {0x00, 0x00, 0x01} (version 1) of the file format. As with version 0, the length of the vector is inferred from the size of the file.
Random access in both read and write are possible. And it is possible to write beyond length(), in which case length() will be updated to reflect the change
Definition at line 77 of file IntVecFile.h.
|
Default constructor, you must then call open.
Definition at line 92 of file IntVecFile.h. References PLearn::byte_order(), endianness_, f, filename, length_, and version_number_. |
|
Definition at line 96 of file IntVecFile.h. |
|
The copy constructor opens the file a second time in readonly mode only.
Definition at line 62 of file IntVecFile.cc. |
|
Definition at line 119 of file IntVecFile.cc. References close(). |
|
Definition at line 138 of file IntVecFile.cc. References PLearn::byte_order(), PLearn::TVec< T >::data(), endianness_, PLearn::endianswap(), f, PLearn::TVec< T >::length(), length(), length_, and seek_to_index(). |
|
Definition at line 112 of file IntVecFile.h. References append(), and length(). Referenced by append(), PLearn::filter(), PLearn::VVMatrix::generateFilterIndexFile(), PLearn::VVMatrix::generateVMatIndex(), PLearn::grep(), and PLearn::FilteredVMatrix::openIndex(). |
|
Definition at line 112 of file IntVecFile.cc. References f. Referenced by PLearn::VVMatrix::generateFilterIndexFile(), open(), PLearn::FilteredVMatrix::openIndex(), and ~IntVecFile(). |
|
Definition at line 94 of file IntVecFile.cc. References BIG_ENDIAN_ORDER, endianness_, f, PLearn::fread_int(), length(), PLERROR, and seek_to_index(). |
|
Definition at line 124 of file IntVecFile.cc. References PLearn::byte_order(), PLearn::TVec< T >::data(), endianness_, PLearn::endianswap(), f, length(), PLERROR, and seek_to_index(). Referenced by PLearn::VVMatrix::generateVMatIndex(). |
|
store in data members < unbelievable (bis) Definition at line 171 of file IntVecFile.cc. References BIG_ENDIAN_ORDER, endianness_, f, filename, PLearn::filesize(), header_size, length_, LITTLE_ENDIAN_ORDER, PLERROR, signature, and version_number_. Referenced by open(). |
|
Definition at line 110 of file IntVecFile.h. References length_. Referenced by append(), PLearn::SelectRowsFileIndexVMatrix::build_(), PLearn::VVMatrix::generateVMatIndex(), get(), PLearn::FilteredVMatrix::getNewRow(), getVec(), and PLearn::FilteredVMatrix::openIndex(). |
|
Definition at line 69 of file IntVecFile.cc. References close(), f, PLearn::file_exists(), filename, getVersionAndSize(), PLearn::isfile(), PLERROR, and writeFileSignature(). Referenced by PLearn::SelectRowsFileIndexVMatrix::build_(), and PLearn::FilteredVMatrix::openIndex(). |
|
Definition at line 111 of file IntVecFile.h. References operator[](). Referenced by operator[](). |
|
Definition at line 104 of file IntVecFile.cc. References BIG_ENDIAN_ORDER, endianness_, f, PLearn::fwrite_int(), length_, and seek_to_index(). Referenced by PLearn::fullyRebalance2Classes(), and PLearn::rebalanceNClasses(). |
|
seek depending on version
Definition at line 213 of file IntVecFile.cc. References f, header_size, and version_number_. |
|
write magic signature < write without Definition at line 155 of file IntVecFile.cc. References PLearn::byte_order(), endianness_, f, length_, signature, and version_number_. Referenced by open(). |
|
either 'L' or 'B'
Definition at line 85 of file IntVecFile.h. Referenced by append(), get(), getVec(), getVersionAndSize(), IntVecFile(), put(), and writeFileSignature(). |
|
Definition at line 81 of file IntVecFile.h. Referenced by append(), close(), get(), getVec(), getVersionAndSize(), IntVecFile(), open(), put(), seek_to_index(), and writeFileSignature(). |
|
Definition at line 80 of file IntVecFile.h. Referenced by getVersionAndSize(), IntVecFile(), and open(). |
|
Initial value: index array by version number
Definition at line 56 of file IntVecFile.cc. Referenced by getVersionAndSize(), and seek_to_index(). |
|
Definition at line 82 of file IntVecFile.h. Referenced by append(), getVersionAndSize(), IntVecFile(), length(), put(), and writeFileSignature(). |
|
Initial value: magic signature
Definition at line 52 of file IntVecFile.cc. Referenced by getVersionAndSize(), and writeFileSignature(). |
|
0 if old version, 1 if < current version
Definition at line 83 of file IntVecFile.h. Referenced by getVersionAndSize(), IntVecFile(), seek_to_index(), and writeFileSignature(). |