line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PawsX::DynamoDB::DocumentClient::Util; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
5128688
|
use strict; |
|
8
|
|
|
|
|
26
|
|
|
8
|
|
|
|
|
254
|
|
4
|
8
|
|
|
8
|
|
252
|
use 5.008_005; |
|
8
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
48
|
use parent qw(Exporter); |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
62
|
|
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
|
|
4638
|
use Net::Amazon::DynamoDB::Marshaler; |
|
8
|
|
|
|
|
17912
|
|
|
8
|
|
|
|
|
468
|
|
18
|
8
|
|
|
8
|
|
3683
|
use Paws::DynamoDB::AttributeValue; |
|
8
|
|
|
|
|
417513
|
|
|
8
|
|
|
|
|
395
|
|
19
|
8
|
|
|
8
|
|
5017
|
use Paws::DynamoDB::AttributeMap; |
|
8
|
|
|
|
|
213348
|
|
|
8
|
|
|
|
|
390
|
|
20
|
8
|
|
|
8
|
|
4972
|
use Paws::DynamoDB::ExpressionAttributeNameMap; |
|
8
|
|
|
|
|
256830
|
|
|
8
|
|
|
|
|
379
|
|
21
|
8
|
|
|
8
|
|
4679
|
use Paws::DynamoDB::MapAttributeValue; |
|
8
|
|
|
|
|
87750
|
|
|
8
|
|
|
|
|
332
|
|
22
|
8
|
|
|
8
|
|
4642
|
use Paws::DynamoDB::Key; |
|
8
|
|
|
|
|
94145
|
|
|
8
|
|
|
|
|
6791
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub make_arg_transformer { |
25
|
6
|
|
|
6
|
0
|
30
|
my %args = @_; |
26
|
6
|
|
50
|
|
|
36
|
my $method_name = $args{method_name} || die; |
27
|
6
|
|
50
|
|
|
28
|
my $to_marshall = $args{to_marshall} || die; |
28
|
6
|
|
|
|
|
21
|
my %to_marshall = map { $_ => 1 } @$to_marshall; |
|
11
|
|
|
|
|
48
|
|
29
|
|
|
|
|
|
|
return sub { |
30
|
41
|
|
|
41
|
|
102
|
my ($name, $val) = @_; |
31
|
41
|
100
|
|
|
|
184
|
return $val unless $to_marshall{$name}; |
32
|
22
|
100
|
66
|
|
|
237
|
die "$method_name(): $name must be a hashref" |
33
|
|
|
|
|
|
|
unless ref $val && ref $val eq 'HASH'; |
34
|
11
|
|
|
|
|
62
|
return dynamodb_marshal($val); |
35
|
6
|
|
|
|
|
51
|
}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub unmarshal_attribute_map { |
39
|
21
|
|
|
21
|
0
|
89
|
my ($map) = @_; |
40
|
21
|
|
|
|
|
607
|
my $plain_vals = _translate_attr_map($map->Map); |
41
|
21
|
|
|
|
|
840
|
return dynamodb_unmarshal($plain_vals); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub make_attr_map { |
45
|
15
|
|
|
15
|
0
|
20785
|
my ($attrs) = @_; |
46
|
15
|
|
|
|
|
64
|
my %map = map { $_ => _make_attr_val($attrs->{$_}) } keys %$attrs; |
|
32
|
|
|
|
|
32848
|
|
47
|
15
|
|
|
|
|
26601
|
return Paws::DynamoDB::AttributeMap->new(Map => \%map); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub make_key { |
51
|
7
|
|
|
7
|
0
|
8932
|
my ($val) = @_; |
52
|
7
|
|
|
|
|
27
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
6
|
|
|
|
|
36
|
|
53
|
7
|
|
|
|
|
10581
|
return Paws::DynamoDB::Key->new( |
54
|
|
|
|
|
|
|
Map => \%map |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_attr_name_map { |
59
|
1
|
|
|
1
|
0
|
983
|
my ($names) = @_; |
60
|
1
|
|
|
|
|
10
|
return Paws::DynamoDB::ExpressionAttributeNameMap->new( |
61
|
|
|
|
|
|
|
Map => $names, |
62
|
|
|
|
|
|
|
); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub make_assert_arrayref { |
66
|
2
|
|
|
2
|
0
|
5
|
my ($prefix) = @_; |
67
|
|
|
|
|
|
|
return sub { |
68
|
15
|
|
|
15
|
|
42
|
my ($label, $val) = @_; |
69
|
15
|
100
|
66
|
|
|
161
|
die "$prefix: $label must be an arrayref" unless ( |
|
|
|
66
|
|
|
|
|
70
|
|
|
|
|
|
|
$val |
71
|
|
|
|
|
|
|
&& ref $val |
72
|
|
|
|
|
|
|
&& ref $val eq 'ARRAY' |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
10
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub make_assert_hashref { |
78
|
2
|
|
|
2
|
0
|
7
|
my ($prefix) = @_; |
79
|
|
|
|
|
|
|
return sub { |
80
|
48
|
|
|
48
|
|
134
|
my ($label, $val) = @_; |
81
|
48
|
100
|
66
|
|
|
518
|
die "$prefix: $label must be a hashref" unless ( |
|
|
|
66
|
|
|
|
|
82
|
|
|
|
|
|
|
$val |
83
|
|
|
|
|
|
|
&& ref $val |
84
|
|
|
|
|
|
|
&& ref $val eq 'HASH' |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
} |
87
|
2
|
|
|
|
|
17
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _translate_attr_map { |
90
|
22
|
|
|
22
|
|
244
|
my ($map) = @_; |
91
|
22
|
|
|
|
|
74
|
return { map { $_ => _translate_attr_val($map->{$_}) } keys %$map }; |
|
40
|
|
|
|
|
708
|
|
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub _translate_attr_val { |
95
|
42
|
|
|
42
|
|
86
|
my ($attr_val) = @_; |
96
|
42
|
|
|
|
|
88
|
return { $_ => $attr_val->$_ } for grep { defined $attr_val->$_ } |
|
336
|
|
|
|
|
9158
|
|
97
|
|
|
|
|
|
|
qw(NULL S N BOOL B BS NS SS); |
98
|
2
|
100
|
|
|
|
78
|
return { M => _translate_attr_map($attr_val->M->Map) } |
99
|
|
|
|
|
|
|
if defined $attr_val->M; |
100
|
1
|
50
|
|
|
|
34
|
return { L => [ map { _translate_attr_val($_) } @{ $attr_val->L } ] } |
|
2
|
|
|
|
|
40
|
|
|
1
|
|
|
|
|
35
|
|
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
|
|
100
|
my ($type_and_val) = @_; |
107
|
42
|
|
|
|
|
180
|
my ($type, $val) = %$type_and_val; |
108
|
42
|
100
|
|
|
|
165
|
if ($type eq 'L') { |
109
|
1
|
|
|
|
|
4
|
my @list = map { _make_attr_val($_) } @$val; |
|
2
|
|
|
|
|
1795
|
|
110
|
1
|
|
|
|
|
1829
|
return Paws::DynamoDB::AttributeValue->new( |
111
|
|
|
|
|
|
|
L => \@list, |
112
|
|
|
|
|
|
|
); |
113
|
|
|
|
|
|
|
} |
114
|
41
|
100
|
|
|
|
125
|
if ($type eq 'M') { |
115
|
1
|
|
|
|
|
5
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
2
|
|
|
|
|
1865
|
|
116
|
1
|
|
|
|
|
1712
|
return Paws::DynamoDB::AttributeValue->new( |
117
|
|
|
|
|
|
|
M => Paws::DynamoDB::MapAttributeValue->new( |
118
|
|
|
|
|
|
|
Map => \%map, |
119
|
|
|
|
|
|
|
), |
120
|
|
|
|
|
|
|
); |
121
|
|
|
|
|
|
|
} |
122
|
40
|
|
|
|
|
252
|
return Paws::DynamoDB::AttributeValue->new( |
123
|
|
|
|
|
|
|
L => [], # Paws always returns an empty list |
124
|
|
|
|
|
|
|
$type => $val, |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
__END__ |