00001 /*========================================================================== 00002 * Copyright (c) 2005 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.lemurproject.org/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 // 00013 // DiskKeyfileVocabularyIterator 00014 // 00015 // 20 January 2005 -- tds 00016 // 00017 00018 #ifndef INDRI_DISKKEYFILEVOCABULARYITERATOR_HPP 00019 #define INDRI_DISKKEYFILEVOCABULARYITERATOR_HPP 00020 00021 #include "indri/DiskTermData.hpp" 00022 #include "Keyfile.hpp" 00023 #include "indri/VocabularyIterator.hpp" 00024 #include "indri/Mutex.hpp" 00025 #include "indri/BulkTree.hpp" 00026 00027 namespace indri { 00028 namespace index { 00029 class DiskKeyfileVocabularyIterator : public VocabularyIterator { 00030 private: 00031 DiskTermData* _diskTermData; 00032 int _baseID; 00033 indri::file::BulkTreeReader& _bulkTree; 00034 indri::file::BulkTreeIterator* _bulkIterator; 00035 int _fieldCount; 00036 00037 char _termString[1024]; 00038 00039 indri::utility::Buffer _compressedData; 00040 indri::utility::Buffer _decompressedData; 00041 00042 indri::thread::Mutex& _mutex; 00043 bool _holdingLock; 00044 bool _finished; 00045 00046 void _acquire(); 00047 void _release(); 00048 bool _readData(); 00049 00050 // this tells us if the last nextEntry() came from 00051 // a start iteration or not - needed for nextEntry(const char*) 00052 // call 00053 bool _justStartedIteration; 00054 00055 public: 00056 DiskKeyfileVocabularyIterator( int baseID, indri::file::BulkTreeReader& bulkTree, indri::thread::Mutex& mutex, int fieldCount ); 00057 ~DiskKeyfileVocabularyIterator(); 00058 00059 void startIteration(); 00060 bool nextEntry(); 00061 bool nextEntry(const char *skipTo); 00062 indri::index::DiskTermData* currentEntry(); 00063 bool finished(); 00064 }; 00065 } 00066 } 00067 00068 #endif // INDRI_DISKKEYFILEVOCABULARYITERATOR_HPP 00069