| 1 | # This code is part of Perl distribution Apache-Solr version 1.12. | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # The POD got stripped from this file by OODoc version 3.06. | ||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # For contributors see file ChangeLog. | ||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # This software is copyright (c) 2012-2026 by Mark Overmeer. | ||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # SPDX-License-Identifier: Artistic-1.0-Perl OR GPL-1.0-or-later | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | package Apache::Solr;{ | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 6 | our $VERSION = '1.12'; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 6 | ▶ | use Apache::Solr::Tables; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | use Log::Report qw/solr/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | use Scalar::Util qw/blessed/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | use Encode qw/encode/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 6 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | ▶ | use LWP::UserAgent (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | use MIME::Types (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 6 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 6 | LATEST_SOLR_VERSION => '9.8', # newest support by this module | |||||||||||||||||||||||||||||||||||||||||||||
| 33 | ENETDOWN => 100, # error codes may not be available on all platforms | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ENETUNREACH => 101, # so cannot use Errno. | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 6 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | # overrule this when your host has a different unique field | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6 | our $uniqueKey = 'id'; | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | 6 | my $mimetypes = MIME::Types->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6 | my $http_agent; | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | sub _to_bool($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 22 | ▶ | { my $b = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_to_bool: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 22 | ▶ | !defined $b ? undef : ($b && $b ne 'false' && $b ne 'off') ? 'true' : 'false'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%4/6
$b and $b ne "false" and $b ne "off"
$b and $b ne "false"
MC/DC33%1/3
$b and $b ne "false" and $b ne "off"
$b
$b ne "false"
$b ne "off"
Truth table50%2/4
A and B and C
A= $bB= $b ne "false"C= $b ne "off"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub new(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | ▶ | { my ($class, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | ▶ | if($class eq __PACKAGE__) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2 | ▶ | { my $format = delete $args{format} || 'XML'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $args{'format'} || 'XML'
MC/DC0%0/1
delete $args{'format'} || 'XML'
delete $args{'format'}
Truth table50%1/2
A
A= delete $args{'format'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2 | ▶ | $format eq 'XML' || $format eq 'JSON' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$format eq "XML" or $format eq "JSON"
MC/DC0%0/2
$format eq "XML" or $format eq "JSON"
$format eq "XML"
$format eq "JSON"
Truth table33%1/3
A or B
A= $format eq "XML"B= $format eq "JSON"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | or panic "unknown communication format '$format' for solr"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2 | $class .= '::' . $format; | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 2 | ▶ | eval "require $class"; panic $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | (bless {}, $class)->init(\%args) | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | sub init($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | { my ($self, $args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=8 SCAR=23.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 4 | $self->server($args->{server}); | |||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | $self->{AS_core} = $args->{core}; | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | ▶ | $self->{AS_commit} = exists $args->{autocommit} ? $args->{autocommit} : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | $self->{AS_sversion} = $args->{server_version} || LATEST_SOLR_VERSION; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{'server_version'} || '9.8'
MC/DC0%0/1
$args->{'server_version'} || '9.8'
$args->{'server_version'}
Truth table50%1/2
A
A= $args->{'server_version'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | ▶ | $self->{AS_retry_wait} = $args->{retry_wait} // 5; # seconds | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"retry_wait"} // 5
MC/DC0%0/1
$args->{"retry_wait"} // 5
$args->{"retry_wait"}
Truth table50%1/2
A
A= $args->{"retry_wait"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | ▶ | $self->{AS_retry_max} = $args->{retry_max} // 60; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args->{"retry_max"} // 60
MC/DC0%0/1
$args->{"retry_max"} // 60
$args->{"retry_max"}
Truth table50%1/2
A
A= $args->{"retry_max"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 4 | ▶ | $self->{AS_underscore} = exists $args->{field_key_simplify} ? $args->{field_key_simplify} : 1; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | $http_agent = $self->{AS_agent} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 4 | ▶ | $args->{agent} || $http_agent || LWP::UserAgent->new(keep_alive=>1); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$args->{'agent'} || $http_agent || 'LWP::UserAgent'->new('keep_alive', 1)
$args->{"agent"} or $http_agent
MC/DC0%0/3
$args->{'agent'} || $http_agent || 'LWP::UserAgent'->new('keep_alive', 1)
$args->{"agent"}
$http_agent
'LWP::UserAgent'->new('keep_alive', 1)
Truth table25%1/4
A or B || C
A= $args->{"agent"}B= $http_agentC= 'LWP::UserAgent'->new('keep_alive', 1)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 4 | weaken $http_agent; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | sub core(;$) { my $s = shift; @_ ? $s->{AS_core} = shift : $s->{AS_core} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
core: called CC=2 SCAR=7.2
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | sub autocommit(;$) { my $s = shift; @_ ? $s->{AS_commit} = shift : $s->{AS_commit} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
autocommit: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub agent() { $_[0]->{AS_agent} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
agent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 26 | ▶ | sub serverVersion() { $_[0]->{AS_sversion} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serverVersion: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub server(;$) | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 5 | ▶ | { my ($self, $uri) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 5 | ▶ | $uri or return $self->{AS_server}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | $uri = URI->new($uri) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($uri) and $uri->isa("URI")
MC/DC0%0/2
builtin::blessed($uri) and $uri->isa("URI")
builtin::blessed($uri)
$uri->isa("URI")
Truth table33%1/3
A and B
A= builtin::blessed($uri)B= $uri->isa("URI")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | unless blessed $uri && $uri->isa('URI'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | $self->{AS_server} = $uri; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 127 | ▶ | sub fieldKeySimplify() { $_[0]->{AS_underscore} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fieldKeySimplify: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | sub select(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
select: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | my $args = @_ && ref $_[0] eq 'HASH' ? shift : {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@_ and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ and ref $_[0] eq "HASH"
@_
ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= @_B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->_select($args, scalar $self->expandSelect(@_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub _select($$) {panic "not extended"} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_select: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | sub queryTerms(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
queryTerms: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $self->_terms(scalar $self->expandTerms(@_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | sub _terms(@) {panic "not implemented"} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_terms: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | sub addDocument($%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | { my ($self, $docs, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
addDocument: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $docs = [ $docs ] if ref $docs ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $sv = $self->serverVersion; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my (%attrs, %params); | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $params{commit} = _to_bool(exists $args{commit} ? $args{commit} : $self->autocommit); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if(my $cw = $args{commitWithin}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | { if($sv lt '3.4') { $attrs{commit} = 'true' } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | else { $attrs{commitWithin} = int($cw * 1000) } | |||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | $attrs{overwrite} = _to_bool delete $args{overwrite} | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if exists $args{overwrite}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | foreach my $depr (qw/allowDups overwritePending overwriteCommitted/) | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | { if(exists $args{$depr}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | { if($sv ge '4.0') { $self->removed("add($depr)"); delete $args{$depr} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | elsif($sv ge '1.0') { $self->deprecated("add($depr)") } | |||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | else { $attrs{$depr} = _to_bool delete $args{$depr} } | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->_add($docs, \%attrs, \%params); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | sub commit(%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
commit: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $sv = $self->serverVersion; | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if(exists $args{waitFlush}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | { if($sv ge '4.0') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | { $self->removed("commit(waitFlush)"); delete $args{waitFlush} } | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | elsif($sv ge '1.4') { $self->deprecated("commit(waitFlush)") } | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | else { $attrs{waitFlush} = _to_bool delete $args{waitFlush} } | |||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | $attrs{waitSearcher} = _to_bool delete $args{waitSearcher} | ||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if exists $args{waitSearcher}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if(exists $args{softCommit}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | { if($sv lt '4.0') { $self->ignored("commit(softCommit)") } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | else { $attrs{softCommit} = _to_bool delete $args{softCommit} } | |||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | if(exists $args{expungeDeletes}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | { if($sv lt '1.4') { $self->ignored("commit(expungeDeletes)") } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | else { $attrs{expungeDeletes} = _to_bool delete $args{expungeDeletes} } | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $self->_commit(\%attrs); | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub _commit($) {panic "not implemented"} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_commit: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | sub optimize(%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
optimize: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $sv = $self->serverVersion; | |||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if(exists $args{waitFlush}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | { if($sv ge '4.0') { $self->removed("commit(waitFlush)"); delete $args{waitFlush} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | elsif($sv ge '1.4') { $self->deprecated("optimize(waitFlush)") } | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | else { $attrs{waitFlush} = _to_bool delete $args{waitFlush} } | |||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | $attrs{waitSearcher} = _to_bool delete $args{waitSearcher} | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if exists $args{waitSearcher}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if(exists $args{softCommit}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | { if($sv lt '4.0') { $self->ignored("optimize(softCommit)") } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | else { $attrs{softCommit} = _to_bool delete $args{softCommit} } | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if(exists $args{maxSegments}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | { if($sv lt '1.3') { $self->ignored("optimize(maxSegments)") } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | else { $attrs{maxSegments} = delete $args{maxSegments} } | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $self->_optimize(\%attrs); | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub _optimize($) {panic "not implemented"} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_optimize: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | sub delete(%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my %attrs; | |||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | $attrs{commit} = _to_bool(exists $args{commit} ? $args{commit} : $self->autocommit); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if(exists $args{fromPending}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | { $self->deprecated("delete(fromPending)"); | |||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $attrs{fromPending} = _to_bool delete $args{fromPending}; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if(exists $args{fromCommitted}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | { $self->deprecated("delete(fromCommitted)"); | |||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $attrs{fromCommitted} = _to_bool delete $args{fromCommitted}; | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my @which; | |||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if(my $id = $args{id}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | { push @which, map +(id => $_), ref $id eq 'ARRAY' ? @$id : $id; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | if(my $q = $args{query}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | { push @which, map +(query => $_), ref $q eq 'ARRAY' ? @$q : $q; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | @which or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # JSON calls do not accept multiple ids at once (it seems in 4.0) | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if($self->serverVersion ge '1.4' && !$self->isa('Apache::Solr::JSON')) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->serverVersion ge "1.4" and not $self->isa("Apache::Solr::JSON")
MC/DC0%0/2
$self->serverVersion ge "1.4" and not $self->isa("Apache::Solr::JSON")
$self->serverVersion ge "1.4"
not $self->isa("Apache::Solr::JSON")
Truth table0%0/3
A and not(B)
A= $self->serverVersion ge "1.4"B= not $self->isa("Apache::Solr::JSON")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | { $result = $self->_delete(\%attrs, \@which); | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 233 | { # old servers accept only one id or query per delete | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | $result = $self->_delete(\%attrs, [splice @which, 0, 2]) while @which; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub _delete(@) {panic "not implemented"} | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_delete: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub rollback() | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rollback: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | $self->serverVersion ge '1.4' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | or error __x"rollback not supported by your solr server version."; | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->_rollback; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | sub extractDocument(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extractDocument: not called CC=15 SCAR=54.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $self->serverVersion ge '1.4' | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | or error __x"extractDocument() requires Solr v1.4 or higher."; | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my %p = $self->expandExtract(@_); | |||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # expand* changes '_' into '.' | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $ct = delete $p{'content.type'}; | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $fn = delete $p{file}; | |||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | $p{'resource.name'} ||= $fn if $fn && !ref $fn; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$fn and not ref $fn
$p{"resource.name"} ||= $fn
MC/DC0%0/2
$fn and not ref $fn
$fn
not ref $fn
MC/DC0%0/2
$p{"resource.name"} ||= $fn
$p{"resource.name"}
$fn
Truth table0%0/3
A and not(B)
A= $fnB= not ref $fn
Truth table0%0/3
A ||= B
A= $p{"resource.name"}B= $fn
| |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | $p{commit} = _to_bool $self->autocommit | ||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | unless exists $p{commit}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | if(defined $p{string}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | { # try to avoid copying the data, which can be huge | ||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $data = $ct =~ m!^text/!i | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | ? \encode(utf8 => (ref $p{string} eq 'SCALAR' ? ${$p{string}} : $p{string})) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | : (ref $p{string} eq 'SCALAR' ? $p{string} : \$p{string} ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | delete $p{string}; | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 275 | elsif($fn) | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | { local $/; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if(ref $fn eq 'GLOB') { $data = \<$fn> } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | { local *IN; | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | open IN, '<:raw', $fn or fault __x"Cannot read document from {fn}", fn => $fn; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $data = \<IN>; | |||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | close IN or fault __x"Read error for document {fn}", fn => $fn; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | $ct ||= $mimetypes->mimeTypeOf($fn); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ct ||= $mimetypes->mimeTypeOf($fn)
MC/DC0%0/2
$ct ||= $mimetypes->mimeTypeOf($fn)
$ct
$mimetypes->mimeTypeOf($fn)
Truth table0%0/3
A ||= B
A= $ctB= $mimetypes->mimeTypeOf($fn)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 286 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | { error __x"extract requires document as file or string."; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->_extract([%p], $data, $ct); | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub _extract($) { panic "not implemented" } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | sub _core_admin($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | { my ($self, $action, $params) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_core_admin: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $params->{core} ||= $self->core; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$params->{"core"} ||= $self->core
MC/DC0%0/2
$params->{"core"} ||= $self->core
$params->{"core"}
$self->core
Truth table0%0/3
A ||= B
A= $params->{"core"}B= $self->core
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my $endpoint = $self->endpoint('cores', core => 'admin', params => $params); | |||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my @params = %$params; | |||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $result = Apache::Solr::Result->new(params => [ %$params ], endpoint => $endpoint, core => $self); | |||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $self->request($endpoint, $result); | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | sub coreStatus(%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coreStatus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $self->_core_admin('STATUS', \%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | sub coreReload(%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coreReload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $self->_core_admin('RELOAD', \%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||
| 322 | sub coreUnload($%) | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | { my ($self, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
coreUnload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $self->_core_admin('UNLOAD', \%args); | |||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | sub _calling_sub() | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 1 | ▶ | { for(my $i=0;$i <10; $i++) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_calling_sub: called CC=4 SCAR=14.2
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 4 | { my $sub = (caller $i)[3]; | |||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | return $sub if !$sub || index($sub, 'Apache::Solr::') < 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $sub or index($sub, "Apache::Solr::") == -1
MC/DC50%1/2
not $sub or index($sub, "Apache::Solr::") == -1
not $sub
index($sub, "Apache::Solr::") == -1
Truth table66%2/3
not(A) or B
A= not $subB= index($sub, "Apache::Solr::") == -1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub _simpleExpand($$$) | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 26 | ▶ | { my ($self, $p, $prefix) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_simpleExpand: called CC=14 SCAR=26.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 26 | ▶ | my @p = ref $p eq 'HASH' ? %$p : @$p; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 26 | my $sv = $self->serverVersion; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 26 | my @t; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 26 | ▶ | while(@p) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 90 | { my ($k, $v) = (shift @p, shift @p); | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | 90 | ▶ | $k =~ s/_/./g if $self->fieldKeySimplify; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 90 | ▶ | $k = $prefix.$k if defined $prefix && index($k, $prefix)!=0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $prefix and index($k, $prefix) != 0
MC/DC100%2/2
defined $prefix and index($k, $prefix) != 0
defined $prefix
index($k, $prefix) != 0
Truth table100%3/3
A and B
A= defined $prefixB= index($k, $prefix) != 0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 90 | ▶ | my $param = $k =~ m/^f\.[^\.]+\.(.*)/ ? $1 : $k; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 90 | my ($dv, $iv); | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 90 | ▶ | if(($dv = $deprecated{$param}) && $sv ge $dv) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$dv = $Apache::Solr::deprecated{$param} and $sv ge $dv
MC/DC50%1/2
$dv = $Apache::Solr::deprecated{$param} and $sv ge $dv
$dv = $Apache::Solr::deprecated{$param}
$sv ge $dv
Truth table66%2/3
A and B
A= $dv = $Apache::Solr::deprecated{$param}B= $sv ge $dv
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | { my $command = _calling_sub; | |||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | $self->deprecated("$command($param) since $dv"); | |||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ▶ | elsif(($iv = $introduced{$param}) && $iv gt $sv) | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$iv = $Apache::Solr::introduced{$param} and $iv gt $sv
MC/DC0%0/2
$iv = $Apache::Solr::introduced{$param} and $iv gt $sv
$iv = $Apache::Solr::introduced{$param}
$iv gt $sv
Truth table66%2/3
A and B
A= $iv = $Apache::Solr::introduced{$param}B= $iv gt $sv
| |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | { my $command = _calling_sub; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $self->ignored("$command($param) introduced in $iv"); | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | push @t, $k => $boolparams{$param} ? _to_bool($_) : $_ | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 90 | ▶ | for ref $v eq 'ARRAY' ? @$v : $v; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 26 | @t; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | sub expandTerms(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expandTerms: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 1 | ▶ | my $p = @_==1 ? shift : [@_]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 1 | my @t = $self->_simpleExpand($p, 'terms.'); | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | 1 | ▶ | wantarray ? @t : \@t; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | sub _expand_flatten($$) | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | ▶ | { my ($self, $v, $prefix) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_expand_flatten: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 4 | ▶ | my @l = ref $v eq 'HASH' ? %$v : @$v; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 4 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 4 | ▶ | push @s, $prefix.(shift @l) => (shift @l) while @l; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 4 | @s; | |||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | sub expandExtract(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expandExtract: called CC=12 SCAR=26.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | my @p = @_==1 ? @{(shift)} : @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | ▶ | while(@p) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 10 | { my ($k, $v) = (shift @p, shift @p); | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 10 | ▶ | if(!ref $v || ref $v eq 'SCALAR') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
not ref $v or ref $v eq "SCALAR"
MC/DC50%1/2
not ref $v or ref $v eq "SCALAR"
not ref $v
ref $v eq "SCALAR"
Truth table66%2/3
not(A) or B
A= not ref $vB= ref $v eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 6 | { push @s, $k => $v } | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | ▶ | elsif($k eq 'literal' || $k eq 'literals') | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$k eq "literal" or $k eq "literals"
MC/DC100%2/2
$k eq "literal" or $k eq "literals"
$k eq "literal"
$k eq "literals"
Truth table100%3/3
A or B
A= $k eq "literal"B= $k eq "literals"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 2 | { push @s, $self->_expand_flatten($v, 'literal.') } | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | ▶ | elsif($k eq 'fmap' || $k eq 'boost' || $k eq 'resource') | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$k eq "fmap" or $k eq "boost" or $k eq "resource"
$k eq "fmap" or $k eq "boost"
MC/DC0%0/3
$k eq "fmap" or $k eq "boost" or $k eq "resource"
$k eq "fmap"
$k eq "boost"
$k eq "resource"
Truth table50%2/4
A or B or C
A= $k eq "fmap"B= $k eq "boost"C= $k eq "resource"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | { push @s, $self->_expand_flatten($v, "$k.") } | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | else { panic "unknown set '$k'" } | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1 | ▶ | my @t = @s ? $self->_simpleExpand(\@s) : (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1 | ▶ | wantarray ? @t : \@t; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # probably more config later, currently only one column | ||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # "also-per-field" means, not only $set.$more, but also f.$field.$set.$more | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 6 | my %sets = ( #also-per-field? | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | expand => [0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | facet => [1], | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | hl => [1], | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | mlt => [0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 409 | stats => [0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | suggest => [0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 411 | group => [0], | ||||||||||||||||||||||||||||||||||||||||||||||
| 412 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | sub expandSelect(@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 9 | ▶ | { my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expandSelect: called CC=13 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 9 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | 9 | my (@flat, %seen_set); | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 9 | ▶ | while(@_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 37 | { my ($k, $v) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 420 | 37 | ▶ | $k =~ s/_/./g if $self->fieldKeySimplify; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 37 | my @p = split /\./, $k; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # fields are $set.$more or f.$field.$set.$more | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 37 | ▶ | my $per_field = $p[0] eq 'f' && @p > 2; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$p[0] eq 'f' && @p > 2
MC/DC50%1/2
$p[0] eq 'f' && @p > 2
$p[0] eq 'f'
@p > 2
Truth table66%2/3
A && B
A= $p[0] eq 'f'B= @p > 2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 37 | ▶ | my ($set, $more) = $per_field ? @p[2,3] : @p[0,1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 37 | ▶ | if(my $def = $sets{$set}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 15 | { $seen_set{$set} = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | 15 | ▶ | !$per_field || $def->[0] | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $per_field or $def->[0]
MC/DC0%0/2
not $per_field or $def->[0]
not $per_field
$def->[0]
Truth table66%2/3
not(A) or B
A= not $per_fieldB= $def->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | or error __x"set {set} cannot be used per field, in {field}.", set => $set, field => $k; | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 15 | ▶ | if(ref $v eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 15 | ▶ | { !$more or error __x"field {field} is not simple for a set.", field => $k; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 15 | push @s, $self->_simpleExpand($v, "$k."); | |||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 436 | elsif($more) # skip $set=true for now | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | { push @flat, $k => $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | elsif(ref $v eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | { error __x"unknown field set {set}.", set => $set; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 443 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 22 | { push @flat, $k => $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 9 | push @flat, %seen_set; | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 9 | unshift @s, $self->_simpleExpand(\@flat); | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | 9 | ▶ | wantarray ? @s : \@s; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||
| 453 | sub deprecated($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | ▶ | { my ($self, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deprecated: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | ▶ | return if $self->{AS_depr_msg}{$msg}++; # report only once | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | warning __x"deprecated solr {message}", message => $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | sub ignored($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | { my ($self, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignored: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | return if $self->{AS_ign_msg}{$msg}++; # report only once | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | warning __x"ignored solr {message}", message => $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||
| 467 | sub removed($) | ||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | { my ($self, $msg) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
removed: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | return if $self->{AS_rem_msg}{$msg}++; # report only once | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | warning __x"removed solr {message}", message => $msg; | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | sub endpoint($@) | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | ▶ | { my ($self, $action, %args) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
endpoint: called CC=9 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | ▶ | my $core = $args{core} || $self->core; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$args{'core'} || $self->core
MC/DC0%0/2
$args{'core'} || $self->core
$args{'core'}
$self->core
Truth table33%1/3
A || B
A= $args{'core'}B= $self->core
| |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 1 | my $take = $self->server->clone; # URI | |||||||||||||||||||||||||||||||||||||||||||||
| 480 | 1 | ▶ | $take->path($take->path . (defined $core ? "/$core" : '') . "/$action"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | # make parameters ordered | ||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | ▶ | my $params = $args{params} || []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'params'} || []
MC/DC0%0/1
$args{'params'} || []
$args{'params'}
Truth table50%1/2
A
A= $args{'params'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | ▶ | $params = [ %$params ] if ref $params eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | @$params or return $take; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||
| 487 | # remove paramers with undefined value | ||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | my @p = @$params; | |||||||||||||||||||||||||||||||||||||||||||||
| 489 | 1 | my @params; | |||||||||||||||||||||||||||||||||||||||||||||
| 490 | 1 | ▶ | while(@p) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 3 | ▶ | { push @params, $p[0] => $p[1] if defined $p[1]; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 3 | shift @p, shift @p; | |||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 1 | ▶ | $take->query_form(@params) if @params; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1 | $take; | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||
| 500 | sub request($$;$$) | ||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | ▶ | { my ($self, $url, $result, $body, $body_ct) = @_; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
request: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $req; | |||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | if($body) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | { # request with 'form' payload | ||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | $req = HTTP::Request->new( | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | POST => $url, | ||||||||||||||||||||||||||||||||||||||||||||||
| 508 | [ Content_Type => $body_ct | ||||||||||||||||||||||||||||||||||||||||||||||
| 509 | , Content_Disposition => 'form-data; name="content"' | ||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ], | ||||||||||||||||||||||||||||||||||||||||||||||
| 511 | (ref $body eq 'SCALAR' ? $$body : $body) | ||||||||||||||||||||||||||||||||||||||||||||||
| 512 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 514 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 515 | { # request without payload | ||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $req = HTTP::Request->new(GET => $url); | |||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $result->request($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $retries = $self->{AS_retry_max}; | |||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $wait = $self->{AS_retry_wait}; | |||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my $start = time; | |||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | ▶ | while($retries--) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | { $resp = $self->agent->request($req); | |||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $result->response($resp); | |||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $dec = $result->decoded($self->decodeResponse($resp)); | |||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | last if $resp->is_success; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | if($resp->code==500) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | { $! = ENETDOWN; # HTTP(500) -> unix error | |||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | alert __x"Solr request failed with {code}, {retries} retries left", | |||||||||||||||||||||||||||||||||||||||||||||
| 536 | code => $resp->code, retries => $retries, result => $result; | ||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | sleep $wait if $wait && $retries; # let remote settle a bit | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$wait and $retries
MC/DC0%0/2
$wait and $retries
$wait
$retries
Truth table0%0/3
A and B
A= $waitB= $retries
| |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | error __x"Solr request failed with: {err}", | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$result->solrError || $result->httpError
MC/DC0%0/2
$result->solrError || $result->httpError
$result->solrError
$result->httpError
Truth table0%0/3
A || B
A= $result->solrErrorB= $result->httpError
| |||||||||||||||||||||||||||||||||||||||||||||||
| 542 | err => ($result->solrError || $result->httpError), result => $result; | ||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | ▶ | unless($resp->is_success) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | { $! = $resp->code==500 ? ENETDOWN : ENETUNREACH; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 547 | fault __x"Solr request failed after {elapse} seconds after {retries} retries", | ||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | elapse => time - $start, retries => $self->{AS_retry_max} - $retries -1, result => $result; | |||||||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | $resp; | |||||||||||||||||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | sub decodeResponse($) { undef } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decodeResponse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||
| 556 | #-------------------- | ||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||