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 
2 // Copyright (c) 2009-2014 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 public:
32  BooleanScorer(const SimilarityPtr& similarity, int32_t minNrShouldMatch, Collection<ScorerPtr> optionalScorers, Collection<ScorerPtr> prohibitedScorers);
33  virtual ~BooleanScorer();
34 
36 
37 protected:
40  int32_t maxCoord;
42  int32_t requiredMask;
43  int32_t prohibitedMask;
44  int32_t nextMask;
46  int32_t end;
48  int32_t doc;
49 
50 protected:
51  // firstDocID is ignored since nextDoc() initializes 'current'
52  virtual bool score(const CollectorPtr& collector, int32_t max, int32_t firstDocID);
53 
54 public:
55  virtual int32_t advance(int32_t target);
56  virtual int32_t docID();
57  virtual int32_t nextDoc();
58  virtual double score();
59  virtual void score(const CollectorPtr& collector);
60  virtual String toString();
61 };
62 
64 public:
65  BooleanScorerCollector(int32_t mask, const BucketTablePtr& bucketTable);
66  virtual ~BooleanScorerCollector();
67 
69 
70 protected:
72  int32_t mask;
74 
75 public:
76  virtual void collect(int32_t doc);
77  virtual void setNextReader(const IndexReaderPtr& reader, int32_t docBase);
78  virtual void setScorer(const ScorerPtr& scorer);
79  virtual bool acceptsDocsOutOfOrder();
80 };
81 
82 // An internal class which is used in score(Collector, int32_t) for setting the current score. This is required
83 // since Collector exposes a setScorer method and implementations that need the score will call scorer->score().
84 // Therefore the only methods that are implemented are score() and doc().
85 class BucketScorer : public Scorer {
86 public:
87  BucketScorer();
88  virtual ~BucketScorer();
89 
91 
92 public:
93  double _score;
94  int32_t doc;
95 
96 public:
97  virtual int32_t advance(int32_t target);
98  virtual int32_t docID();
99  virtual int32_t nextDoc();
100  virtual double score();
101 };
102 
103 class Bucket : public LuceneObject {
104 public:
105  Bucket();
106  virtual ~Bucket();
107 
109 
110 public:
111  int32_t doc; // tells if bucket is valid
112  double score; // incremental score
113  int32_t bits; // used for bool constraints
114  int32_t coord; // count of terms in score
115  BucketWeakPtr _next; // next valid bucket
116 };
117 
119 class BucketTable : public LuceneObject {
120 public:
121  BucketTable();
122  virtual ~BucketTable();
123 
125 
126 public:
127  static const int32_t SIZE;
128  static const int32_t MASK;
129 
131  BucketPtr first; // head of valid list
132 
133 public:
134  CollectorPtr newCollector(int32_t mask);
135  int32_t size();
136 };
137 
138 class SubScorer : public LuceneObject {
139 public:
141  virtual ~SubScorer();
142 
144 
145 public:
147  bool required;
151 };
152 
153 }
154 
155 #endif

clucene.sourceforge.net