| 1 | package KinoSearch1::Search::QueryFilter; | ||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use KinoSearch1::Util::ToolSet; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use base qw( KinoSearch1::Util::Class ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | __PACKAGE__->init_instance_vars( | |||||||||
| 9 | # constructor params / members | ||||||||||
| 10 | query => undef, | ||||||||||
| 11 | # members | ||||||||||
| 12 | cached_bits => undef, | ||||||||||
| 13 | ); | ||||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 2 | ▶ | use KinoSearch1::Search::HitCollector; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | ▶ | sub init_instance { | ||||||||
|
Subroutine
init_instance: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||
| 19 | 1 | my $self = shift; | |||||||||
| 20 | confess("required parameter query is not a KinoSearch1::Search::Query") | ||||||||||
| 21 | 1 | ▶ | unless a_isa_b( $self->{query}, 'KinoSearch1::Search::Query' ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 22 | } | ||||||||||
| 23 | |||||||||||
| 24 | 1 | ▶ | sub bits { | ||||||||
|
Subroutine
bits: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 25 | 1 | my ( $self, $searcher ) = @_; | |||||||||
| 26 | |||||||||||
| 27 | # fill the cache | ||||||||||
| 28 | 1 | ▶ | if ( !defined $self->{cache} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | my $collector = KinoSearch1::Search::BitCollector->new( | |||||||||
| 30 | capacity => $searcher->max_doc, ); | ||||||||||
| 31 | |||||||||||
| 32 | # perform the search | ||||||||||
| 33 | $searcher->search_hit_collector( | ||||||||||
| 34 | 1 | weight => $self->{query}->to_weight($searcher), | |||||||||
| 35 | hit_collector => $collector, | ||||||||||
| 36 | ); | ||||||||||
| 37 | |||||||||||
| 38 | # save the bitvector of doc hits | ||||||||||
| 39 | 1 | $self->{cached_bits} = $collector->get_bit_vector; | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 1 | return $self->{cached_bits}; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 2 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||