Lucene++ - a full-featured, c++ search engine
API Documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
include
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
:
33
BooleanScorer
(
SimilarityPtr
similarity
, int32_t
minNrShouldMatch
,
Collection<ScorerPtr>
optionalScorers,
Collection<ScorerPtr>
prohibitedScorers);
34
virtual
~BooleanScorer
();
35
36
LUCENE_CLASS
(
BooleanScorer
);
37
38
protected
:
39
SubScorerPtr
scorers
;
40
BucketTablePtr
bucketTable
;
41
int32_t
maxCoord
;
42
Collection<double>
coordFactors
;
43
int32_t
requiredMask
;
44
int32_t
prohibitedMask
;
45
int32_t
nextMask
;
46
int32_t
minNrShouldMatch
;
47
int32_t
end
;
48
BucketPtr
current
;
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
64
class
BooleanScorerCollector
:
public
Collector
65
{
66
public
:
67
BooleanScorerCollector
(int32_t
mask
,
BucketTablePtr
bucketTable);
68
virtual
~BooleanScorerCollector
();
69
70
LUCENE_CLASS
(
BooleanScorerCollector
);
71
72
protected
:
73
BucketTableWeakPtr
_bucketTable
;
74
int32_t
mask
;
75
ScorerWeakPtr
_scorer
;
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
93
LUCENE_CLASS
(
BucketScorer
);
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
112
LUCENE_CLASS
(
Bucket
);
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
129
LUCENE_CLASS
(
BucketTable
);
130
131
public
:
132
static
const
int32_t
SIZE
;
133
static
const
int32_t
MASK
;
134
135
Collection<BucketPtr>
buckets
;
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
:
146
SubScorer
(
ScorerPtr
scorer
,
bool
required
,
bool
prohibited
,
CollectorPtr
collector
,
SubScorerPtr
next
);
147
virtual
~SubScorer
();
148
149
LUCENE_CLASS
(
SubScorer
);
150
151
public
:
152
ScorerPtr
scorer
;
153
bool
required
;
154
bool
prohibited
;
155
CollectorPtr
collector
;
156
SubScorerPtr
next
;
157
};
158
}
159
160
#endif
clucene.sourceforge.net