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


Loading...
Searching...
No Matches
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
13namespace Lucene {
14
30class LPPAPI BooleanScorer : public Scorer {
31public:
32 BooleanScorer(const SimilarityPtr& similarity, int32_t minNrShouldMatch, Collection<ScorerPtr> optionalScorers, Collection<ScorerPtr> prohibitedScorers);
33 virtual ~BooleanScorer();
34
36
37
38protected:
41 int32_t maxCoord;
43 int32_t requiredMask;
45 int32_t nextMask;
47 int32_t end;
49 Bucket* __current = nullptr;
50 int32_t doc;
51
52protected:
53 // firstDocID is ignored since nextDoc() initializes 'current'
54 virtual bool score(const CollectorPtr& collector, int32_t max, int32_t firstDocID);
55
56public:
57 virtual int32_t advance(int32_t target);
58 virtual int32_t docID();
59 virtual int32_t nextDoc();
60 virtual double score();
61 virtual void score(const CollectorPtr& collector);
62 virtual String toString();
63
64};
65
67public:
68 BooleanScorerCollector(int32_t mask, const BucketTablePtr& bucketTable);
70
72
73protected:
76 int32_t mask;
78 Scorer* __scorer = nullptr;
79
80public:
81 virtual void collect(int32_t doc);
82 virtual void setNextReader(const IndexReaderPtr& reader, int32_t docBase);
83 virtual void setScorer(const ScorerPtr& scorer);
84 virtual bool acceptsDocsOutOfOrder();
85};
86
87// An internal class which is used in score(Collector, int32_t) for setting the current score. This is required
88// since Collector exposes a setScorer method and implementations that need the score will call scorer->score().
89// Therefore the only methods that are implemented are score() and doc().
90class BucketScorer : public Scorer {
91public:
93 virtual ~BucketScorer();
94
95
96 int32_t freq;
98 float termFreq(){
99 return freq;
100 }
101
102
103public:
104 double _score;
105 int32_t doc;
106
107public:
108 virtual int32_t advance(int32_t target);
109 virtual int32_t docID();
110 virtual int32_t nextDoc();
111 virtual double score();
112};
113
114class Bucket : public LuceneObject {
115public:
117 virtual ~Bucket();
118
120
121public:
122 int32_t doc; // tells if bucket is valid
123 double score; // incremental score
124 int32_t bits; // used for bool constraints
125 int32_t coord; // count of terms in score
126 BucketWeakPtr _next; // next valid bucket
127 Bucket* __next = nullptr; // next valid bucket
128};
129
131class BucketTable : public LuceneObject {
132public:
134 virtual ~BucketTable();
135
137
138public:
139 static const int32_t SIZE;
140 static const int32_t MASK;
141
143 BucketPtr first; // head of valid list
144 Bucket* __first = nullptr; // head of valid list
145
146public:
148 int32_t size();
149};
150
165
166}
167
168#endif
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Definition BooleanScorer.h:66
virtual void collect(int32_t doc)
Called once for every document matching a query, with the unbased document number.
Scorer * __scorer
Definition BooleanScorer.h:78
int32_t mask
Definition BooleanScorer.h:76
virtual void setScorer(const ScorerPtr &scorer)
Called before successive calls to collect(int32_t). Implementations that need the score of the curren...
BooleanScorerCollector(int32_t mask, const BucketTablePtr &bucketTable)
virtual bool acceptsDocsOutOfOrder()
Return true if this collector does not require the matching docIDs to be delivered in int sort order ...
ScorerWeakPtr _scorer
Definition BooleanScorer.h:77
virtual void setNextReader(const IndexReaderPtr &reader, int32_t docBase)
Called before collecting from each IndexReader. All doc ids in collect(int32_t) will correspond to re...
BucketTableWeakPtr _bucketTable
Definition BooleanScorer.h:74
BucketTable * __bucketTable
Definition BooleanScorer.h:75
BooleanScorer uses a ~16k array to score windows of docs. So it scores docs 0-16k first,...
Definition BooleanScorer.h:30
Collection< double > coordFactors
Definition BooleanScorer.h:42
virtual int32_t nextDoc()
Advances to the next document in the set and returns the doc it is currently on, or NO_MORE_DOCS if t...
SubScorerPtr scorers
Definition BooleanScorer.h:39
int32_t maxCoord
Definition BooleanScorer.h:41
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
virtual bool score(const CollectorPtr &collector, int32_t max, int32_t firstDocID)
Collects matching documents in a range. Hook for optimization. Note, firstDocID is added to ensure th...
BucketTablePtr bucketTable
Definition BooleanScorer.h:40
int32_t minNrShouldMatch
Definition BooleanScorer.h:46
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target....
BooleanScorer(const SimilarityPtr &similarity, int32_t minNrShouldMatch, Collection< ScorerPtr > optionalScorers, Collection< ScorerPtr > prohibitedScorers)
int32_t requiredMask
Definition BooleanScorer.h:43
int32_t doc
Definition BooleanScorer.h:50
int32_t nextMask
Definition BooleanScorer.h:45
virtual String toString()
Returns a string representation of the object.
int32_t end
Definition BooleanScorer.h:47
BucketPtr current
Definition BooleanScorer.h:48
virtual void score(const CollectorPtr &collector)
Scores and collects all matching documents.
int32_t prohibitedMask
Definition BooleanScorer.h:44
virtual int32_t docID()
Returns the following:
Definition BooleanScorer.h:90
virtual int32_t docID()
Returns the following:
virtual int32_t nextDoc()
Advances to the next document in the set and returns the doc it is currently on, or NO_MORE_DOCS if t...
float termFreq()
Definition BooleanScorer.h:98
virtual double score()
Returns the score of the current document matching the query. Initially invalid, until nextDoc() or a...
int32_t freq
Definition BooleanScorer.h:96
double _score
Definition BooleanScorer.h:104
virtual int32_t advance(int32_t target)
Advances to the first beyond the current whose document number is greater than or equal to target....
int32_t doc
Definition BooleanScorer.h:105
A simple hash table of document scores within a range.
Definition BooleanScorer.h:131
Collection< BucketPtr > buckets
Definition BooleanScorer.h:142
BucketPtr first
Definition BooleanScorer.h:143
static const int32_t SIZE
Definition BooleanScorer.h:139
virtual ~BucketTable()
CollectorPtr newCollector(int32_t mask)
Bucket * __first
Definition BooleanScorer.h:144
static const int32_t MASK
Definition BooleanScorer.h:140
Definition BooleanScorer.h:114
Bucket * __next
Definition BooleanScorer.h:127
virtual ~Bucket()
double score
Definition BooleanScorer.h:123
int32_t bits
Definition BooleanScorer.h:124
BucketWeakPtr _next
Definition BooleanScorer.h:126
int32_t doc
Definition BooleanScorer.h:122
int32_t coord
Definition BooleanScorer.h:125
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Collectors are primarily meant to be used to gather raw results from a search, and implement sorting ...
Definition Collector.h:100
Base class for all Lucene classes.
Definition LuceneObject.h:31
Common scoring functionality for different types of queries.
Definition Scorer.h:33
Definition BooleanScorer.h:151
virtual ~SubScorer()
CollectorPtr collector
Definition BooleanScorer.h:162
bool required
Definition BooleanScorer.h:160
SubScorer(const ScorerPtr &scorer, bool required, bool prohibited, const CollectorPtr &collector, const SubScorerPtr &next)
SubScorerPtr next
Definition BooleanScorer.h:163
ScorerPtr scorer
Definition BooleanScorer.h:159
bool prohibited
Definition BooleanScorer.h:161
Definition AbstractAllTermDocs.h:12
boost::shared_ptr< Similarity > SimilarityPtr
Definition LuceneTypes.h:435
boost::weak_ptr< Bucket > BucketWeakPtr
Definition LuceneTypes.h:284
boost::shared_ptr< Collector > CollectorPtr
Definition LuceneTypes.h:295
boost::weak_ptr< Scorer > ScorerWeakPtr
Definition LuceneTypes.h:429
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
boost::shared_ptr< Scorer > ScorerPtr
Definition LuceneTypes.h:429
boost::shared_ptr< SubScorer > SubScorerPtr
Definition LuceneTypes.h:462
boost::weak_ptr< BucketTable > BucketTableWeakPtr
Definition LuceneTypes.h:286
boost::shared_ptr< BucketTable > BucketTablePtr
Definition LuceneTypes.h:286
boost::shared_ptr< Bucket > BucketPtr
Definition LuceneTypes.h:284

clucene.sourceforge.net