Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

DeletedDocumentList.hpp

Go to the documentation of this file.
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 // DeletedDocumentList
00014 //
00015 // 3 February 2005 -- tds
00016 //
00017 // While vector<bool> might have been a nice clean choice for this
00018 // bitmap, there was no platform-independent way to just blit it
00019 // to disk.  I decided to roll my own using a Buffer.
00020 //
00021 
00022 #ifndef INDRI_DELETEDDOCUMENTLIST_HPP
00023 #define INDRI_DELETEDDOCUMENTLIST_HPP
00024 
00025 #include <vector>
00026 #include "indri/ReadersWritersLock.hpp"
00027 #include "indri/ReaderLockable.hpp"
00028 #include "indri/WriterLockable.hpp"
00029 #include "indri/Buffer.hpp"
00030 #include "IndexTypes.hpp"
00031 
00032 namespace indri
00033 {
00034   namespace index
00035   {
00036     
00037     class DeletedDocumentList {
00038     private:
00039       bool _modified;
00040       indri::thread::ReadersWritersLock _lock;
00041       indri::thread::ReaderLockable _readLock;
00042       indri::thread::WriterLockable _writeLock;
00043       UINT64 _deletedCount;
00044 
00045       indri::utility::Buffer _bitmap;
00046       void _grow( lemur::api::DOCID_T documentID );
00047       void _calculateDeletedCount();
00048 
00049     public:
00050       class read_transaction {
00051       private:
00052         indri::thread::ReadersWritersLock& _lock;
00053         indri::utility::Buffer& _bitmap;
00054 
00055       public:
00056         read_transaction( DeletedDocumentList& list );
00057         ~read_transaction();
00058 
00059         lemur::api::DOCID_T nextCandidateDocument( lemur::api::DOCID_T documentID );
00060         bool isDeleted( lemur::api::DOCID_T documentID ) const;
00061       };
00062 
00063       DeletedDocumentList();
00064 
00065       void append( DeletedDocumentList& other, int documentCount );
00066       void markDeleted( lemur::api::DOCID_T documentID );
00067       bool isDeleted( lemur::api::DOCID_T documentID );
00068       UINT64 deletedCount() const;
00069       read_transaction* getReadTransaction();
00070 
00071       void read( const std::string& filename );
00072       void write( const std::string& filename );
00073     };
00074   }
00075 }
00076 
00077 #endif // INDRI_DELETEDDOCUMENTLIST_HPP
00078 
00079 

Generated on Tue Jun 15 11:02:53 2010 for Lemur by doxygen 1.3.4