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

tsp00_PageNo cbd500_Tree::bd500LeftNeighborId ( cbd600_Node auxNode  )  const

function: bd500LeftNeighborId description: Determines the left neighbor without changeing the current tree. returns: pageno of left neighbor node

Definition at line 533 of file vbd500.cpp.

References bd500Print(), cbd600_Node::bd600GetId(), cbd600_Node::bd600IsAccessable(), cbd600_Node::bd600MaxRecIndex(), cbd600_Node::bd600Move(), cbd600_Node::bd600RecPtr(), cbd600_Node::bd600Release(), cbd600_Node::bd600RightNeighbor(), cbd600_Node::bd600TrError(), and cbd600_Node::m_RequestKind.

Referenced by bd500LeftNeighbor().

{
    // This uses the m_PathInfo, but does not change it.
    
    ROUTINE_DBG_MEO00 ("bd500LeftNeighborId");

    // PTS 1122998 UH 2003-07-09 new

    if ( g01vtrace.vtrBdIndex_gg00 )
        bd500Print("bd500LeftNeighborId::BEGIN");

    if ( auxNode.bd600IsAccessable() )
    {
        auxNode.bd600TrError() = e_not_implemented;
        return NIL_PAGE_NO_GG00;
    }
    
    if ( m_CurrLevel >= m_RootLevel )
        return NIL_PAGE_NO_GG00;

    const tsp00_Int4   TargetLevel = m_CurrLevel;
    const tsp00_PageNo checkId     = m_PathInfo[m_CurrLevel].piId_bd500;

      tsp00_Int4   CurrentLevel        = m_CurrLevel;
    tsp00_Int4   CurrentSubNodeIndex = NIL_REC_INDEX;
    tsp00_PageNo IndexNodeId         = NIL_PAGE_NO_GG00;

          
    // position node to left leaf or to index node to go down again

    while ( CurrentLevel < m_RootLevel
            &&
            IndexNodeId == NIL_PAGE_NO_GG00 )
    {
        if ( m_PathInfo[CurrentLevel].piLeftId_bd500 != NIL_PAGE_NO_GG00 )
        {
            // left neighbor is known so take this one
            // the rightmost separator must be used
            // this is indeicated by NIL_REC_INDEX
            IndexNodeId = m_PathInfo[CurrentLevel].piLeftId_bd500;

            if ( nr_for_read == m_Node.m_RequestKind
                 &&
                 m_PathInfo[CurrentLevel+1].piSubNodeRecIndex_bd500 == FIRST_REC_INDEX_BD00 )
            {
                // if for_update this may not be valid because of overflow or underflow handling
                auxNode.bd600TrError() = e_invalid_index_structure;
                bd500Print("bd500LeftNeighborId: Wrong PathInfo1");
                return NIL_PAGE_NO_GG00;
            }
            break;
        }
        ++CurrentLevel;
        if ( m_PathInfo[CurrentLevel].piSubNodeRecIndex_bd500 > FIRST_REC_INDEX_BD00 )
        {
            // on the next higher level the index node can be used to go down again
            // the left subnode is used
            IndexNodeId         = m_PathInfo[CurrentLevel].piId_bd500;
            CurrentSubNodeIndex = m_PathInfo[CurrentLevel].piSubNodeRecIndex_bd500-1;
            break;
        }
    }

    if ( NIL_PAGE_NO_GG00 == IndexNodeId )
    {
        if ( g01vtrace.vtrBdIndex_gg00 )
            bd500Print("bd500LeftNeighborId: NOT FOUND");
        return NIL_PAGE_NO_GG00; // the loop above did not find any left neighbor
    }

    if ( CurrentLevel == TargetLevel )
    {
        if ( g01vtrace.vtrBdIndex_gg00 )
            bd500Print("bd500LeftNeighborId: FOUND simple");
        return IndexNodeId;
    }
    
    // The CurrentLevel is above the TargetLevel so go down over the rightmost separator.

    auxNode.bd600Move(IndexNodeId);
    if ( e_ok != auxNode.bd600TrError() )
    {
        auxNode.bd600Release (false); // release aux node if necessary
        bd500Print("bd500LeftNeighborId: no access to index node");
        return NIL_PAGE_NO_GG00;
    }
    
    if ( CurrentSubNodeIndex == NIL_REC_INDEX )
        CurrentSubNodeIndex = auxNode.bd600MaxRecIndex();
        
    /* Find leaf node again from found index node */

    while ( CurrentLevel > TargetLevel )
    {
        auxNode.bd600Move(auxNode.bd600RecPtr(CurrentSubNodeIndex)->recPno_gg00().gg90GetInt4());
        if ( e_ok != auxNode.bd600TrError() )
        {
            auxNode.bd600Release (false); // release aux node
            bd500Print("bd500LeftNeighborId:no access to subnode1");
            return NIL_PAGE_NO_GG00;
        }
        --CurrentLevel;
        CurrentSubNodeIndex = auxNode.bd600MaxRecIndex();
    }
    if ( CurrentLevel != TargetLevel )
    {
        auxNode.bd600Release (false); // release aux node
        auxNode.bd600TrError() = e_invalid_index_structure;
        bd500Print("bd500LeftNeighborId: target level not reached");
        return NIL_PAGE_NO_GG00;
    }
    
    if ( checkId != NIL_PAGE_NO_GG00
         &&
         auxNode.bd600IsAccessable()
         &&
         checkId != auxNode.bd600RightNeighbor() )
    {
        auxNode.bd600TrError() = e_invalid_index_structure;
        bd500Print("bd500LeftNeighborId: Wrong PathInfo3");
        return NIL_PAGE_NO_GG00;
    }
    
    if ( g01vtrace.vtrBdIndex_gg00 )
        bd500Print("bd500LeftNeighborId::FOUND complex");

    const tsp00_PageNo leftId = auxNode.bd600GetId();
    auxNode.bd600Release (false); // release aux node
    return leftId;
}


Generated by  Doxygen 1.6.0   Back to index