You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/07/31 13:19:27 UTC

git commit: refs/heads/master - Remove alias and wrapper for Query#Make_Compiler

Repository: lucy
Updated Branches:
  refs/heads/master 83c98ee6a -> 2e5f018c1


Remove alias and wrapper for Query#Make_Compiler

This makes 'boost' a required param of $query->make_compiler which
breaks backward compatibility.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/2e5f018c
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/2e5f018c
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/2e5f018c

Branch: refs/heads/master
Commit: 2e5f018c17fe6b5d99f5f9b3a699816ad3e3ee53
Parents: 83c98ee
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Jul 30 22:26:06 2014 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Jul 30 22:28:40 2014 +0200

----------------------------------------------------------------------
 core/Lucy/Search/Query.cfh                  |  2 +-
 perl/buildlib/Lucy/Build/Binding/Search.pm  |  4 ----
 perl/lib/Lucy.pm                            |  6 ------
 perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod |  5 ++++-
 perl/lib/LucyX/Remote/ClusterSearcher.pm    |  5 ++++-
 perl/t/501-termquery.t                      |  5 ++++-
 perl/t/502-phrasequery.t                    |  5 ++++-
 perl/t/515-range_query.t                    |  5 ++++-
 perl/t/523-and_query.t                      | 17 ++++++++++++-----
 perl/t/524-poly_query.t                     | 17 ++++++++++++-----
 perl/t/525-match_all_query.t                |  5 ++++-
 perl/t/526-not_query.t                      |  5 ++++-
 perl/t/527-req_opt_query.t                  | 11 ++++++++---
 perl/t/528-leaf_query.t                     |  7 ++++++-
 perl/t/529-no_match_query.t                 |  5 ++++-
 perl/t/613-proximityquery.t                 |  6 ++++--
 perl/t/binding/303-highlighter.t            |  5 ++++-
 perl/t/binding/800-stack.t                  |  5 ++++-
 18 files changed, 83 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/core/Lucy/Search/Query.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/Query.cfh b/core/Lucy/Search/Query.cfh
index 1bcfc23..2774ee6 100644
--- a/core/Lucy/Search/Query.cfh
+++ b/core/Lucy/Search/Query.cfh
@@ -51,7 +51,7 @@ public class Lucy::Search::Query inherits Clownfish::Obj {
     /** Abstract factory method returning a Compiler derived from this Query.
      *
      * @param searcher A Searcher.
-     * @param boost A scoring multiplier. Defaults to the Query's own boost.
+     * @param boost A scoring multiplier.
      * @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

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/buildlib/Lucy/Build/Binding/Search.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build/Binding/Search.pm b/perl/buildlib/Lucy/Build/Binding/Search.pm
index eb3202c..eae6295 100644
--- a/perl/buildlib/Lucy/Build/Binding/Search.pm
+++ b/perl/buildlib/Lucy/Build/Binding/Search.pm
@@ -633,10 +633,6 @@ END_CONSTRUCTOR_CODE_SAMPLE
         class_name => "Lucy::Search::Query",
     );
     $binding->bind_method(
-        alias  => '_make_compiler',
-        method => 'Make_Compiler',
-    );
-    $binding->bind_method(
         alias  => '_load',
         method => 'Load',
     );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/lib/Lucy.pm
----------------------------------------------------------------------
diff --git a/perl/lib/Lucy.pm b/perl/lib/Lucy.pm
index ad9b46c..dfa1c3a 100644
--- a/perl/lib/Lucy.pm
+++ b/perl/lib/Lucy.pm
@@ -219,12 +219,6 @@ BEGIN {
     our $VERSION = '0.003000';
     $VERSION = eval $VERSION;
     use Lucy qw( STORABLE_freeze STORABLE_thaw load );
-
-    sub make_compiler {
-        my ( $self, %args ) = @_;
-        $args{boost} = $self->get_boost unless defined $args{boost};
-        return $self->_make_compiler(%args);
-    }
 }
 
 {

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
----------------------------------------------------------------------
diff --git a/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod b/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
index 53740de..2c78bf1 100644
--- a/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
+++ b/perl/lib/Lucy/Docs/Cookbook/CustomQuery.pod
@@ -64,7 +64,10 @@ together the three classes.
 
     sub hits {
         my ( $self, $query ) = @_;
-        my $compiler = $query->make_compiler( searcher => $self );
+        my $compiler = $query->make_compiler(
+            searcher => $self,
+            boost    => $query->get_boost,
+        );
         my $matcher = $compiler->make_matcher(
             reader     => $self->get_reader,
             need_score => 1,

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/lib/LucyX/Remote/ClusterSearcher.pm
----------------------------------------------------------------------
diff --git a/perl/lib/LucyX/Remote/ClusterSearcher.pm b/perl/lib/LucyX/Remote/ClusterSearcher.pm
index 5bfe684..c5e22ee 100644
--- a/perl/lib/LucyX/Remote/ClusterSearcher.pm
+++ b/perl/lib/LucyX/Remote/ClusterSearcher.pm
@@ -267,7 +267,10 @@ sub top_docs {
     my $compiler
         = $query->isa("Lucy::Search::Compiler")
         ? $query
-        : $query->make_compiler( searcher => $self );
+        : $query->make_compiler(
+            searcher => $self,
+            boost    => $query->get_boost,
+          );
 
     # Create HitQueue.
     my $hit_q;

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/501-termquery.t
----------------------------------------------------------------------
diff --git a/perl/t/501-termquery.t b/perl/t/501-termquery.t
index d18f90f..68ad90e 100644
--- a/perl/t/501-termquery.t
+++ b/perl/t/501-termquery.t
@@ -58,7 +58,10 @@ my $different_field = Lucy::Search::TermQuery->new(
 ok( !$term_query->equals($different_term),  "!equals (term)" );
 ok( !$term_query->equals($different_field), "!equals (field)" );
 
-my $term_compiler = $term_query->make_compiler( searcher => $searcher );
+my $term_compiler = $term_query->make_compiler(
+    searcher => $searcher,
+    boost    => $term_query->get_boost,
+);
 $frozen = freeze($term_compiler);
 $thawed = thaw($frozen);
 ok( $term_compiler->equals($thawed), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/502-phrasequery.t
----------------------------------------------------------------------
diff --git a/perl/t/502-phrasequery.t b/perl/t/502-phrasequery.t
index 03f5f46..b924ac1 100644
--- a/perl/t/502-phrasequery.t
+++ b/perl/t/502-phrasequery.t
@@ -78,7 +78,10 @@ my $thawed = thaw($frozen);
 $hits = $searcher->hits( query => $thawed );
 is( $hits->total_hits, 3, 'freeze/thaw' );
 
-my $phrase_compiler = $phrase_query->make_compiler( searcher => $searcher );
+my $phrase_compiler = $phrase_query->make_compiler(
+    searcher => $searcher,
+    boost    => $phrase_query->get_boost,
+);
 $frozen = freeze($phrase_compiler);
 $thawed = thaw($frozen);
 ok( $phrase_compiler->equals($thawed), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/515-range_query.t
----------------------------------------------------------------------
diff --git a/perl/t/515-range_query.t b/perl/t/515-range_query.t
index 486afae..81c51e8 100644
--- a/perl/t/515-range_query.t
+++ b/perl/t/515-range_query.t
@@ -288,7 +288,10 @@ sub test_range_search {
     my $thawed = thaw($frozen);
     ok( $query->equals($thawed), 'equals' );
 
-    my $compiler = $query->make_compiler( searcher => $searcher );
+    my $compiler = $query->make_compiler(
+        searcher => $searcher,
+        boost    => $query->get_boost,
+    );
     $frozen = nfreeze($compiler);
     $thawed = thaw($frozen);
     ok( $compiler->equals($thawed), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/523-and_query.t
----------------------------------------------------------------------
diff --git a/perl/t/523-and_query.t b/perl/t/523-and_query.t
index b6c2dec..e7557c6 100644
--- a/perl/t/523-and_query.t
+++ b/perl/t/523-and_query.t
@@ -56,7 +56,10 @@ ok( !$and_query->equals($different_children),
 my $one_child = Lucy::Search::ANDQuery->new( children => [$a_query] );
 ok( !$and_query->equals($one_child), '!equals (too few children)' );
 
-my $and_compiler = $and_query->make_compiler( searcher => $searcher );
+my $and_compiler = $and_query->make_compiler(
+    searcher => $searcher,
+    boost    => $and_query->get_boost,
+);
 isa_ok( $and_compiler, "Lucy::Search::ANDCompiler", "make_compiler" );
 $frozen = freeze($and_compiler);
 $thawed = thaw($frozen);
@@ -68,8 +71,10 @@ my $and_matcher = $and_compiler->make_matcher(
 );
 isa_ok( $and_matcher, "Lucy::Search::ANDMatcher", "make_matcher" );
 
-my $term_matcher = $one_child->make_compiler( searcher => $searcher )
-    ->make_matcher( reader => $reader, need_score => 0 );
+my $term_matcher = $one_child->make_compiler(
+    searcher => $searcher,
+    boost    => $one_child->get_boost,
+)->make_matcher( reader => $reader, need_score => 0 );
 isa_ok( $term_matcher, "Lucy::Search::TermMatcher",
     "make_matcher compiles to child's Matcher if there's only one child" );
 
@@ -78,8 +83,10 @@ my $hopeless_query = Lucy::Search::TermQuery->new(
     term  => 'nein',
 );
 $and_query->add_child($hopeless_query);
-my $nope = $and_query->make_compiler( searcher => $searcher )
-    ->make_matcher( reader => $reader, need_score => 0 );
+my $nope = $and_query->make_compiler(
+    searcher => $searcher,
+    boost    => $and_query->get_boost,
+)->make_matcher( reader => $reader, need_score => 0 );
 ok( !defined $nope,
     "If matcher wouldn't return any docs, make_matcher returns undef" );
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/524-poly_query.t
----------------------------------------------------------------------
diff --git a/perl/t/524-poly_query.t b/perl/t/524-poly_query.t
index c49c6df..7f886c0 100644
--- a/perl/t/524-poly_query.t
+++ b/perl/t/524-poly_query.t
@@ -52,7 +52,10 @@ for my $conjunction (qw( AND OR )) {
     my $one_child = $class->new( children => [$a_query] );
     ok( !$polyquery->equals($one_child), '!equals (too few children)' );
 
-    my $compiler = $polyquery->make_compiler( searcher => $searcher );
+    my $compiler = $polyquery->make_compiler(
+        searcher => $searcher,
+        boost    => $polyquery->get_boost,
+    );
     isa_ok( $compiler, "Lucy::Search::${conjunction}Compiler",
         "make_compiler" );
     $frozen = freeze($compiler);
@@ -67,8 +70,10 @@ for my $conjunction (qw( AND OR )) {
         : 'Lucy::Search::ORScorer';
     isa_ok( $matcher, $wanted_class, "make_matcher with need_score" );
 
-    my $term_matcher = $one_child->make_compiler( searcher => $searcher )
-        ->make_matcher( reader => $reader, need_score => 0 );
+    my $term_matcher = $one_child->make_compiler(
+        searcher => $searcher,
+        boost    => $one_child->get_boost,
+    )->make_matcher( reader => $reader, need_score => 0 );
     isa_ok( $term_matcher, "Lucy::Search::TermMatcher",
         "make_matcher compiles to child's Matcher if there's only one child"
     );
@@ -83,8 +88,10 @@ for my $conjunction (qw( AND OR )) {
     );
     $polyquery
         = $class->new( children => [ $hopeless_query, $doomed_query ] );
-    my $nope = $polyquery->make_compiler( searcher => $searcher )
-        ->make_matcher( reader => $reader, need_score => 0 );
+    my $nope = $polyquery->make_compiler(
+        searcher => $searcher,
+        boost    => $polyquery->get_boost,
+    )->make_matcher( reader => $reader, need_score => 0 );
     ok( !defined $nope,
         "If Matcher wouldn't return any docs, make_matcher returns undef" );
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/525-match_all_query.t
----------------------------------------------------------------------
diff --git a/perl/t/525-match_all_query.t b/perl/t/525-match_all_query.t
index c9b8d22..f45d5ba 100644
--- a/perl/t/525-match_all_query.t
+++ b/perl/t/525-match_all_query.t
@@ -52,7 +52,10 @@ ok( $match_all_query->equals($thawed), "equals" );
 $thawed->set_boost(10);
 ok( !$match_all_query->equals($thawed), '!equals (boost)' );
 
-my $compiler = $match_all_query->make_compiler( searcher => $searcher );
+my $compiler = $match_all_query->make_compiler(
+    searcher => $searcher,
+    boost    => $match_all_query->get_boost,
+);
 $frozen = freeze($compiler);
 $thawed = thaw($frozen);
 ok( $thawed->equals($compiler), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/526-not_query.t
----------------------------------------------------------------------
diff --git a/perl/t/526-not_query.t b/perl/t/526-not_query.t
index 2c3c246..c5541c5 100644
--- a/perl/t/526-not_query.t
+++ b/perl/t/526-not_query.t
@@ -60,7 +60,10 @@ ok( !$not_b_query->equals($thawed), '!equals (boost)' );
 ok( !$not_b_query->equals($not_c_query),
     "!equals (different negated query)" );
 
-my $compiler = $not_b_query->make_compiler( searcher => $searcher );
+my $compiler = $not_b_query->make_compiler(
+    searcher => $searcher,
+    boost    => $not_b_query->get_boost,
+);
 $frozen = freeze($compiler);
 $thawed = thaw($frozen);
 ok( $thawed->equals($compiler), 'freeze/thaw compiler' );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/527-req_opt_query.t
----------------------------------------------------------------------
diff --git a/perl/t/527-req_opt_query.t b/perl/t/527-req_opt_query.t
index 115ba98..3b3f48d 100644
--- a/perl/t/527-req_opt_query.t
+++ b/perl/t/527-req_opt_query.t
@@ -44,7 +44,10 @@ my $req_opt_query = Lucy::Search::RequiredOptionalQuery->new(
 );
 is( $req_opt_query->to_string, "(+content:b content:c)", "to_string" );
 
-my $compiler = $req_opt_query->make_compiler( searcher => $searcher );
+my $compiler = $req_opt_query->make_compiler(
+    searcher => $searcher,
+    boost    => $req_opt_query->get_boost,
+);
 my $frozen   = freeze($compiler);
 my $thawed   = thaw($frozen);
 ok( $thawed->equals($compiler), "freeze/thaw compiler" );
@@ -55,8 +58,10 @@ $req_opt_query = Lucy::Search::RequiredOptionalQuery->new(
     required_query => $x_query,
     optional_query => $b_query,
 );
-$matcher = $req_opt_query->make_compiler( searcher => $searcher )
-    ->make_matcher( reader => $reader, need_score => 0 );
+$matcher = $req_opt_query->make_compiler(
+    searcher => $searcher,
+    boost    => $req_opt_query->get_boost,
+)->make_matcher( reader => $reader, need_score => 0 );
 ok( !defined($matcher), "if required matcher has no match, return undef" );
 
 $frozen = freeze($req_opt_query);

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/528-leaf_query.t
----------------------------------------------------------------------
diff --git a/perl/t/528-leaf_query.t b/perl/t/528-leaf_query.t
index 2f83dec..764d6be 100644
--- a/perl/t/528-leaf_query.t
+++ b/perl/t/528-leaf_query.t
@@ -47,7 +47,12 @@ my $diff_text
     = Lucy::Search::LeafQuery->new( field => 'content', text => 'c' );
 ok( !$diff_text->equals($leaf_query), "!equals (different text)" );
 
-eval { $leaf_query->make_compiler( searcher => $searcher ); };
+eval {
+    $leaf_query->make_compiler(
+        searcher => $searcher,
+        boost    => $leaf_query->get_boost,
+    );
+};
 like( $@, qr/Make_Compiler/, "Make_Compiler throws error" );
 
 my $frozen = freeze($leaf_query);

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/529-no_match_query.t
----------------------------------------------------------------------
diff --git a/perl/t/529-no_match_query.t b/perl/t/529-no_match_query.t
index d78f1a8..e983d68 100644
--- a/perl/t/529-no_match_query.t
+++ b/perl/t/529-no_match_query.t
@@ -36,7 +36,10 @@ ok( $no_match_query->equals($thawed), "equals" );
 $thawed->set_boost(10);
 ok( !$no_match_query->equals($thawed), '!equals (boost)' );
 
-my $compiler = $no_match_query->make_compiler( searcher => $searcher );
+my $compiler = $no_match_query->make_compiler(
+    searcher => $searcher,
+    boost    => $no_match_query->get_boost,
+);
 $frozen = freeze($compiler);
 $thawed = thaw($frozen);
 ok( $compiler->equals($thawed), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/613-proximityquery.t
----------------------------------------------------------------------
diff --git a/perl/t/613-proximityquery.t b/perl/t/613-proximityquery.t
index ad9fba2..b571e09 100644
--- a/perl/t/613-proximityquery.t
+++ b/perl/t/613-proximityquery.t
@@ -86,8 +86,10 @@ my $thawed = thaw($frozen);
 $hits = $searcher->hits( query => $thawed );
 is( $hits->total_hits, 4, 'freeze/thaw' );
 
-my $proximity_compiler
-    = $proximity_query->make_compiler( searcher => $searcher, );
+my $proximity_compiler = $proximity_query->make_compiler(
+    searcher => $searcher,
+    boost    => $proximity_query->get_boost,
+);
 $frozen = freeze($proximity_compiler);
 $thawed = thaw($frozen);
 ok( $proximity_compiler->equals($thawed), "freeze/thaw compiler" );

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/binding/303-highlighter.t
----------------------------------------------------------------------
diff --git a/perl/t/binding/303-highlighter.t b/perl/t/binding/303-highlighter.t
index 9d9f453..5ff0d7e 100644
--- a/perl/t/binding/303-highlighter.t
+++ b/perl/t/binding/303-highlighter.t
@@ -109,7 +109,10 @@ like(
 );
 
 $q = $searcher->glean_query("foo");
-my $compiler = $q->make_compiler( searcher => $searcher );
+my $compiler = $q->make_compiler(
+    searcher => $searcher,
+    boost    => $q->get_boost,
+);
 $hl = Lucy::Highlight::Highlighter->new(
     searcher => $searcher,
     query    => $compiler,

http://git-wip-us.apache.org/repos/asf/lucy/blob/2e5f018c/perl/t/binding/800-stack.t
----------------------------------------------------------------------
diff --git a/perl/t/binding/800-stack.t b/perl/t/binding/800-stack.t
index da7b76e..ed84821 100644
--- a/perl/t/binding/800-stack.t
+++ b/perl/t/binding/800-stack.t
@@ -47,7 +47,10 @@ for ( 1 .. 50 ) {
     $q = Lucy::Search::ORQuery->new( children => \@kids );
 }
 my $searcher = MockSearcher->new( schema => Lucy::Plan::Schema->new );
-my $compiler = $q->make_compiler( searcher => $searcher );
+my $compiler = $q->make_compiler(
+    searcher => $searcher,
+    boost    => $q->get_boost,
+);
 
 pass("Made it through deep recursion with multiple stack reallocations");