Return Type | Function name | Arguments |
---|---|---|
hzEcode | hdbIndexText::Export | (const hzString&,bool,) |
Declared in file: hzDatabase.h
Defined in file : hdbIndex.cpp
Function Logic:
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 ; }