Output list of words and associated idsets to the supplied filepath. The output is human radable for diagnostic purposes

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

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

Function Logic:

0:START 1:unknown 2:Return hzerr(E_ARGUMENT,No pathname for Index Export) 3:items 4:unknown 5:Return hzerr(E_OPENFAIL,Cannot open %s,*filepath) 6:items 7:unknown 8:word bm nSegs nInst items 9:unknown 10:unknown 11:nFetched 12:unknown 13:items 14:items items 15:unknown 16:items items 17:Return E_WRITEFAIL 18:items items items items items items 19:Return E_OK

Function body:

hzEcode hdbIndexText::Export (hzString& filepath)bool bFull, 
{
   //  Output list of words and associated idsets to the supplied filepath. The output is human radable for diagnostic purposes 
   //  
   //  Arguments: 1) Full path of file to dump to
   //     2) Do a full dump (true) or just segments (false)
   //  
   //  Returns: E_ARGUMENT If the filename is not supplied
   //     E_OPENFAIL If the supplied filename cannot be opened
   //     E_WRITEFAIL If there was a write error
   //     E_OK  If the index was dumped to file
   _hzfunc("hdbIndexText::Export") ;
   hzVect<uint32_t>    res ;   //  Results of bitmap Fetch
   ofstream    os ;            //  Output file
   hzChain     Z ;             //  For constructing bitmap export
   hzIntset    bm ;            //  Current word bitmap
   hzIntset    S ;             //  Current segment
   hzString    word ;          //  Current word
   uint32_t    nIndex ;        //  Word/bitmap iterator
   uint32_t    nStart ;        //  Starting position for bitmap Fetch
   uint32_t    nFetched ;      //  Number of ids fetched
   uint32_t    nPosn ;         //  Fetch result iterator
   uint32_t    nSegs = 0;      //  Segment counter
   uint32_t    nInst = 0;      //  Incidence counter
   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 ;
}