line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package PawsX::DynamoDB::DocumentClient::BatchWrite; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
614
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
19
|
use 5.008_005; |
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Net::Amazon::DynamoDB::Marshaler; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
7
|
1
|
|
|
|
|
533
|
use PawsX::DynamoDB::DocumentClient::Util qw( |
8
|
|
|
|
|
|
|
make_assert_arrayref |
9
|
|
|
|
|
|
|
make_assert_hashref |
10
|
|
|
|
|
|
|
unmarshal_attribute_map |
11
|
1
|
|
|
1
|
|
5
|
); |
|
1
|
|
|
|
|
2
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $METHOD_NAME = 'batch_write()'; |
14
|
|
|
|
|
|
|
my $ASSERT_HASHREF = make_assert_hashref($METHOD_NAME); |
15
|
|
|
|
|
|
|
my $ASSERT_ARRAYREF = make_assert_arrayref($METHOD_NAME); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub transform_arguments { |
18
|
11
|
|
|
11
|
0
|
8750
|
my $class = shift; |
19
|
11
|
|
|
|
|
34
|
my %args = @_; |
20
|
|
|
|
|
|
|
return ( |
21
|
|
|
|
|
|
|
%args, |
22
|
11
|
|
|
|
|
30
|
RequestItems => _marshall_request_items($args{RequestItems}), |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub transform_output { |
27
|
1
|
|
|
1
|
0
|
2805
|
my ($class, $output) = @_; |
28
|
1
|
|
|
|
|
28
|
my $tables = $output->UnprocessedItems->Map; |
29
|
1
|
50
|
|
|
|
39
|
return undef unless %$tables; |
30
|
|
|
|
|
|
|
return { |
31
|
1
|
|
|
|
|
3
|
map { $_ => _unmarshall_requests($tables->{$_}) } |
|
2
|
|
|
|
|
35
|
|
32
|
|
|
|
|
|
|
keys %$tables |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub run_service_command { |
37
|
0
|
|
|
0
|
0
|
0
|
my ($class, $service, %args) = @_; |
38
|
0
|
|
|
|
|
0
|
return $service->BatchWriteItem(%args); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _marshall_request_items { |
42
|
11
|
|
|
11
|
|
22
|
my ($tables) = @_; |
43
|
11
|
|
|
|
|
42
|
$ASSERT_HASHREF->('RequestItems', $tables); |
44
|
|
|
|
|
|
|
return { |
45
|
10
|
|
|
|
|
32
|
map { $_ => _marshall_request_items_list($tables->{$_}) } |
|
11
|
|
|
|
|
86
|
|
46
|
|
|
|
|
|
|
keys %$tables |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub _marshall_request_items_list { |
51
|
11
|
|
|
11
|
|
21
|
my ($requests) = @_; |
52
|
11
|
|
|
|
|
36
|
$ASSERT_ARRAYREF->('RequestItems value', $requests); |
53
|
10
|
|
|
|
|
24
|
return [ map { _marshall_request($_) } @$requests ]; |
|
12
|
|
|
|
|
87
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _marshall_request { |
57
|
12
|
|
|
12
|
|
20
|
my ($request) = @_; |
58
|
12
|
|
|
|
|
36
|
$ASSERT_HASHREF->('write request', $request); |
59
|
11
|
|
|
|
|
20
|
my $put_request = $request->{PutRequest}; |
60
|
11
|
|
|
|
|
22
|
my $delete_request = $request->{DeleteRequest}; |
61
|
|
|
|
|
|
|
|
62
|
11
|
100
|
100
|
|
|
44
|
die "$METHOD_NAME: write request missing PutRequest or DeleteRequest" |
63
|
|
|
|
|
|
|
unless ($put_request || $delete_request); |
64
|
|
|
|
|
|
|
|
65
|
10
|
100
|
|
|
|
27
|
return _marshall_put_request($put_request) if $put_request; |
66
|
4
|
|
|
|
|
10
|
return _marshall_delete_request($delete_request); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub _marshall_put_request { |
70
|
6
|
|
|
6
|
|
11
|
my ($val) = @_; |
71
|
6
|
|
|
|
|
17
|
$ASSERT_HASHREF->('PutRequest', $val); |
72
|
5
|
|
|
|
|
10
|
my $item = $val->{Item}; |
73
|
5
|
100
|
|
|
|
19
|
die "$METHOD_NAME: PutRequest must contain Item" unless $item; |
74
|
4
|
|
|
|
|
11
|
$ASSERT_HASHREF->(q|PutRequest's Item|, $item); |
75
|
|
|
|
|
|
|
return { |
76
|
3
|
|
|
|
|
10
|
PutRequest => { |
77
|
|
|
|
|
|
|
Item => dynamodb_marshal($item), |
78
|
|
|
|
|
|
|
}, |
79
|
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _marshall_delete_request { |
83
|
4
|
|
|
4
|
|
8
|
my ($val) = @_; |
84
|
4
|
|
|
|
|
13
|
$ASSERT_HASHREF->(q|DeleteRequest|, $val); |
85
|
3
|
|
|
|
|
6
|
my $key = $val->{Key}; |
86
|
3
|
100
|
|
|
|
15
|
die "$METHOD_NAME: DeleteRequest must contain Key" unless $key; |
87
|
2
|
|
|
|
|
7
|
$ASSERT_HASHREF->(q|DeleteRequest's Key|, $key); |
88
|
|
|
|
|
|
|
return { |
89
|
1
|
|
|
|
|
3
|
DeleteRequest => { |
90
|
|
|
|
|
|
|
Key => dynamodb_marshal($key), |
91
|
|
|
|
|
|
|
}, |
92
|
|
|
|
|
|
|
}; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _unmarshall_requests { |
96
|
2
|
|
|
2
|
|
5
|
my ($requests) = @_; |
97
|
2
|
|
|
|
|
4
|
return [ map { _unmarshall_request($_) } @$requests ]; |
|
3
|
|
|
|
|
38
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _unmarshall_request { |
101
|
3
|
|
|
3
|
|
6
|
my ($request) = @_; |
102
|
3
|
100
|
|
|
|
71
|
return $request->PutRequest |
103
|
|
|
|
|
|
|
? _unmarshall_put_request($request->PutRequest) |
104
|
|
|
|
|
|
|
: _unmarshall_delete_request($request->DeleteRequest); |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _unmarshall_put_request { |
108
|
2
|
|
|
2
|
|
63
|
my ($request) = @_; |
109
|
|
|
|
|
|
|
return { |
110
|
2
|
|
|
|
|
43
|
PutRequest => { |
111
|
|
|
|
|
|
|
Item => unmarshal_attribute_map($request->Item), |
112
|
|
|
|
|
|
|
}, |
113
|
|
|
|
|
|
|
}; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _unmarshall_delete_request { |
117
|
1
|
|
|
1
|
|
37
|
my ($request) = @_; |
118
|
|
|
|
|
|
|
return { |
119
|
1
|
|
|
|
|
29
|
DeleteRequest => { |
120
|
|
|
|
|
|
|
Key => unmarshal_attribute_map($request->Key), |
121
|
|
|
|
|
|
|
}, |
122
|
|
|
|
|
|
|
}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
__END__ |