Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | Private Attributes

fsc_nsStream Class Reference
[G_new_group]

is a fio_Vector take care of DB vectors in chain. More...

#include <fsc_nsStream.h>

Inheritance diagram for fsc_nsStream:
Inheritance graph
[legend]
Collaboration diagram for fsc_nsStream:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 fsc_nsStream (fio_RelFileTrans &a_relFile, UInt8_t a_size, ivd_RecordIDX_t a_idx)
 ~fsc_nsStream (void)
bool Write2DB (fio_VecQualifers &a_vq, fio_Transaction &a_trans)
void ReadFromDB (df_Stream &a_attrStream)
void SetLimitedStream (df_LimitedStream *a_firstStream_p)

Public Attributes

 log_CLASSID_m

Protected Attributes

int m_recSize
df_LimitedStreamm_firstStream_p

Private Member Functions

bool Write2DB (df_LimitedStream *a_limStream_p, fio_VecQualifers &a_vq, fio_Transaction &a_trans)
void RemoveLeftVectors (fio_VecQualifers &a_vq, fio_Transaction &a_trans)
int NumOfRecords (int a_size)
 nuumber of records need for a_size buffer length

Private Attributes

unsigned int m_maxStreamSize

Detailed Description

is a fio_Vector take care of DB vectors in chain.

When stream is to large for one vector then df_LimitedStream member helps manage it just to store data from vectors. But all DB works is done by itself. It reads all data from DB and writes it back.

Definition at line 52 of file fsc_nsStream.h.


Constructor & Destructor Documentation

fsc_nsStream::fsc_nsStream ( fio_RelFileTrans a_relFile,
UInt8_t  a_size,
ivd_RecordIDX_t  a_idx 
) [inline]

Definition at line 54 of file fsc_nsStream.h.

        :
        fio_Vector(a_relFile,
                   (a_idx > 0 && a_size == 0)
                   ? c_fio_numOfDifVector
                   : a_size, 
                   a_idx),
        m_recSize(a_relFile.GetRecordSize()),
        m_maxStreamSize(ivd_MAX_STREAM_SIZE(m_recSize)),
        m_firstStream_p(NULL)
    { };

fsc_nsStream::~fsc_nsStream ( void   )  [inline]

Definition at line 68 of file fsc_nsStream.h.

References m_firstStream_p.

                        {
        if (m_firstStream_p) {
            delete m_firstStream_p;
        }
    };


Member Function Documentation

int fsc_nsStream::NumOfRecords ( int  a_size  )  [inline, private]

nuumber of records need for a_size buffer length

Definition at line 104 of file fsc_nsStream.h.

References m_recSize.

Referenced by Write2DB().

                                 {
        return ((a_size + m_recSize - 1) / m_recSize);
    };

Here is the caller graph for this function:

void fsc_nsStream::ReadFromDB ( df_Stream a_attrStream  ) 

Definition at line 127 of file fsc_nsStream.cpp.

References c_fio_numOfDifVector, dbg_DETAIL, fio_Vector::GetVectorIndex(), fio_Vector::GetVectorSize(), log_DBG_m, log_FUNC_m, m_maxStreamSize, m_recSize, fio_Vector::SetVector(), and df_Stream::Write().

Referenced by fsc_nsAttrStream::ReadSplitsFromDB().

                                                     {
    log_FUNC_m(ReadFromDB);
    // same vector is used to read all limStreams
    fio_VecQualifers origVQ(GetVectorSize(), GetVectorIndex());

    while (GetVectorIndex() > 0) {        
        string limStream;
        ivd_VectorSize_t vecSize = GetVectorSize();
        log_DBG_m(dbg_DETAIL, " get attribute stream from idx " << GetVectorIndex()
                            << " size " << vecSize
                            << ", m_recSize" << m_recSize);
        // NOTE! Dirty solution, string doesn't now about filled data.
        limStream.resize(vecSize * m_recSize); // prepare enought place for data
        fio_Vector::ReadFromDB((void*)const_cast<char*>(limStream.data()));
        if (vecSize == c_fio_numOfDifVector) { // vector is full posible exits another 
            log_DBG_m(dbg_DETAIL, " Vector is full. Maybe exist another one." );
            const fio_VecQualifers &vq = *reinterpret_cast<const fio_VecQualifers*>(
                                        limStream.data() + m_maxStreamSize);
            SetVector(vq);
            // cut off vec qualifer from the end of the lim-stream
            limStream.resize(m_maxStreamSize);
            a_attrStream.Write(limStream);            // add string as limString to a_attrStream
        } 
        else {
            a_attrStream.Write(limStream);
            break;
        }
    }        
//    SetLimitedStream(a_attrStream.StealFirstStream());
    SetVector(origVQ);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsStream::RemoveLeftVectors ( fio_VecQualifers a_vq,
fio_Transaction a_trans 
) [private]

Definition at line 107 of file fsc_nsStream.cpp.

References c_fio_numOfDifVector, dbg_DETAIL, fio_VecQualifers::idx, fio_RelFile::Idx2Pos(), log_DBG_m, log_FUNC_m, m_maxStreamSize, fio_Vector::m_relFileTrans, fio_File::PosRead(), fio_RelFileTrans::ReleaseVectorIdx(), and fio_VecQualifers::size.

Referenced by Write2DB().

                                                                 {
    log_FUNC_m(RemoveLeftVectors);
    log_DBG_m(dbg_DETAIL, "a_vq.idx = " << a_vq.idx
                        << ", a_vq.size = " << a_vq.size);
    if (a_vq.idx > 0) { // previous data was written to a_vq.idx location
        if (a_vq.size == c_fio_numOfDifVector) {
            fio_VecQualifers vq; // next vector qualifers
            // get next vector size and index
            m_relFileTrans.PosRead(m_relFileTrans.Idx2Pos(a_vq.idx)
                                   + m_maxStreamSize, &vq, sizeof(vq));
            RemoveLeftVectors(vq, a_trans);
        }
        m_relFileTrans.ReleaseVectorIdx(a_vq.idx, a_vq.size, &a_trans);
        a_vq.size = 0;        
        a_vq.idx = 0;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fsc_nsStream::SetLimitedStream ( df_LimitedStream a_firstStream_p  )  [inline]

Definition at line 94 of file fsc_nsStream.h.

References m_firstStream_p, and NULL.

Referenced by fsc_nsAttrMgr::ChgAttributes(), and fsc_nsAttrMgr::RemoveAttributes().

                                                               {
        if (m_firstStream_p != NULL) {
            delete m_firstStream_p;
        }
        m_firstStream_p = a_firstStream_p;
    };

Here is the caller graph for this function:

bool fsc_nsStream::Write2DB ( fio_VecQualifers a_vq,
fio_Transaction a_trans 
) [inline]

Definition at line 74 of file fsc_nsStream.h.

References m_firstStream_p, NULL, and RemoveLeftVectors().

Referenced by Write2DB(), and fsc_nsAttrMgr::Write2DB().

                                              {
        if (m_firstStream_p == NULL) {
            RemoveLeftVectors(a_vq, a_trans);
            return true;
        }
        return Write2DB(m_firstStream_p, a_vq, a_trans);
    };

Here is the call graph for this function:

Here is the caller graph for this function:

bool fsc_nsStream::Write2DB ( df_LimitedStream a_limStream_p,
fio_VecQualifers a_vq,
fio_Transaction a_trans 
) [private]

Definition at line 52 of file fsc_nsStream.cpp.

References c_fio_numOfDifVector, c_zroesString(), dbg_DETAIL, df_LimitedStream::GetLimStreamBufRef(), df_LimitedStream::GetNextLimStream(), fio_VecQualifers::idx, fio_RelFile::Idx2Pos(), log_DBG_m, log_FUNC_m, fio_Vector::m_changed, m_maxStreamSize, m_recSize, fio_Vector::m_relFileTrans, NULL, NumOfRecords(), fio_File::PosRead(), RemoveLeftVectors(), fio_Vector::SetVector(), fio_VecQualifers::size, and Write2DB().

                                                        {
    if (a_limStream_p == NULL) {
        log_FUNC_m(Write2DB);
        log_DBG_m(dbg_DETAIL, "No more chained limStreams.");
        RemoveLeftVectors(a_vq, a_trans);
        return true;
    }

    //log_DBG_m(dbg_DETAIL, "vector qualifers of attrib stream. idx " 
    //                    << a_vq.idx << " size " << a_vq.size);
    fio_VecQualifers vq; // next vector qualifers
    if (a_vq.idx > 0) { // previous data was written to a_vq.idx location        
        if (a_vq.size == c_fio_numOfDifVector) {
            // get next vector size and index
            m_relFileTrans.PosRead(m_relFileTrans.Idx2Pos(a_vq.idx)
                                   + m_maxStreamSize, &vq, sizeof(vq));
        }
    }

    if (a_limStream_p->GetNextLimStream()) { // recursion
//        log_DBG_m(dbg_DETAIL, "Got next lim stream.");
        Write2DB(a_limStream_p->GetNextLimStream(), vq, a_trans);
    }
    else { // no
    }

    SetVector(a_vq);

    string &limStream = a_limStream_p->GetLimStreamBufRef();
    unsigned int streamSize = limStream.size();
    ivd_VectorSize_t vecSize = NumOfRecords(streamSize);
    //log_DBG_m(dbg_DETAIL, "Current stream size " << streamSize
    //                   << " this is " << vecSize 
    //                   << " vector elements of size " << m_recSize );
    if (vecSize == c_fio_numOfDifVector) {
        if (streamSize < vecSize * m_recSize - sizeof(vq)) {
            // fill zeroes to rest of the last record
            limStream.append(c_zroesString.data(), vecSize * m_recSize - sizeof(vq) - streamSize);
        }
        limStream.append((char*)&vq, sizeof(vq)); // append size and idx of next vector
    }
    else if (streamSize < (unsigned int)vecSize * m_recSize) {
        // fill zeroes to rest of the last record
        limStream.append(c_zroesString.data(), vecSize * m_recSize - streamSize);
    }

//    log_DBG_m(dbg_DETAIL, "Write2DB");
    m_changed = true;
    a_vq.size = vecSize;
    return fio_Vector::Write2DB(limStream.data(), a_vq.size, a_vq.idx, a_trans);
}

Here is the call graph for this function:


Member Data Documentation

Reimplemented from fio_Vector.

Reimplemented in fsc_nsAttrStream.

Definition at line 99 of file fsc_nsStream.h.

Definition at line 112 of file fsc_nsStream.h.

Referenced by fsc_nsAttrStream::Dump(), SetLimitedStream(), Write2DB(), and ~fsc_nsStream().

unsigned int fsc_nsStream::m_maxStreamSize [private]

Definition at line 110 of file fsc_nsStream.h.

Referenced by ReadFromDB(), RemoveLeftVectors(), and Write2DB().

int fsc_nsStream::m_recSize [protected]

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