| 1 | package Elastijk::oo; | ||||||||||||||||||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Elastijk; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | sub new { | ||||||||||||||||||||||||||||
| 7 | 100005 | ▶ | my $class = shift; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 8 | 100005 | return bless { host => "localhost", port => "9200", @_ }, $class; | |||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | { | ||||||||||||||||||||||||||||
| 12 | 3 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 100002 | ▶ | *Elastijk::new = sub { shift; Elastijk::oo->new(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | }; | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | sub __fleshen_request_args { | ||||||||||||||||||||||||||||
| 17 | 14 | ▶ | my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
__fleshen_request_args: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||
| 18 | 14 | ▶ | $args->{$_} ||= $self->{$_} for grep { exists $self->{$_} } qw(host port index type head socket_cache on_connect connect_timeout read_timeout); | ||||||||||||||||||||||||||
|
Condition33%1/3
$args->{$_} ||= $self->{$_}
MC/DC0%0/2
$args->{$_} ||= $self->{$_}
$args->{$_}
$self->{$_}
Truth table33%1/3
A ||= B
A= $args->{$_}B= $self->{$_}
| |||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub request { | ||||||||||||||||||||||||||||
| 22 | 14 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
request: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 14 | __fleshen_request_args($self, \%args); | |||||||||||||||||||||||||||
| 24 | 14 | return Elastijk::request(\%args); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub request_raw { | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
request_raw: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 0 | __fleshen_request_args($self, \%args); | |||||||||||||||||||||||||||
| 30 | 0 | return Elastijk::request_raw(\%args); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub index { | ||||||||||||||||||||||||||||
| 34 | 1 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
index: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | return $self->request(method => ( exists $args{id} ? "PUT" : "POST" ), %args); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub get { | ||||||||||||||||||||||||||||
| 39 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
get: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 1 | return $self->request(method => "GET", @_); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub put { | ||||||||||||||||||||||||||||
| 44 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
put: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 0 | $self->request(method => "PUT", @_); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | sub delete { | ||||||||||||||||||||||||||||
| 49 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 1 | return $self->request(method => "DELETE", @_); | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub head { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
head: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 55 | 0 | return $self->request(method => "HEAD", @_); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub post { | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
post: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | 0 | return $self->request(method => "POST", @_); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub exists { | ||||||||||||||||||||||||||||
| 64 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
exists: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 6 | my ($status,$res) = $self->request(method => "HEAD", @_); | |||||||||||||||||||||||||||
| 66 | 6 | return ($status,'2' eq substr($status,0,1)); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | sub search { | ||||||||||||||||||||||||||||
| 70 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
search: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | 4 | return $self->request(command => "_search", method => "GET", @_); | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | sub count { | ||||||||||||||||||||||||||||
| 75 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 76 | 0 | my ($status,$res) = $self->request(command => "_count", method => "GET", @_); | |||||||||||||||||||||||||||
| 77 | 0 | return ($status, $res->{count}); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | sub bulk { | ||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
bulk: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 0 | $args{body} = join("", map { $Elastijk::JSON->encode($_)."\n" } @{$args{body}}); | |||||||||||||||||||||||||||
| 84 | 0 | my ($status,$res) = $self->request_raw(method => "POST", command => "_bulk", %args); | |||||||||||||||||||||||||||
| 85 | 0 | ▶ | $res = $Elastijk::JSON->decode($res) if $res; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | 0 | return ($status, $res); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub scan_scroll { | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
scan_scroll: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $on_response_callback = delete $args{on_response}; | |||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my %uri_param = %{ delete($args{uri_param}) || {} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 94 | 0 | $uri_param{search_type} = "scan"; | |||||||||||||||||||||||||||
| 95 | 0 | ▶ | $uri_param{scroll} ||= "10m"; | ||||||||||||||||||||||||||
|
Condition0%0/2
$uri_param{"scroll"} ||= "10m"
MC/DC0%0/1
$uri_param{"scroll"} ||= "10m"
$uri_param{"scroll"}
Truth table0%0/2
A
A= $uri_param{"scroll"}
| |||||||||||||||||||||||||||||
| 96 | 0 | my $scroll_id; | |||||||||||||||||||||||||||
| 97 | 0 | my ($status, $res) = $self->get(%args, command => "_search", uri_param => \%uri_param); | |||||||||||||||||||||||||||
| 98 | 0 | ▶ | if (substr($status,0,1) ne '2') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 0 | return; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | while (1) { | |||||||||||||||||||||||||||
| 103 | 0 | $scroll_id = $res->{_scroll_id}; | |||||||||||||||||||||||||||
| 104 | ($status,$res) = $self->get( | ||||||||||||||||||||||||||||
| 105 | index => "_search", type => "scroll", #WTF | ||||||||||||||||||||||||||||
| 106 | 0 | uri_param => { scroll => $uri_param{scroll}, scroll_id => $scroll_id } | |||||||||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (substr($status,0,1) eq '2' && @{$res->{hits}{hits}} > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
substr($status, 0, 1) eq 2 and @{$res->{"hits"}{"hits"};} > 0
MC/DC0%0/2
substr($status, 0, 1) eq 2 and @{$res->{"hits"}{"hits"};} > 0
substr($status, 0, 1) eq 2
@{$res->{"hits"}{"hits"};} > 0
Truth table0%0/3
A and B
A= substr($status, 0, 1) eq 2B= @{$res->{"hits"}{"hits"};} > 0
| |||||||||||||||||||||||||||||
| 109 | 0 | my $r = $on_response_callback->($status, $res); | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | last if defined($r) && !$r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $r and not $r
MC/DC0%0/2
defined $r and not $r
defined $r
not $r
Truth table0%0/3
A and not(B)
A= defined $rB= not $r
| |||||||||||||||||||||||||||||
| 111 | 0 | $scroll_id = $res->{_scroll_id}; | |||||||||||||||||||||||||||
| 112 | } else { | ||||||||||||||||||||||||||||
| 113 | 0 | last; | |||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 3 | 1; | |||||||||||||||||||||||||||