~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/CLucene/index/SegmentInfos.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*------------------------------------------------------------------------------
2
 
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
3
 
4
 
* Distributable under the terms of either the Apache License (Version 2.0) or 
5
 
* the GNU Lesser General Public License, as specified in the COPYING file.
6
 
------------------------------------------------------------------------------*/
7
 
#ifndef _lucene_index_SegmentInfos_
8
 
#define _lucene_index_SegmentInfos_
9
 
 
10
 
#if defined(_LUCENE_PRAGMA_ONCE)
11
 
# pragma once
12
 
#endif
13
 
 
14
 
#include "CLucene/util/VoidList.h"
15
 
#include "CLucene/store/Directory.h"
16
 
 
17
 
CL_NS_DEF(index)
18
 
 
19
 
        class SegmentInfo :LUCENE_BASE{
20
 
        private:
21
 
                //Directory where the segment resides
22
 
                CL_NS(store)::Directory* dir;           
23
 
        public:
24
 
                ///Gets the Directory where the segment resides
25
 
                CL_NS(store)::Directory* getDir() const{ return dir; } 
26
 
 
27
 
        //Unique name in directory dir
28
 
                char name[CL_MAX_NAME]; 
29
 
                //Number of docs in the segment
30
 
                const int32_t docCount;                                           
31
 
 
32
 
                SegmentInfo(const char* Name, const int32_t DocCount, CL_NS(store)::Directory* Dir);
33
 
 
34
 
                ~SegmentInfo();
35
 
        };
36
 
 
37
 
        typedef CL_NS(util)::CLVector<SegmentInfo*,CL_NS(util)::Deletor::Object<SegmentInfo> > segmentInfosType;
38
 
  //SegmentInfos manages a list of SegmentInfo instances
39
 
  //Each SegmentInfo contains information about a segment in a directory.
40
 
  //
41
 
  //The active segments in the index are stored in the segment info file. 
42
 
  //An index only has a single file in this format, and it is named "segments". 
43
 
  //This lists each segment by name, and also contains the size of each segment.
44
 
  //The format of the file segments is defined as follows:
45
 
  //
46
 
  //                                        SegCount
47
 
  //Segments --> SegCount, <SegName, SegSize>
48
 
  //
49
 
  //SegCount, SegSize --> UInt32
50
 
  //
51
 
  //SegName --> String
52
 
  //
53
 
  //SegName is the name of the segment, and is used as the file name prefix 
54
 
  //for all of the files that compose the segment's index.
55
 
  //
56
 
  //SegSize is the number of documents contained in the segment index. 
57
 
  //
58
 
  //Note:
59
 
  //At http://jakarta.apache.org/lucene/docs/fileformats.html the definition
60
 
  //of all file formats can be found. Note that java lucene currently 
61
 
  //defines Segments as follows:
62
 
  //
63
 
  //Segments --> Format, Version, SegCount, <SegName, SegSize>SegCount
64
 
  //        
65
 
  //Format, SegCount, SegSize --> UInt32        
66
 
  //      
67
 
  //Format and Version have not been implemented yet
68
 
        class SegmentInfos: LUCENE_BASE {
69
 
                /** The file format version, a negative number. */
70
 
                /* Works since counter, the old 1st entry, is always >= 0 */
71
 
                LUCENE_STATIC_CONSTANT(int32_t,FORMAT=-1);
72
 
 
73
 
                /**
74
 
                * counts how often the index has been changed by adding or deleting docs.
75
 
                * starting with the current time in milliseconds forces to create unique version numbers.
76
 
                */
77
 
                int64_t version;
78
 
 
79
 
                segmentInfosType infos;
80
 
                
81
 
        int32_t counter;  // used to name new segments
82
 
                friend class IndexWriter; //allow IndexWriter to use counter
83
 
    public:
84
 
        SegmentInfos(bool deleteMembers=true);
85
 
        ~SegmentInfos();
86
 
 
87
 
                
88
 
                //delete and clears objects 'from' from to 'to'
89
 
                void clearto(size_t to);
90
 
                
91
 
                //count of segment infos
92
 
                int32_t size() const;
93
 
                //add a segment info
94
 
                void add(SegmentInfo* info);
95
 
                //Returns a reference to the i-th SegmentInfo in the list.
96
 
                SegmentInfo* info(int32_t i);
97
 
                
98
 
                /**
99
 
                * version number when this SegmentInfos was generated.
100
 
                */
101
 
                int64_t getVersion() { return version; }
102
 
                
103
 
                static int64_t readCurrentVersion(CL_NS(store)::Directory* directory);
104
 
 
105
 
                  //Reads segments file that resides in directory
106
 
                  void read(CL_NS(store)::Directory* directory);
107
 
 
108
 
          //Writes a new segments file based upon the SegmentInfo instances it manages
109
 
      void write(CL_NS(store)::Directory* directory);
110
 
  };
111
 
CL_NS_END
112
 
#endif