← Index
NYTProf Performance Profile   « block view • line view • sub view »
For mentat.storage.mongo.pl
  Run on Tue Jun 24 09:58:41 2014
Reported on Tue Jun 24 09:59:25 2014

Filename/usr/local/lib/site_perl/Mentat/Storage.pm
StatementsExecuted 19 statements in 543µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11112µs15µsMentat::Storage::::BEGIN@2Mentat::Storage::BEGIN@2
11110µs8.84msMentat::Storage::::newMentat::Storage::new
1117µs30µsMentat::Storage::::BEGIN@57Mentat::Storage::BEGIN@57
1117µs12µsMentat::Storage::::BEGIN@3Mentat::Storage::BEGIN@3
1117µs44µsMentat::Storage::::BEGIN@56Mentat::Storage::BEGIN@56
1117µs37µsMentat::Storage::::BEGIN@82Mentat::Storage::BEGIN@82
1114µs4µsMentat::Storage::::BEGIN@81Mentat::Storage::BEGIN@81
1112µs2µsMentat::Storage::::ENDMentat::Storage::END
0000s0sMentat::Storage::::_initMentat::Storage::_init
0000s0sMentat::Storage::::countMentat::Storage::count
0000s0sMentat::Storage::::deleteMentat::Storage::delete
0000s0sMentat::Storage::::disconnectMentat::Storage::disconnect
0000s0sMentat::Storage::::fetchMentat::Storage::fetch
0000s0sMentat::Storage::::findMentat::Storage::find
0000s0sMentat::Storage::::insertMentat::Storage::insert
0000s0sMentat::Storage::::reconnectMentat::Storage::reconnect
0000s0sMentat::Storage::::removeMentat::Storage::remove
0000s0sMentat::Storage::::updateMentat::Storage::update
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Mentat::Storage;
2223µs218µs
# spent 15µs (12+3) within Mentat::Storage::BEGIN@2 which was called: # once (12µs+3µs) by Mentat::Storage::Mongo::BEGIN@166 at line 2
use strict;
# spent 15µs making 1 call to Mentat::Storage::BEGIN@2 # spent 3µs making 1 call to strict::import
3243µs217µs
# spent 12µs (7+5) within Mentat::Storage::BEGIN@3 which was called: # once (7µs+5µs) by Mentat::Storage::Mongo::BEGIN@166 at line 3
use warnings;
# spent 12µs making 1 call to Mentat::Storage::BEGIN@3 # spent 5µs making 1 call to warnings::import
4
5#*******************************************************************************
6# DOCUMENTATION SECTION
7#*******************************************************************************
8
9=head1 NAME
10
11Mentat::Storage - Base module for all Mentat object storage engines
12
13=head1 SYNOPSIS
14
15 use Mentat::Storage;
16
17 use vars qw(@ISA);
18 @ISA = ('Mentat::Storage');
19
20 # Now implement the mandatory interface
21
22=head1 DESCRIPTION
23
24This module is the base class for all Mentat::Storage engines.
25
26=head1 AUTHOR
27
28Jan Mach
29Cesnet, z.s.p.o
30jan.mach@cesnet.cz
31http://www.cesnet.cz
32
33=head1 COPYRIGHT
34
35This program is free software; you can redistribute
36it and/or modify it under the same terms as Perl itself.
37
38The full text of the license can be found in the
39LICENSE file included with this module.
40
41=head1 SEE ALSO
42
43perl(1).
44
45=head1 FUNCTION REFERENCE
46
47=over 4
48
49=cut
50
51#*******************************************************************************
52# LIBRARY LOADING SECTION
53#*******************************************************************************
54
55#-- Perl core modules ---------------------------------------------------------#
56226µs282µs
# spent 44µs (7+38) within Mentat::Storage::BEGIN@56 which was called: # once (7µs+38µs) by Mentat::Storage::Mongo::BEGIN@166 at line 56
use Carp;
# spent 44µs making 1 call to Mentat::Storage::BEGIN@56 # spent 38µs making 1 call to Exporter::import
57246µs253µs
# spent 30µs (7+23) within Mentat::Storage::BEGIN@57 which was called: # once (7µs+23µs) by Mentat::Storage::Mongo::BEGIN@166 at line 57
use Scalar::Util 'blessed';
# spent 30µs making 1 call to Mentat::Storage::BEGIN@57 # spent 23µs making 1 call to Exporter::import
58
59#use Data::Dumper; #-+-> DEVEL ONLY <-+-#
60#use Smart::Comments; #-+-> DEVEL ONLY <-+-#
61
62#-- Perl CPAN modules ---------------------------------------------------------#
63
64#-- Custom application modules ------------------------------------------------#
65
66#*******************************************************************************
67# CONSTANTS AND GLOBAL VARIABLES DEFINITION SECTION
68#*******************************************************************************
69
70#-- Constants -----------------------------------------------------------------#
71
72#-- Static public class variables (our) ---------------------------------------#
73
74#-- Static protected class variables (my) -------------------------------------#
75
76#*******************************************************************************
77# INITIALIZATION AND CLEANUP SECTION
78#*******************************************************************************
79
80#-- Module initializations ----------------------------------------------------#
81
# spent 4µs within Mentat::Storage::BEGIN@81 which was called: # once (4µs+0s) by Mentat::Storage::Mongo::BEGIN@166 at line 85
BEGIN {
82230µs267µs
# spent 37µs (7+30) within Mentat::Storage::BEGIN@82 which was called: # once (7µs+30µs) by Mentat::Storage::Mongo::BEGIN@166 at line 82
use vars qw($VERSION $DEVEL);
# spent 37µs making 1 call to Mentat::Storage::BEGIN@82 # spent 30µs making 1 call to vars::import
8324µs $VERSION = '0.6';
84 $DEVEL = 0;
851356µs14µs}
# spent 4µs making 1 call to Mentat::Storage::BEGIN@81
86
87
88#-- Module clean-up code (global destructor) ----------------------------------#
8912µs
# spent 2µs within Mentat::Storage::END which was called: # once (2µs+0s) by main::RUNTIME at line 0 of mentat.storage.mongo.pl
END {
90
91}
92
93#*******************************************************************************
94# IMPLEMENTATION SECTION
95#*******************************************************************************
96
97=item new() [PUBLIC,STATIC]
98
99 Usage : my $instance = Mentat::Storage->new()
100 Purpose : Create and return reference to the new instance
101 Arguments : Same as the the _init() method
102 Throws : Dies, if invoked on object
103 Comments : Internally uses _init() method
104 See Also : _init() method
105
106=cut
107
108sub new
109
# spent 8.84ms (10µs+8.83) within Mentat::Storage::new which was called: # once (10µs+8.83ms) by main::RUNTIME at line 24 of mentat.storage.mongo.pl
{
110510µs my $class = shift;
1111600ns confess "Class method not invoked on class" if blessed($class);
# spent 600ns making 1 call to Scalar::Util::blessed
112 my $self = bless ({}, $class);
11318.83ms $self->_init(@_);
# spent 8.83ms making 1 call to Mentat::Storage::Mongo::_init
114 return $self;
115}
116
117=item insert($) [PUBLIC,ABSTRACT]
118
119 Usage : my ($record_id, $error) = $storage->insert($object);
120 Purpose : Insert the given object into storage
121 Arguments : MIXED $object - object to be stored into storage
122 Returns : STRING $oid - ID of the inserted object on SUCCESS, undef on FAILURE
123 STRING $error - undef on SUCCESS, error string on failure
124 Throws : Dies, if not invoked on instance
125 Croaks on insert failure
126 Comments : This method dies in case of insert failure, it must be taken care of on higher levels !
127
128=cut
129
130sub insert($)
131{
132 my $self = shift;
133 confess "Method needs implementation in child class";
134}
135
136=item fetch($) [PUBLIC,ABSTRACT]
137
138 Usage : my $object = $storage->fetch($oid);
139 Purpose : Fetch the Mentat message with given ID from storage
140 Arguments : STRING $oid - unique identifier of the object in storage
141 Returns : HASH REFERENCE $object reference on SUCCESS,
142 undef if object with given ID was not found,
143 Throws : Dies, if not invoked on instance
144 Croaks on query failure
145
146=cut
147
148sub fetch($)
149{
150 my $self = shift;
151 confess "Method needs implementation in child class";
152}
153
154=item update($$;$) [PUBLIC,ABSTRACT]
155
156 Usage : my $result = $storage->update($filter, $values, $options);
157 Purpose : Update the existing object in the storage
158 Arguments : HASH REFERENCE $filter - Update filter [MANDATORY]
159 HASH REFERENCE $values - Object values [MANDATORY]
160 HASH REFERENCE $options - Update options [OPTIONAL]
161 Returns : HASH REFERENCE containing information about the operation result:
162 ok => success flag
163 n => number of affected items
164 err => error flag
165 Throws : Dies, if not invoked on instance
166
167=cut
168
169sub update($$;$)
170{
171 my $self = shift;
172 confess "Method needs implementation in child class";
173}
174
175=item delete($) [PUBLIC,ABSTRACT]
176
177 Usage : my $result = $storage->delete($oid);
178 Purpose : Delete the object with given ID from the storage
179 Arguments : STRING $oid - unique identifier of the object in storage
180 Returns : HASH REFERENCE containing information about the operation result:
181 ok => success flag
182 n => number of affected items
183 err => error flag
184 Throws : Dies, if not invoked on instance
185 Comments : This operation should always remove only one object
186 See Also : For bulk delete operation see remove() method
187
188=cut
189
190sub delete($)
191{
192 my $self = shift;
193 confess "Method needs implementation in child class";
194}
195
196=item count(;$) [PUBLIC,ABSTRACT]
197
198 Usage : my $count = $storage->count(); or
199 my $count = $storage->count($filter);
200 Purpose : Get the number of Mentat messages in storage
201 Arguments : HASH REFERENCE $filter - Query filter [OPTIONAL]
202 Returns : INTEGER on SUCCESS
203 Throws : Dies, if not invoked on instance
204 Dies on operation failure
205
206=cut
207
208sub count(;$)
209{
210 my $self = shift;
211 confess "Method needs implementation in child class";
212}
213
214=item find(;$$$$$) [PUBLIC,ABSTRACT]
215
216 Usage : my ($objects, $count) = $storage->find(); or
217 my ($objects, $count) = $storage->find($filter);
218 Purpose : Find the object(s) according to the given filter
219 Arguments : HASH REFERENCE $filter - Query filter [OPTIONAL]
220 HASH REFERENCE $selection - Record attribute selection [OPTIONAL]
221 HASH REFERENCE $sort - Sorting specification [OPTIONAL]
222 INTEGER $limit - Maximum number of records to be returned [OPTIONAL]
223 INTEGER $skip - Number of objects to skip from the beginning of the result set [OPTIONAL]
224 Returns : ARRAY REFERENCE containing objects
225 INTEGER total count of objects
226 Throws : Dies, if not invoked on instance
227
228=cut
229
230sub find(;$$$$$)
231{
232 my $self = shift;
233 confess "Method needs implementation in child class";
234}
235
236=item remove(;$) [PUBLIC,ABSTRACT]
237
238 Usage : my $result = $storage->remove(); or
239 my $result = $storage->remove($filter);
240 Purpose : Remove the objects(s) according to the given filter
241 Arguments : HASH REFERENCE $filter - Filter for selecting items to be removed [OPTIONAL]
242 Returns : HASH REFERENCE containing information about the operation result:
243 ok => success flag
244 n => number of affected items
245 err => error flag
246 Throws : Dies, if not invoked on instance
247 Croaks on query failure
248 Comments : This operation performs bulk delete operation
249 See Also : For single delete operation see delete() method
250 Warning : DELETES ALL DATA, IF GIVEN NO FILTER !!!
251
252=cut
253
254sub remove(;$)
255{
256 my $self = shift;
257 confess "Method needs implementation in child class";
258}
259
260=item disconnect() [PUBLIC,ABSTRACT]
261
262 Usage : $storage->disconnect();
263 Purpose : Close existing storage connection
264 Arguments : NONE
265 Returns : UNDEF on SUCCESS, STRING $error on FAILURE
266 Throws : Dies, if not invoked on instance
267
268=cut
269
270sub disconnect()
271{
272 my $self = shift;
273 confess "Method needs implementation in child class";
274}
275
276=item reconnect() [PUBLIC,ABSTRACT]
277
278 Usage : $storage->reconnect();
279 Purpose : Optionally close existing storage connection and reopen it
280 Arguments : NONE
281 Returns : UNDEF on SUCCESS, STRING $error on FAILURE
282 Throws : Dies, if not invoked on instance
283
284=cut
285
286sub reconnect()
287{
288 my $self = shift;
289 confess "Method needs implementation in child class";
290}
291
292#-------------------------------------------------------------------------------
293
294# _init [PROTECTED]
295#
296# Usage :
297# Purpose :
298# Arguments :
299# Returns :
300# Throws : Dies, if not invoked on instance
301# Comments :
302# See Also :
303
304sub _init
305{
306 my $self = shift;
307 confess "Method needs implementation in child class";
308}
309
310=pod
311
312=back
313
314=cut
315
31612µs1;