Return TypeFunction nameArguments
hzEcodehdbIndexText::Export(const hzString&,bool,)

Declared in file: hzDatabase.h
Defined in file : hdbIndex.cpp

Function Logic:

0:START 1:!filepath 2:Return hzerr(E_ARGUMENT,No pathname for Index Export) 3:ofstream::open ofstream::fail 4:os.fail() 5:Return hzerr(E_OPENFAIL,Cannot open %s,*filepath) 6:nIndex 7:nIndex 8:hzMapS::GetKey word hzMapS::GetObj bm hdbIdset::NoNodes nSegs hdbIdset::Count nInst hdbIdset::NoNodes hdbIdset::Count hzChain::Printf 9:bFull 10:nStart 11:hdbIdset::Fetch nFetched nPosn 12:nPosn 13:hzChain::Printf 14:items hzChain::Clear ofstream::fail 15:os.fail() 16:close 17:Return E_WRITEFAIL 18:hzMapS::Count hzChain::Printf hzChain::Printf hzChain::Printf items close hzChain::Clear 19:Return E_OK

Function body:

hzEcode hdbIndexText::Export (const hzString& filepath, bool bFull)
{
   _hzfunc("hdbIndexText::Export") ;
   hzVect<uint32_t>    res ;
   ofstream    os ;
   hzChain     Z ;
   hdbIdset    bm ;
   hdbIdset    S ;
   hzString    word ;
   uint32_t    nIndex ;
   uint32_t    nStart ;
   uint32_t    nFetched ;
   uint32_t    nPosn ;
   uint32_t    nSegs = 0;
   uint32_t    nInst = 0;
   if (!filepath)
       return hzerr(E_ARGUMENT, "No pathname for Index Export") ;
   os.open(filepath) ;
   if (os.fail())
       return hzerr(E_OPENFAIL, "Cannot open %s", *filepath) ;
   threadLog("Index has:-\n") ;
   for (nIndex = 0; nIndex < m_Keys.Count() ; nIndex++)
   {
       word = m_Keys.GetKey(nIndex) ;
       bm = m_Keys.GetObj(nIndex) ;
       nSegs += bm.NoNodes() ;
       nInst += bm.Count() ;
       Z.Printf("%u %s: s=%u c=%u\n", nIndex, *word, bm.NoNodes(), bm.Count()) ;
       if (bFull)
       {
           for (nStart = 0; nStart < bm.Count() ; nStart += 20)
           {
               nFetched = bm.Fetch(res, nPosn, 20);
               for (nPosn = 0; nPosn < nFetched ; nPosn++)
                   Z.Printf("\t%u", res[nPosn]) ;
           }
       }
       os << Z ;
       Z.Clear() ;
       if (os.fail())
       {
           os.close() ;
           hzerr(E_WRITEFAIL, "Write fail to %s", *filepath) ;
           return E_WRITEFAIL ;
       }
   }
   Z.Printf("\tWords (maps): %d\n", m_Keys.Count()) ;
   Z.Printf("\tSegments:     %d\n", nSegs) ;
   Z.Printf("\tInstances:    %d\n", nInst) ;
   os << Z ;
   os.close() ;
   Z.Clear() ;
   return E_OK ;
}