Insert an atomic-value/object-id pair into the unique key index. Note that as hdbIndexUkey can only be applied to data members with a minimun and maximum population of 1, the member cannot be NULL and therefore a NULL value to insert is an error.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbIndexUkey::Insert | (hzAtom&,uint32_t,) |
Declared in file: hzDatabase.h
Defined in file : hdbIndex.cpp
Function Logic:
Function body:
hzEcode hdbIndexUkey::Insert (hzAtom& atom)uint32_t objId,
{
// Insert an atomic-value/object-id pair into the unique key index.
//
// Arguments: 1) atom The atomic value
// 2) objId The object identifier
//
// Returns: E_TYPE If the atomic value is not of the expected data type
// E_NODATA If the atomic value is not set (see note)
// E_OK If the operation was successful
//
// Note that as hdbIndexUkey can only be applied to data members with a minimun and maximum population of 1, the member cannot be NULL and therefore a NULL
// value to insert is an error.
_hzfunc("hdbIndexUkey::Insert") ;
hzChain Z ; // For writing delta
hzString str ; // String value if applicable
hzDomain dom ; // Domain name if applicable
hzEmaddr ema ; // Email address if applicable
hzUrl url ; // URL
hzEcode rc = E_OK ; // Return code
if (!m_bInit) return E_NOINIT ;
if (atom.IsNull()) return E_NODATA ;
if (atom.Type() != m_eBasetype)
return hzerr(E_TYPE, "Index type %s - supplied value type %s", Basetype2Txt(m_eBasetype), Basetype2Txt(atom.Type())) ;
switch (m_eBasetype)
{
case BASETYPE_DOMAIN: _hzGlobal_setDomains.Insert(atom.Domain()) ;
ema = _hzGlobal_setDomains[atom.Domain()] ;
rc = m_keys.pEma->Insert(ema, objId) ;
break ;
case BASETYPE_EMADDR: _hzGlobal_setEmaddrs.Insert(atom.Emaddr()) ;
ema = _hzGlobal_setEmaddrs[atom.Emaddr()] ;
rc = m_keys.pEma->Insert(ema, objId) ;
break ;
case BASETYPE_STRING: str = atom.Str() ;
if (!_hzGlobal_setStrings.Exists(str))
_hzGlobal_setStrings.Insert(str) ;
str = _hzGlobal_setStrings[str] ;
rc = m_keys.pStr->Insert(str, objId) ;
break ;
case BASETYPE_URL: rc = m_keys.pUrl->Insert(atom.Url(), objId) ; break ;
case BASETYPE_XDATE: rc = m_keys.pXD->Insert(atom.XDate(), objId) ; break ;
case BASETYPE_INT64: rc = m_keys.pSI64->Insert(atom.Int64(), objId) ; break ;
case BASETYPE_UINT64: rc = m_keys.pUI64->Insert(atom.Unt64(), objId) ; break ;
case BASETYPE_IPADDR: rc = m_keys.pIpa->Insert(atom.Ipaddr(), objId) ; break ;
case BASETYPE_TIME: rc = m_keys.pTime->Insert(atom.Time(), objId) ; break ;
case BASETYPE_SDATE: rc = m_keys.pSD->Insert(atom.SDate(), objId) ; break ;
case BASETYPE_INT32: rc = m_keys.pSI32->Insert(atom.Int32(), objId) ; break ;
case BASETYPE_UINT32: rc = m_keys.pUI32->Insert(atom.Unt32(), objId) ; break ;
}
if (rc == E_OK)
{
Z.Printf("@%u:%s\n", objId, atom.Show()) ;
// m_osDelta << Z ;
}
return rc ;
}