You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/10/13 22:31:13 UTC
[lucy-commits] svn commit: r1183075 - in /incubator/lucy/branches/0.2: ./
core/Lucy/Highlight/ core/Lucy/Index/ core/Lucy/Search/ core/LucyX/Search/
perl/lib/Lucy/Docs/Cookbook/ perl/lib/Lucy/Search/ perl/lib/LucyX/Search/
perl/sample/ perl/t/binding/
Author: marvin
Date: Thu Oct 13 20:31:11 2011
New Revision: 1183075
URL: http://svn.apache.org/viewvc?rev=1183075&view=rev
Log:
LUCY-183 Eliminate spurious "extra" query normalization.
Remove Normalize() calls from Compiler constructors. Add a boolean
"subordinate" parameter to Query_Make_Compiler(), and change the contract to
indicate that if it is false, the implmention should invoke Normalize() on the
new Compiler object.
Modified:
incubator/lucy/branches/0.2/ (props changed)
incubator/lucy/branches/0.2/core/Lucy/Highlight/Highlighter.c
incubator/lucy/branches/0.2/core/Lucy/Index/DeletionsWriter.c
incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/Compiler.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/IndexSearcher.c
incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/PolyQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/PolySearcher.c
incubator/lucy/branches/0.2/core/Lucy/Search/Query.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.cfh
incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.c
incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.cfh
incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.c
incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.cfh
incubator/lucy/branches/0.2/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
incubator/lucy/branches/0.2/perl/lib/Lucy/Search/Query.pm
incubator/lucy/branches/0.2/perl/lib/LucyX/Search/Filter.pm
incubator/lucy/branches/0.2/perl/sample/PrefixQuery.pm
incubator/lucy/branches/0.2/perl/t/binding/800-stack.t
Propchange: incubator/lucy/branches/0.2/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 13 20:31:11 2011
@@ -1 +1 @@
-/incubator/lucy/trunk:1148076,1148119,1159913,1164648,1171825
+/incubator/lucy/trunk:1148076,1148119,1159913,1164648,1171825,1183066
Modified: incubator/lucy/branches/0.2/core/Lucy/Highlight/Highlighter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Highlight/Highlighter.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Highlight/Highlighter.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Highlight/Highlighter.c Thu Oct 13 20:31:11 2011
@@ -58,7 +58,8 @@ Highlighter_init(Highlighter *self, Sear
self->searcher = (Searcher*)INCREF(searcher);
self->field = CB_Clone(field);
self->compiler = Query_Make_Compiler(self->query, searcher,
- Query_Get_Boost(self->query));
+ Query_Get_Boost(self->query),
+ false);
self->excerpt_length = excerpt_length;
self->slop = excerpt_length / 3;
self->window_width = excerpt_length + (self->slop * 2);
Modified: incubator/lucy/branches/0.2/core/Lucy/Index/DeletionsWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Index/DeletionsWriter.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Index/DeletionsWriter.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Index/DeletionsWriter.c Thu Oct 13 20:31:11 2011
@@ -274,7 +274,7 @@ DefDelWriter_delete_by_term(DefaultDelet
void
DefDelWriter_delete_by_query(DefaultDeletionsWriter *self, Query *query) {
Compiler *compiler = Query_Make_Compiler(query, (Searcher*)self->searcher,
- Query_Get_Boost(query));
+ Query_Get_Boost(query), false);
uint32_t i, max;
for (i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.c Thu Oct 13 20:31:11 2011
@@ -72,8 +72,13 @@ ANDQuery_equals(ANDQuery *self, Obj *oth
}
Compiler*
-ANDQuery_make_compiler(ANDQuery *self, Searcher *searcher, float boost) {
- return (Compiler*)ANDCompiler_new(self, searcher, boost);
+ANDQuery_make_compiler(ANDQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate) {
+ ANDCompiler *compiler = ANDCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ ANDCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
/**********************************************************************/
@@ -89,7 +94,6 @@ ANDCompiler_init(ANDCompiler *self, ANDQ
float boost) {
PolyCompiler_init((PolyCompiler*)self, (PolyQuery*)parent, searcher,
boost);
- ANDCompiler_Normalize(self);
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/ANDQuery.cfh Thu Oct 13 20:31:11 2011
@@ -35,7 +35,8 @@ class Lucy::Search::ANDQuery inherits Lu
init(ANDQuery *self, VArray *children = NULL);
public incremented Compiler*
- Make_Compiler(ANDQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(ANDQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public incremented CharBuf*
To_String(ANDQuery *self);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/Compiler.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/Compiler.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/Compiler.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/Compiler.cfh Thu Oct 13 20:31:11 2011
@@ -35,7 +35,7 @@ parcel Lucy;
*
* Compiling a Matcher is a two stage process.
*
- * The first stage takes place during the Compiler's constructor, which is
+ * The first stage takes place during the Compiler's construction, which is
* where the Query object meets a L<Searcher|Lucy::Search::Searcher>
* object for the first time. Searchers operate on a specific document
* collection and they can tell you certain statistical information about the
@@ -121,8 +121,8 @@ class Lucy::Search::Compiler inherits Lu
Apply_Norm_Factor(Compiler *self, float factor);
/** Take a newly minted Compiler object and apply query-specific
- * normalization factors. Should be called at or near the end of
- * construction.
+ * normalization factors. Should be invoked by Query subclasses during
+ * Make_Compiler() for top-level nodes.
*
* For a TermQuery, the scoring formula is approximately:
*
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/IndexSearcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/IndexSearcher.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/IndexSearcher.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/IndexSearcher.c Thu Oct 13 20:31:11 2011
@@ -132,7 +132,7 @@ IxSearcher_collect(IndexSearcher *self,
Compiler *compiler = Query_Is_A(query, COMPILER)
? (Compiler*)INCREF(query)
: Query_Make_Compiler(query, (Searcher*)self,
- Query_Get_Boost(query));
+ Query_Get_Boost(query), false);
// Accumulate hits into the Collector.
for (i = 0, max = VA_Get_Size(seg_readers); i < max; i++) {
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.c Thu Oct 13 20:31:11 2011
@@ -103,10 +103,12 @@ LeafQuery_deserialize(LeafQuery *self, I
}
Compiler*
-LeafQuery_make_compiler(LeafQuery *self, Searcher *searcher, float boost) {
+LeafQuery_make_compiler(LeafQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate) {
UNUSED_VAR(self);
UNUSED_VAR(searcher);
UNUSED_VAR(boost);
+ UNUSED_VAR(subordinate);
THROW(ERR, "Can't Make_Compiler() from LeafQuery");
UNREACHABLE_RETURN(Compiler*);
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/LeafQuery.cfh Thu Oct 13 20:31:11 2011
@@ -66,7 +66,8 @@ class Lucy::Search::LeafQuery inherits L
/** Throws an error.
*/
public incremented Compiler*
- Make_Compiler(LeafQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(LeafQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public void
Destroy(LeafQuery *self);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.c Thu Oct 13 20:31:11 2011
@@ -56,8 +56,12 @@ MatchAllQuery_to_string(MatchAllQuery *s
Compiler*
MatchAllQuery_make_compiler(MatchAllQuery *self, Searcher *searcher,
- float boost) {
- return (Compiler*)MatchAllCompiler_new(self, searcher, boost);
+ float boost, bool_t subordinate) {
+ MatchAllCompiler *compiler = MatchAllCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ MatchAllCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
/**********************************************************************/
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/MatchAllQuery.cfh Thu Oct 13 20:31:11 2011
@@ -41,7 +41,8 @@ abstract class Lucy::Search::MatchAllQue
To_String(MatchAllQuery *self);
public incremented Compiler*
- Make_Compiler(MatchAllQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(MatchAllQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
}
class Lucy::Search::MatchAllCompiler
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.c Thu Oct 13 20:31:11 2011
@@ -67,8 +67,13 @@ NOTQuery_equals(NOTQuery *self, Obj *oth
}
Compiler*
-NOTQuery_make_compiler(NOTQuery *self, Searcher *searcher, float boost) {
- return (Compiler*)NOTCompiler_new(self, searcher, boost);
+NOTQuery_make_compiler(NOTQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate) {
+ NOTCompiler *compiler = NOTCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ NOTCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
/**********************************************************************/
@@ -84,7 +89,6 @@ NOTCompiler_init(NOTCompiler *self, NOTQ
float boost) {
PolyCompiler_init((PolyCompiler*)self, (PolyQuery*)parent, searcher,
boost);
- NOTCompiler_Normalize(self);
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/NOTQuery.cfh Thu Oct 13 20:31:11 2011
@@ -51,7 +51,8 @@ class Lucy::Search::NOTQuery inherits Lu
Set_Negated_Query(NOTQuery *self, Query *negated_query);
public incremented Compiler*
- Make_Compiler(NOTQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(NOTQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public incremented CharBuf*
To_String(NOTQuery *self);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.c Thu Oct 13 20:31:11 2011
@@ -57,8 +57,12 @@ NoMatchQuery_to_string(NoMatchQuery *sel
Compiler*
NoMatchQuery_make_compiler(NoMatchQuery *self, Searcher *searcher,
- float boost) {
- return (Compiler*)NoMatchCompiler_new(self, searcher, boost);
+ float boost, bool_t subordinate) {
+ NoMatchCompiler *compiler = NoMatchCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ NoMatchCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
void
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/NoMatchQuery.cfh Thu Oct 13 20:31:11 2011
@@ -61,7 +61,8 @@ class Lucy::Search::NoMatchQuery inherit
To_String(NoMatchQuery *self);
public incremented Compiler*
- Make_Compiler(NoMatchQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(NoMatchQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
}
class Lucy::Search::NoMatchCompiler
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.c Thu Oct 13 20:31:11 2011
@@ -38,8 +38,13 @@ ORQuery_init(ORQuery *self, VArray *chil
}
Compiler*
-ORQuery_make_compiler(ORQuery *self, Searcher *searcher, float boost) {
- return (Compiler*)ORCompiler_new(self, searcher, boost);
+ORQuery_make_compiler(ORQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate) {
+ ORCompiler *compiler = ORCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ ORCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
bool_t
@@ -85,7 +90,6 @@ ORCompiler_init(ORCompiler *self, ORQuer
float boost) {
PolyCompiler_init((PolyCompiler*)self, (PolyQuery*)parent, searcher,
boost);
- ORCompiler_Normalize(self);
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/ORQuery.cfh Thu Oct 13 20:31:11 2011
@@ -37,7 +37,8 @@ class Lucy::Search::ORQuery inherits Luc
init(ORQuery *self, VArray *children = NULL);
public incremented Compiler*
- Make_Compiler(ORQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(ORQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public incremented CharBuf*
To_String(ORQuery *self);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.c Thu Oct 13 20:31:11 2011
@@ -125,7 +125,7 @@ PhraseQuery_to_string(PhraseQuery *self)
Compiler*
PhraseQuery_make_compiler(PhraseQuery *self, Searcher *searcher,
- float boost) {
+ float boost, bool_t subordinate) {
if (VA_Get_Size(self->terms) == 1) {
// Optimize for one-term "phrases".
Obj *term = VA_Fetch(self->terms, 0);
@@ -134,12 +134,17 @@ PhraseQuery_make_compiler(PhraseQuery *s
TermQuery_Set_Boost(term_query, self->boost);
term_compiler
= (TermCompiler*)TermQuery_Make_Compiler(term_query, searcher,
- boost);
+ boost, subordinate);
DECREF(term_query);
return (Compiler*)term_compiler;
}
else {
- return (Compiler*)PhraseCompiler_new(self, searcher, boost);
+ PhraseCompiler *compiler
+ = PhraseCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ PhraseCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
}
@@ -187,9 +192,6 @@ PhraseCompiler_init(PhraseCompiler *self
// Calculate raw weight.
self->raw_weight = self->idf * self->boost;
- // Make final preparations.
- PhraseCompiler_Normalize(self);
-
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/PhraseQuery.cfh Thu Oct 13 20:31:11 2011
@@ -49,7 +49,8 @@ class Lucy::Search::PhraseQuery inherits
Get_Terms(PhraseQuery *self);
public incremented Compiler*
- Make_Compiler(PhraseQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(PhraseQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public bool_t
Equals(PhraseQuery *self, Obj *other);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/PolyQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/PolyQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/PolyQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/PolyQuery.c Thu Oct 13 20:31:11 2011
@@ -118,8 +118,9 @@ PolyCompiler_init(PolyCompiler *self, Po
for (i = 0; i < num_kids; i++) {
Query *child_query = (Query*)VA_Fetch(parent->children, i);
float sub_boost = boost * Query_Get_Boost(child_query);
- VA_Push(self->children,
- (Obj*)Query_Make_Compiler(child_query, searcher, sub_boost));
+ Compiler *child_compiler
+ = Query_Make_Compiler(child_query, searcher, sub_boost, true);
+ VA_Push(self->children, (Obj*)child_compiler);
}
return self;
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/PolySearcher.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/PolySearcher.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/PolySearcher.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/PolySearcher.c Thu Oct 13 20:31:11 2011
@@ -135,7 +135,8 @@ PolySearcher_top_docs(PolySearcher *self
Compiler *compiler = Query_Is_A(query, COMPILER)
? ((Compiler*)INCREF(query))
: Query_Make_Compiler(query, (Searcher*)self,
- Query_Get_Boost(query));
+ Query_Get_Boost(query),
+ false);
uint32_t i, max;
for (i = 0, max = VA_Get_Size(searchers); i < max; i++) {
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/Query.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/Query.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/Query.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/Query.cfh Thu Oct 13 20:31:11 2011
@@ -52,9 +52,14 @@ class Lucy::Search::Query inherits Lucy:
*
* @param searcher A Searcher.
* @param boost A scoring multiplier. Defaults to the Query's own boost.
+ * @param subordinate Indicates whether the Query is a subquery (as
+ * opposed to a top-level query). If false, the implementation must
+ * invoke Normalize() on the newly minted Compiler object before returning
+ * it.
*/
public abstract incremented Compiler*
- Make_Compiler(Query *self, Searcher *searcher, float boost);
+ Make_Compiler(Query *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
/** Set the Query's boost.
*/
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.c Thu Oct 13 20:31:11 2011
@@ -158,8 +158,12 @@ RangeQuery_deserialize(RangeQuery *self,
RangeCompiler*
RangeQuery_make_compiler(RangeQuery *self, Searcher *searcher,
- float boost) {
- return RangeCompiler_new(self, searcher, boost);
+ float boost, bool_t subordinate) {
+ RangeCompiler *compiler = RangeCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ RangeCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
/**********************************************************************/
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/RangeQuery.cfh Thu Oct 13 20:31:11 2011
@@ -61,7 +61,8 @@ class Lucy::Search::RangeQuery inherits
To_String(RangeQuery *self);
public incremented RangeCompiler*
- Make_Compiler(RangeQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(RangeQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public void
Serialize(RangeQuery *self, OutStream *outstream);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.c Thu Oct 13 20:31:11 2011
@@ -82,8 +82,13 @@ ReqOptQuery_equals(RequiredOptionalQuery
Compiler*
ReqOptQuery_make_compiler(RequiredOptionalQuery *self, Searcher *searcher,
- float boost) {
- return (Compiler*)ReqOptCompiler_new(self, searcher, boost);
+ float boost, bool_t subordinate) {
+ RequiredOptionalCompiler *compiler
+ = ReqOptCompiler_new(self, searcher, boost);
+ if (!subordinate) {
+ ReqOptCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
/**********************************************************************/
@@ -103,7 +108,6 @@ ReqOptCompiler_init(RequiredOptionalComp
Searcher *searcher, float boost) {
PolyCompiler_init((PolyCompiler*)self, (PolyQuery*)parent, searcher,
boost);
- ReqOptCompiler_Normalize(self);
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/RequiredOptionalQuery.cfh Thu Oct 13 20:31:11 2011
@@ -55,7 +55,7 @@ class Lucy::Search::RequiredOptionalQuer
public incremented Compiler*
Make_Compiler(RequiredOptionalQuery *self, Searcher *searcher,
- float boost);
+ float boost, bool_t subordinate = false);
public incremented CharBuf*
To_String(RequiredOptionalQuery *self);
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.c (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.c Thu Oct 13 20:31:11 2011
@@ -101,8 +101,14 @@ TermQuery_to_string(TermQuery *self) {
}
Compiler*
-TermQuery_make_compiler(TermQuery *self, Searcher *searcher, float boost) {
- return (Compiler*)TermCompiler_new((Query*)self, searcher, boost);
+TermQuery_make_compiler(TermQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate) {
+ TermCompiler *compiler = TermCompiler_new((Query*)self, searcher, boost);
+ if (!subordinate) {
+ TermCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
+
}
/******************************************************************/
@@ -147,9 +153,6 @@ TermCompiler_init(TermCompiler *self, Qu
*/
self->raw_weight = self->idf * self->boost;
- // Make final preparations.
- TermCompiler_Normalize(self);
-
return self;
}
Modified: incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/Lucy/Search/TermQuery.cfh Thu Oct 13 20:31:11 2011
@@ -50,7 +50,8 @@ class Lucy::Search::TermQuery inherits L
Get_Term(TermQuery *self);
public incremented Compiler*
- Make_Compiler(TermQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(TermQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public incremented CharBuf*
To_String(TermQuery *self);
Modified: incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.c
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.c?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.c (original)
+++ incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.c Thu Oct 13 20:31:11 2011
@@ -133,7 +133,7 @@ ProximityQuery_to_string(ProximityQuery
Compiler*
ProximityQuery_make_compiler(ProximityQuery *self, Searcher *searcher,
- float boost) {
+ float boost, bool_t subordinate) {
if (VA_Get_Size(self->terms) == 1) {
// Optimize for one-term "phrases".
Obj *term = VA_Fetch(self->terms, 0);
@@ -142,13 +142,17 @@ ProximityQuery_make_compiler(ProximityQu
TermQuery_Set_Boost(term_query, self->boost);
term_compiler
= (TermCompiler*)TermQuery_Make_Compiler(term_query, searcher,
- boost);
+ boost, subordinate);
DECREF(term_query);
return (Compiler*)term_compiler;
}
else {
- return (Compiler*)ProximityCompiler_new(self, searcher, boost,
- self->within);
+ ProximityCompiler *compiler
+ = ProximityCompiler_new(self, searcher, boost, self->within);
+ if (!subordinate) {
+ ProximityCompiler_Normalize(compiler);
+ }
+ return (Compiler*)compiler;
}
}
@@ -205,9 +209,6 @@ ProximityCompiler_init(ProximityCompiler
// Calculate raw weight.
self->raw_weight = self->idf * self->boost;
- // Make final preparations.
- ProximityCompiler_Normalize(self);
-
return self;
}
Modified: incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.cfh?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.cfh (original)
+++ incubator/lucy/branches/0.2/core/LucyX/Search/ProximityQuery.cfh Thu Oct 13 20:31:11 2011
@@ -55,7 +55,8 @@ class LucyX::Search::ProximityQuery inhe
Get_Within(ProximityQuery *self);
public incremented Compiler*
- Make_Compiler(ProximityQuery *self, Searcher *searcher, float boost);
+ Make_Compiler(ProximityQuery *self, Searcher *searcher, float boost,
+ bool_t subordinate = false);
public bool_t
Equals(ProximityQuery *self, Obj *other);
Modified: incubator/lucy/branches/0.2/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod (original)
+++ incubator/lucy/branches/0.2/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod Thu Oct 13 20:31:11 2011
@@ -131,8 +131,11 @@ The last thing we'll need is a make_comp
a subclass of L<Compiler|Lucy::Search::Compiler>.
sub make_compiler {
- my $self = shift;
- return PrefixCompiler->new( @_, parent => $self );
+ my ( $self, %args ) = @_;
+ my $subordinate = delete $args{subordinate};
+ my $compiler = PrefixCompiler->new( %args, parent => $self );
+ $compiler->normalize unless $subordinate;
+ return $compiler;
}
=head2 PrefixCompiler
Modified: incubator/lucy/branches/0.2/perl/lib/Lucy/Search/Query.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/perl/lib/Lucy/Search/Query.pm?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/perl/lib/Lucy/Search/Query.pm (original)
+++ incubator/lucy/branches/0.2/perl/lib/Lucy/Search/Query.pm Thu Oct 13 20:31:11 2011
@@ -28,8 +28,11 @@ my $synopsis = <<'END_SYNOPSIS';
use base qw( Lucy::Search::Query );
sub make_compiler {
- my $self = shift;
- return MyCompiler->new( @_, parent => $self );
+ my ( $self, %args ) = @_;
+ my $subordinate = delete $args{subordinate};
+ my $compiler = MyCompiler->new( %args, parent => $self );
+ $compiler->normalize unless $subordinate;
+ return $compiler;
}
package MyCompiler;
Modified: incubator/lucy/branches/0.2/perl/lib/LucyX/Search/Filter.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/perl/lib/LucyX/Search/Filter.pm?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/perl/lib/LucyX/Search/Filter.pm (original)
+++ incubator/lucy/branches/0.2/perl/lib/LucyX/Search/Filter.pm Thu Oct 13 20:31:11 2011
@@ -49,8 +49,12 @@ sub DESTROY {
}
sub make_compiler {
- my $self = shift;
- return LucyX::Search::FilterCompiler->new( @_, parent => $self );
+ my ( $self, %args ) = @_;
+ my $subordinate = delete $args{subordinate};
+ my $compiler
+ = LucyX::Search::FilterCompiler->new( %args, parent => $self );
+ $compiler->normalize unless $subordinate;
+ return $compiler;
}
sub serialize {
Modified: incubator/lucy/branches/0.2/perl/sample/PrefixQuery.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/perl/sample/PrefixQuery.pm?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/perl/sample/PrefixQuery.pm (original)
+++ incubator/lucy/branches/0.2/perl/sample/PrefixQuery.pm Thu Oct 13 20:31:11 2011
@@ -65,8 +65,11 @@ sub to_string {
}
sub make_compiler {
- my $self = shift;
- return PrefixCompiler->new( @_, parent => $self );
+ my ( $self, %args ) = @_;
+ my $subordinate = delete $args{subordinate};
+ my $compiler = PrefixCompiler->new( %args, parent => $self );
+ $compiler->normalize unless $subordinate;
+ return $compiler;
}
package PrefixCompiler;
Modified: incubator/lucy/branches/0.2/perl/t/binding/800-stack.t
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/0.2/perl/t/binding/800-stack.t?rev=1183075&r1=1183074&r2=1183075&view=diff
==============================================================================
--- incubator/lucy/branches/0.2/perl/t/binding/800-stack.t (original)
+++ incubator/lucy/branches/0.2/perl/t/binding/800-stack.t Thu Oct 13 20:31:11 2011
@@ -23,8 +23,11 @@ package MyQuery;
use base qw( Lucy::Search::Query );
sub make_compiler {
- my $self = shift;
- return MyCompiler->new( @_, parent => $self );
+ my ( $self, %args ) = @_;
+ my $subordinate = delete $args{subordinate};
+ my $compiler = MyCompiler->new( %args, parent => $self );
+ $compiler->normalize unless $subordinate;
+ return $compiler;
}
package MyCompiler;