Public Member Functions | Private Member Functions | Private Attributes

fio_AlterJour Class Reference
[Classes for large file i/o, relative file, and DataBase]

#include <fio_AlterJour.h>

Collaboration diagram for fio_AlterJour:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fio_AlterJour (fio_RelFileTransLstMgr &a_relFileTransLstMgr)
 ~fio_AlterJour ()
void Clear ()
void Insert (UInt16_t a_fileID, ivd_FilePosition_t a_filePosition, ivd_FileBufSize_t a_bufSize)
 return size of inserted data
void Insert (const UInt8_t *a_data, int a_size)
void Insert (fio_Alter_t &a_alter, fio_JourHandle *a_jourHnd_p)
void WriteToLog (fio_JourHandle *m_jourHnd_p)
void UpdateDB ()
ivd_FileBufSize_t Size ()

Private Member Functions

void NewAJB ()

Private Attributes

fio_RelFileTransLstMgrm_relFileTransLstMgr
fio_AlterJourBlockm_currAJB_p
fio_AlterJourBlock_p_v_t m_ajbVec
fio_AlterJourBlock_p_v_i m_iter
ivd_FileBufSize_t m_alterDataSize
 log_CLASSID_m

Detailed Description

Definition at line 58 of file fio_AlterJour.h.


Constructor & Destructor Documentation

fio_AlterJour::fio_AlterJour ( fio_RelFileTransLstMgr a_relFileTransLstMgr  ) 

Definition at line 52 of file fio_AlterJour.cpp.

References log_FUNC_m, m_ajbVec, m_currAJB_p, and m_iter.

fio_AlterJour::~fio_AlterJour (  ) 

Definition at line 65 of file fio_AlterJour.cpp.

References log_FUNC_m, and m_ajbVec.

{
    log_FUNC_m(~fio_AlterJour);
    fio_AlterJourBlock **pi = &(*m_ajbVec.begin());
    fio_AlterJourBlock **pe = &(*m_ajbVec.end());
    for (; pi < pe; ++pi ) {
        delete *pi;
    }
}


Member Function Documentation

void fio_AlterJour::Clear ( void   ) 

Definition at line 77 of file fio_AlterJour.cpp.

References log_FUNC_m, m_ajbVec, m_alterDataSize, m_currAJB_p, and m_iter.

Referenced by fio_Transaction::ClearAlterVector(), and fio_Transaction::UpdateDB().

                          {
    log_FUNC_m(Clear);
    fio_AlterJourBlock **pi = &(*m_ajbVec.begin());
    fio_AlterJourBlock **pe = &(*m_ajbVec.end());
    for (; pi < pe; ++pi ) {
        (*pi)->Clear();
//        log_DBG_m(dbg_NORM, "fio_AlterJourBlock ptr " << (*pi));
    }
    m_alterDataSize = 0;
    m_iter          = m_ajbVec.begin();
    m_currAJB_p     = *m_iter;
}

Here is the caller graph for this function:

void fio_AlterJour::Insert ( UInt16_t  a_fileID,
ivd_FilePosition_t  a_filePosition,
ivd_FileBufSize_t  a_bufSize 
)

return size of inserted data

Definition at line 92 of file fio_AlterJour.cpp.

References fio_AlterJourBlock::Insert(), m_alterDataSize, m_currAJB_p, and NewAJB().

Referenced by Insert(), and fio_Transaction::InsertAlteration().

{   
//    log_FUNC_m(Insert(alterHdr));
    m_alterDataSize += sizeof(fio_Alter_t);
    int inserted = m_currAJB_p->Insert( a_fileID, a_filePosition, a_bufSize);
    if (inserted == 0) {
        NewAJB();
        m_currAJB_p->Insert( a_fileID, a_filePosition, a_bufSize);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_AlterJour::Insert ( fio_Alter_t a_alter,
fio_JourHandle a_jourHnd_p 
)

Definition at line 131 of file fio_AlterJour.cpp.

References fio_Alter_t::bufSize, Insert(), fio_AlterJourBlock::Insert(), fio_JourHandle::JourRead(), m_alterDataSize, m_currAJB_p, and NewAJB().

                                                        {
//    log_FUNC_m(Insert(from jounal));
    m_alterDataSize += sizeof(fio_Alter_t);
    int inserted = m_currAJB_p->Insert(a_alter);
    if (inserted == 0) {
        NewAJB();
        m_currAJB_p->Insert(a_alter);
    }

    m_alterDataSize += a_alter.bufSize;

    UInt8_t *buffer = new UInt8_t[a_alter.bufSize]; 
    a_jourHnd_p->JourRead(buffer, a_alter.bufSize);
    Insert(buffer, a_alter.bufSize);

    delete [] buffer;
}

Here is the call graph for this function:

void fio_AlterJour::Insert ( const UInt8_t a_data,
int  a_size 
)

Definition at line 107 of file fio_AlterJour.cpp.

References fio_AlterJourBlock::Insert(), m_alterDataSize, m_currAJB_p, NewAJB(), size, and fio_AlterJourBlock::SizeAvail().

                                                            {
//    log_FUNC_m(Insert(data));
    m_alterDataSize += a_size;
    int sizeAvail; 
    if (  (sizeAvail = m_currAJB_p->SizeAvail()) < a_size
        && sizeAvail < 1024 ) { // to small space to be used eficiently
//            log_DBG_m(dbg_NORM, " New AlterJourBlock sizeAvail " << sizeAvail);
            NewAJB();                   
    }

    int inserted = m_currAJB_p->Insert( a_data, a_size);
    if (inserted != a_size) {
        const UInt8_t *p = a_data;
        int   size = a_size;
        do {
            size -= inserted;
            p    += inserted;
            NewAJB();           
        } while (size > (inserted = m_currAJB_p->Insert(p, size))); 
    }
}

Here is the call graph for this function:

void fio_AlterJour::NewAJB (  )  [private]

Definition at line 213 of file fio_AlterJour.cpp.

References log_FUNC_m, m_ajbVec, m_currAJB_p, and m_iter.

Referenced by Insert().

                           {
    log_FUNC_m(NewAJB);
    ++m_iter;
    if (m_iter == m_ajbVec.end()) {
//        log_DBG_m(dbg_NORM, "no fio_AlterJourBlock available.");
        m_currAJB_p = new fio_AlterJourBlock;
        m_iter = m_ajbVec.insert(m_iter, m_currAJB_p);
    }
    else {
//        log_DBG_m(dbg_NORM, "curr fio_AlterJourBlock ptr " << (*m_iter));
        m_currAJB_p = *m_iter;
    }
}

Here is the caller graph for this function:

ivd_FileBufSize_t fio_AlterJour::Size (  )  [inline]

Definition at line 80 of file fio_AlterJour.h.

Referenced by fio_Transaction::EndTransaction().

{ return m_alterDataSize; };

Here is the caller graph for this function:

void fio_AlterJour::UpdateDB (  ) 

Definition at line 165 of file fio_AlterJour.cpp.

References fio_Alter_t::bufSize, fio_Alter_t::fileID, fio_Alter_t::filePosition, fio_AlterJourBlock::GetBlock(), fio_AlterJourBlock::GetDataSizeOn(), fio_RelFileTransLstMgr::GetRelFileTrans(), fio_AlterJourBlock::IsAlterHdrOn(), log_FUNC_m, m_ajbVec, m_relFileTransLstMgr, and size.

Referenced by fio_Transaction::UpdateDB().

                             {
    log_FUNC_m(UpdateDB);
    fio_AlterJourBlock **pi = &(*m_ajbVec.begin());
    fio_AlterJourBlock **pe = &(*m_ajbVec.end());
    fio_AlterJourBlock *alterJourBlk = *pi;
    UInt8_t* bp = alterJourBlk->GetBlock();
    do  {
        while (!alterJourBlk->IsAlterHdrOn(bp)) { // change block
            if (++pi >= pe) {
                return;
            }
            alterJourBlk = *pi;
            bp = alterJourBlk->GetBlock();
        }
        fio_Alter_t &alterHdr = *reinterpret_cast<fio_Alter_t*>(bp);
        fio_RelFileTrans &rf  = *m_relFileTransLstMgr.GetRelFileTrans(alterHdr.fileID);

        bp += sizeof(fio_Alter_t);

        // how much data can be read form buffer
        UInt32_t read = alterJourBlk->GetDataSizeOn(bp, alterHdr.bufSize);
        rf.fio_File::PosWrite(alterHdr.filePosition,
                              bp,
                              read);
        if (read != alterHdr.bufSize) {
            UInt32_t   size = alterHdr.bufSize;
            ivd_FilePosition_t filePos = alterHdr.filePosition;
            do { // use next block
                if (++pi >= pe) {
                    return; // this should not happened
                }
                alterJourBlk = *pi;
                bp = alterJourBlk->GetBlock();
                size    -= read;
                filePos += read;

                read = alterJourBlk->GetDataSizeOn(bp, size); 
                rf.fio_File::PosWrite(filePos,
                                      bp,
                                      read);
            } while (size > read); 
        }
        bp += read;
    } while (true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fio_AlterJour::WriteToLog ( fio_JourHandle m_jourHnd_p  ) 

Definition at line 154 of file fio_AlterJour.cpp.

References log_FUNC_m, and m_ajbVec.

Referenced by fio_Transaction::WriteAlterationToLog().

                                                          {
    log_FUNC_m(WriteToLog);
    fio_AlterJourBlock **pi = &(*m_ajbVec.begin());
    fio_AlterJourBlock **pe = &(*m_ajbVec.end());
    for (; pi < pe; ++pi ) {
        (*pi)->WriteToLog(m_jourHnd_p);
    }
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 94 of file fio_AlterJour.h.

Definition at line 89 of file fio_AlterJour.h.

Referenced by Clear(), fio_AlterJour(), NewAJB(), UpdateDB(), WriteToLog(), and ~fio_AlterJour().

Definition at line 92 of file fio_AlterJour.h.

Referenced by Clear(), and Insert().

Definition at line 88 of file fio_AlterJour.h.

Referenced by Clear(), fio_AlterJour(), Insert(), and NewAJB().

Definition at line 90 of file fio_AlterJour.h.

Referenced by Clear(), fio_AlterJour(), and NewAJB().

Definition at line 86 of file fio_AlterJour.h.

Referenced by UpdateDB().


The documentation for this class was generated from the following files: