line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PawsX::DynamoDB::DocumentClient::Util; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
4009605
|
use strict; |
|
8
|
|
|
|
|
23
|
|
|
8
|
|
|
|
|
229
|
|
4
|
8
|
|
|
8
|
|
219
|
use 5.008_005; |
|
8
|
|
|
|
|
31
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
40
|
use parent qw(Exporter); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
68
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
8
|
|
|
|
|
|
|
make_arg_transformer |
9
|
|
|
|
|
|
|
make_attr_map |
10
|
|
|
|
|
|
|
make_attr_name_map |
11
|
|
|
|
|
|
|
make_key |
12
|
|
|
|
|
|
|
make_assert_arrayref |
13
|
|
|
|
|
|
|
make_assert_hashref |
14
|
|
|
|
|
|
|
unmarshal_attribute_map |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
8
|
|
|
8
|
|
3973
|
use Net::Amazon::DynamoDB::Marshaler; |
|
8
|
|
|
|
|
16466
|
|
|
8
|
|
|
|
|
443
|
|
18
|
8
|
|
|
8
|
|
2971
|
use Paws::DynamoDB::AttributeValue; |
|
8
|
|
|
|
|
342745
|
|
|
8
|
|
|
|
|
367
|
|
19
|
8
|
|
|
8
|
|
4651
|
use Paws::DynamoDB::AttributeMap; |
|
8
|
|
|
|
|
172712
|
|
|
8
|
|
|
|
|
297
|
|
20
|
8
|
|
|
8
|
|
3986
|
use Paws::DynamoDB::ExpressionAttributeNameMap; |
|
8
|
|
|
|
|
202670
|
|
|
8
|
|
|
|
|
318
|
|
21
|
8
|
|
|
8
|
|
4104
|
use Paws::DynamoDB::MapAttributeValue; |
|
8
|
|
|
|
|
74916
|
|
|
8
|
|
|
|
|
257
|
|
22
|
8
|
|
|
8
|
|
3620
|
use Paws::DynamoDB::Key; |
|
8
|
|
|
|
|
76799
|
|
|
8
|
|
|
|
|
5525
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub make_arg_transformer { |
25
|
6
|
|
|
6
|
0
|
29
|
my %args = @_; |
26
|
6
|
|
50
|
|
|
35
|
my $method_name = $args{method_name} || die; |
27
|
6
|
|
50
|
|
|
30
|
my $to_marshall = $args{to_marshall} || die; |
28
|
6
|
|
|
|
|
23
|
my %to_marshall = map { $_ => 1 } @$to_marshall; |
|
11
|
|
|
|
|
48
|
|
29
|
|
|
|
|
|
|
return sub { |
30
|
41
|
|
|
41
|
|
91
|
my ($name, $val) = @_; |
31
|
41
|
100
|
|
|
|
214
|
return $val unless $to_marshall{$name}; |
32
|
22
|
100
|
66
|
|
|
218
|
die "$method_name(): $name must be a hashref" |
33
|
|
|
|
|
|
|
unless ref $val && ref $val eq 'HASH'; |
34
|
11
|
|
|
|
|
48
|
return dynamodb_marshal($val); |
35
|
6
|
|
|
|
|
51
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub unmarshal_attribute_map { |
39
|
21
|
|
|
21
|
0
|
80
|
my ($map) = @_; |
40
|
21
|
|
|
|
|
474
|
my $plain_vals = _translate_attr_map($map->Map); |
41
|
21
|
|
|
|
|
733
|
return dynamodb_unmarshal($plain_vals); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub make_attr_map { |
45
|
15
|
|
|
15
|
0
|
11971
|
my ($attrs) = @_; |
46
|
15
|
|
|
|
|
57
|
my %map = map { $_ => _make_attr_val($attrs->{$_}) } keys %$attrs; |
|
32
|
|
|
|
|
32498
|
|
47
|
15
|
|
|
|
|
27417
|
return Paws::DynamoDB::AttributeMap->new(Map => \%map); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub make_key { |
51
|
7
|
|
|
7
|
0
|
6626
|
my ($val) = @_; |
52
|
7
|
|
|
|
|
27
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
6
|
|
|
|
|
24
|
|
53
|
7
|
|
|
|
|
9723
|
return Paws::DynamoDB::Key->new( |
54
|
|
|
|
|
|
|
Map => \%map |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_attr_name_map { |
59
|
1
|
|
|
1
|
0
|
996
|
my ($names) = @_; |
60
|
1
|
|
|
|
|
9
|
return Paws::DynamoDB::ExpressionAttributeNameMap->new( |
61
|
|
|
|
|
|
|
Map => $names, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub make_assert_arrayref { |
66
|
2
|
|
|
2
|
0
|
4
|
my ($prefix) = @_; |
67
|
|
|
|
|
|
|
return sub { |
68
|
15
|
|
|
15
|
|
31
|
my ($label, $val) = @_; |
69
|
15
|
100
|
66
|
|
|
134
|
die "$prefix: $label must be an arrayref" unless ( |
|
|
|
66
|
|
|
|
|
70
|
|
|
|
|
|
|
$val |
71
|
|
|
|
|
|
|
&& ref $val |
72
|
|
|
|
|
|
|
&& ref $val eq 'ARRAY' |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
8
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub make_assert_hashref { |
78
|
2
|
|
|
2
|
0
|
6
|
my ($prefix) = @_; |
79
|
|
|
|
|
|
|
return sub { |
80
|
48
|
|
|
48
|
|
103
|
my ($label, $val) = @_; |
81
|
48
|
100
|
66
|
|
|
370
|
die "$prefix: $label must be a hashref" unless ( |
|
|
|
66
|
|
|
|
|
82
|
|
|
|
|
|
|
$val |
83
|
|
|
|
|
|
|
&& ref $val |
84
|
|
|
|
|
|
|
&& ref $val eq 'HASH' |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
2
|
|
|
|
|
13
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _translate_attr_map { |
90
|
22
|
|
|
22
|
|
226
|
my ($map) = @_; |
91
|
22
|
|
|
|
|
64
|
return { map { $_ => _translate_attr_val($map->{$_}) } keys %$map }; |
|
40
|
|
|
|
|
654
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _translate_attr_val { |
95
|
42
|
|
|
42
|
|
83
|
my ($attr_val) = @_; |
96
|
42
|
|
|
|
|
89
|
return { $_ => $attr_val->$_ } for grep { defined $attr_val->$_ } |
|
336
|
|
|
|
|
8554
|
|
97
|
|
|
|
|
|
|
qw(NULL S N BOOL B BS NS SS); |
98
|
2
|
100
|
|
|
|
59
|
return { M => _translate_attr_map($attr_val->M->Map) } |
99
|
|
|
|
|
|
|
if defined $attr_val->M; |
100
|
1
|
50
|
|
|
|
27
|
return { L => [ map { _translate_attr_val($_) } @{ $attr_val->L } ] } |
|
2
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
27
|
|
101
|
|
|
|
|
|
|
if defined $attr_val->L; |
102
|
0
|
|
|
|
|
0
|
die 'unable to extract value out of Paws::DynamoDB::AttributeValue object!'; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _make_attr_val { |
106
|
42
|
|
|
42
|
|
116
|
my ($type_and_val) = @_; |
107
|
42
|
|
|
|
|
136
|
my ($type, $val) = %$type_and_val; |
108
|
42
|
100
|
|
|
|
150
|
if ($type eq 'L') { |
109
|
1
|
|
|
|
|
3
|
my @list = map { _make_attr_val($_) } @$val; |
|
2
|
|
|
|
|
1576
|
|
110
|
1
|
|
|
|
|
1569
|
return Paws::DynamoDB::AttributeValue->new( |
111
|
|
|
|
|
|
|
L => \@list, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
} |
114
|
41
|
100
|
|
|
|
109
|
if ($type eq 'M') { |
115
|
1
|
|
|
|
|
16
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
2
|
|
|
|
|
1609
|
|
116
|
1
|
|
|
|
|
1588
|
return Paws::DynamoDB::AttributeValue->new( |
117
|
|
|
|
|
|
|
M => Paws::DynamoDB::MapAttributeValue->new( |
118
|
|
|
|
|
|
|
Map => \%map, |
119
|
|
|
|
|
|
|
), |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
40
|
|
|
|
|
236
|
return Paws::DynamoDB::AttributeValue->new( |
123
|
|
|
|
|
|
|
L => [], # Paws always returns an empty list |
124
|
|
|
|
|
|
|
$type => $val, |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
__END__ |