Purpose: Insert an element by non-unique value. Exits: E_CORRUPT If a target data node and slot was not located (integrity) or a population test fails E_MEMORY If there was insufficient memory

Return TypeFunction nameArguments
_hz_vn_Dat*_hz_tmpl_ISAM::InsertKeyM(int32_t&,const void*,)

Declared in file: hzIsamT.h
Defined in file : hzIsamT.cpp

Function Logic:

0:START 1:unknown 2:pDN 3:unknown 4:items 5:pDN items pDN pDN m_nElements m_pRoot nSlot 6:Return pDN 7:pDN 8:unknown 9:items 10:unknown 11:items 12:unknown 13:unknown 14:Return pDN 15:pDN 16:unknown 17:items 18:unknown 19:items 20:Return pDN

Function body:

_hz_vn_Dat* _hz_tmpl_ISAM::InsertKeyM (int32_t& nSlot)const void* pKey, 
{
   //  Purpose: Insert an element by non-unique value.
   //  
   //  Arguments: 1) key  The key to insert
   //  
   //  Returns: E_OK  If operation successful
   //  
   //  Exits:  E_CORRUPT If a target data node and slot was not located (integrity) or a population test fails
   //     E_MEMORY If there was insufficient memory
   _hzfunc("_hz_tmpl_ISAM::InsertKeyM") ;
   _hz_vn_Dat* pDN = 0;        //  Current data node
   uint32_t    nPosn ;         //  Needed for _findAllByKey()
   //  If ordered list is empty
   if (!Root())
   {
       pDN = new _hz_vn_Dat ;
       if (!pDN)
           Fatal("Isam=%d: Could not allocate root node\n", IsamId()) ;
       pDN->m_pElements = new uchar[HZ_T_ISAMNODE_FULL * (m_nSizeKey + m_nSizeObj)] ;
       memset(pDN->m_pElements, 0,HZ_T_ISAMNODE_FULL * (m_nSizeKey + m_nSizeObj)) ;
       pDN->m_isamId = IsamId() ;
       pDN->usage = 1;
       m_nElements = 1;
       m_pRoot = pDN ;
       nSlot = 0;
       return pDN ;
   }
   //  Locate the 'target' top level node
   pDN = _findAllByKey(nSlot, nPosn, pKey, HZ_ISAMSRCH_END) ;
   if (!pDN)
       Fatal("Isam=%d: No data node found\n", IsamId()) ;
   if (nSlot > HZ_T_ISAMNODE_FULL)
       Fatal("Isam=%d: Illegal slot no %d for node %d\n", IsamId(), nSlot, pDN->m_Id) ;
   //  If new element has identical key then ignore
   if (nSlot < HZ_T_ISAMNODE_FULL)
   {
       if (m_compare(pKey, pDN, nSlot) == 0)
           return pDN ;
   }
   pDN = (_hz_vn_Dat*) _allocDataSlot(pDN, nSlot) ;
   if (Count() != Population())
       Fatal("Isam=%d: Expected population %d, actual %d\n", IsamId(), Population(), Count()) ;
   if (IntegBase() != E_OK)
       Fatal("Isam=%d: INTEGRITY FAILURE\n", IsamId()) ;
   return pDN ;
}