line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PawsX::DynamoDB::DocumentClient::Util; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
4482815
|
use strict; |
|
8
|
|
|
|
|
24
|
|
|
8
|
|
|
|
|
250
|
|
4
|
8
|
|
|
8
|
|
257
|
use 5.008_005; |
|
8
|
|
|
|
|
30
|
|
5
|
|
|
|
|
|
|
|
6
|
8
|
|
|
8
|
|
45
|
use parent qw(Exporter); |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
64
|
|
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
|
|
4700
|
use Net::Amazon::DynamoDB::Marshaler; |
|
8
|
|
|
|
|
495588
|
|
|
8
|
|
|
|
|
742
|
|
18
|
8
|
|
|
8
|
|
4303
|
use Paws::DynamoDB::AttributeValue; |
|
8
|
|
|
|
|
388945
|
|
|
8
|
|
|
|
|
393
|
|
19
|
8
|
|
|
8
|
|
5006
|
use Paws::DynamoDB::AttributeMap; |
|
8
|
|
|
|
|
184279
|
|
|
8
|
|
|
|
|
364
|
|
20
|
8
|
|
|
8
|
|
5951
|
use Paws::DynamoDB::ExpressionAttributeNameMap; |
|
8
|
|
|
|
|
233519
|
|
|
8
|
|
|
|
|
415
|
|
21
|
8
|
|
|
8
|
|
5209
|
use Paws::DynamoDB::MapAttributeValue; |
|
8
|
|
|
|
|
79667
|
|
|
8
|
|
|
|
|
334
|
|
22
|
8
|
|
|
8
|
|
4397
|
use Paws::DynamoDB::Key; |
|
8
|
|
|
|
|
85395
|
|
|
8
|
|
|
|
|
5994
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub make_arg_transformer { |
25
|
6
|
|
|
6
|
0
|
26
|
my %args = @_; |
26
|
6
|
|
50
|
|
|
33
|
my $method_name = $args{method_name} || die; |
27
|
6
|
|
50
|
|
|
25
|
my $to_marshall = $args{to_marshall} || die; |
28
|
6
|
|
|
|
|
16
|
my %to_marshall = map { $_ => 1 } @$to_marshall; |
|
11
|
|
|
|
|
41
|
|
29
|
|
|
|
|
|
|
return sub { |
30
|
58
|
|
|
58
|
|
146
|
my ($name, $val, $force_type) = @_; |
31
|
58
|
100
|
|
|
|
324
|
return $val unless $to_marshall{$name}; |
32
|
31
|
100
|
66
|
|
|
352
|
die "$method_name(): $name must be a hashref" |
33
|
|
|
|
|
|
|
unless ref $val && ref $val eq 'HASH'; |
34
|
20
|
|
100
|
|
|
91
|
$force_type ||= {}; |
35
|
20
|
|
|
|
|
100
|
return dynamodb_marshal($val, force_type => $force_type); |
36
|
6
|
|
|
|
|
45
|
}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub unmarshal_attribute_map { |
40
|
21
|
|
|
21
|
0
|
96
|
my ($map) = @_; |
41
|
21
|
|
|
|
|
548
|
my $plain_vals = _translate_attr_map($map->Map); |
42
|
21
|
|
|
|
|
813
|
return dynamodb_unmarshal($plain_vals); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub make_attr_map { |
46
|
15
|
|
|
15
|
0
|
13791
|
my ($attrs) = @_; |
47
|
15
|
|
|
|
|
96
|
my %map = map { $_ => _make_attr_val($attrs->{$_}) } keys %$attrs; |
|
32
|
|
|
|
|
33520
|
|
48
|
15
|
|
|
|
|
28044
|
return Paws::DynamoDB::AttributeMap->new(Map => \%map); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub make_key { |
52
|
7
|
|
|
7
|
0
|
7126
|
my ($val) = @_; |
53
|
7
|
|
|
|
|
31
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
6
|
|
|
|
|
27
|
|
54
|
7
|
|
|
|
|
10218
|
return Paws::DynamoDB::Key->new( |
55
|
|
|
|
|
|
|
Map => \%map |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub make_attr_name_map { |
60
|
1
|
|
|
1
|
0
|
1065
|
my ($names) = @_; |
61
|
1
|
|
|
|
|
12
|
return Paws::DynamoDB::ExpressionAttributeNameMap->new( |
62
|
|
|
|
|
|
|
Map => $names, |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub make_assert_arrayref { |
67
|
2
|
|
|
2
|
0
|
6
|
my ($prefix) = @_; |
68
|
|
|
|
|
|
|
return sub { |
69
|
17
|
|
|
17
|
|
41
|
my ($label, $val) = @_; |
70
|
17
|
100
|
66
|
|
|
156
|
die "$prefix: $label must be an arrayref" unless ( |
|
|
|
66
|
|
|
|
|
71
|
|
|
|
|
|
|
$val |
72
|
|
|
|
|
|
|
&& ref $val |
73
|
|
|
|
|
|
|
&& ref $val eq 'ARRAY' |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
2
|
|
|
|
|
8
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub make_assert_hashref { |
79
|
2
|
|
|
2
|
0
|
7
|
my ($prefix) = @_; |
80
|
|
|
|
|
|
|
return sub { |
81
|
58
|
|
|
58
|
|
123
|
my ($label, $val) = @_; |
82
|
58
|
100
|
66
|
|
|
474
|
die "$prefix: $label must be a hashref" unless ( |
|
|
|
66
|
|
|
|
|
83
|
|
|
|
|
|
|
$val |
84
|
|
|
|
|
|
|
&& ref $val |
85
|
|
|
|
|
|
|
&& ref $val eq 'HASH' |
86
|
|
|
|
|
|
|
); |
87
|
|
|
|
|
|
|
} |
88
|
2
|
|
|
|
|
15
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _translate_attr_map { |
91
|
22
|
|
|
22
|
|
265
|
my ($map) = @_; |
92
|
22
|
|
|
|
|
74
|
return { map { $_ => _translate_attr_val($map->{$_}) } keys %$map }; |
|
40
|
|
|
|
|
693
|
|
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _translate_attr_val { |
96
|
42
|
|
|
42
|
|
90
|
my ($attr_val) = @_; |
97
|
42
|
|
|
|
|
92
|
return { $_ => $attr_val->$_ } for grep { defined $attr_val->$_ } |
|
336
|
|
|
|
|
9010
|
|
98
|
|
|
|
|
|
|
qw(NULL S N BOOL B BS NS SS); |
99
|
2
|
100
|
|
|
|
75
|
return { M => _translate_attr_map($attr_val->M->Map) } |
100
|
|
|
|
|
|
|
if defined $attr_val->M; |
101
|
1
|
50
|
|
|
|
32
|
return { L => [ map { _translate_attr_val($_) } @{ $attr_val->L } ] } |
|
2
|
|
|
|
|
43
|
|
|
1
|
|
|
|
|
30
|
|
102
|
|
|
|
|
|
|
if defined $attr_val->L; |
103
|
0
|
|
|
|
|
0
|
die 'unable to extract value out of Paws::DynamoDB::AttributeValue object!'; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _make_attr_val { |
107
|
42
|
|
|
42
|
|
110
|
my ($type_and_val) = @_; |
108
|
42
|
|
|
|
|
160
|
my ($type, $val) = %$type_and_val; |
109
|
42
|
100
|
|
|
|
172
|
if ($type eq 'L') { |
110
|
1
|
|
|
|
|
5
|
my @list = map { _make_attr_val($_) } @$val; |
|
2
|
|
|
|
|
1701
|
|
111
|
1
|
|
|
|
|
2142
|
return Paws::DynamoDB::AttributeValue->new( |
112
|
|
|
|
|
|
|
L => \@list, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
41
|
100
|
|
|
|
129
|
if ($type eq 'M') { |
116
|
1
|
|
|
|
|
5
|
my %map = map { $_ => _make_attr_val($val->{$_}) } keys %$val; |
|
2
|
|
|
|
|
1754
|
|
117
|
1
|
|
|
|
|
1651
|
return Paws::DynamoDB::AttributeValue->new( |
118
|
|
|
|
|
|
|
M => Paws::DynamoDB::MapAttributeValue->new( |
119
|
|
|
|
|
|
|
Map => \%map, |
120
|
|
|
|
|
|
|
), |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
} |
123
|
40
|
|
|
|
|
288
|
return Paws::DynamoDB::AttributeValue->new( |
124
|
|
|
|
|
|
|
L => [], # Paws always returns an empty list |
125
|
|
|
|
|
|
|
$type => $val, |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
__END__ |