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

« back to all changes in this revision

Viewing changes to src/CLucene/index/Terms.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_Terms_
8
 
#define _lucene_index_Terms_
9
 
 
10
 
#if defined(_LUCENE_PRAGMA_ONCE)
11
 
# pragma once
12
 
#endif
13
 
 
14
 
#include "Term.h"
15
 
CL_NS_DEF(index)
16
 
 
17
 
class TermEnum; //predefine
18
 
class TermPositions;
19
 
 
20
 
/** TermDocs provides an interface for enumerating <document, frequency>
21
 
 pairs for a term.  <p> The document portion names each document containing
22
 
 the term.  Documents are indicated by number.  The frequency portion gives
23
 
 the number of times the term occurred in each document.  <p> The pairs are
24
 
 ordered by document number.
25
 
 
26
 
 @see IndexReader#termDocs()
27
 
 */
28
 
class TermDocs: LUCENE_BASE {
29
 
public:
30
 
        virtual ~TermDocs(){
31
 
        }
32
 
 
33
 
        // Sets this to the data for a term.
34
 
        // The enumeration is reset to the start of the data for this term.
35
 
        virtual void seek(Term* term)=0;
36
 
 
37
 
        /** Sets this to the data for the current term in a {@link TermEnum}.
38
 
        * This may be optimized in some implementations.
39
 
        */
40
 
        virtual void seek(TermEnum* termEnum)=0;
41
 
 
42
 
        // Returns the current document number.  <p> This is invalid until {@link
43
 
        //      #next()} is called for the first time.
44
 
        virtual int32_t doc() const=0;
45
 
 
46
 
        // Returns the frequency of the term within the current document.  <p> This
47
 
        //      is invalid until {@link #next()} is called for the first time.
48
 
        virtual int32_t freq() const=0;
49
 
 
50
 
        // Moves to the next pair in the enumeration.  <p> Returns true iff there is
51
 
        //      such a next pair in the enumeration.
52
 
        virtual bool next() =0;
53
 
 
54
 
        // Attempts to read multiple entries from the enumeration, up to length of
55
 
        // <i>docs</i>.  Document numbers are stored in <i>docs</i>, and term
56
 
        // frequencies are stored in <i>freqs</i>.  The <i>freqs</i> array must be as
57
 
        // int64_t as the <i>docs</i> array.
58
 
        //
59
 
        // <p>Returns the number of entries read.  Zero is only returned when the
60
 
        // stream has been exhausted.
61
 
        virtual int32_t read(int32_t* docs, int32_t* freqs, int32_t length)=0;
62
 
 
63
 
        // Skips entries to the first beyond the current whose document number is
64
 
        // greater than or equal to <i>target</i>. <p>Returns true iff there is such
65
 
        // an entry.  <p>Behaves as if written: <pre>
66
 
        //   bool skipTo(int32_t target) {
67
 
        //     do {
68
 
        //       if (!next())
69
 
        //           return false;
70
 
        //     } while (target > doc());
71
 
        //     return true;
72
 
        //   }
73
 
        // </pre>
74
 
        // Some implementations are considerably more efficient than that.
75
 
        virtual bool skipTo(const int32_t target)=0;
76
 
 
77
 
        // Frees associated resources.
78
 
        virtual void close() = 0;
79
 
 
80
 
        
81
 
        /** Solve the diamond inheritence problem by providing a reinterpret function.
82
 
    *   No dynamic casting is required and no RTTI data is needed to do this
83
 
    */
84
 
        virtual TermPositions* __asTermPositions()=0;
85
 
};
86
 
 
87
 
 
88
 
// Abstract class for enumerating terms.
89
 
//
90
 
//<p>Term enumerations are always ordered by Term.compareTo().  Each term in
91
 
//the enumeration is greater than all that precede it.  
92
 
class TermEnum: LUCENE_BASE {
93
 
public:
94
 
        // Increments the enumeration to the next element.  True if one exists.
95
 
        virtual bool next()=0;
96
 
 
97
 
        // Returns a pointer to the current Term in the enumeration.
98
 
        virtual Term* term()=0;
99
 
        
100
 
        // Returns the current Term in the enumeration.
101
 
        virtual Term* term(bool pointer){
102
 
                Term* ret = term();
103
 
                if ( !pointer )
104
 
                        ret->__cl_decref();
105
 
                return ret;
106
 
        }
107
 
 
108
 
        // Returns the docFreq of the current Term in the enumeration.
109
 
        virtual int32_t docFreq() const=0;
110
 
 
111
 
        // Closes the enumeration to further activity, freeing resources.
112
 
        virtual void close() =0;
113
 
 
114
 
        virtual ~TermEnum(){
115
 
        }
116
 
        
117
 
        // Term Vector support
118
 
        /** Skips terms to the first beyond the current whose value is
119
 
        * greater or equal to <i>target</i>. <p>Returns true iff there is such
120
 
        * an entry.  <p>Behaves as if written: <pre>
121
 
        *   public boolean skipTo(Term target) {
122
 
        *     do {
123
 
        *       if (!next())
124
 
        *            return false;
125
 
        *     } while (target > term());
126
 
        *     return true;
127
 
        *   }
128
 
        * </pre>
129
 
        * Some implementations are considerably more efficient than that.
130
 
        */
131
 
        virtual bool skipTo(Term* target){
132
 
                do {
133
 
                        if (!next())
134
 
                                return false;
135
 
                } while (target->compareTo(term(false)) > 0);
136
 
                return true;
137
 
        }
138
 
 
139
 
        /**
140
 
        * Because we need to know how to cast the object, we need the objects name.
141
 
        */
142
 
        virtual const char* getObjectName() = 0;
143
 
};
144
 
 
145
 
 
146
 
 
147
 
/**
148
 
 * TermPositions provides an interface for enumerating the &lt;document,
149
 
 * frequency, &lt;position&gt;* &gt; tuples for a term.  <p> The document and
150
 
 * frequency are the same as for a TermDocs.  The positions portion lists the ordinal
151
 
 * positions of each occurrence of a term in a document.
152
 
 *
153
 
 * @see IndexReader#termPositions()
154
 
 */
155
 
class TermPositions: public virtual TermDocs {
156
 
public:
157
 
        // Returns next position in the current document.  It is an error to call
158
 
        //      this more than {@link #freq()} times
159
 
        //      without calling {@link #next()}<p> This is
160
 
        //      invalid until {@link #next()} is called for
161
 
        //      the first time.
162
 
        virtual int32_t nextPosition() = 0;
163
 
 
164
 
        virtual ~TermPositions(){
165
 
        }
166
 
 
167
 
        /** Solve the diamond inheritence problem by providing a reinterpret function.
168
 
          *     No dynamic casting is required and no RTTI data is needed to do this
169
 
          */
170
 
        virtual TermDocs* __asTermDocs()=0;
171
 
        virtual TermPositions* __asTermPositions()=0;
172
 
};
173
 
CL_NS_END
174
 
#endif