Output list of words and associated idsets to the supplied filepath. The output is human radable for diagnostic purposes
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | hdbIndexText::Export | (hzString&,bool,) |
Declared in file: hzDatabase.h
Defined in file : hdbIndex.cpp
Function Logic:
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 ;
}