Lucene++ - a full-featured, c++ search engine
API Documentation


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
BooleanScorer.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef BOOLEANSCORER_H
8 #define BOOLEANSCORER_H
9 
10 #include "Scorer.h"
11 #include "Collector.h"
12 
13 namespace Lucene
14 {
30  class BooleanScorer : public Scorer
31  {
32  public:
34  virtual ~BooleanScorer();
35 
37 
38  protected:
41  int32_t maxCoord;
43  int32_t requiredMask;
44  int32_t prohibitedMask;
45  int32_t nextMask;
47  int32_t end;
49  int32_t doc;
50 
51  protected:
52  // firstDocID is ignored since nextDoc() initializes 'current'
53  virtual bool score(CollectorPtr collector, int32_t max, int32_t firstDocID);
54 
55  public:
56  virtual int32_t advance(int32_t target);
57  virtual int32_t docID();
58  virtual int32_t nextDoc();
59  virtual double score();
60  virtual void score(CollectorPtr collector);
61  virtual String toString();
62  };
63 
65  {
66  public:
67  BooleanScorerCollector(int32_t mask, BucketTablePtr bucketTable);
68  virtual ~BooleanScorerCollector();
69 
71 
72  protected:
74  int32_t mask;
76 
77  public:
78  virtual void collect(int32_t doc);
79  virtual void setNextReader(IndexReaderPtr reader, int32_t docBase);
80  virtual void setScorer(ScorerPtr scorer);
81  virtual bool acceptsDocsOutOfOrder();
82  };
83 
84  // An internal class which is used in score(Collector, int32_t) for setting the current score. This is required
85  // since Collector exposes a setScorer method and implementations that need the score will call scorer->score().
86  // Therefore the only methods that are implemented are score() and doc().
87  class BucketScorer : public Scorer
88  {
89  public:
90  BucketScorer();
91  virtual ~BucketScorer();
92 
94 
95  public:
96  double _score;
97  int32_t doc;
98 
99  public:
100  virtual int32_t advance(int32_t target);
101  virtual int32_t docID();
102  virtual int32_t nextDoc();
103  virtual double score();
104  };
105 
106  class Bucket : public LuceneObject
107  {
108  public:
109  Bucket();
110  virtual ~Bucket();
111 
113 
114  public:
115  int32_t doc; // tells if bucket is valid
116  double score; // incremental score
117  int32_t bits; // used for bool constraints
118  int32_t coord; // count of terms in score
119  BucketWeakPtr _next; // next valid bucket
120  };
121 
123  class BucketTable : public LuceneObject
124  {
125  public:
126  BucketTable();
127  virtual ~BucketTable();
128 
130 
131  public:
132  static const int32_t SIZE;
133  static const int32_t MASK;
134 
136  BucketPtr first; // head of valid list
137 
138  public:
139  CollectorPtr newCollector(int32_t mask);
140  int32_t size();
141  };
142 
143  class SubScorer : public LuceneObject
144  {
145  public:
147  virtual ~SubScorer();
148 
150 
151  public:
153  bool required;
157  };
158 }
159 
160 #endif

clucene.sourceforge.net