#include <fio_RelFileTrans.h>


Definition at line 48 of file fio_RelFileTrans.h.
Public Member Functions | |
| fio_RelFileTrans (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, int a_recommendUVBufferSize=fio_RECOMENDED_UV_BUFFER_SIZE_d) | |
| virtual | ~fio_RelFileTrans () |
| virtual void | SyncRelFileObj () |
| Sync relative file object with data on disk after transaction reply. | |
| void | SetDataBase (fio_DataBase *a_database_p) |
| set DB | |
| void | SetRecommendBufferSize (int a_size) |
| Set recommended buffer size to all UV, Tuning reason. | |
| void | SetRecommendBufferSize (int a_numOfRec, int a_size) |
| Set recommended buffer size to particular UV, Tuning reason. | |
| int | GetRecommendBufferSize (unsigned int a_numOfRec) |
| get the recomend buffer size for vector with proper number of record | |
| void | PutVectorToBufferAndFlush (const fio_RecordIDX_t a_index, unsigned int a_numOfRec) |
| Put released vector to UVbuffer. | |
| void | RemoveVectorFromBuffer (const fio_RecordIDX_t a_index, unsigned int a_numOfRec) |
| This method is used only by replied transaction at start up. | |
| void | AddVectorToBuffer (const fio_RecordIDX_t a_index, unsigned int a_numOfRec) |
| This method is used only by reply method in transaction. | |
| void | ReleaseVectorIdx (const fio_RecordIDX_t a_index, unsigned int a_numOfRec, fio_Transaction *a_transaction_p) |
| Add released vector to free list inside transaciton. | |
| ivd_RecordIDX_t | GetVectorIDX (unsigned int a_numOfRec, fio_Transaction *a_transaction_p) |
| Get one unused proper sized vectore. | |
| void | GetBunchOfVectorIDXes (ivd_RecIdxVec_t &a_recIdxVec, unsigned int a_numOfRec, fio_Transaction *a_transaction_p) |
| Get a bunch of unused vectors same size and put its indeces to vector of ivd_RecordIDX_t set as element as vector size. | |
| void | Synchronize (fio_Transaction *a_transaction_p) |
| All unused vectors in lists have to be saved, called by DB. | |
Public Attributes | |
| log_CLASSID_m | |
| Macro for class name member. | |
Protected Member Functions | |
| virtual int | PosWrite (ivd_FilePosition_t a_position, const void *a_buffer_p, ivd_FileBufSize_t a_size, fio_Transaction *a_transaction_p) const |
| PosWrite method is virtual. | |
Protected Attributes | |
| fio_DataBase * | m_database_p |
| The relative file is not responsible to destruct databse. | |
| fio_uvListMgr_v_t | m_uvListMgr_v |
| vector of list managers of unused vectors | |
Friends | |
| class | fio_uvListMgr |
| fio_RelFileTrans::fio_RelFileTrans | ( | 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, |
|||
| int | a_recommendUVBufferSize = fio_RECOMENDED_UV_BUFFER_SIZE_d | |||
| ) |
Definition at line 39 of file fio_RelFileTrans.cpp.
References assert, c_fio_maxRelFileHeadLen, dbg_DETAIL, log_DBG_m, log_FUNC_m, fio_RelFile::m_listOfUV_v, fio_RelFile::m_loUVHeaderLen, fio_RelFile::m_numOfDifVector, fio_RelFile::m_recordSize, and m_uvListMgr_v.
00051 : 00052 fio_RelFile(a_readOnly, 00053 a_fileID, 00054 a_path, 00055 a_fileName, 00056 a_recordSize, 00057 a_recordStructVersion, 00058 a_numOfDifVector, 00059 a_smallestVectorSize, 00060 a_accessToIdx0), 00061 m_database_p(NULL) { 00062 00063 log_FUNC_m(fio_RelFileTrans); 00064 00065 log_DBG_m(dbg_DETAIL, 00066 "fileID " << a_fileID << endl 00067 << "path " << a_path << endl 00068 << "fileName " << a_fileName << endl 00069 << "recordSize " << a_recordSize << endl 00070 << "recordStructVersion " << a_recordStructVersion << endl 00071 << "numOfDifVector " << a_numOfDifVector << endl 00072 << "smallestVectorSize " << a_smallestVectorSize << endl 00073 << "recommendUVBufferSize " << a_recommendUVBufferSize ); 00074 00075 00076 // reserve space for UV list manager instances from one element deafault constructor 00077 // const fio_uvListMgr listMgr(); 00078 m_uvListMgr_v.resize(m_numOfDifVector); 00079 00080 // initialize all UV list managers now 00081 for (unsigned int i = 0; i < m_numOfDifVector; i++) { 00082 m_uvListMgr_v[i].Init(this, // which relative file use manager 00083 &m_listOfUV_v[i], // addres of header that is stored in file header 00084 i + a_smallestVectorSize, // size of vector (vector index + smalest vector) 00085 i * m_loUVHeaderLen + c_fio_maxRelFileHeadLen, // file offset 00086 a_recommendUVBufferSize); // recomend buffer size 00087 } 00088 00089 assert(sizeof(fio_UnusedRec_t) > m_recordSize); 00090 } //============================================================================//
| fio_RelFileTrans::~fio_RelFileTrans | ( | ) | [virtual] |
Definition at line 94 of file fio_RelFileTrans.cpp.
References log_FUNC_m.
00094 { 00095 log_FUNC_m(~fio_RelFileTrans ); 00096 }
| virtual void fio_RelFileTrans::SyncRelFileObj | ( | ) | [inline, virtual] |
Sync relative file object with data on disk after transaction reply.
Reimplemented from fio_RelFile.
Reimplemented in fio_CirFileTrans.
Definition at line 69 of file fio_RelFileTrans.h.
References fio_RelFile::SyncRelFileObj().
Referenced by fio_CirFileTrans::SyncRelFileObj().
00069 { fio_RelFile::SyncRelFileObj(); };


| int fio_RelFileTrans::PosWrite | ( | ivd_FilePosition_t | a_position, | |
| const void * | a_buffer_p, | |||
| ivd_FileBufSize_t | a_size, | |||
| fio_Transaction * | a_transaction_p | |||
| ) | const [protected, virtual] |
PosWrite method is virtual.
In this RelFileTrans class put alteration to transaction.
Reimplemented from fio_RelFile.
Definition at line 242 of file fio_RelFileTrans.cpp.
References fio_File::GetFileID(), fio_File::GetFileName(), ie_REL_FILE_NO_TRANS_OBJ, fio_Transaction::InsertAlteration(), ivd_Error, log_FUNC_m, and NULL.
Referenced by fio_CirFileTrans::NewWriteBackBlock(), fio_uvListMgr::ReadUV(), fio_CirFileTrans::UpdateReadFrontBlockIdx(), fio_CirFileTrans::UpdateWriteBackBlockIdx(), and fio_uvListMgr::WriteUV().
00246 { 00247 00248 if (a_transaction == NULL) { 00249 log_FUNC_m(PosWrite); 00250 string name = GetFileName(); 00251 throw ivd_Error(ie_REL_FILE_NO_TRANS_OBJ, 00252 "Can't write to file " + name + " without transaction object.", true); 00253 } 00254 else { 00255 // reserve space for data on heap 00256 // char *data_p = new char[a_size]; 00257 //log_DBG_m(dbg_DETAIL, "Write : pos = " << a_position << endl << 00258 // cmn_HexDump(a_buffer_p, a_size, 16, false) ); 00259 00260 // memcpy(data_p, a_buffer_p, a_size); 00261 00262 //fio_Alteration *alteration_p = new fio_Alteration(const_cast<fio_RelFileTrans*>(this), 00263 // a_position, 00264 // a_size, 00265 // data_p); 00266 00267 a_transaction->InsertAlteration(GetFileID(), a_position, a_size, (const UInt8_t*)a_buffer_p); 00268 } 00269 return a_size; 00270 }


| void fio_RelFileTrans::SetDataBase | ( | fio_DataBase * | a_database_p | ) | [inline] |
set DB
Definition at line 97 of file fio_RelFileTrans.h.
Referenced by fio_RelFileTransLstMgr::SetDataBase().
00097 { 00098 m_database_p = a_database_p; 00099 };

| void fio_RelFileTrans::SetRecommendBufferSize | ( | int | a_size | ) |
Set recommended buffer size to all UV, Tuning reason.
Definition at line 285 of file fio_RelFileTrans.cpp.
References m_uvListMgr_v.
Referenced by SetRecommendBufferSize().
00285 { 00286 // log_FUNC_m(SetRecommendBufferSize(size)); 00287 00288 fio_uvListMgr_v_t::iterator p; 00289 for (p = m_uvListMgr_v.begin(); p != m_uvListMgr_v.end(); p++) { 00290 p->SetRecommendBufferSize(a_size); 00291 } 00292 }

| void fio_RelFileTrans::SetRecommendBufferSize | ( | int | a_numOfRec, | |
| int | a_size | |||
| ) |
Set recommended buffer size to particular UV, Tuning reason.
Definition at line 296 of file fio_RelFileTrans.cpp.
References ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, m_uvListMgr_v, SetRecommendBufferSize(), and size.
00296 { 00297 00298 int listIDX = a_numOfRec - m_smallestVectorSize; 00299 if (listIDX < 0) { 00300 log_FUNC_m(SetRecommendBufferSize(numOfRec, size)); 00301 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector.", true); 00302 } 00303 m_uvListMgr_v[listIDX].SetRecommendBufferSize(a_size); 00304 }

| int fio_RelFileTrans::GetRecommendBufferSize | ( | unsigned int | a_numOfRec | ) |
get the recomend buffer size for vector with proper number of record
Definition at line 308 of file fio_RelFileTrans.cpp.
References ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, and m_uvListMgr_v.
00308 { 00309 00310 int listIDX = a_numOfRec - m_smallestVectorSize; 00311 if (listIDX < 0) { 00312 log_FUNC_m(GetRecommendBufferSize); 00313 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector.", true); 00314 } 00315 return m_uvListMgr_v[listIDX].GetRecommendBufferSize(); 00316 }
| void fio_RelFileTrans::PutVectorToBufferAndFlush | ( | const fio_RecordIDX_t | a_index, | |
| unsigned int | a_numOfRec | |||
| ) |
Put released vector to UVbuffer.
This is done by transaction after commit When max buffer size is reached then half vectors is flushed to file.
Definition at line 99 of file fio_RelFileTrans.cpp.
References cmn_Num2Str(), fio_File::GetFileName(), ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, and m_uvListMgr_v.
00101 { 00102 // log_FUNC_m(PutVectorToBufferAndFlush); 00103 // put vector to appropriate list manager 00104 int listIDX = a_numOfRec - m_smallestVectorSize; 00105 if (listIDX < 0) { 00106 log_FUNC_m(PutVectorToBufferAndFlush); 00107 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector. size = " 00108 + cmn_Num2Str(a_numOfRec) 00109 + " idx = " + cmn_Num2Str(a_index) 00110 + " file = " + GetFileName(), true); 00111 } 00112 // log_DBG_m(dbg_DETAIL, "PutVect of size " << a_numOfRec); 00113 m_uvListMgr_v[listIDX].PutVector(a_index); 00114 }

| void fio_RelFileTrans::RemoveVectorFromBuffer | ( | const fio_RecordIDX_t | a_index, | |
| unsigned int | a_numOfRec | |||
| ) |
This method is used only by replied transaction at start up.
Transaction remove used vectore from buffer before is commited. It has the same functionality as at normal work when DB need some vector and pull it out before commit. Vector must be in buffer fore sure, othervise internal error occure.
Definition at line 139 of file fio_RelFileTrans.cpp.
References ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, and m_uvListMgr_v.
00142 { 00143 00144 int listIDX = a_numOfRec - m_smallestVectorSize; 00145 if (listIDX < 0) { 00146 log_FUNC_m(RemoveVectorFromBuffer); 00147 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector.", true); 00148 } 00149 m_uvListMgr_v[listIDX].RemoveVectorFromBuff(a_index); 00150 }
| void fio_RelFileTrans::AddVectorToBuffer | ( | const fio_RecordIDX_t | a_index, | |
| unsigned int | a_numOfRec | |||
| ) |
This method is used only by reply method in transaction.
Its behaviour is to add vector to buffer directly without trig flush vectors to disk.
Definition at line 154 of file fio_RelFileTrans.cpp.
References dbg_DETAIL, fio_File::GetFileName(), ie_INVALID_ARG, log_DBG_m, log_FUNC_m, fio_RelFile::m_smallestVectorSize, and m_uvListMgr_v.
00157 { 00158 // log_FUNC_m(AddVectorToBuffer); 00159 00160 int listIDX = a_numOfRec - m_smallestVectorSize; 00161 if (listIDX < 0) { 00162 log_FUNC_m(AddVectorToBuffer); 00163 log_DBG_m(dbg_DETAIL, 00164 "File " << GetFileName() << endl << 00165 "VecIdx " << a_index << endl << 00166 "Vecsize " << a_numOfRec << endl); 00167 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector. VecSize = ", true); 00168 } 00169 // log_DBG_m(dbg_DETAIL, "AddVect of size " << a_numOfRec); 00170 m_uvListMgr_v[listIDX].AddVectorToBuff(a_index); 00171 }

| void fio_RelFileTrans::ReleaseVectorIdx | ( | const fio_RecordIDX_t | a_index, | |
| unsigned int | a_numOfRec, | |||
| fio_Transaction * | a_transaction_p | |||
| ) |
Add released vector to free list inside transaciton.
Definition at line 121 of file fio_RelFileTrans.cpp.
References fio_File::GetFileID(), log_ERR_m, log_FUNC_m, and fio_Transaction::VectorIsFreed().
Referenced by fio_CirFileTrans::GetRFIdxFromNextBlock(), hdb_RemoveName(), hsm_FileHeader::RemoveFromActiveList(), fsc_nsStream::RemoveLeftVectors(), hsm_FileHeader::RemoveNameFromHSMDB(), hsm_FHrelc::Truncate(), fsc_SplitMgr::Write2DB(), fsc_GenerationMgr::Write2DB(), fsc_CopyMgr::Write2DB(), and fio_Vector::Write2DB().
00125 { 00126 if (a_index == 0) { 00127 log_FUNC_m(ReleaseVectorIdx); 00128 log_ERR_m("Can't release vector. Idx = 0 RelFileID = " << (int)GetFileID() 00129 << " vectorSize = " << a_numOfRec); 00130 } 00131 else { 00132 // put vector to transaction free list 00133 a_transaction_p->VectorIsFreed(GetFileID(), a_numOfRec, a_index); 00134 } 00135 }


| fio_RecordIDX_t fio_RelFileTrans::GetVectorIDX | ( | unsigned int | a_numOfRec, | |
| fio_Transaction * | a_transaction_p | |||
| ) |
Get one unused proper sized vectore.
First try to find it inside transaction, then try get it form UV buffer
Definition at line 175 of file fio_RelFileTrans.cpp.
References fio_File::GetFileID(), ie_FATAL_ERROR, ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, m_uvListMgr_v, and fio_Transaction::VectorIsUsed().
Referenced by fio_CirFileTrans::NewWriteBackBlock(), fsc_SplitMgr::Write2DB(), fsc_CopyMgr::Write2DB(), and fio_Vector::Write2DB().
00178 { 00179 // log_FUNC_m(GetVectorIDX); 00180 // log_DBG_m(dbg_DETAIL, "Search new vector of size = " << a_numOfRec << endl); 00181 00182 // try to find freed vectore inside current transaction 00183 // to much effort for so small hits 00184 // fio_RecordIDX_t newIndex = a_transaction_p->GetVectorIDX(GetFileID(), a_numOfRec); 00185 00186 // try to get vector from appropriate list manager 00187 fio_RecordIDX_t newIndex; 00188 // if (newIndex == 0) { 00189 int listIDX = a_numOfRec - m_smallestVectorSize; 00190 if (listIDX < 0) { 00191 log_FUNC_m(GetVectorIDX); 00192 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector.", true); 00193 } 00194 newIndex = m_uvListMgr_v[listIDX].GetVectorIDX(); 00195 if (newIndex != 0) { 00196 // vector is removed from buffer, so is used now 00197 a_transaction_p->VectorIsUsed(GetFileID(), a_numOfRec, newIndex); 00198 } 00199 else { 00200 log_FUNC_m(GetVectorIDX); 00201 throw ivd_InternalError(ie_FATAL_ERROR, "Can't find free vector", true); 00202 } 00203 // log_DBG_m(dbg_DETAIL, " Got idx from m_uvListMgr_v[" <<listIDX << "] " << newIndex << endl); 00204 // } 00205 // else { 00206 // log_DBG_m(dbg_DETAIL, " Got idx from transaction " << newIndex << endl); 00207 // } 00208 00209 return newIndex; 00210 }


| void fio_RelFileTrans::GetBunchOfVectorIDXes | ( | ivd_RecIdxVec_t & | a_recIdxVec, | |
| unsigned int | a_numOfRec, | |||
| fio_Transaction * | a_transaction_p | |||
| ) |
Get a bunch of unused vectors same size and put its indeces to vector of ivd_RecordIDX_t set as element as vector size.
Definition at line 214 of file fio_RelFileTrans.cpp.
References ie_INVALID_ARG, log_FUNC_m, fio_RelFile::m_smallestVectorSize, and m_uvListMgr_v.
Referenced by fsc_DataLMgr::GetBunchOfFileIDs().
00217 { 00218 00219 ivd_RecIdxVec_i recIdxVectIter = a_recIdxVec.begin(); // set a iterator 00220 00222 //a_transaction_p->GetBunchOfVectorIDXes(a_recIdxVec, 00223 // recIdxVectIter, 00224 // GetFileID(), 00225 // a_numOfRec); 00226 00227 // try to get vector from appropriate list manager 00228 if (recIdxVectIter != a_recIdxVec.end()) { // not filled yet 00229 int listIDX = a_numOfRec - m_smallestVectorSize; 00230 if (listIDX < 0) { 00231 log_FUNC_m(GetBunchOfVectorIDXes); 00232 throw ivd_InternalError(ie_INVALID_ARG, "Too small vector.", true); 00233 } 00234 m_uvListMgr_v[listIDX].GetBunchOfVectorIDXes(a_recIdxVec, 00235 recIdxVectIter, 00236 a_transaction_p); 00237 } 00238 }

| void fio_RelFileTrans::Synchronize | ( | fio_Transaction * | a_transaction_p | ) |
All unused vectors in lists have to be saved, called by DB.
Definition at line 274 of file fio_RelFileTrans.cpp.
References log_FUNC_m, and m_uvListMgr_v.
00274 { 00275 log_FUNC_m(Synchronize); 00276 00277 fio_uvListMgr_v_t::iterator p; 00278 for (p = m_uvListMgr_v.begin(); p != m_uvListMgr_v.end(); p++) { 00279 p->Synchronize(a_transaction_p); 00280 } 00281 }
friend class fio_uvListMgr [friend] |
fio_DataBase* fio_RelFileTrans::m_database_p [protected] |
The relative file is not responsible to destruct databse.
Definition at line 69 of file fio_RelFileTrans.h.
Referenced by fio_CirFileTrans::GetRFIdxFromNextBlock(), fio_CirFileTrans::NewWriteBackBlock(), fio_uvListMgr::PutVector(), and fio_uvListMgr::ReadUV().
fio_uvListMgr_v_t fio_RelFileTrans::m_uvListMgr_v [protected] |
vector of list managers of unused vectors
Definition at line 76 of file fio_RelFileTrans.h.
Referenced by AddVectorToBuffer(), fio_RelFileTrans(), GetBunchOfVectorIDXes(), GetRecommendBufferSize(), GetVectorIDX(), PutVectorToBufferAndFlush(), RemoveVectorFromBuffer(), SetRecommendBufferSize(), and Synchronize().
Macro for class name member.
Reimplemented from fio_RelFile.
Reimplemented in fio_CirFileTrans, and fio_VarLenRFT.
Definition at line 93 of file fio_RelFileTrans.h.
1.5.6