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
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
35
LUCENE_CLASS
(
BooleanScorer
);
36
37
protected
:
38
SubScorerPtr
scorers
;
39
BucketTablePtr
bucketTable
;
40
int32_t
maxCoord
;
41
Collection<double>
coordFactors
;
42
int32_t
requiredMask
;
43
int32_t
prohibitedMask
;
44
int32_t
nextMask
;
45
int32_t
minNrShouldMatch
;
46
int32_t
end
;
47
BucketPtr
current
;
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
63
class
BooleanScorerCollector
:
public
Collector
{
64
public
:
65
BooleanScorerCollector
(int32_t
mask
,
const
BucketTablePtr
& bucketTable);
66
virtual
~BooleanScorerCollector
();
67
68
LUCENE_CLASS
(
BooleanScorerCollector
);
69
70
protected
:
71
BucketTableWeakPtr
_bucketTable
;
72
int32_t
mask
;
73
ScorerWeakPtr
_scorer
;
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
90
LUCENE_CLASS
(
BucketScorer
);
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
108
LUCENE_CLASS
(
Bucket
);
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
124
LUCENE_CLASS
(
BucketTable
);
125
126
public
:
127
static
const
int32_t
SIZE
;
128
static
const
int32_t
MASK
;
129
130
Collection<BucketPtr>
buckets
;
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
:
140
SubScorer
(
const
ScorerPtr
&
scorer
,
bool
required
,
bool
prohibited
,
const
CollectorPtr
&
collector
,
const
SubScorerPtr
&
next
);
141
virtual
~SubScorer
();
142
143
LUCENE_CLASS
(
SubScorer
);
144
145
public
:
146
ScorerPtr
scorer
;
147
bool
required
;
148
bool
prohibited
;
149
CollectorPtr
collector
;
150
SubScorerPtr
next
;
151
};
152
153
}
154
155
#endif
clucene.sourceforge.net