IndexReaderPtr Index::acquireReader(bool bRefresh) { if ((m_accessMode != READ) && (m_accessMode != RDWR)) { FX_LOG(INFO, _T("The access mode is WRITE or APPEND, " "can't aquire reader of the index")); return IndexReaderPtr(); } if (bRefresh) { CommitList commits; commits.load(m_pFileSys); commitid_t lastCommit = commits.getLastCommit(); commitid_t curCommit = m_pReader->getBarrelsInfo()->getCommitId(); if (lastCommit > curCommit) { m_pIndexBarrelKeeper->refresh(); IndexReaderPtr pNewReader(m_pReader->clone()); pNewReader->reopen(); ScopedRWLock lock(m_lock, true); m_pReader = pNewReader; pNewReader.reset(); if (m_pIndexBarrelKeeper->getHeldCommitCount() >= 2) { m_pIndexBarrelKeeper->housekeep(); } return m_pReader; } if (lastCommit < curCommit) { FIRTEX_THROW(IndexCollapseException, "Invalid commit id: " "current commit: [%d], last comit: [%d]", curCommit, lastCommit); } } ScopedRWLock lock(m_lock, false); return m_pReader; }
IndexReaderPtr IndexReader::reopen() { SyncLock syncLock(this); boost::throw_exception(UnsupportedOperationException(L"This reader does not support reopen().")); return IndexReaderPtr(); }