Files

51 lines
1.7 KiB
C
Raw Permalink Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Jun 2001
// . IndexList is a list of keys
// . some keys are 12 bytes, some are 6 bytes (compressed)
// . see Indexdb.h for format of the keys
// . you can set from a TitleRec/SiteRec pair
// . you can set from a TermTable
// . we use this class to generate the final indexList for a parsed document
// . we have to do some #include's in the .cpp cuz the TitleRec contains an
// IndexList for holding indexed link Text
// . the TermTable has an addIndexList() function
// . we map 32bit scores from a TermTable to 8bits scores by taking the log
// of the score if it's >= 128*256, otherwise, we keep it as is
// override all funcs in RdbList where m_useShortKeys is true...
// skipCurrentRec() etc need to use m_useHalfKeys in RdbList cuz
// that is needed by many generic routines, like merge_r, RdbMap, Msg1, Msg22..
// We would need to make it a virtual function which would slow things down...
// or make those classes have specialized functions for IndexLists... in
// addition to the RdbLists they already support
2016-03-08 22:14:30 +01:00
#ifndef GB_INDEXLIST_H
#define GB_INDEXLIST_H
2013-08-02 13:12:24 -07:00
#include "RdbList.h"
2016-03-03 21:57:28 +01:00
#include "Titledb.h"
2013-08-02 13:12:24 -07:00
class IndexList : public RdbList {
public:
// these 2 assume 12 and 6 byte keys respectively
2014-10-30 13:36:39 -06:00
int64_t getCurrentDocId () {
2013-08-02 13:12:24 -07:00
if ( isHalfBitOn ( m_listPtr ) ) return getDocId6 (m_listPtr);
else return getDocId12(m_listPtr);
2016-05-19 18:37:26 +02:00
}
2014-10-30 13:36:39 -06:00
int64_t getDocId12 ( char *rec ) {
2016-05-19 18:37:26 +02:00
return ((*(uint64_t *)(rec)) >> 2) & DOCID_MASK; }
2014-10-30 13:36:39 -06:00
int64_t getDocId6 ( char *rec ) {
int64_t docid;
*(int32_t *)(&docid) = *(int32_t *)(void*)rec;
2013-08-02 13:12:24 -07:00
((char *)&docid)[4] = rec[4];
docid >>= 2;
return docid & DOCID_MASK;
2016-05-19 18:37:26 +02:00
}
2013-08-02 13:12:24 -07:00
};
2016-03-08 22:14:30 +01:00
#endif // GB_INDEXLIST_H