#include <fio_RelFile.h>


Definition at line 169 of file fio_RelFile.h.
Public Member Functions | |
| fio_RelFile (bool a_readOnly, const int a_fileID, cmn_Path a_path, string a_fileName, const int a_recordSize, const Int16_t a_recordStructVersion, const UInt16_t a_numOfDifVector=ivd_MAX_NUM_OF_DIF_VECTOR_IN_REL_FILES_d, const UInt16_t a_smallestVectorSize=1, const bool a_accessToIdx0=false) | |
| virtual | ~fio_RelFile () |
| fio_RelFileHeader_t | GetRelFileHeader () |
| virtual void | SyncRelFileObj () |
| Sync relative file object with data on disk after transaction reply. | |
| ivd_RecordIDX_t | FirstNewIDX () |
| void | SetFirstNewIDX () |
| calculate with FirstNewIDX methos and set m_firstNewIDX member | |
| ivd_RecordIDX_t | GetFirstNewIDX () |
| ivd_FilePosition_t | Idx2Pos (ivd_RecordIDX_t a_idx) |
| pass index and return position in file | |
| int | WriteRec (const fio_RecordIDX_t a_index, const void *a_buffer, const unsigned int a_numOfRec=1, fio_Transaction *a_transaction=NULL) |
| Write one or more records (vector) from a_buffer to a_index place in file. | |
| int | ReadRec (const fio_RecordIDX_t, void *, const unsigned int=1) |
| Read one or more records (vector) from a_buffer to a_index place in file. | |
| void | ReleaseVector (const fio_RecordIDX_t a_index, unsigned int a_numOfRec, fio_Transaction *a_transaction=NULL) |
| Release one or more records (vector) from a_index place in file. | |
| ivd_RecordIDX_t | GetNewVectorIDX (unsigned int) |
| Reserve one or more records (vector) in file and return index to it. | |
| unsigned int | GetFirstRecordOffset () |
| unsigned int | GetRecordSize () |
| unsigned int | GetNumOfRecord () |
| void | Flush () |
| virtual void | DumpHdr (ostream &os) |
| dump header to stream | |
Public Attributes | |
| log_CLASSID_m | |
| Macro for class name member. | |
Protected Member Functions | |
| ivd_RecordIDX_t | GetFirstNewIDX (unsigned int) |
| ivd_RecordIDX_t | GetUnusedVectorIDX (const unsigned int, fio_Transaction *a_transacton_p=NULL) |
| int | UpdateListOfUnusedVector (const unsigned int, fio_Transaction *a_transaction_p=NULL) |
| virtual int | PosWrite (ivd_FilePosition_t a_position, const void *a_buffer_p, ivd_FileBufSize_t a_size, fio_Transaction *a_transaction) const |
| PosWrite with transaction method is virtual. | |
| void | CreateFile () |
| when file has not yet created then this method is called | |
| void | WriteHeader () |
| void | WriteListOfUnusedVector () |
| void | ReadListOfUnusedVector () |
| ivd_RecordIDX_t | ReadNextUnusedVectorIDX (fio_RecordIDX_t a_index, UInt16_t a_vecSize) |
| read record at index and return the index to next record; | |
Protected Attributes | |
| const unsigned int | m_recordSize |
| const unsigned int | m_loUVHeaderLen |
| const unsigned int | m_numOfDifVector |
| const UInt16_t | m_smallestVectorSize |
| const ivd_FileBufSize_t | m_sizeOfListOfUnusedVector |
| const unsigned int | m_firstRecordOffset |
| const Int16_t | m_recordStructVersion |
| const bool | m_accessToIdx0 |
| struct fio_RelFileHeader_t | m_fileHeader |
| struct fio_RelFileHeader_t | m_currFileHeader |
| fio_LoUV_v_t | m_listOfUV_v |
| vector of list of unused vectors | |
| ivd_RecordIDX_t | m_firstNewIDX |
| cmn_Mutex | m_RelativeFile_x |
| Exclusive access to Relative file. | |
| cmn_Mutex | m_listOfLoUV_x |
| Exclusive access to list of list of unused vectors. | |
| cmn_Mutex | m_firstNewIDX_x |
| Exclusive access m_firstNewIDX. | |
Friends | |
| class | fio_uvListMgr |
| class | fsc_RawUpdate |
| fio_RelFile::fio_RelFile | ( | bool | a_readOnly, | |
| const int | a_fileID, | |||
| cmn_Path | a_path, | |||
| string | a_fileName, | |||
| const int | a_recordSize, | |||
| const Int16_t | a_recordStructVersion, | |||
| const UInt16_t | a_numOfDifVector = ivd_MAX_NUM_OF_DIF_VECTOR_IN_REL_FILES_d, |
|||
| const UInt16_t | a_smallestVectorSize = 1, |
|||
| const bool | a_accessToIdx0 = false | |||
| ) |
Definition at line 136 of file fio_RelFile.cpp.
References assert, fio_RelFileHeader_t::byteOrder, CreateFile(), dbg_DETAIL, fio_RelFileHeader_t::fileID, fio_FH_IDENTIFICATION_LEN_d, g_notCheckRFHeader, fio_File::GetFileName(), fio_RelFileHeader_t::headerStructVersion, fio_RelFileHeader_t::identification, ie_RECORD_TOO_SMALL, ie_REL_FILE_HEADER_INV, ivd_Error, log_DBG_m, log_ERR_m, log_FUNC_m, fio_RelFileHeader_t::loUVHeaderLen, m_currFileHeader, m_fileHeader, m_firstRecordOffset, m_listOfUV_v, m_numOfDifVector, m_recordSize, fio_RelFileHeader_t::numOfDifVector, fio_RelFileHeader_t::recordSize, fio_RelFileHeader_t::recordStructVersion, fio_RelFileHeader_t::relFileHeaderLen, cmn_File::SeekEndF(), fio_RelFileHeader_t::smallestVectorSize, and str.
00146 : 00147 fio_File(a_readOnly, a_fileID, a_path, a_fileName), 00148 m_recordSize(a_recordSize), 00149 m_loUVHeaderLen(sizeof(fio_uvListHeader_t)), 00150 m_numOfDifVector(a_numOfDifVector), 00151 m_smallestVectorSize(a_smallestVectorSize), 00152 m_sizeOfListOfUnusedVector(m_numOfDifVector * m_loUVHeaderLen), 00153 m_firstRecordOffset(m_sizeOfListOfUnusedVector + c_fio_maxRelFileHeadLen), 00154 m_recordStructVersion(a_recordStructVersion), 00155 m_accessToIdx0(a_accessToIdx0), 00156 m_fileHeader( // create file header 00157 GetFileName(), 00158 GetFileID(), 00159 m_recordStructVersion, 00160 m_recordSize, 00161 m_loUVHeaderLen, 00162 m_numOfDifVector, 00163 m_smallestVectorSize) 00164 { 00165 log_FUNC_m(fio_RelFile); 00166 00167 assert(sizeof(fio_UnusedRec_t) > m_recordSize); 00168 if (m_recordSize < sizeof(ivd_RecordIDX_t)) { 00169 throw ivd_Error(ie_RECORD_TOO_SMALL, "There is no space for index to bind unused vector (record).", true); 00170 } 00171 00172 m_listOfUV_v.resize(m_numOfDifVector, fio_uvListHeader_t()); 00173 00174 // Check if file is new (empty) 00175 ivd_FilePosition_t fileSize = SeekEndF(); 00176 if (fileSize <= m_firstRecordOffset) { // new or empty file 00177 CreateFile(); // write file header, filler, and list of unused vector to file 00178 } 00179 else { 00180 struct fio_RelFileHeader_t currentFileHeader(*this);// get file header from file 00181 m_currFileHeader = currentFileHeader; 00182 // check if currentFileHeader match with instantiated fileHeader by constructor 00183 log_DBG_m(dbg_DETAIL,"Check relative file header structure." << currentFileHeader << endl 00184 << " Expected header : " << m_fileHeader); 00185 int pos = strncmp(m_fileHeader.identification, currentFileHeader.identification, fio_FH_IDENTIFICATION_LEN_d); 00186 if ( (pos != 0) 00187 || (m_fileHeader.fileID != currentFileHeader.fileID) 00188 || (m_fileHeader.recordStructVersion != currentFileHeader.recordStructVersion) 00189 || (m_fileHeader.recordSize != currentFileHeader.recordSize) 00190 || (m_fileHeader.loUVHeaderLen != currentFileHeader.loUVHeaderLen) 00191 || (m_fileHeader.numOfDifVector != currentFileHeader.numOfDifVector) 00192 || (m_fileHeader.smallestVectorSize != currentFileHeader.smallestVectorSize) 00193 || (m_fileHeader.relFileHeaderLen != currentFileHeader.relFileHeaderLen) 00194 || (m_fileHeader.byteOrder != currentFileHeader.byteOrder) 00195 ) { 00196 ostringstream str; 00197 str << "\nEXPECTED HEADER: \n" << m_fileHeader 00198 << "\nDB HEADER :\n" << currentFileHeader; 00199 00200 if (g_notCheckRFHeader) { 00201 m_fileHeader.recordSize = currentFileHeader.recordSize; 00202 if (pos != 0) { 00203 strncpy(m_fileHeader.identification, currentFileHeader.identification, fio_FH_IDENTIFICATION_LEN_d); 00204 } 00205 log_ERR_m("Header is damaged. The FSC may be corrupted." 00206 + str.str() ); 00207 } 00208 else { 00209 throw ivd_Error(ie_REL_FILE_HEADER_INV, 00210 "Relative file header of " + GetFileName() 00211 + " doesn't match." 00212 + str.str(), true); 00213 } 00214 } 00215 if (m_fileHeader.headerStructVersion != currentFileHeader.headerStructVersion) { 00216 if (g_notCheckRFHeader) { 00217 log_ERR_m("Header is damaged. The FSC may be corrupted."); 00218 } 00219 else { 00220 throw ivd_Error(ie_REL_FILE_HEADER_INV, 00221 "Structure version of relative file header of " + GetFileName() + " doesn't match.", true); 00222 } 00223 } 00224 } 00225 } //============================================================================//

| fio_RelFile::~fio_RelFile | ( | ) | [virtual] |
Definition at line 229 of file fio_RelFile.cpp.
References log_FUNC_m.
00229 { 00230 log_FUNC_m(~fio_RelFile); 00231 00232 }
| fio_RelFileHeader_t fio_RelFile::GetRelFileHeader | ( | ) | [inline] |
Definition at line 189 of file fio_RelFile.h.
Referenced by RevertUpdate(), and Update().
00189 { return m_currFileHeader; };

| void fio_RelFile::SyncRelFileObj | ( | ) | [virtual] |
Sync relative file object with data on disk after transaction reply.
Reimplemented in fio_CirFileTrans, and fio_RelFileTrans.
Definition at line 235 of file fio_RelFile.cpp.
References log_FUNC_m, ReadListOfUnusedVector(), and SetFirstNewIDX().
Referenced by fio_RelFileTrans::SyncRelFileObj().
00235 { 00236 log_FUNC_m(SyncRelFileObj); 00237 ReadListOfUnusedVector(); 00238 SetFirstNewIDX(); 00239 }


| fio_RecordIDX_t fio_RelFile::FirstNewIDX | ( | ) |
Definition at line 242 of file fio_RelFile.cpp.
References assert, log_FUNC_m, m_firstRecordOffset, m_recordSize, and cmn_File::SeekEndF().
Referenced by i_FSC_i::ChkLastFileID(), hdb_Tables::DumpMigratedFiles(), hsm_FHmigc::GetFileIDs(), main(), nsc_ScanForIVDFSRecovery(), fsc_RawUpdate::ScanAllFileID(), and SetFirstNewIDX().
00242 { 00243 log_FUNC_m(FirstNewIDX); 00244 00245 assert(0 < m_recordSize); 00246 // number of current used records is new index, cause index 0 is reserved. 00247 // STRANGE it must return result + 1 ??? 00248 // maybe method WriteRec(...) solved this problem by updating m_firstNewIDX 00249 // and method void fio_uvListMgr::ReadUV(), where write a byte in next record 00250 return (SeekEndF() - m_firstRecordOffset) / m_recordSize; 00251 }


| void fio_RelFile::SetFirstNewIDX | ( | ) |
calculate with FirstNewIDX methos and set m_firstNewIDX member
Definition at line 255 of file fio_RelFile.cpp.
References FirstNewIDX(), log_ERR_m, log_FUNC_m, and m_firstNewIDX.
Referenced by fio_CirFileTrans::fio_CirFileTrans(), and SyncRelFileObj().
00255 { 00256 log_FUNC_m(SetFirstNewIDX); 00257 m_firstNewIDX = FirstNewIDX(); 00258 if (m_firstNewIDX < 1) { 00259 log_ERR_m("first unused vector IDX is less than 1. Set it to 1."); 00260 m_firstNewIDX = 1; 00261 } 00262 }


| fio_RecordIDX_t fio_RelFile::GetFirstNewIDX | ( | unsigned int | a_numOfRec | ) | [protected] |
Definition at line 266 of file fio_RelFile.cpp.
References cmn_Mutex::Lock(), m_firstNewIDX, m_firstNewIDX_x, and cmn_Mutex::Unlock().
Referenced by fio_uvListMgr::ReadUV().
00266 { 00267 // log_FUNC_m(GetFirstNewIDX); 00268 00269 m_firstNewIDX_x.Lock(); 00270 fio_RecordIDX_t firstNewIDX = m_firstNewIDX; 00271 m_firstNewIDX += a_numOfRec; 00272 m_firstNewIDX_x.Unlock(); 00273 00274 return firstNewIDX; 00275 }


| fio_RecordIDX_t fio_RelFile::GetUnusedVectorIDX | ( | const unsigned int | a_numOfRec, | |
| fio_Transaction * | a_transacton_p = NULL | |||
| ) | [protected] |
Definition at line 398 of file fio_RelFile.cpp.
References fio_uvListHeader_t::firstUnusedIDX, cmn_Mutex::Lock(), m_listOfLoUV_x, m_listOfUV_v, m_smallestVectorSize, fio_UnusedRec_t::next, fio_uvListHeader_t::numOfElements, ReadRec(), cmn_Mutex::Unlock(), and UpdateListOfUnusedVector().
Referenced by GetNewVectorIDX().
00400 { 00401 // log_FUNC_m(GetUnusedVectorIDX); 00402 00403 unsigned int listIDX = a_numOfRec - m_smallestVectorSize; 00404 00405 fio_uvListHeader_t &uvlHeader = m_listOfUV_v[listIDX];// get proper header 00406 00407 m_listOfLoUV_x.Lock(); 00408 00409 fio_RecordIDX_t newIndex = uvlHeader.firstUnusedIDX; // get index of proper size vector 00410 00411 if (newIndex != 0) { 00412 00413 fio_UnusedRec_t unusedRec; 00414 00415 ReadRec( newIndex, &unusedRec ); 00416 uvlHeader.firstUnusedIDX = unusedRec.next; // rebound the unused list 00417 uvlHeader.numOfElements--; // decrement number of list element 00418 00419 UpdateListOfUnusedVector(listIDX, a_transaction_p);// update unused list at index 00420 } 00421 m_listOfLoUV_x.Unlock(); 00422 00423 return newIndex; 00424 }


| int fio_RelFile::UpdateListOfUnusedVector | ( | const unsigned int | a_listIdx, | |
| fio_Transaction * | a_transaction_p = NULL | |||
| ) | [protected] |
Definition at line 577 of file fio_RelFile.cpp.
References c_fio_maxRelFileHeadLen, ie_REL_FILE_VEC_SIZE_INV, ivd_Error, log_FUNC_m, m_listOfUV_v, m_loUVHeaderLen, m_numOfDifVector, and PosWrite().
Referenced by GetUnusedVectorIDX(), and ReleaseVector().
00579 { 00580 00581 if(a_listIdx >= m_numOfDifVector) { 00582 log_FUNC_m(UpdateListOfUnusedVector); 00583 throw ivd_Error(ie_REL_FILE_VEC_SIZE_INV, "Too large vector (list index)", true); 00584 } 00585 00586 ivd_FilePosition_t position = a_listIdx * m_loUVHeaderLen + c_fio_maxRelFileHeadLen; 00587 00588 return PosWrite( position, 00589 &m_listOfUV_v[a_listIdx].firstUnusedIDX, 00590 m_loUVHeaderLen, 00591 a_transaction_p); 00592 }


| virtual int fio_RelFile::PosWrite | ( | ivd_FilePosition_t | a_position, | |
| const void * | a_buffer_p, | |||
| ivd_FileBufSize_t | a_size, | |||
| fio_Transaction * | a_transaction | |||
| ) | const [inline, protected, virtual] |
PosWrite with transaction method is virtual.
In this RelFile class write alteration directly to file.
Reimplemented in fio_RelFileTrans.
Definition at line 248 of file fio_RelFile.h.
References fio_File::PosWrite().
Referenced by UpdateListOfUnusedVector(), and WriteRec().
00253 { 00254 return fio_File::PosWrite(a_position, a_buffer_p, a_size); 00255 };


| void fio_RelFile::CreateFile | ( | ) | [protected] |
when file has not yet created then this method is called
Definition at line 496 of file fio_RelFile.cpp.
References alloca(), c_fio_maxRelFileHeadLen, fio_GuardRecordFiller_c, log_FUNC_m, m_accessToIdx0, m_fileHeader, m_firstRecordOffset, m_recordSize, cmn_File::SeekF(), cmn_File::WriteF(), WriteHeader(), and WriteListOfUnusedVector().
Referenced by fio_RelFile().
00496 { 00497 log_FUNC_m(CreateFile); 00498 00499 WriteHeader(); 00500 ivd_FileBufSize_t written; 00501 for (unsigned int i = sizeof(m_fileHeader); i < c_fio_maxRelFileHeadLen; i++) { 00502 static char c = '\0'; 00503 written = WriteF(&c, 1); 00504 } 00505 WriteListOfUnusedVector(); 00506 00507 SeekF(m_firstRecordOffset); 00508 if (m_accessToIdx0) { 00509 // write zeroes 00510 char * zerroBuff = reinterpret_cast<char*>(alloca(m_recordSize)); 00511 memset(zerroBuff, 0, m_recordSize); 00512 WriteF(zerroBuff, m_recordSize); 00513 } 00514 else if (m_recordSize > sizeof(fio_GuardRecordFiller_c)) { 00515 // write guard record if idx 0 is not used 00516 int n = m_recordSize / sizeof(fio_GuardRecordFiller_c); 00517 for (int i = 0; i < n; i++) { 00518 WriteF( fio_GuardRecordFiller_c, m_recordSize); 00519 } 00520 WriteF( fio_GuardRecordFiller_c, m_recordSize); 00521 } 00522 else { 00523 WriteF( fio_GuardRecordFiller_c, m_recordSize % sizeof(fio_GuardRecordFiller_c)); 00524 } 00525 }


| void fio_RelFile::WriteHeader | ( | ) | [protected] |
Definition at line 481 of file fio_RelFile.cpp.
References fio_File::GetFileName(), ie_FILE_ERROR, ivd_Error, log_ERR_m, log_FUNC_m, m_fileHeader, and fio_File::PosWrite().
Referenced by CreateFile(), and fsc_RawUpdate::UpdateHeaders().
00481 { 00482 log_FUNC_m(WriteHeader); 00483 00484 unsigned int fileHeaderSize = sizeof(m_fileHeader); 00485 00486 ivd_FileBufSize_t written = fio_File::PosWrite(0, &m_fileHeader, fileHeaderSize); 00487 00488 if (written != fileHeaderSize) { 00489 log_ERR_m("Can't write to relative file " << GetFileName() << endl); 00490 throw ivd_Error(ie_FILE_ERROR, "Can't write to relative file.", true); 00491 } 00492 }


| void fio_RelFile::WriteListOfUnusedVector | ( | ) | [protected] |
Definition at line 529 of file fio_RelFile.cpp.
References c_fio_maxRelFileHeadLen, fio_File::GetFileName(), ie_FILE_ERROR, ivd_Error, log_ERR_m, log_FUNC_m, m_listOfUV_v, m_sizeOfListOfUnusedVector, and fio_File::PosWrite().
Referenced by CreateFile().
00529 { 00530 00531 ivd_FileBufSize_t written = fio_File::PosWrite( 00532 c_fio_maxRelFileHeadLen, // position after space reserved for file header 00533 &*m_listOfUV_v.begin(), 00534 m_sizeOfListOfUnusedVector); 00535 00536 if (written != m_sizeOfListOfUnusedVector) { 00537 log_FUNC_m(WriteListOfUnusedVector); 00538 log_ERR_m("Can't write to relative file " << GetFileName() << endl); 00539 throw ivd_Error(ie_FILE_ERROR, "Can't write to relative file.", true); 00540 } 00541 }


| void fio_RelFile::ReadListOfUnusedVector | ( | ) | [protected] |
Definition at line 545 of file fio_RelFile.cpp.
References c_fio_maxRelFileHeadLen, dbg_DETAIL, dbg_GetLevel(), dbg_IsActive(), fio_File::GetFileName(), cmn_File::GetFullPathRef(), ie_FILE_ERROR, ivd_Error, log_DBG_m, log_ERR_m, log_FUNC_m, m_listOfUV_v, m_sizeOfListOfUnusedVector, and fio_File::PosRead().
Referenced by SyncRelFileObj().
00545 { 00546 log_FUNC_m(ReadListOfUnusedVector); 00547 00548 ivd_FileBufSize_t read = fio_File::PosRead( 00549 c_fio_maxRelFileHeadLen, // position after space reserved for file header 00550 &*m_listOfUV_v.begin(), 00551 m_sizeOfListOfUnusedVector); 00552 00553 if (dbg_IsActive() && (dbg_GetLevel() == dbg_DETAIL)) { 00554 ostringstream sstr; 00555 log_DBG_m(dbg_DETAIL,"List of list of UV relative file : '" << GetFullPathRef() << "'"); 00556 log_DBG_m(dbg_DETAIL,"Vec size #ofUV First index"); 00557 log_DBG_m(dbg_DETAIL,"-----------------------------"); 00558 00559 fio_LoUV_v_i iter = m_listOfUV_v.begin(); 00560 int i = 1; 00561 for (; iter != m_listOfUV_v.end(); ++iter, ++i) { 00562 log_DBG_m(dbg_DETAIL, setw(8) << i 00563 << setw(8) << (*iter).numOfElements 00564 << setw(13) << (*iter).firstUnusedIDX); 00565 } 00566 } 00567 00568 if (read != m_sizeOfListOfUnusedVector) { 00569 log_ERR_m( 00570 "Can't read list of UV from relative file " << GetFileName() << endl); 00571 throw ivd_Error(ie_FILE_ERROR, "Can't read list of UV from relative file.", true); 00572 } 00573 }


| fio_RecordIDX_t fio_RelFile::ReadNextUnusedVectorIDX | ( | fio_RecordIDX_t | a_index, | |
| UInt16_t | a_vecSize | |||
| ) | [protected] |
read record at index and return the index to next record;
NOTE a_vecSize is decremented by one.
Definition at line 430 of file fio_RelFile.cpp.
References cmn_HexDump(), fio_MAX_UV_SIZE_TO_COMPARE_d, cmn_File::GetFullPathRef(), ie_INV_UNUSED_VECT_STRUCT, IsUVFillerCorrupted(), ivd_Error, log_FUNC_m, m_recordSize, fio_UnusedRec_t::next, ReadRec(), fio_UnusedRec_t::vecSize, and fio_UnusedRec_t::wordFiller.
Referenced by fio_uvListMgr::ReadUV().
00430 { 00431 log_FUNC_m(ReadNextUnusedVectorIDX); 00432 00433 fio_UnusedRec_t unusedRec; 00434 ReadRec( a_index, &unusedRec ); 00435 bool invalidRecord(false); 00436 ostringstream sstr; 00437 00438 //SimulateUVStructureError(&unusedRec); 00439 00440 if (a_vecSize != unusedRec.vecSize) { 00441 sstr << "Expected vector size: " << a_vecSize 00442 << ", but got vector size: " << unusedRec.vecSize << endl 00443 << "NOTE! stored vector size values are one less then real vector size." << endl; 00444 invalidRecord = true; 00445 } 00446 /* 00447 If vector is unused everything except next and vecSize members must be set to zero. 00448 This depends on m_recordSize. e.g: 00449 if it is set to 8 (bytes, 4(next) + 2(vecSize) + 2(wordFiller)) then 00450 wordFiller must be set to 0. 00451 if it is set to 12 (bytes, 4(next) + 2(vecSize) + 2(wordFiller) + 4(longFiller1)) then 00452 wordFiller and longFiller1 must be set to 0. 00453 */ 00454 UInt16_t sizeToCompare(m_recordSize - (sizeof(unusedRec.next) + sizeof(unusedRec.vecSize))); 00455 /* 00456 Do not test if last filler is set to 0 since it can contain anything. 00457 */ 00458 if (sizeToCompare > fio_MAX_UV_SIZE_TO_COMPARE_d) { 00459 sizeToCompare = fio_MAX_UV_SIZE_TO_COMPARE_d; 00460 } 00461 00462 char* filler_p = reinterpret_cast<char*>(&unusedRec.wordFiller); 00463 if (IsUVFillerCorrupted(filler_p, sizeToCompare)) { 00464 sstr << "Expected zero fillers, but got non-zero fillers." << endl; 00465 invalidRecord = true; 00466 } 00467 00468 if (invalidRecord) { 00469 ostringstream errStr; 00470 errStr << "In relative file : '" << GetFullPathRef() << "'" 00471 << " at index: " << a_index << "." << endl << sstr.str() 00472 << cmn_HexDump(&unusedRec, m_recordSize, m_recordSize, false); 00473 throw ivd_Error(ie_INV_UNUSED_VECT_STRUCT, errStr.str(), true); 00474 } 00475 return unusedRec.next; 00476 }


| ivd_RecordIDX_t fio_RelFile::GetFirstNewIDX | ( | ) | [inline] |
Definition at line 277 of file fio_RelFile.h.
Referenced by GetNewVectorIDX().
00277 { return m_firstNewIDX; };

| ivd_FilePosition_t fio_RelFile::Idx2Pos | ( | ivd_RecordIDX_t | a_idx | ) | [inline] |
pass index and return position in file
Definition at line 280 of file fio_RelFile.h.
Referenced by fio_CirFileTrans::CheckBlockChain(), fio_CirFileTrans::fio_CirFileTrans(), fio_CirFileTrans::GetRFIdxFromNextBlock(), fio_CirFileTrans::GetRNIdxFromNextBlock(), fio_CirFileTrans::NewWriteBackBlock(), ReadRec(), fio_uvListMgr::ReadUV(), fsc_nsStream::RemoveLeftVectors(), fsc_RawUpdate::ScanAllCopy(), fsc_RawScan::ScanAllCopy(), fsc_RawUpdate::ScanAllGeneration(), fsc_RawScan::ScanAllGeneration(), fsc_RawUpdate::ScanAllSplit(), fsc_RawScan::ScanAllSplit(), fsc_nsStream::Write2DB(), WriteRec(), and fio_uvListMgr::WriteUV().
00280 { 00281 return (ivd_FilePosition_t)a_idx * m_recordSize + m_firstRecordOffset; 00282 };

| int fio_RelFile::WriteRec | ( | const fio_RecordIDX_t | a_index, | |
| const void * | a_buffer, | |||
| const unsigned int | a_numOfRec = 1, |
|||
| fio_Transaction * | a_transaction = NULL | |||
| ) |
Write one or more records (vector) from a_buffer to a_index place in file.
Definition at line 280 of file fio_RelFile.cpp.
References Idx2Pos(), ie_REL_FILE_INDEX_INV, ie_REL_FILE_VEC_SIZE_INV, ivd_Error, cmn_Mutex::Lock(), log_FUNC_m, m_accessToIdx0, m_firstNewIDX, m_firstNewIDX_x, m_numOfDifVector, m_recordSize, m_smallestVectorSize, PosWrite(), and cmn_Mutex::Unlock().
Referenced by hsm_FHrelc::Append(), i_FSC_i::ChkLastFileID(), hsm_FileHeader::CompleteMigIsDone(), fsc_DataLMgr::GetBunchOfFileIDs(), hsm_FHmigc::GetFileIDs(), fio_CirFileTrans::NewWriteBackBlock(), hsm_FHrelc::Release(), ReleaseVector(), hsm_FileHeader::RemoveNameFromHSMDB(), hsm_FHrelc::Truncate(), fsc_SplitMgr::Write2DB(), fsc_DataL::Write2DB(), fsc_CopyMgr::Write2DB(), fio_Vector::Write2DB(), and fio_CirFileTrans::WriteRec().
00283 { 00284 00285 if( !m_accessToIdx0 00286 && a_index == 0) { 00287 log_FUNC_m(WriteRec); 00288 throw ivd_Error(ie_REL_FILE_INDEX_INV, 00289 "Can't write on index 0. It's reserved.", true); 00290 } 00291 00292 m_firstNewIDX_x.Lock(); 00293 if(a_index >= m_firstNewIDX) { 00294 m_firstNewIDX = a_index + 1; 00295 } 00296 m_firstNewIDX_x.Unlock(); 00297 00298 if (a_numOfRec > m_smallestVectorSize) { 00299 if((a_numOfRec - m_smallestVectorSize) >= m_numOfDifVector) { 00300 log_FUNC_m(WriteRec); 00301 throw ivd_Error(ie_REL_FILE_VEC_SIZE_INV, "Too large vector write", true); 00302 } 00303 } 00304 00305 return PosWrite(Idx2Pos(a_index), 00306 a_buffer, 00307 a_numOfRec * m_recordSize, 00308 a_transaction); 00309 }


| int fio_RelFile::ReadRec | ( | const fio_RecordIDX_t | a_index, | |
| void * | a_buffer, | |||
| const unsigned int | a_numOfRec = 1 | |||
| ) |
Read one or more records (vector) from a_buffer to a_index place in file.
number of read records is return
Reimplemented in fio_CirFileTrans.
Definition at line 313 of file fio_RelFile.cpp.
References Idx2Pos(), ie_REL_FILE_INDEX_INV, ivd_Error, log_FUNC_m, m_accessToIdx0, m_recordSize, and fio_File::PosRead().
Referenced by TreeWalk::CheckDir(), hdb_Tables::DumpMigratedFiles(), fsc_CopyMgr::fsc_CopyMgr(), fsc_DataL_t::fsc_DataL_t(), fsc_GenerationMgr::fsc_GenerationMgr(), fsc_nsElement_t::fsc_nsElement_t(), fsc_SplitMgr::fsc_SplitMgr(), GetUnusedVectorIDX(), hdb_RemoveName(), hdbReadNameOwnRec(), hsm_CheckFile2hsmdbRec(), hsm_FileHeader::InitFromDB(), ReadNextUnusedVectorIDX(), fio_CirFileTrans::ReadRec(), fsc_RawUpdate::ScanAllFileID(), fsc_RawScan::ScanAllFileID(), and fio_CirFileTrans::SetRecIndeces().
00316 { 00317 00318 if( !m_accessToIdx0 00319 && a_index == 0) { 00320 log_FUNC_m(ReadRec); 00321 throw ivd_Error(ie_REL_FILE_INDEX_INV, 00322 "Can't read on index 0. It's reserved.", true); 00323 } 00324 // return the number of record read 00325 return PosRead( Idx2Pos(a_index), 00326 a_buffer, 00327 m_recordSize * a_numOfRec) / m_recordSize; 00328 }


| void fio_RelFile::ReleaseVector | ( | const fio_RecordIDX_t | a_index, | |
| unsigned int | a_numOfRec, | |||
| fio_Transaction * | a_transaction = NULL | |||
| ) |
Release one or more records (vector) from a_index place in file.
Definition at line 332 of file fio_RelFile.cpp.
References assert, fio_uvListHeader_t::firstUnusedIDX, ie_INVALID_ARG, ie_REL_FILE_INDEX_INV, ie_REL_FILE_VEC_SIZE_INV, ivd_Error, cmn_Mutex::Lock(), log_FUNC_m, m_listOfLoUV_x, m_listOfUV_v, m_numOfDifVector, m_recordSize, m_smallestVectorSize, fio_uvListHeader_t::numOfElements, cmn_Mutex::Unlock(), UpdateListOfUnusedVector(), and WriteRec().
00335 { 00336 00337 if(a_index == 0) { 00338 log_FUNC_m(ReleaseVector); 00339 throw ivd_Error(ie_REL_FILE_INDEX_INV, 00340 "Can't release vector on index 0. It's reserved.", true); 00341 } 00342 00343 if (a_numOfRec < m_smallestVectorSize) { 00344 log_FUNC_m(ReleaseVector); 00345 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector."); 00346 } 00347 unsigned int listIDX = a_numOfRec - m_smallestVectorSize; 00348 00349 if(listIDX >= m_numOfDifVector) { 00350 log_FUNC_m(ReleaseVector); 00351 throw ivd_Error(ie_REL_FILE_VEC_SIZE_INV, "Too large vector search", true); 00352 } 00353 00354 fio_uvListHeader_t &uvlHeader = m_listOfUV_v[listIDX]; // get proper header 00355 00356 assert(sizeof(fio_UnusedRec_t) > m_recordSize); 00357 00358 00359 m_listOfLoUV_x.Lock(); 00360 00361 // released record point to current in list 00362 fio_UnusedRec_t unusedRec(uvlHeader.firstUnusedIDX, listIDX); 00363 00364 uvlHeader.firstUnusedIDX = a_index; // rebound the unused list 00365 uvlHeader.numOfElements++; // increment number of list element 00366 WriteRec( a_index, &unusedRec, 1); // update unused record 00367 UpdateListOfUnusedVector(listIDX, a_transaction_p); // update unused list at index 00368 00369 m_listOfLoUV_x.Unlock(); 00370 }

| fio_RecordIDX_t fio_RelFile::GetNewVectorIDX | ( | unsigned int | a_numOfRec | ) |
Reserve one or more records (vector) in file and return index to it.
Definition at line 374 of file fio_RelFile.cpp.
References GetFirstNewIDX(), GetUnusedVectorIDX(), ie_INVALID_ARG, ie_REL_FILE_VEC_SIZE_INV, ivd_Error, log_FUNC_m, m_numOfDifVector, and m_smallestVectorSize.
00374 { 00375 00376 if (a_numOfRec < m_smallestVectorSize) { 00377 log_FUNC_m(GetNewVectorIDX); 00378 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector."); 00379 } 00380 unsigned int listIDX = a_numOfRec - m_smallestVectorSize; 00381 00382 if(listIDX >= m_numOfDifVector) { 00383 log_FUNC_m(GetNewVectorIDX); 00384 throw ivd_Error(ie_REL_FILE_VEC_SIZE_INV, "Too large vector search", true); 00385 } 00386 00387 fio_RecordIDX_t newIndex = GetUnusedVectorIDX(a_numOfRec); // try to find it inside list of list of unused vector 00388 if (newIndex == 0) { 00389 return GetFirstNewIDX(a_numOfRec); // if not get it from the end of the file 00390 } 00391 else { 00392 return newIndex; 00393 } 00394 }

| unsigned int fio_RelFile::GetFirstRecordOffset | ( | ) | [inline] |
| unsigned int fio_RelFile::GetRecordSize | ( | ) | [inline] |
Definition at line 310 of file fio_RelFile.h.
Referenced by fio_uvListMgr::WriteUV().
00310 { return m_recordSize;};

| unsigned int fio_RelFile::GetNumOfRecord | ( | ) | [inline] |
Definition at line 311 of file fio_RelFile.h.
Referenced by DumpHdr(), fsc_DataLMgr::GetNumOfUsedFileID(), and main().
00311 { return m_firstNewIDX - 1;};

| void fio_RelFile::Flush | ( | ) | [inline] |
Definition at line 313 of file fio_RelFile.h.
Referenced by fio_RelFileTransLstMgr::Flush().

| void fio_RelFile::DumpHdr | ( | ostream & | os | ) | [virtual] |
dump header to stream
Reimplemented in fio_CirFileTrans.
Definition at line 596 of file fio_RelFile.cpp.
References GetNumOfRecord(), log_FUNC_m, and m_currFileHeader.
Referenced by fio_CirFileTrans::DumpHdr().
00596 { 00597 log_FUNC_m(DumpHdr); 00598 os << m_currFileHeader; 00599 os << "USED RECORDS = " << GetNumOfRecord() << endl; 00600 }


friend class fio_uvListMgr [friend] |
friend class fsc_RawUpdate [friend] |
Definition at line 173 of file fio_RelFile.h.
const unsigned int fio_RelFile::m_recordSize [protected] |
Definition at line 189 of file fio_RelFile.h.
Referenced by fio_CirFileTrans::CheckBlockChain(), CreateFile(), fio_RelFile(), fio_RelFileTrans::fio_RelFileTrans(), FirstNewIDX(), ReadNextUnusedVectorIDX(), ReadRec(), ReleaseVector(), fio_CirFileTrans::SetRecIndeces(), fio_CirFileTrans::WriteBack(), and WriteRec().
const unsigned int fio_RelFile::m_loUVHeaderLen [protected] |
Definition at line 195 of file fio_RelFile.h.
Referenced by fio_RelFileTrans::fio_RelFileTrans(), and UpdateListOfUnusedVector().
const unsigned int fio_RelFile::m_numOfDifVector [protected] |
Definition at line 196 of file fio_RelFile.h.
Referenced by fio_RelFile(), fio_RelFileTrans::fio_RelFileTrans(), GetNewVectorIDX(), ReleaseVector(), UpdateListOfUnusedVector(), and WriteRec().
const UInt16_t fio_RelFile::m_smallestVectorSize [protected] |
Definition at line 197 of file fio_RelFile.h.
Referenced by fio_RelFileTrans::AddVectorToBuffer(), fio_CirFileTrans::fio_CirFileTrans(), fio_RelFileTrans::GetBunchOfVectorIDXes(), GetNewVectorIDX(), fio_RelFileTrans::GetRecommendBufferSize(), fio_CirFileTrans::GetRFIdxFromNextBlock(), GetUnusedVectorIDX(), fio_RelFileTrans::GetVectorIDX(), fio_CirFileTrans::NewWriteBackBlock(), fio_RelFileTrans::PutVectorToBufferAndFlush(), fio_CirFileTrans::ReadFront(), fio_CirFileTrans::ReadNext(), ReleaseVector(), fio_RelFileTrans::RemoveVectorFromBuffer(), fio_CirFileTrans::SetRecIndeces(), fio_RelFileTrans::SetRecommendBufferSize(), fio_CirFileTrans::WriteBack(), and WriteRec().
const ivd_FileBufSize_t fio_RelFile::m_sizeOfListOfUnusedVector [protected] |
Definition at line 198 of file fio_RelFile.h.
Referenced by ReadListOfUnusedVector(), and WriteListOfUnusedVector().
const unsigned int fio_RelFile::m_firstRecordOffset [protected] |
Definition at line 199 of file fio_RelFile.h.
Referenced by CreateFile(), fio_RelFile(), and FirstNewIDX().
const Int16_t fio_RelFile::m_recordStructVersion [protected] |
Definition at line 200 of file fio_RelFile.h.
const bool fio_RelFile::m_accessToIdx0 [protected] |
Definition at line 201 of file fio_RelFile.h.
Referenced by CreateFile(), ReadRec(), and WriteRec().
struct fio_RelFileHeader_t fio_RelFile::m_fileHeader [read, protected] |
Definition at line 204 of file fio_RelFile.h.
Referenced by CreateFile(), fio_RelFile(), and WriteHeader().
struct fio_RelFileHeader_t fio_RelFile::m_currFileHeader [read, protected] |
fio_LoUV_v_t fio_RelFile::m_listOfUV_v [protected] |
vector of list of unused vectors
Definition at line 210 of file fio_RelFile.h.
Referenced by fio_RelFile(), fio_RelFileTrans::fio_RelFileTrans(), GetUnusedVectorIDX(), ReadListOfUnusedVector(), ReleaseVector(), UpdateListOfUnusedVector(), and WriteListOfUnusedVector().
ivd_RecordIDX_t fio_RelFile::m_firstNewIDX [protected] |
Definition at line 212 of file fio_RelFile.h.
Referenced by GetFirstNewIDX(), SetFirstNewIDX(), and WriteRec().
cmn_Mutex fio_RelFile::m_RelativeFile_x [mutable, protected] |
cmn_Mutex fio_RelFile::m_listOfLoUV_x [mutable, protected] |
Exclusive access to list of list of unused vectors.
Definition at line 218 of file fio_RelFile.h.
Referenced by GetUnusedVectorIDX(), and ReleaseVector().
cmn_Mutex fio_RelFile::m_firstNewIDX_x [mutable, protected] |
Exclusive access m_firstNewIDX.
Definition at line 221 of file fio_RelFile.h.
Referenced by GetFirstNewIDX(), and WriteRec().
Macro for class name member.
Reimplemented from fio_File.
Reimplemented in fio_CirFileTrans, fio_RelFileTrans, and fio_VarLenRFT.
Definition at line 273 of file fio_RelFile.h.
1.5.6