00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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