Mailing List Archive

r3656 - in trunk/perl: . lib/KSx/Search lib/KinoSearch/Search t
Author: creamyg
Date: 2008-07-28 10:51:19 -0700 (Mon, 28 Jul 2008)
New Revision: 3656

Added:
trunk/perl/lib/KSx/Search/MockScorer.pm
Removed:
trunk/perl/lib/KinoSearch/Search/MockScorer.pm
Modified:
trunk/perl/MANIFEST
trunk/perl/t/513-scorer.t
trunk/perl/t/514-and_scorer.t
trunk/perl/t/518-or_scorer.t
trunk/perl/t/519-req_opt_scorer.t
trunk/perl/t/526-not_query.t
Log:
Move MockScorer into the KSx hierarchy.


Modified: trunk/perl/MANIFEST
===================================================================
--- trunk/perl/MANIFEST 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/MANIFEST 2008-07-28 17:51:19 UTC (rev 3656)
@@ -131,7 +131,6 @@
lib/KinoSearch/Search/LeafQuery.pm
lib/KinoSearch/Search/MatchAllQuery.pm
lib/KinoSearch/Search/MatchAllScorer.pm
-lib/KinoSearch/Search/MockScorer.pm
lib/KinoSearch/Search/MultiSearcher.pm
lib/KinoSearch/Search/NoMatchQuery.pm
lib/KinoSearch/Search/NoMatchScorer.pm
@@ -207,9 +206,10 @@
lib/KSx/Remote/SearchServer.pm
lib/KSx/Search/Filter.pm
lib/KSx/Search/LongFieldSim.pm
+lib/KSx/Search/MockScorer.pm
lib/KSx/Simple.pm
Makefile.PL
-MANIFEST copy
+MANIFEST copy
META.yml
ppport.h
README

Copied: trunk/perl/lib/KSx/Search/MockScorer.pm (from rev 3654, trunk/perl/lib/KinoSearch/Search/MockScorer.pm)
===================================================================
--- trunk/perl/lib/KSx/Search/MockScorer.pm (rev 0)
+++ trunk/perl/lib/KSx/Search/MockScorer.pm 2008-07-28 17:51:19 UTC (rev 3656)
@@ -0,0 +1,89 @@
+use strict;
+use warnings;
+
+package KSx::Search::MockScorer;
+use KinoSearch::Util::ToolSet qw( confess reftype );
+use KinoSearch::base qw( KinoSearch::Search::Scorer );
+
+our %instance_vars = __PACKAGE__->init_instance_vars(
+ # params / members
+ doc_nums => \our %doc_nums,
+ scores => \our %scores,
+ # members
+ tick => \our %tick,
+ tally => \our %tally,
+);
+
+use KinoSearch::Search::Tally;
+use KinoSearch::Search::Similarity;
+
+sub new {
+ my ( $either, %args ) = @_;
+ for (qw( doc_nums scores )) {
+ confess("Required parameter $_ isn't an array")
+ unless reftype( $args{$_} ) eq 'ARRAY';
+ }
+ my $doc_nums = delete $args{doc_nums};
+ my $scores = delete $args{scores};
+ $args{similarity} ||= KinoSearch::Search::Similarity->new;
+ my $self = $either->SUPER::new(%args);
+ $doc_nums{$$self} = $doc_nums;
+ $scores{$$self} = $scores;
+ $tick{$$self} = -1;
+ $tally{$$self} = KinoSearch::Search::Tally->new;
+ return $self;
+}
+
+sub get_doc_num {
+ my $self = shift;
+ return $doc_nums{$$self}->[ $tick{$$self} ];
+}
+
+sub next {
+ my $self = shift;
+ my $tick = ++$tick{$$self};
+ my $docs = $doc_nums{$$self};
+ return 0 if $tick > $#$docs;
+ return $self->get_doc_num;
+}
+
+sub tally {
+ my $self = shift;
+ my $tally = $tally{$$self};
+ $tally->set_score( $scores{$$self}->[ $tick{$$self} ] );
+ return $tally;
+}
+
+sub reset {
+ my $self = shift;
+ $tick{$$self} = -1;
+}
+
+1;
+
+__END__
+
+__POD__
+
+=begin devdocs
+
+=head1 PRIVATE CLASS
+
+KSx::Search::MockScorer - Scorer with arbitrary docs and scores.
+
+=head1 DESCRIPTION
+
+Used for testing combining scorers such as ANDScorer, MockScorer allows
+arbitrary match criteria to be supplied, obviating the need for clever index
+construction to cover corner cases.
+
+=head1 COPYRIGHT
+
+Copyright 2007-2008 Marvin Humphrey
+
+=head1 LICENSE, DISCLAIMER, BUGS, etc.
+
+See L<KinoSearch> version 0.20.
+
+=end devdocs
+=cut

Deleted: trunk/perl/lib/KinoSearch/Search/MockScorer.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Search/MockScorer.pm 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/lib/KinoSearch/Search/MockScorer.pm 2008-07-28 17:51:19 UTC (rev 3656)
@@ -1,89 +0,0 @@
-use strict;
-use warnings;
-
-package KinoSearch::Search::MockScorer;
-use KinoSearch::Util::ToolSet qw( confess reftype );
-use KinoSearch::base qw( KinoSearch::Search::Scorer );
-
-our %instance_vars = __PACKAGE__->init_instance_vars(
- # params / members
- doc_nums => \our %doc_nums,
- scores => \our %scores,
- # members
- tick => \our %tick,
- tally => \our %tally,
-);
-
-use KinoSearch::Search::Tally;
-use KinoSearch::Search::Similarity;
-
-sub new {
- my ( $either, %args ) = @_;
- for (qw( doc_nums scores )) {
- confess("Required parameter $_ isn't an array")
- unless reftype( $args{$_} ) eq 'ARRAY';
- }
- my $doc_nums = delete $args{doc_nums};
- my $scores = delete $args{scores};
- $args{similarity} ||= KinoSearch::Search::Similarity->new;
- my $self = $either->SUPER::new(%args);
- $doc_nums{$$self} = $doc_nums;
- $scores{$$self} = $scores;
- $tick{$$self} = -1;
- $tally{$$self} = KinoSearch::Search::Tally->new;
- return $self;
-}
-
-sub get_doc_num {
- my $self = shift;
- return $doc_nums{$$self}->[ $tick{$$self} ];
-}
-
-sub next {
- my $self = shift;
- my $tick = ++$tick{$$self};
- my $docs = $doc_nums{$$self};
- return 0 if $tick > $#$docs;
- return $self->get_doc_num;
-}
-
-sub tally {
- my $self = shift;
- my $tally = $tally{$$self};
- $tally->set_score( $scores{$$self}->[ $tick{$$self} ] );
- return $tally;
-}
-
-sub reset {
- my $self = shift;
- $tick{$$self} = -1;
-}
-
-1;
-
-__END__
-
-__POD__
-
-=begin devdocs
-
-=head1 PRIVATE CLASS
-
-KinoSearch::Search::MockScorer - Scorer with arbitrary docs and scores.
-
-=head1 DESCRIPTION
-
-Used for testing combining scorers such as ANDScorer, MockScorer allows
-arbitrary match criteria to be supplied, obviating the need for clever index
-construction to cover corner cases.
-
-=head1 COPYRIGHT
-
-Copyright 2007-2008 Marvin Humphrey
-
-=head1 LICENSE, DISCLAIMER, BUGS, etc.
-
-See L<KinoSearch> version 0.20.
-
-=end devdocs
-=cut

Modified: trunk/perl/t/513-scorer.t
===================================================================
--- trunk/perl/t/513-scorer.t 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/t/513-scorer.t 2008-07-28 17:51:19 UTC (rev 3656)
@@ -9,7 +9,7 @@

use Test::More tests => 11;

-use KinoSearch::Search::MockScorer;
+use KSx::Search::MockScorer;
use KinoSearch::Search::TopDocCollector;
use KinoSearch::Util::VArray;

@@ -52,7 +52,7 @@
my $seg_starts
= KinoSearch::Util::IntMap->new( ints => $args{seg_starts} );

- my $scorer = KinoSearch::Search::MockScorer->new(
+ my $scorer = KSx::Search::MockScorer->new(
doc_nums => [ 1 .. 10 ],
scores => [ (0) x 10 ],
);

Modified: trunk/perl/t/514-and_scorer.t
===================================================================
--- trunk/perl/t/514-and_scorer.t 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/t/514-and_scorer.t 2008-07-28 17:51:19 UTC (rev 3656)
@@ -6,7 +6,7 @@

use KinoSearch::Search::ANDScorer;
use KinoSearch::Search::Similarity;
-use KinoSearch::Search::MockScorer;
+use KSx::Search::MockScorer;
use KinoSearch::Search::TopDocCollector;
use KinoTestUtils qw( modulo_set doc_nums_from_td_coll );

@@ -29,7 +29,7 @@
my $and_scorer
= KinoSearch::Search::ANDScorer->new( similarity => $sim, );
for my $doc_num_array (@doc_num_arrays) {
- my $mock = KinoSearch::Search::MockScorer->new(
+ my $mock = KSx::Search::MockScorer->new(
doc_nums => $doc_num_array,
scores => [ (0) x scalar @$doc_num_array ],
);

Modified: trunk/perl/t/518-or_scorer.t
===================================================================
--- trunk/perl/t/518-or_scorer.t 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/t/518-or_scorer.t 2008-07-28 17:51:19 UTC (rev 3656)
@@ -6,7 +6,7 @@

use KinoSearch::Search::ORScorer;
use KinoSearch::Search::Similarity;
-use KinoSearch::Search::MockScorer;
+use KSx::Search::MockScorer;
use KinoSearch::Search::TopDocCollector;
use KinoTestUtils qw( modulo_set doc_nums_from_td_coll );

@@ -28,7 +28,7 @@
my $subscorers
= KinoSearch::Util::VArray->new( capacity => scalar @intervals );
for my $doc_num_array (@doc_num_arrays) {
- my $mock = KinoSearch::Search::MockScorer->new(
+ my $mock = KSx::Search::MockScorer->new(
doc_nums => $doc_num_array,
scores => [ (1) x scalar @$doc_num_array ],
);

Modified: trunk/perl/t/519-req_opt_scorer.t
===================================================================
--- trunk/perl/t/519-req_opt_scorer.t 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/t/519-req_opt_scorer.t 2008-07-28 17:51:19 UTC (rev 3656)
@@ -5,7 +5,7 @@
use Test::More tests => 726;

use KinoSearch::Search::RequiredOptionalScorer;
-use KinoSearch::Search::MockScorer;
+use KSx::Search::MockScorer;
use KinoSearch::Search::Similarity;
use KinoSearch::Search::TopDocCollector;
use KinoTestUtils qw( modulo_set doc_nums_from_td_coll );
@@ -23,11 +23,11 @@
my ( $req_interval, $opt_interval ) = @_;
my $req_docs = modulo_set( $req_interval, 100 );
my $opt_docs = modulo_set( $opt_interval, 100 );
- my $req_mock = KinoSearch::Search::MockScorer->new(
+ my $req_mock = KSx::Search::MockScorer->new(
doc_nums => $req_docs,
scores => [ (1) x scalar @$req_docs ],
);
- my $opt_mock = KinoSearch::Search::MockScorer->new(
+ my $opt_mock = KSx::Search::MockScorer->new(
doc_nums => $opt_docs,
scores => [ (1) x scalar @$opt_docs ],
);

Modified: trunk/perl/t/526-not_query.t
===================================================================
--- trunk/perl/t/526-not_query.t 2008-07-28 17:50:51 UTC (rev 3655)
+++ trunk/perl/t/526-not_query.t 2008-07-28 17:51:19 UTC (rev 3656)
@@ -9,7 +9,7 @@
use KinoSearch::Search::NOTScorer;
use KinoSearch::Index::IndexReader;
use KinoSearch::Searcher;
-use KinoSearch::Search::MockScorer;
+use KSx::Search::MockScorer;

use Storable qw( freeze thaw );
use KinoTestUtils qw( create_invindex );
@@ -68,7 +68,7 @@
push @mock_nums, splice( @source_nums, $tick, 1 );
}
@mock_nums = sort { $a <=> $b } @mock_nums;
- my $mock_scorer = KinoSearch::Search::MockScorer->new(
+ my $mock_scorer = KSx::Search::MockScorer->new(
doc_nums => \@mock_nums,
scores => [ (1) x scalar @mock_nums ],
);


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits