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