Logo Search packages:      
Sourcecode: maxdb-7.5.00 version File versions

tgg00_BasisError Join_AccessOperator::Next ( tgg00_Rec *&  recptr  )  [virtual, inherited]

get next record from stream

Parameters:
record [in/out] pointer to memory should be filled with record
Returns:
information code [e_ok, e_no_next_record] / error code

Implements Join_IAccessOperator.

Definition at line 222 of file Join_AccessOperator.cpp.

References Join_AccessOperator::GetRecordLength(), IOperator::m_acv, Join_AccessDesc::MBlock(), SAPDB_MemFillNoCheck(), and SQLMan_Context::TransContext().

{
    SAPDBTRACE_METHOD_DEBUG( "Join_AccessOperator::Next", Join_Trace, 1 );

    m_acv.TransContext().trError_gg00 = e_ok;

    if ( is_empty_buffer() )
    {
        if ( e_no_next_record == m_BDState )
        {
            SAPDBTRACE_WRITELN( Join_Trace, 3, "file empty!" );
            m_acv.TransContext().trError_gg00 = e_no_next_record;
            m_BDState = e_ok;
        }

        if ( e_ok == m_acv.TransContext().trError_gg00 )
        {
            SAPDBTRACE_WRITELN( Join_Trace, 3, "fill buffer" );
            SAPDBTRACE_IF( Join_Trace, 3, SAPDB_MemFillNoCheck(m_RecBuf, ':', m_RecBufSize) );
            m_acv.TransContext().trRteCommPtr_gg00->file_root = NIL_PAGE_NO_GG00;

            // child classes need to implement this:
            this->SelectRecords();

            // bd delivers e_buffer_limit if one record fits not at all
            // we can't get this error because auf m_RecBufSize >= BUF8L_MXSP00
            m_BDState = m_acv.TransContext().trError_gg00;

            SAPDBTRACE_WRITELN( Join_Trace, 5, "BD call: " << SAPDBTrace::BasisError(m_acv.TransContext().trError_gg00) );
            if ( ( e_no_next_record == m_BDState && this->result_cnt() > 0 ))
                m_acv.TransContext().trError_gg00 = e_ok;

            SAPDBTRACE_WRITELN( Join_Trace, 5, "records from BD: " << this->result_cnt() );

            if ( e_no_next_record == m_BDState && m_FirstBufferFill )
            {
                SAPDBTRACE_WRITELN( Join_Trace, 5, "all recs in buffer " );
                m_AllRecsInBuf = this->result_cnt();
                m_BufferReusagePossible = true;
            }
            m_FirstBufferFill = false;


            // get first record from buffer
            m_Record = reinterpret_cast<SAPDB_Byte*>( m_RecBuf );
        }
    }
    else
    {
        SAPDBTRACE_WRITELN( Join_Trace, 3, "get record from buffer" );
        SAPDBTRACE_WRITELN( Join_Trace, 5, "records in buffer: " << this->result_cnt() );
        // get next record from buffer
        m_Record += this->rec_offset();
    }
    SAPDBTRACE_WRITELN(
        Join_Trace, 3,
        "Next(): "
        << SAPDBTrace::BasisError(
            m_acv.TransContext().trError_gg00) );

#ifdef SAPDB_SLOW
    if ( e_ok == m_acv.TransContext().trError_gg00 )
    {
        SAPDBTRACE_IF( Join_Trace, 5, 
        t01surrogate(
            td_always, "sel TABID   ",
                m_AccessDesc.MBlock().mb_qual()->mtree().fileTabId_gg00()));
        SAPDBTRACE_WRITELN(
            Join_Trace, 5,
            "records (reclen w/o rec offset="
            << this->rec_offset()
            << "[" << GetRecordLength()-cgg_rec_key_offset << "])" );
        SAPDBTRACE_WRITELN( Join_Trace, 5, "next rec is " );
        SAPDBTRACE_IF( Join_Trace, 5, 
            t01buf( td_always, m_Record, 1,
                    this->rec_offset()
                    <= 300
                    ? (this->rec_offset() + cgg_rec_key_offset)
                    : 300 ));
        SAPDBTRACE_WRITELN( Join_Trace, 5, "rec buffer:" );
        SAPDBTRACE_IF( Join_Trace, 9, 
        t01buf( td_always, m_Record, 1,
                    this->result_cnt()
                    * this->rec_offset()
                <= 300
                    ? (this->result_cnt()
                       * this->rec_offset() + cgg_rec_key_offset)
                    : 300 ));
    }
#endif
    --this->result_cnt();
    recptr = reinterpret_cast<tgg00_Rec*>( m_Record );

    return m_acv.TransContext().trError_gg00;
}


Generated by  Doxygen 1.6.0   Back to index