← Index
NYTProf Performance Profile   « block view • line view • sub view »
For 05.Domain_and_Item.t
  Run on Tue May 4 17:21:41 2010
Reported on Tue May 4 17:23:13 2010

File /data/SimpleDB-Class/author.t/../lib/SimpleDB/Class/ResultSet.pm
Statements Executed 644
Statement Execution Time 3.58ms
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
231021.80ms602msSimpleDB::Class::ResultSet::::nextSimpleDB::Class::ResultSet::next
1021770µs848msSimpleDB::Class::ResultSet::::fetch_resultSimpleDB::Class::ResultSet::fetch_result
441248µs316msSimpleDB::Class::ResultSet::::countSimpleDB::Class::ResultSet::count
111111µs391msSimpleDB::Class::ResultSet::::paginateSimpleDB::Class::ResultSet::paginate
11132µs2.54msSimpleDB::Class::ResultSet::::BEGIN@21SimpleDB::Class::ResultSet::BEGIN@21
71120µs20µsSimpleDB::Class::ResultSet::::__ANON__[../lib/SimpleDB/Class/ResultSet.pm:109]SimpleDB::Class::ResultSet::__ANON__[../lib/SimpleDB/Class/ResultSet.pm:109]
11113µs112µsSimpleDB::Class::ResultSet::::BEGIN@520SimpleDB::Class::ResultSet::BEGIN@520
1115µs5µsSimpleDB::Class::ResultSet::::BEGIN@22SimpleDB::Class::ResultSet::BEGIN@22
0000s0sSimpleDB::Class::ResultSet::::__ANON__[../lib/SimpleDB/Class/ResultSet.pm:182]SimpleDB::Class::ResultSet::__ANON__[../lib/SimpleDB/Class/ResultSet.pm:182]
0000s0sSimpleDB::Class::ResultSet::::deleteSimpleDB::Class::ResultSet::delete
0000s0sSimpleDB::Class::ResultSet::::searchSimpleDB::Class::ResultSet::search
0000s0sSimpleDB::Class::ResultSet::::to_array_refSimpleDB::Class::ResultSet::to_array_ref
0000s0sSimpleDB::Class::ResultSet::::updateSimpleDB::Class::ResultSet::update
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package SimpleDB::Class::ResultSet;
2
3=head1 NAME
4
5SimpleDB::Class::ResultSet - An iterator of items from a domain.
6
7=head1 DESCRIPTION
8
9This class is an iterator to walk to the items passed back from a query.
10
11B<Warning:> Once you have a result set and you start calling methods on it, it will begin iterating over the result set. Therefore you can't call both C<next> and C<search>, or any other combinations of methods on an existing result set.
12
13B<Warning:> If you call a method like C<search> on a result set which causes another query to be run, know that the original result set must be very small. This is because there is a limit of 20 comparisons per request as a limitation of SimpleDB.
14
15=head1 METHODS
16
17The following methods are available from this class.
18
19=cut
20
21330µs25.05ms
# spent 2.54ms (32µs+2.51) within SimpleDB::Class::ResultSet::BEGIN@21 which was called # once (32µs+2.51ms) by SimpleDB::Class::Domain::BEGIN@19 at line 21
use Moose;
# spent 2.54ms making 1 call to SimpleDB::Class::ResultSet::BEGIN@21 # spent 2.51ms making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:389]
223994µs15µs
# spent 5µs within SimpleDB::Class::ResultSet::BEGIN@22 which was called # once (5µs+0s) by SimpleDB::Class::Domain::BEGIN@19 at line 22
use SimpleDB::Class::SQL;
# spent 5µs making 1 call to SimpleDB::Class::ResultSet::BEGIN@22
23
24#--------------------------------------------------------
25
26=head2 new ( params )
27
28Constructor.
29
30=head3 params
31
32A hash.
33
34=head4 simpledb
35
36Required. A L<SimpleDB::Class> object.
37
38=head4 item_class
39
40Required. A L<SimpleDB::Class::Item> subclass name.
41
42=head4 result
43
44A result as returned from the send_request() method from L<SimpleDB::Client>. Either this or a where is required.
45
46=head4 where
47
48A where clause as defined in L<SimpleDB::Class::SQL>. Either this or a result is required.
49
50=head4 order_by
51
52An order_by clause as defined in L<SimpleDB::Class::SQL>. Optional.
53
54=head4 limit
55
56A limit clause as defined in L<SimpleDB::Class::SQL>. Optional. B<NOTE:>SimpleDB defines a limit as the number of results to limit to each Next Token, but SimpleDB::Class::ResultSet enforces the limit to be more like a traditional relational database, so calling C<next()> after the limit will return C<undef> just as if there were no more results left to display.
57
58=head4 consistent
59
60A boolean that if set true will get around Eventual Consistency, but at a reduced performance. Optional.
61
62=head4 set
63
64A hash reference of attribute names and values, which will be set on the item as C<next> is called. Doing so helps to prevent stale object references.
65
66=cut
67
68#--------------------------------------------------------
69
70=head2 item_class ( )
71
72Returns the item_class passed into the constructor.
73
74=cut
75
7613µs11.45mshas item_class => (
# spent 1.45ms making 1 call to Moose::has
77 is => 'ro',
78 isa => 'ClassName',
79 required => 1,
80);
81
8212µs159.8mswith 'SimpleDB::Class::Role::Itemized';
# spent 59.8ms making 1 call to Moose::with
83
84#--------------------------------------------------------
85
86=head2 consistent ( )
87
88Returns the consistent value passed into the constructor.
89
90=cut
91
9214µs11.70mshas consistent => (
# spent 1.70ms making 1 call to Moose::has
93 is => 'ro',
94 isa => 'Bool',
95 default => 0,
96);
97
98#--------------------------------------------------------
99
100=head2 set ( )
101
102Returns the set value passed into the constructor.
103
104=cut
105
106has set => (
107 is => 'ro',
108 isa => 'HashRef',
109725µs
# spent 20µs within SimpleDB::Class::ResultSet::__ANON__[../lib/SimpleDB/Class/ResultSet.pm:109] which was called 7 times, avg 3µs/call: # 7 times (20µs+0s) by Class::MOP::Mixin::AttributeCore::default at line 53 of Class/MOP/Mixin/AttributeCore.pm, avg 3µs/call
default => sub { {} },
11016µs11.10ms);
# spent 1.10ms making 1 call to Moose::has
111
112#--------------------------------------------------------
113
114=head2 where ( )
115
116Returns the where passed into the constructor.
117
118=cut
119
12012µs1940µshas where => (
# spent 940µs making 1 call to Moose::has
121 is => 'ro',
122 isa => 'HashRef',
123);
124
125#--------------------------------------------------------
126
127=head2 order_by ( )
128
129Returns the order_by passed into the constructor.
130
131=cut
132
13312µs13.19mshas order_by => (
# spent 3.19ms making 1 call to Moose::has
134 is => 'ro',
135 isa => 'Str | ArrayRef[Str]',
136 predicate => 'has_order_by',
137);
138
139#--------------------------------------------------------
140
141=head2 limit ( )
142
143Returns the limit passed into the constructor.
144
145=cut
146
14712µs11.50mshas limit => (
# spent 1.50ms making 1 call to Moose::has
148 is => 'rw',
149 isa => 'Str',
150 predicate => 'has_limit',
151);
152
153#--------------------------------------------------------
154
155=head2 simpledb ( )
156
157Returns the simpledb passed into the constructor.
158
159=cut
160
16112µs1914µshas simpledb => (
# spent 914µs making 1 call to Moose::has
162 is => 'ro',
163 required => 1,
164);
165
166#--------------------------------------------------------
167
168=head2 result ( )
169
170Returns the result passed into the constructor, or the one generated by fetch_result() if a where is passed into the constructor.
171
172=head2 has_result ()
173
174A boolean indicating whether a result was passed into the constructor, or generated by fetch_result().
175
176=cut
177
178has result => (
179 is => 'rw',
180 isa => 'HashRef',
181 predicate => 'has_result',
182 default => sub {{}},
18316µs11.55ms lazy => 1,
# spent 1.55ms making 1 call to Moose::has
184);
185
186#--------------------------------------------------------
187
188=head2 iterator ( )
189
190Returns an integer which represents the current position in the result set as traversed by C<next()>.
191
192=cut
193
19412µs11.17mshas iterator => (
# spent 1.17ms making 1 call to Moose::has
195 is => 'rw',
196 isa => 'Int',
197 default => 0,
198);
199
200#--------------------------------------------------------
201
202=head2 limit_counter ( )
203
204Returns an integer representing how many items have been traversed so far by C<next()>. When this reaches the value of C<limit> then no more results will be returned by C<next()>.
205
206=cut
207
20812µs11.21mshas limit_counter => (
# spent 1.21ms making 1 call to Moose::has
209 is => 'rw',
210 isa => 'Int',
211 default => 0,
212);
213
214#--------------------------------------------------------
215
216=head2 fetch_result ( [ next ] )
217
218Fetches a result, based on a where clause passed into a constructor, and then makes it accessible via the C<result()> method.
219
220=head3 next
221
222A next token, in order to fetch the next part of a result set.
223
224=cut
225
226
# spent 848ms (770µs+847) within SimpleDB::Class::ResultSet::fetch_result which was called 10 times, avg 84.8ms/call: # 9 times (656µs+538ms) by SimpleDB::Class::ResultSet::next at line 432, avg 59.9ms/call # once (114µs+309ms) by SimpleDB::Class::ResultSet::paginate at line 410
sub fetch_result {
2271012µs my ($self, $next) = @_;
22810106µs3098µs my %sql_params = (
# spent 41µs making 10 calls to SimpleDB::Class::ResultSet::where, avg 4µs/call # spent 32µs making 10 calls to SimpleDB::Class::ResultSet::item_class, avg 3µs/call # spent 25µs making 10 calls to SimpleDB::Class::ResultSet::simpledb, avg 3µs/call
229 item_class => $self->item_class,
230 simpledb => $self->simpledb,
231 where => $self->where,
232 );
2331041µs1239µs if ($self->has_order_by) {
# spent 32µs making 10 calls to SimpleDB::Class::ResultSet::has_order_by, avg 3µs/call # spent 8µs making 2 calls to SimpleDB::Class::ResultSet::order_by, avg 4µs/call
234 $sql_params{order_by} = $self->order_by;
235 }
2361026µs1219µs if ($self->has_limit) {
# spent 14µs making 10 calls to SimpleDB::Class::ResultSet::has_limit, avg 1µs/call # spent 5µs making 2 calls to SimpleDB::Class::ResultSet::limit, avg 3µs/call
237 $sql_params{limit} = $self->limit;
238 }
2391058µs10327µs my $select = SimpleDB::Class::SQL->new(%sql_params);
# spent 327µs making 10 calls to SimpleDB::Class::SQL::new, avg 33µs/call
2401058µs103.69ms my %params = (SelectExpression => $select->to_sql);
# spent 3.69ms making 10 calls to SimpleDB::Class::SQL::to_sql, avg 369µs/call
2411048µs1041µs if ($self->consistent) {
# spent 41µs making 10 calls to SimpleDB::Class::ResultSet::consistent, avg 4µs/call
242 $params{ConsistentRead} = 'true';
243 }
244
245 # if we're fetching and we already have a result, we can assume we're getting the next batch
246107µs if (defined $next && $next ne '') {
247 $params{NextToken} = $next;
248 }
249
2501081µs30843ms my $result = $self->simpledb->http->send_request('Select', \%params);
# spent 843ms making 10 calls to SimpleDB::Client::send_request, avg 84.3ms/call # spent 51µs making 10 calls to SimpleDB::Class::http, avg 5µs/call # spent 17µs making 10 calls to SimpleDB::Class::ResultSet::simpledb, avg 2µs/call
2511055µs10197µs $self->result($result);
# spent 197µs making 10 calls to SimpleDB::Class::ResultSet::result, avg 20µs/call
25210156µs return $result;
253}
254
255#--------------------------------------------------------
256
257=head2 count ( [ options ] )
258
259Counts the items in the result set. Returns an integer.
260
261=head3 options
262
263A hash of extra options you can pass to modify the count.
264
265=head4 where
266
267A where clause as defined by L<SimpleDB::Class::SQL>. If this is specified, then an additional query is executed before counting the items in the result set.
268
269=cut
270
271
# spent 316ms (248µs+315) within SimpleDB::Class::ResultSet::count which was called 4 times, avg 78.9ms/call: # once (118µs+112ms) by main::RUNTIME at line 71 of 05.Domain_and_Item.t # once (47µs+76.6ms) by main::RUNTIME at line 69 of 05.Domain_and_Item.t # once (57µs+70.2ms) by main::RUNTIME at line 73 of 05.Domain_and_Item.t # once (26µs+56.8ms) by main::RUNTIME at line 74 of 05.Domain_and_Item.t
sub count {
27244µs my ($self, %options) = @_;
27341µs my @ids;
2744134µs28262ms while (my $item = $self->next) {
# spent 261ms making 12 calls to SimpleDB::Class::ResultSet::next, avg 21.8ms/call # spent 445µs making 8 calls to Moose::Object::DESTROY, avg 56µs/call # spent 34µs making 8 calls to SimpleDB::Class::Item::id, avg 4µs/call
275 push @ids, $item->id;
276 }
27743µs if ($options{where}) {
27814µs my $clauses = {
279 'itemName()' => ['in',@ids],
280 '-and' => $options{where},
281 };
28219µs337µs my $select = SimpleDB::Class::SQL->new(
# spent 33µs making 1 call to SimpleDB::Class::SQL::new # spent 2µs making 1 call to SimpleDB::Class::ResultSet::item_class # spent 1µs making 1 call to SimpleDB::Class::ResultSet::simpledb
283 item_class => $self->item_class,
284 simpledb => $self->simpledb,
285 where => $clauses,
286 output => 'count(*)',
287 );
28816µs1427µs my %params = ( SelectExpression => $select->to_sql );
# spent 427µs making 1 call to SimpleDB::Class::SQL::to_sql
28915µs14µs if ($self->consistent) {
# spent 4µs making 1 call to SimpleDB::Class::ResultSet::consistent
290 $params{ConsistentRead} = 'true';
291 }
29219µs353.4ms my $result = $self->simpledb->http->send_request('Select', \%params);
# spent 53.4ms making 1 call to SimpleDB::Client::send_request # spent 5µs making 1 call to SimpleDB::Class::http # spent 1µs making 1 call to SimpleDB::Class::ResultSet::simpledb
293118µs return $result->{SelectResult}{Item}[0]{Attribute}{Value};
294 }
295 else {
296317µs return scalar @ids;
297 }
298}
299
300#--------------------------------------------------------
301
302=head2 search ( options )
303
304Just like L<SimpleDB::Class::Domain/"search">, but searches within the confines of the current result set, and then returns a new result set.
305
306=head3 options
307
308A hash of extra options to modify the search.
309
310=head4 where
311
312A where clause as defined by L<SimpleDB::Class::SQL>.
313
314=cut
315
316sub search {
317 my ($self, %options) = @_;
318 my @ids;
319 while (my $item = $self->next) {
320 push @ids, $item->id;
321 }
322 my $clauses = {
323 'itemName()' => ['in',@ids],
324 '-and' => $options{where},
325 };
326 return $self->new(
327 simpledb => $self->simpledb,
328 item_class => $self->item_class,
329 where => $clauses,
330 consistent => $self->consistent,
331 set => $self->set,
332 );
333}
334
335#--------------------------------------------------------
336
337=head2 update ( attributes )
338
339Calls C<update> and then C<put> on all the items in the result set.
340
341=head3 attributes
342
343A hash reference containing name/value pairs to update in each item.
344
345=cut
346
347sub update {
348 my ($self, $attributes) = @_;
349 while (my $item = $self->next) {
350 $item->update($attributes)->put;
351 }
352}
353
354#--------------------------------------------------------
355
356=head2 delete ( )
357
358Calls C<delete> on all the items in the result set.
359
360=cut
361
362sub delete {
363 my ($self) = @_;
364 while (my $item = $self->next) {
365 $item->delete;
366 }
367}
368
369#--------------------------------------------------------
370
371=head2 paginate ( items_per_page, page_number )
372
373Use on a new result set to fast forward to the desired data. After you've paginated, you can call C<next> to start fetching your data. Returns a reference to the result set for easy method chaining.
374
375B<NOTE:> Unless you've already set a limit, the limit for this result set will be set to C<items_per_page> as a convenience.
376
377=head3 items_per_page
378
379An integer representing how many items you're fetching/displaying per page.
380
381=head3 page_number
382
383An integer representing what page number you'd like to skip ahead to.
384
385=cut
386
387
# spent 391ms (111µs+391) within SimpleDB::Class::ResultSet::paginate which was called # once (111µs+391ms) by main::RUNTIME at line 118 of 05.Domain_and_Item.t
sub paginate {
38811µs my ($self, $items_per_page, $page_number) = @_;
38916µs214µs unless ($self->has_limit) {
# spent 11µs making 1 call to SimpleDB::Class::ResultSet::limit # spent 3µs making 1 call to SimpleDB::Class::ResultSet::has_limit
390 $self->limit($items_per_page);
391 }
39211µs my $limit = ($items_per_page * ($page_number - 1));
3931400ns return $self if $limit == 0;
394113µs310µs my %sql_params = (
# spent 4µs making 1 call to SimpleDB::Class::ResultSet::where # spent 4µs making 1 call to SimpleDB::Class::ResultSet::item_class # spent 3µs making 1 call to SimpleDB::Class::ResultSet::simpledb
395 item_class => $self->item_class,
396 simpledb => $self->simpledb,
397 where => $self->where,
398 output => 'count(*)',
399 limit => $limit,
400 );
40117µs27µs if ($self->has_order_by) {
# spent 4µs making 1 call to SimpleDB::Class::ResultSet::order_by # spent 3µs making 1 call to SimpleDB::Class::ResultSet::has_order_by
402 $sql_params{order_by} = $self->order_by;
403 }
40418µs133µs my $select = SimpleDB::Class::SQL->new(%sql_params);
# spent 33µs making 1 call to SimpleDB::Class::SQL::new
40516µs1538µs my %params = (SelectExpression => $select->to_sql);
# spent 538µs making 1 call to SimpleDB::Class::SQL::to_sql
40615µs14µs if ($self->consistent) {
# spent 4µs making 1 call to SimpleDB::Class::ResultSet::consistent
407 $params{ConsistentRead} = 'true';
408 }
409110µs380.8ms my $result = $self->simpledb->http->send_request('Select', \%params);
# spent 80.8ms making 1 call to SimpleDB::Client::send_request # spent 5µs making 1 call to SimpleDB::Class::http # spent 1µs making 1 call to SimpleDB::Class::ResultSet::simpledb
41016µs1309ms $self->fetch_result($result->{SelectResult}{NextToken});
# spent 309ms making 1 call to SimpleDB::Class::ResultSet::fetch_result
411122µs return $self;
412}
413
414
415#--------------------------------------------------------
416
417=head2 next ()
418
419Returns the next result in the result set. Also fetches th next partial result set if there's a next token in the first result set and you've iterated through the first partial set.
420
421=cut
422
423
# spent 602ms (1.80+600) within SimpleDB::Class::ResultSet::next which was called 23 times, avg 26.2ms/call: # 12 times (725µs+260ms) by SimpleDB::Class::ResultSet::count at line 274, avg 21.8ms/call # 3 times (236µs+10.5ms) by main::RUNTIME at line 135 of 05.Domain_and_Item.t, avg 3.57ms/call # once (104µs+71.6ms) by main::RUNTIME at line 59 of 05.Domain_and_Item.t # once (128µs+66.6ms) by main::RUNTIME at line 88 of 05.Domain_and_Item.t # once (104µs+64.0ms) by main::RUNTIME at line 53 of 05.Domain_and_Item.t # once (139µs+63.9ms) by main::RUNTIME at line 134 of 05.Domain_and_Item.t # once (89µs+53.9ms) by main::RUNTIME at line 62 of 05.Domain_and_Item.t # once (151µs+4.60ms) by main::RUNTIME at line 123 of 05.Domain_and_Item.t # once (66µs+2.38ms) by main::RUNTIME at line 63 of 05.Domain_and_Item.t # once (55µs+2.22ms) by main::RUNTIME at line 54 of 05.Domain_and_Item.t
sub next {
4242318µs my ($self) = @_;
425
426 # handle limit counter
4272390µs3394µs if ($self->has_limit && $self->limit_counter >= $self->limit) {
# spent 64µs making 23 calls to SimpleDB::Class::ResultSet::has_limit, avg 3µs/call # spent 15µs making 5 calls to SimpleDB::Class::ResultSet::limit_counter, avg 3µs/call # spent 15µs making 5 calls to SimpleDB::Class::ResultSet::limit, avg 3µs/call
428 return undef;
429 }
430
431 # get the current results
43222104µs44539ms my $result = ($self->has_result) ? $self->result : $self->fetch_result;
# spent 539ms making 9 calls to SimpleDB::Class::ResultSet::fetch_result, avg 59.9ms/call # spent 55µs making 22 calls to SimpleDB::Class::ResultSet::has_result, avg 2µs/call # spent 34µs making 13 calls to SimpleDB::Class::ResultSet::result, avg 3µs/call
4332216µs my $items = [];
4342248µs if (ref $result->{SelectResult}{Item} eq 'ARRAY') {
435 $items = $result->{SelectResult}{Item};
436 }
437
438 # fetch more results if needed
4392262µs2270µs my $iterator = $self->iterator;
# spent 70µs making 22 calls to SimpleDB::Class::ResultSet::iterator, avg 3µs/call
4402214µs if ($iterator >= scalar @{$items}) {
44144µs if (exists $result->{SelectResult}{NextToken}) {
442 $self->iterator(0);
443 $iterator = 0;
444 $result = $self->fetch_result($result->{SelectResult}{NextToken});
445 $items = $result->{SelectResult}{Item};
446 }
447 else {
44848µs return undef;
449 }
450 }
451
452 # iterate
4531813µs my $item = $items->[$iterator];
454185µs return undef unless defined $item;
455184µs $iterator++;
4561822µs18281µs $self->iterator($iterator);
# spent 281µs making 18 calls to SimpleDB::Class::ResultSet::iterator, avg 16µs/call
457
458 # make the item object
4591851µs1850µs my $db = $self->simpledb;
# spent 50µs making 18 calls to SimpleDB::Class::ResultSet::simpledb, avg 3µs/call
46018183µs54312µs my $domain_name = $db->add_domain_prefix($self->item_class->domain_name);
# spent 209µs making 18 calls to SimpleDB::Class::add_domain_prefix, avg 12µs/call # spent 54µs making 18 calls to SimpleDB::Class::ResultSet::item_class, avg 3µs/call # spent 44µs making 17 calls to Foo::Domain::domain_name, avg 3µs/call # spent 4µs making 1 call to Foo::Child::domain_name
4611851µs1882µs my $cache = $db->cache;
# spent 82µs making 18 calls to SimpleDB::Class::cache, avg 5µs/call
462 ## fetch from cache even though we've already pulled it back from the db, because the one in cache
463 ## might be more up to date than the one from the DB
4643681µs1818.4ms my $attributes = eval{$cache->get($domain_name, $item->{Name})};
# spent 18.4ms making 18 calls to SimpleDB::Class::Cache::get, avg 1.02ms/call
465183µs my $e;
466182µs my $itemobj;
46718199µs5126.9ms if ($e = SimpleDB::Class::Exception::ObjectNotFound->caught) {
# spent 26.5ms making 15 calls to SimpleDB::Class::Role::Itemized::instantiate_item, avg 1.77ms/call # spent 361µs making 33 calls to Exception::Class::Base::caught, avg 11µs/call # spent 6µs making 3 calls to Exception::Class::Base::__ANON__[Exception/Class/Base.pm:30], avg 2µs/call
468310µs312.7ms $itemobj = $self->parse_item($item->{Name}, $item->{Attribute});
# spent 12.7ms making 3 calls to SimpleDB::Class::Role::Itemized::parse_item, avg 4.23ms/call
46932µs if (defined $itemobj) {
470617µs61.59ms eval{$cache->set($domain_name, $item->{Name}, $itemobj->to_hashref)};
# spent 1.01ms making 3 calls to SimpleDB::Class::Cache::set, avg 336µs/call # spent 582µs making 3 calls to SimpleDB::Class::Item::to_hashref, avg 194µs/call
471 }
472 }
473 elsif ($e = SimpleDB::Class::Exception->caught) {
474 warn $e->error;
475 $e->rethrow;
476 }
477 elsif (defined $attributes) {
478 $itemobj = $self->instantiate_item($attributes,$item->{Name});
479 }
480 else {
481 SimpleDB::Class::Exception->throw(error=>"An undefined error occured while fetching the item from cache.");
482 }
483
484 # process the 'set' option
4851883µs1868µs my %set = %{$self->set};
# spent 68µs making 18 calls to SimpleDB::Class::ResultSet::set, avg 4µs/call
4861834µs foreach my $attribute (keys %set) {
487515µs521µs $itemobj->$attribute( $set{$attribute} );
# spent 14µs making 4 calls to Foo::Domain::parent, avg 4µs/call # spent 7µs making 1 call to Foo::Child::domain
488 }
489
490 # increment limit counter
4911880µs36297µs $self->limit_counter($self->limit_counter + 1);
# spent 297µs making 36 calls to SimpleDB::Class::ResultSet::limit_counter, avg 8µs/call
492
49318205µs return $itemobj;
494}
495
496#--------------------------------------------------------
497
498=head2 to_array_ref ()
499
500Returns an array reference containing all the objects in the result set. If the result set has already been partially walked, then only the remaining objects will be returned.
501
502=cut
503
504sub to_array_ref {
505 my ($self) = @_;
506 my @all;
507 while (my $object = $self->next) {
508 push @all, $object;
509 }
510 return \@all;
511}
512
513
514=head1 LEGAL
515
516SimpleDB::Class is Copyright 2009-2010 Plain Black Corporation (L<http://www.plainblack.com/>) and is licensed under the same terms as Perl itself.
517
518=cut
519
520352µs2212µs
# spent 112µs (13+99) within SimpleDB::Class::ResultSet::BEGIN@520 which was called # once (13µs+99µs) by SimpleDB::Class::Domain::BEGIN@19 at line 520
no Moose;
# spent 112µs making 1 call to SimpleDB::Class::ResultSet::BEGIN@520 # spent 99µs making 1 call to Moose::Exporter::__ANON__[Moose/Exporter.pm:478]
521179µs23.89ms__PACKAGE__->meta->make_immutable;
# spent 3.88ms making 1 call to Class::MOP::Class::make_immutable # spent 12µs making 1 call to SimpleDB::Class::ResultSet::meta