line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Grep::Query::Parser::QOPS;
|
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
55
|
use strict;
|
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
229
|
|
4
|
10
|
|
|
10
|
|
40
|
use warnings;
|
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
6392
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.010';
|
7
|
|
|
|
|
|
|
$VERSION = eval $VERSION;
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub __union
|
10
|
|
|
|
|
|
|
{
|
11
|
80
|
|
|
80
|
|
125
|
my $l = shift;
|
12
|
80
|
|
|
|
|
117
|
my $r = shift;
|
13
|
|
|
|
|
|
|
|
14
|
80
|
|
|
|
|
165
|
return __unionOrIntersection($l, $r, 0);
|
15
|
|
|
|
|
|
|
}
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub __intersection
|
18
|
|
|
|
|
|
|
{
|
19
|
385
|
|
|
385
|
|
525
|
my $l = shift;
|
20
|
385
|
|
|
|
|
503
|
my $r = shift;
|
21
|
|
|
|
|
|
|
|
22
|
385
|
|
|
|
|
735
|
return __unionOrIntersection($l, $r, 1);
|
23
|
|
|
|
|
|
|
}
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub __difference
|
26
|
|
|
|
|
|
|
{
|
27
|
57
|
|
|
57
|
|
92
|
my $l = shift;
|
28
|
57
|
|
|
|
|
86
|
my $r = shift;
|
29
|
|
|
|
|
|
|
|
30
|
57
|
|
|
|
|
78
|
my %diff;
|
31
|
57
|
|
|
|
|
229
|
foreach my $item (keys(%$r))
|
32
|
|
|
|
|
|
|
{
|
33
|
1413
|
100
|
|
|
|
2649
|
$diff{$item} = $r->{$item} unless exists($l->{$item});
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
|
36
|
57
|
|
|
|
|
197
|
return \%diff;
|
37
|
|
|
|
|
|
|
}
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub __unionOrIntersection
|
40
|
|
|
|
|
|
|
{
|
41
|
465
|
|
|
465
|
|
707
|
my $l = shift;
|
42
|
465
|
|
|
|
|
591
|
my $r = shift;
|
43
|
465
|
|
|
|
|
556
|
my $modeIntersection = shift;
|
44
|
|
|
|
|
|
|
|
45
|
465
|
|
|
|
|
624
|
my %union;
|
46
|
|
|
|
|
|
|
my %intersect;
|
47
|
|
|
|
|
|
|
|
48
|
465
|
|
|
|
|
1920
|
foreach my $e (keys(%$l), keys(%$r))
|
49
|
|
|
|
|
|
|
{
|
50
|
9500
|
100
|
|
|
|
15275
|
$union{$e}++ && $intersect{$e}++;
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
|
53
|
465
|
100
|
|
|
|
1160
|
my $h = $modeIntersection ? \%intersect : \%union;
|
54
|
|
|
|
|
|
|
|
55
|
465
|
|
|
|
|
581
|
my %answer;
|
56
|
465
|
|
66
|
|
|
3607
|
$answer{$_} = ($l->{$_} || $r->{$_}) foreach (keys(%$h));
|
57
|
|
|
|
|
|
|
|
58
|
465
|
|
|
|
|
2576
|
return \%answer;
|
59
|
|
|
|
|
|
|
}
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
### INDIVIDUAL OPERATIONS
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
## disj
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
package Grep::Query::Parser::QOPS::disj;
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub xeq
|
68
|
|
|
|
|
|
|
{
|
69
|
435
|
|
|
435
|
|
682
|
my $self = shift;
|
70
|
435
|
|
|
|
|
628
|
my $fieldAccessor = shift;
|
71
|
435
|
|
|
|
|
531
|
my $data = shift;
|
72
|
|
|
|
|
|
|
|
73
|
435
|
|
|
|
|
1008
|
my $answer = $self->{conj}->xeq($fieldAccessor, $data);
|
74
|
435
|
100
|
|
|
|
884
|
if (exists($self->{__ALT}))
|
75
|
|
|
|
|
|
|
{
|
76
|
80
|
|
|
|
|
128
|
foreach my $alt (@{$self->{__ALT}})
|
|
80
|
|
|
|
|
204
|
|
77
|
|
|
|
|
|
|
{
|
78
|
80
|
|
|
|
|
202
|
$answer = Grep::Query::Parser::QOPS::__union($answer, $alt->{conj}->xeq($fieldAccessor, $data));
|
79
|
|
|
|
|
|
|
}
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
|
82
|
435
|
|
|
|
|
2594
|
return $answer;
|
83
|
|
|
|
|
|
|
}
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
## conj
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
package Grep::Query::Parser::QOPS::conj;
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub xeq
|
90
|
|
|
|
|
|
|
{
|
91
|
515
|
|
|
515
|
|
735
|
my $self = shift;
|
92
|
515
|
|
|
|
|
676
|
my $fieldAccessor = shift;
|
93
|
515
|
|
|
|
|
666
|
my $data = shift;
|
94
|
|
|
|
|
|
|
|
95
|
515
|
|
|
|
|
1000
|
my $answer = $self->{unary}->xeq($fieldAccessor, $data);
|
96
|
515
|
100
|
|
|
|
1024
|
if (exists($self->{__ALT}))
|
97
|
|
|
|
|
|
|
{
|
98
|
220
|
|
|
|
|
344
|
foreach my $alt (@{$self->{__ALT}})
|
|
220
|
|
|
|
|
529
|
|
99
|
|
|
|
|
|
|
{
|
100
|
385
|
50
|
|
|
|
974
|
next unless keys(%$answer);
|
101
|
385
|
|
|
|
|
834
|
$answer = Grep::Query::Parser::QOPS::__intersection($answer, $alt->{unary}->xeq($fieldAccessor, $data));
|
102
|
|
|
|
|
|
|
}
|
103
|
|
|
|
|
|
|
}
|
104
|
|
|
|
|
|
|
|
105
|
515
|
|
|
|
|
938
|
return $answer;
|
106
|
|
|
|
|
|
|
}
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
## unary
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
package Grep::Query::Parser::QOPS::unary;
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub xeq
|
113
|
|
|
|
|
|
|
{
|
114
|
900
|
|
|
900
|
|
1205
|
my $self = shift;
|
115
|
900
|
|
|
|
|
1111
|
my $fieldAccessor = shift;
|
116
|
900
|
|
|
|
|
1107
|
my $data = shift;
|
117
|
|
|
|
|
|
|
|
118
|
900
|
100
|
|
|
|
1602
|
my $o = exists($self->{disj}) ? $self->{disj} : $self->{field_op_value_test};
|
119
|
900
|
|
|
|
|
1589
|
my $answer = $o->xeq($fieldAccessor, $data);
|
120
|
900
|
100
|
|
|
|
1843
|
$answer = Grep::Query::Parser::QOPS::__difference($answer, $data) if $self->{not};
|
121
|
|
|
|
|
|
|
|
122
|
900
|
|
|
|
|
1631
|
return $answer;
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
## atom
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
package Grep::Query::Parser::QOPS::field_op_value_test;
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub xeq
|
130
|
|
|
|
|
|
|
{
|
131
|
792
|
|
|
792
|
|
949
|
my $self = shift;
|
132
|
792
|
|
|
|
|
1292
|
my $fieldAccessor = shift;
|
133
|
792
|
|
|
|
|
944
|
my $data = shift;
|
134
|
|
|
|
|
|
|
|
135
|
792
|
|
|
|
|
928
|
my %answer;
|
136
|
|
|
|
|
|
|
grep
|
137
|
|
|
|
|
|
|
{
|
138
|
792
|
|
|
|
|
2741
|
my $rv = $data->{$_};
|
|
19242
|
|
|
|
|
24674
|
|
139
|
19242
|
100
|
|
|
|
37492
|
my $v = defined($fieldAccessor) ? $fieldAccessor->access($self->{field}, $$rv) : $$rv;
|
140
|
19242
|
100
|
|
|
|
318967
|
$answer{$_} = $rv if $self->{op}->($v, $self->{value});
|
141
|
19242
|
|
|
|
|
32577
|
0;
|
142
|
|
|
|
|
|
|
} keys(%$data);
|
143
|
|
|
|
|
|
|
|
144
|
792
|
|
|
|
|
2324
|
return \%answer;
|
145
|
|
|
|
|
|
|
}
|
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1;
|