Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | Friends

fsc_RawUpdate Class Reference
[G_new_group]

#include <fsc_RawUpdate.h>

Collaboration diagram for fsc_RawUpdate:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fsc_RawUpdate (const cmn_Path &a_path, bool a_revertUpdate)
 ~fsc_RawUpdate ()
void UpdateHeaders ()
void ScanAllFileID ()
 ScanAllFileID() method sequentialy reads fileID from 1 forward.

Public Attributes

 log_CLASSID_m

Private Member Functions

void CorrectMedPosition (fsc_MediaPosition_t &a_mp)
bool CorrectGenVec (ivd_FilePosition_t a_pos, fsc_Generation_t *ip, fsc_Generation_t *ep)
void ScanAllGeneration (fsc_DataL_t &a_dataL)
void ScanAllCopy (ivd_RecordIDX_t a_idx, UInt32_t a_size)
void ScanAllSplit (ivd_RecordIDX_t a_idx, UInt32_t a_size)

Private Attributes

bool m_revertUpdate
fio_RelFile m_genTem
fio_RelFile m_copTem
fio_RelFile m_splTem

Friends

class ut_fsc_RawUpdate

Detailed Description

Definition at line 45 of file fsc_RawUpdate.h.


Constructor & Destructor Documentation

fsc_RawUpdate::fsc_RawUpdate ( const cmn_Path a_path,
bool  a_revertUpdate 
)

Definition at line 59 of file fsc_RawUpdate.cpp.

References log_FUNC_m.

    :
    m_revertUpdate(a_revertUpdate),
    m_genTem(false, 2, a_path, "fsc_Generation-tem.lrf",
                            sizeof(fsc_Generation_t), a_revertUpdate?1:2),

    m_copTem(false, 4, a_path, "fsc_Copy-tem.lrf"      ,
                            sizeof(fsc_Copy_t)      , a_revertUpdate?1:2),

    m_splTem(false, 5, a_path, "fsc_Split-tem.lrf"     ,
                            sizeof(fsc_Split_t)     , a_revertUpdate?1:2)

{
    log_FUNC_m(fsc_RawUpdate);
}

fsc_RawUpdate::~fsc_RawUpdate (  ) 

Definition at line 76 of file fsc_RawUpdate.cpp.

References log_FUNC_m.


Member Function Documentation

bool fsc_RawUpdate::CorrectGenVec ( ivd_FilePosition_t  a_pos,
fsc_Generation_t ip,
fsc_Generation_t ep 
) [private]

Definition at line 153 of file fsc_RawUpdate.cpp.

References cmn_Num2Str(), CorrectMedPosition(), dlc_Copy, dlc_MediaPos, dlc_Split, fsc_NextEntity_t::dlcType, fsc_Vector_t::entryIdx, fsc_NextEntity_t::GetMedPos(), ie_INVALID_ARG, log_FUNC_m, fsc_Generation_t::nextEntity, fsc_Vector_t::numOfElement, ScanAllCopy(), ScanAllGeneration(), ScanAllSplit(), and fsc_NextEntity_t::vector.

Referenced by ScanAllGeneration().

                                                          {

    bool ret = false;
    int genCount = 1;
    for (;ip < ep; ++ip ) {

        genCount++;

        switch (ip->nextEntity.dlcType) {
            case  dlc_MediaPos : {
                // update structure
                CorrectMedPosition(ip->nextEntity.GetMedPos());
                ret = true;
                break;
            }
            case  dlc_Copy : {
                ScanAllCopy(static_cast<ivd_RecordIDX_t>(ip->nextEntity.vector.entryIdx),
                            ip->nextEntity.vector.numOfElement);
                break;
            }
            case  dlc_Split : {
                ScanAllSplit(static_cast<ivd_RecordIDX_t>(ip->nextEntity.vector.entryIdx),
                             ip->nextEntity.vector.numOfElement);
                break;
            }
            default : {
                log_FUNC_m(ScanAllGeneration);
                throw ivd_InternalError(ie_INVALID_ARG,
                    "Wrong dlcType =" + cmn_Num2Str((int)ip->nextEntity.dlcType), true);
                break;
            }
        }
        a_pos += sizeof(fsc_Generation_t);
    }
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_RawUpdate::CorrectMedPosition ( fsc_MediaPosition_t a_mp  )  [private]

Definition at line 90 of file fsc_RawUpdate.cpp.

References fsc_MediaPosition_t::blockOffset, fsc_MediaPositionVer01_t::blockOffset, m_revertUpdate, fsc_MediaPosition_t::mediaKey, fsc_MediaPositionVer01_t::mediaKey, fsc_MediaPosition_t::medVolNum, and fsc_MediaPositionVer01_t::medVolNum.

Referenced by CorrectGenVec(), ScanAllCopy(), and ScanAllSplit().

                                                                {
    if (m_revertUpdate) {
        fsc_MediaPositionVer01_t mpVer1;
        mpVer1.medVolNum   = a_mp.medVolNum;
        mpVer1.mediaKey    = a_mp.mediaKey;
        mpVer1.blockOffset = a_mp.blockOffset;
        memcpy(&a_mp, &mpVer1, sizeof(fsc_MediaPositionVer01_t));
    }
    else {
        fsc_MediaPositionVer01_t &mpVer01
            = *reinterpret_cast<fsc_MediaPositionVer01_t*>(&a_mp);
        fsc_MediaPosition_t mp;
        mp.medVolNum   = mpVer01.medVolNum;
        mp.mediaKey    = static_cast<UInt16_t>(mpVer01.mediaKey);
        mp.blockOffset = mpVer01.blockOffset;
        a_mp = mp;
    }
}

Here is the caller graph for this function:

void fsc_RawUpdate::ScanAllCopy ( ivd_RecordIDX_t  a_idx,
UInt32_t  a_size 
) [private]

Definition at line 279 of file fsc_RawUpdate.cpp.

References alloca(), cmn_HexDump(), cmn_Num2Str(), CorrectMedPosition(), dbg_DETAIL, dlc_MediaPos, dlc_NotUsed, dlc_Split, fsc_NextEntity_t::dlcType, fsc_Vector_t::entryIdx, g_copyRF_p, fsc_NextEntity_t::GetMedPos(), fio_RelFile::Idx2Pos(), ie_INVALID_ARG, log_DBG_m, log_FUNC_m, m_copTem, fsc_Copy_t::nextEntity, fsc_Vector_t::numOfElement, fio_File::PosRead(), ScanAllSplit(), and fsc_NextEntity_t::vector.

Referenced by CorrectGenVec().

                                                                      {
    log_FUNC_m(ScanAllCopy);
    fsc_Copy_t *copy = reinterpret_cast<fsc_Copy_t*>
                        (alloca(a_size * sizeof(fsc_Copy_t)));

    // direct call can be use if this is a single process
    //static_cast<cmn_File*>(g_copyRF_p)->
    ivd_FilePosition_t pos = g_copyRF_p->Idx2Pos(a_idx);
    g_copyRF_p->PosRead(pos,
                        copy,
                        a_size * sizeof(fsc_Copy_t));
//    g_copyRF_p->ReadRec(a_idx, copy, a_size);
        log_DBG_m(dbg_DETAIL, "R copies from = " << a_idx << endl
                  << ", size = " << a_size << endl <<
            cmn_HexDump(copy, a_size * sizeof(fsc_Copy_t), sizeof(fsc_Copy_t), false) );

    // for each generation

    bool change = false;
    register fsc_Copy_t *ip = copy;
    register fsc_Copy_t *ep = &copy[a_size];
    for (; ip < ep; ++ip ) {
        switch (ip->nextEntity.dlcType) {
        case  dlc_NotUsed : continue;
        case  dlc_MediaPos : {
                // update structure
                CorrectMedPosition(ip->nextEntity.GetMedPos());
                change = true;
//                m_copTem.fio_File::PosWrite(pos, ep->nextEntity.GetMedPos(), sizeof(fsc_Copy_t));
                break;
            }
        case  dlc_Split : {
            ScanAllSplit(static_cast<ivd_RecordIDX_t>(ip->nextEntity.vector.entryIdx),
                         ip->nextEntity.vector.numOfElement);
                break;
            }
        default :  {
                log_FUNC_m(ScanAllCopy);
                throw ivd_InternalError(ie_INVALID_ARG,
                    "Wrong dlcType =" + cmn_Num2Str((int)ip->nextEntity.dlcType), true);
                break;
            }
        }
    }
    if (change) {
        m_copTem.fio_File::PosWrite(pos, copy, a_size * sizeof(fsc_Copy_t));
        log_DBG_m(dbg_DETAIL, "W copies to = " << a_idx << endl
                  << ", size = " << a_size << endl <<
            cmn_HexDump(copy, a_size * sizeof(fsc_Copy_t), sizeof(fsc_Copy_t), false) );
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_RawUpdate::ScanAllFileID (  ) 

ScanAllFileID() method sequentialy reads fileID from 1 forward.

Definition at line 110 of file fsc_RawUpdate.cpp.

References cmn_HexDump(), dbg_DETAIL, dbg_NORM, fio_RelFile::FirstNewIDX(), g_dataLRF_p, fsc_DataL_t::generationIdx, log_DBG_m, log_FUNC_m, fio_RelFile::ReadRec(), and ScanAllGeneration().

Referenced by RevertUpdate(), and Update().

                                  {
    log_FUNC_m(ScanAllFileID);
    const int dataLBuffSize = 1024;
    // remove old files and dirs
    log_DBG_m(dbg_NORM, " Fast read of dataL. buff size " <<
                        dataLBuffSize << " of records.\n");

    fsc_DataL_t dataL[dataLBuffSize];
    ivd_RecordIDX_t fileID = 1;

    UInt32_t files = g_dataLRF_p->FirstNewIDX();
    int showProgEvery = files / 1000;
    if (showProgEvery == 0) {
        showProgEvery = 1;
    }
    cout << (files - 1) << " files has to be updated." << endl;
//    cout << show every " << showProgEvery << endl;
    int count = showProgEvery;
    while (fileID < files) {
        int read = g_dataLRF_p->ReadRec(fileID, &dataL, dataLBuffSize);
        log_DBG_m(dbg_DETAIL, "Read " << read << " records." << endl);
        register fsc_DataL_t *ip = dataL;
        register fsc_DataL_t *ep = &dataL[read];
        for (; ip < ep && fileID < files; ++ip, ++fileID ) {
            log_DBG_m(dbg_DETAIL, "count " << count);
            if (--count == 0) {
                log_DBG_m(dbg_DETAIL, "current fileID " << fileID);
                cout << fileID << "\015";
                cout.flush();
                count = showProgEvery;
            }
            if (ip->generationIdx > 0) {
                log_DBG_m(dbg_DETAIL, "Got DataL from = " << fileID << endl <<
                    cmn_HexDump(ip, sizeof(fsc_DataL_t), sizeof(fsc_DataL_t), false) );

                ScanAllGeneration(*ip);
            }
        }
    }
    cout << fileID - 1 << endl;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_RawUpdate::ScanAllGeneration ( fsc_DataL_t a_dataL  )  [private]

Definition at line 193 of file fsc_RawUpdate.cpp.

References assert, cmn_HexDump(), CorrectGenVec(), dbg_DETAIL, fsc_maxNumOfMember_c, fsc_maxRFVecSize_c, g_generationRF_p, fsc_DataL_t::generationIdx, fio_RelFile::Idx2Pos(), log_DBG_m, log_FUNC_m, m_genTem, fsc_DataL_t::numOfAllGen, fsc_DataL_t::numOfElement, and fio_File::PosRead().

Referenced by CorrectGenVec(), and ScanAllFileID().

                                                          {
    log_FUNC_m(ScanAllGeneration);
    //
    Int32_t numOfGen = a_dataL.numOfAllGen;

    vector<fsc_Generation_t> generation(a_dataL.numOfElement);

    fsc_Generation_t   *ip  = &generation[0];
    fsc_Generation_t   *ep  = &generation[a_dataL.numOfElement];
    ivd_FilePosition_t  pos = g_generationRF_p->Idx2Pos(a_dataL.generationIdx);
    // read first vector
    g_generationRF_p->PosRead(pos,
                              ip,
                              a_dataL.numOfElement * sizeof(fsc_Generation_t));
    log_DBG_m(dbg_DETAIL, "R Generations from = " << a_dataL.generationIdx
                        << " size = " << (int)a_dataL.numOfElement << endl <<
        cmn_HexDump(ip,
                    a_dataL.numOfElement * sizeof(fsc_Generation_t),
                    sizeof(fsc_Generation_t),
                    false) );

    if (numOfGen < fsc_maxRFVecSize_c) { //get pos of next vector and reduce the size of current
        if (CorrectGenVec(pos, ip, ep)) {
            m_genTem.fio_File::PosWrite(pos, ip,
                                a_dataL.numOfElement * sizeof(fsc_Generation_t));
            log_DBG_m(dbg_DETAIL, "W Generations to = " << a_dataL.generationIdx
                                << " size = " << (int)a_dataL.numOfElement << endl <<
            cmn_HexDump(ip,
                        a_dataL.numOfElement * sizeof(fsc_Generation_t),
                        sizeof(fsc_Generation_t),
                        false) );
        }
    }
    else {
        fsc_Generation_t *np = ep - 1;
        if (CorrectGenVec(pos, ip, np)) { // last is index to next vector
            m_genTem.fio_File::PosWrite(pos, ip,
                                a_dataL.numOfElement * sizeof(fsc_Generation_t));
            log_DBG_m(dbg_DETAIL, "W Generations to = " << a_dataL.generationIdx
                                << " size = " << a_dataL.numOfElement << endl <<
            cmn_HexDump(ip,
                        a_dataL.numOfElement * sizeof(fsc_Generation_t),
                        sizeof(fsc_Generation_t),
                        false) );
        }
        ivd_RecordIDX_t nextIdx = reinterpret_cast<fio_UnusedRec_t*>(np)->next;
        pos = g_generationRF_p->Idx2Pos(nextIdx);
        log_DBG_m(dbg_DETAIL, "nextIdx=" << nextIdx << " pos=" << pos);

        numOfGen -= a_dataL.numOfElement - 1;
        log_DBG_m(dbg_DETAIL, "vector resize to " << fsc_maxRFVecSize_c);
        generation.resize(fsc_maxRFVecSize_c); // reserve vector with max element size
        ip = &generation[0];
        ep = &generation[fsc_maxRFVecSize_c];
        np = ep - 1;;
        while (numOfGen >= fsc_maxNumOfMember_c) {

            // 256 elements, last elem contain link to next vector
            g_generationRF_p->PosRead(pos, ip,
                                      fsc_maxRFVecSize_c * sizeof(fsc_Generation_t));
            log_DBG_m(dbg_DETAIL, "Next R Generations from = " << nextIdx
                                << " size = " << fsc_maxRFVecSize_c << endl <<
                cmn_HexDump(ip,
                            fsc_maxRFVecSize_c * sizeof(fsc_Generation_t),
                            sizeof(fsc_Generation_t),
                            false) );

            if (CorrectGenVec(pos, ip, np)) {
                m_genTem.fio_File::PosWrite(pos, ip,
                                               fsc_maxRFVecSize_c * sizeof(fsc_Generation_t));
                log_DBG_m(dbg_DETAIL, "Next W Generations to = " << a_dataL.generationIdx
                                    << " size = " << fsc_maxRFVecSize_c << endl <<
                cmn_HexDump(ip,
                            fsc_maxRFVecSize_c * sizeof(fsc_Generation_t),
                            sizeof(fsc_Generation_t),
                            false) );
            }
            numOfGen -= fsc_maxNumOfMember_c;
            pos = g_generationRF_p->Idx2Pos(reinterpret_cast<fio_UnusedRec_t*>(np)->next);
        }
        log_DBG_m(dbg_DETAIL, "numOfGen=" << numOfGen);
        assert(numOfGen == 0);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_RawUpdate::ScanAllSplit ( ivd_RecordIDX_t  a_idx,
UInt32_t  a_size 
) [private]

Definition at line 332 of file fsc_RawUpdate.cpp.

References alloca(), cmn_HexDump(), cmn_Num2Str(), CorrectMedPosition(), dbg_DETAIL, dlc_MediaPos, fsc_NextEntity_t::dlcType, g_splitRF_p, fsc_NextEntity_t::GetMedPos(), fio_RelFile::Idx2Pos(), ie_INVALID_ARG, log_DBG_m, log_FUNC_m, m_splTem, fsc_Split_t::nextEntity, and fio_File::PosRead().

Referenced by CorrectGenVec(), and ScanAllCopy().

                                                                       {
    log_FUNC_m(ScanAllSplit);
    fsc_Split_t *split = reinterpret_cast<fsc_Split_t*>
                                (alloca(a_size * sizeof(fsc_Split_t)));

    ivd_FilePosition_t pos = g_splitRF_p->Idx2Pos(a_idx);
    g_splitRF_p->PosRead(pos,
                        split,
                        a_size * sizeof(fsc_Split_t));
//    g_splitRF_p->ReadRec(a_idx, split, a_size);
    log_DBG_m(dbg_DETAIL, "R splits from = " << a_idx << endl
                << ", size = " << a_size << endl <<
        cmn_HexDump(split, a_size * sizeof(fsc_Split_t), sizeof(fsc_Split_t), false) );

    // for each generation
    register fsc_Split_t *ip = split;
    register fsc_Split_t *ep = &split[a_size];
    for (; ip < ep; ++ip ) {

        switch (ip->nextEntity.dlcType) {
            case  dlc_MediaPos : {
                // update structure
                CorrectMedPosition(ip->nextEntity.GetMedPos());
                break;
            }
            default : {
                log_FUNC_m(ScanAllSplit);
                throw ivd_InternalError(ie_INVALID_ARG,
                    "Wrong dlcType =" + cmn_Num2Str((int)ip->nextEntity.dlcType), true);
                break;
            }
        }
    }
    m_splTem.fio_File::PosWrite(pos, split, a_size * sizeof(fsc_Split_t));
    log_DBG_m(dbg_DETAIL, "W splits to = " << a_idx << endl
                << ", size = " << a_size << endl <<
        cmn_HexDump(split, a_size * sizeof(fsc_Split_t), sizeof(fsc_Split_t), false) );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_RawUpdate::UpdateHeaders (  ) 

Definition at line 81 of file fsc_RawUpdate.cpp.

References log_FUNC_m, m_copTem, m_genTem, m_splTem, and fio_RelFile::WriteHeader().

Referenced by RevertUpdate(), and Update().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class ut_fsc_RawUpdate [friend]

Definition at line 46 of file fsc_RawUpdate.h.


Member Data Documentation

Definition at line 55 of file fsc_RawUpdate.h.

Definition at line 69 of file fsc_RawUpdate.h.

Referenced by ScanAllCopy(), and UpdateHeaders().

Definition at line 68 of file fsc_RawUpdate.h.

Referenced by ScanAllGeneration(), and UpdateHeaders().

Definition at line 67 of file fsc_RawUpdate.h.

Referenced by CorrectMedPosition().

Definition at line 70 of file fsc_RawUpdate.h.

Referenced by ScanAllSplit(), and UpdateHeaders().


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