Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

FieldListDiskBuilder.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 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 //
00014 // FieldListDiskBuilder.hpp
00015 //
00016 // 5 February 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_KEYFILEFIELDLISTDISKBUILDER_HPP
00020 #define INDRI_KEYFILEFIELDLISTDISKBUILDER_HPP
00021 
00022 #include "indri/FieldListDiskBlockWriter.hpp"
00023 
00024 namespace indri {
00025   namespace index {
00026     class FieldListDiskBuilder {
00027     private:
00028       FieldListDiskBlockWriter _block;
00029       WriteBuffer _writeBuffer;
00030 
00031     public:
00032       FieldListDiskBuilder( File& outputStream, int size, bool numeric = false ) :
00033         _writeBuffer(outputStream,size),
00034         _block(numeric)
00035       {
00036       }
00037 
00038       void addExtent( unsigned int documentID, unsigned int begin, unsigned int end, UINT64 number ) {
00039         if( _block.addExtent( documentID, begin, end, number ) )
00040           return;
00041 
00042         flush();
00043         _block.addExtent( documentID, begin, end, number );
00044       }
00045 
00046       void flush() {
00047         _block.close();
00048         if( _block.lastDocument() != 0 )
00049           _writeBuffer.write( _block.data(), _block.dataSize() );
00050         _block.clear();
00051       }
00052 
00053       void close() {
00054         flush();
00055         _writeBuffer.flush();
00056       }
00057     };
00058   }
00059 }
00060 
00061 #endif // INDRI_FIELDLISTDISKBUILDER_HPP

Generated on Wed Nov 3 12:58:55 2004 for Lemur Toolkit by doxygen1.2.18