mirror of
https://github.com/privacore/open-source-search-engine.git
synced 2025-04-27 15:49:32 -04:00
Cater for newly dumped file in a different way while merging list
This commit is contained in:
parent
eee0725843
commit
b691937dd4
@ -5,13 +5,15 @@
|
||||
RdbIndexQuery::RdbIndexQuery(RdbBase *base)
|
||||
: RdbIndexQuery(base ? (base->getGlobalIndex() ? base->getGlobalIndex() : docidsconst_ptr_t()) : docidsconst_ptr_t(),
|
||||
base ? (base->getTreeIndex() ? base->getTreeIndex()->getDocIds() : docidsconst_ptr_t()) : docidsconst_ptr_t(),
|
||||
base ? base->getNumFiles() : 0) {
|
||||
base ? base->getNumFiles() : 0,
|
||||
base ? base->hasPendingGlobalIndexJob() : false) {
|
||||
}
|
||||
|
||||
RdbIndexQuery::RdbIndexQuery(docidsconst_ptr_t globalIndexData, docidsconst_ptr_t treeIndexData, int32_t numFiles)
|
||||
RdbIndexQuery::RdbIndexQuery(docidsconst_ptr_t globalIndexData, docidsconst_ptr_t treeIndexData, int32_t numFiles, bool hasPendingGlobalIndexJob)
|
||||
: m_globalIndexData(globalIndexData)
|
||||
, m_treeIndexData(treeIndexData)
|
||||
, m_numFiles(numFiles) {
|
||||
, m_numFiles(numFiles)
|
||||
, m_hasPendingGlobalIndexJob(hasPendingGlobalIndexJob) {
|
||||
}
|
||||
|
||||
RdbIndexQuery::~RdbIndexQuery() {
|
||||
|
@ -15,6 +15,7 @@ public:
|
||||
bool documentIsInFile(uint64_t docId, int32_t filenum) const;
|
||||
|
||||
int32_t getNumFiles() const { return m_numFiles; }
|
||||
bool hasPendingGlobalIndexJob() const { return m_hasPendingGlobalIndexJob; }
|
||||
|
||||
void printIndex() const;
|
||||
|
||||
@ -23,11 +24,12 @@ private:
|
||||
RdbIndexQuery(const RdbIndexQuery&);
|
||||
RdbIndexQuery& operator=(const RdbIndexQuery&);
|
||||
|
||||
RdbIndexQuery(docidsconst_ptr_t globalIndexData, docidsconst_ptr_t treeIndexData, int32_t numFiles);
|
||||
RdbIndexQuery(docidsconst_ptr_t globalIndexData, docidsconst_ptr_t treeIndexData, int32_t numFiles, bool hasPendingGlobalIndexJob);
|
||||
|
||||
docidsconst_ptr_t m_globalIndexData;
|
||||
docidsconst_ptr_t m_treeIndexData;
|
||||
int32_t m_numFiles;
|
||||
bool m_hasPendingGlobalIndexJob;
|
||||
};
|
||||
|
||||
#endif // GB_RDBINDEXQUERY_H
|
||||
|
@ -2228,8 +2228,6 @@ bool RdbList::posdbMerge_r(RdbList **lists, int32_t numLists, const char *startK
|
||||
// set the ptrs that are non-empty
|
||||
int32_t n = 0;
|
||||
|
||||
int32_t endFileIndex = startFileIndex + numLists;
|
||||
|
||||
// convenience ptr
|
||||
for (int32_t i = 0; i < numLists; i++) {
|
||||
logTrace(g_conf.m_logTraceRdbList, "===== dumping list #%" PRId32" =====", i);
|
||||
@ -2369,14 +2367,15 @@ bool RdbList::posdbMerge_r(RdbList **lists, int32_t numLists, const char *startK
|
||||
bool found = false;
|
||||
|
||||
// check rdb index
|
||||
for (auto i = endFileIndex - 1; i >= filePos; --i) {
|
||||
for (auto i = rdbIndexQuery.getNumFiles() - 1; i >= filePos; --i) {
|
||||
RdbIndex *index = base->getIndex(i);
|
||||
if (!index) {
|
||||
gbshutdownCorrupted();
|
||||
}
|
||||
|
||||
if (index->exist(docId)) {
|
||||
if (i != filePos) {
|
||||
// cater for newly dumped file that are not in global index
|
||||
if (i != filePos && !rdbIndexQuery.hasPendingGlobalIndexJob() && i != (rdbIndexQuery.getNumFiles() - 1)) {
|
||||
// docId found in newer file
|
||||
gbshutdownCorrupted();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user