KiokuDB.pm

filter: Statementstmt 79.6% 246 / 309 Branchbran 59.0% 65 / 110 Conditioncond 54.5% 12 / 22 MC/DCmcdc 23.0% 3 / 13 Subroutinesub 83.6% 51 / 61 Podpod 71.4% 20 / 28 totaltotal 73.1% 397 / 543 CC 68 SCAR 29.5
CC
68
Cov
73%
exists
135.2
scan
12.0
_build_merged_typemap
8.0
CRAP 19.1
« KiokuDB/Backend/Serialize/JSPON/Expander.pm ↑ Summary KiokuDB/Backend/Serialize/JSPON/Collapser.pm »
1 #!/usr/bin/perl
2  
3 package KiokuDB;
4 12 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 our $VERSION = "0.46_02";
7  
8 12 ▶use constant SERIAL_IDS => not not our $SERIAL_IDS;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 12 ▶use KiokuDB::Backend;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 12 ▶use KiokuDB::Collapser;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use KiokuDB::Linker;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 12 ▶use KiokuDB::LiveObjects;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 12 ▶use KiokuDB::TypeMap;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use KiokuDB::TypeMap::Shadow;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 12 ▶use KiokuDB::TypeMap::Resolver;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 ▶use KiokuDB::Stream::Objects;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 12 ▶use Hash::Util::FieldHash::Compat qw(idhash);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 12 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 12 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 12 ▶use namespace::clean -except => [qw(meta SERIAL_IDS)];
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # with qw(KiokuDB::Role::API); # moved lower
26  
27 12 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 12 our $REQUIRED_CMD_VERSION = "0.03";
30 sub cmd_is_up_to_date {
31 0 ▶ require KiokuDB::Cmd;
Subroutine cmd_is_up_to_date: not called CC=1 SCAR=6.9
Pod undocumented
32 0 ▶ try { KiokuDB::Cmd->VERSION($REQUIRED_CMD_VERSION); 1 };
Subroutine __ANON__: not called CC=1 SCAR=6.9
33 }
34  
35  
36 sub connect {
37 48 ▶ my ( $class, $dsn, @args ) = @_;
Subroutine connect: called CC=3 SCAR=12.7
Pod documented
38  
39 48 ▶ if ( -d $dsn || $dsn =~ /\.yml$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (-d $dsn or $dsn =~ /\.yml$/) { } 0 48 48
Condition33%1/3
-d $dsn or $dsn =~ /\.yml$/
l!l&&r!l&&!r
0048
MC/DC0%0/2
-d $dsn or $dsn =~ /\.yml$/
-d $dsn $dsn =~ /\.yml$/
Truth table33%1/3
A or B
A= -d $dsnB= $dsn =~ /\.yml$/
ABresult
1X1
011
000
40 0 return $class->configure($dsn, @args);
41 } else {
42 48 require KiokuDB::Util;
43 48 return $class->new( backend => KiokuDB::Util::dsn_to_backend($dsn, @args), @args );
44 }
45 }
46  
47 sub configure {
48 0 ▶ my ( $class, $base, @args ) = @_;
Subroutine configure: not called CC=2 SCAR=17.9
Pod documented
49  
50 0 require Path::Class;
51 0 ▶ $base = Path::Class::dir($base) unless blessed $base;
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($base) 0 0 0
52  
53 0 require KiokuDB::Util;
54 0 my $config = KiokuDB::Util::load_config($base);
55  
56 0 my $backend = KiokuDB::Util::config_to_backend( $config, base => $base, @args );
57  
58 # FIXME gin extractor, typemap, etc
59 0 $class->new( %$config, @args, backend => $backend );
60 }
61  
62 12 has typemap => (
63 does => "KiokuDB::Role::TypeMap",
64 is => "ro",
65 );
66  
67 12 has allow_class_builders => (
68 isa => "Bool|HashRef",
69 is => "ro",
70 );
71  
72 12 has [qw(allow_classes allow_bases)] => (
73 isa => "ArrayRef[Str]",
74 is => "ro",
75 );
76  
77 12 has merged_typemap => (
78 does => "KiokuDB::Role::TypeMap",
79 is => "ro",
80 lazy_build => 1,
81 );
82  
83 sub _find_default_typemaps {
84 57 ▶ my $self = shift;
Subroutine _find_default_typemaps: called CC=4 SCAR=15.2
85  
86 57 my $b = $self->backend;
87  
88 57 my @typemaps;
89 57 ▶ if ( $b->can("default_typemap") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->can("default_typemap")) 0 57 57
90 0 push @typemaps, $b->default_typemap;
91 }
92  
93  
94 57 ▶ if ( $b->can("serializer") and $b->serializer->can("default_typemap") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($b->can("serializer") and $b->serializer->can("default_typemap")) 57 0 57
Condition33%1/3
$b->can("serializer") and $b->serializer->can("default_typemap")
!ll&&!rl&&r
0057
MC/DC0%0/2
$b->can("serializer") and $b->serializer->can("default_typemap")
$b->can("serializer") $b->serializer->can("default_typemap")
Truth table33%1/3
A and B
A= $b->can("serializer")B= $b->serializer->can("default_typemap")
ABresult
0X0
100
111
95 57 push @typemaps, $b->serializer->default_typemap;
96 }
97  
98 57 return @typemaps;
99 }
100  
101 sub _build_merged_typemap {
102 57 ▶ my $self = shift;
Subroutine _build_merged_typemap: called CC=8 SCAR=20.8
103  
104 57 my @typemaps;
105  
106 57 ▶ if ( my $typemap = $self->typemap ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $typemap = $self->typemap) 4 53 57
107 4 push @typemaps, $typemap;
108 }
109  
110 57 ▶ if ( my $classes = $self->allow_classes ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $classes = $self->allow_classes) 11 46 57
111 11 require KiokuDB::TypeMap::Entry::Naive;
112  
113 push @typemaps, KiokuDB::TypeMap->new(
114 11 entries => { map { $_ => KiokuDB::TypeMap::Entry::Naive->new } @$classes },
115 );
116 }
117  
118 57 ▶ if ( my $classes = $self->allow_bases ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $classes = $self->allow_bases) 11 46 57
119 11 require KiokuDB::TypeMap::Entry::Naive;
120  
121 push @typemaps, KiokuDB::TypeMap->new(
122 11 isa_entries => { map { $_ => KiokuDB::TypeMap::Entry::Naive->new } @$classes },
123 );
124 }
125  
126 57 ▶ if ( my $opts = $self->allow_class_builders ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $opts = $self->allow_class_builders) 11 46 57
127 11 require KiokuDB::TypeMap::ClassBuilders;
128 11 ▶ push @typemaps, KiokuDB::TypeMap::ClassBuilders->new( ref $opts ? %$opts : () );
Branch: 1 branch
BranchTrueFalseTotal
ref $opts ? : 0 11 11
129 }
130  
131 57 push @typemaps, $self->_find_default_typemaps;
132  
133 57 ▶ if ( not @typemaps ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not @typemaps) { } 0 57 57
elsif (@typemaps == 1) { } 42 15 57
134 0 return KiokuDB::TypeMap->new;
135 } elsif ( @typemaps == 1 ) {
136 42 return $typemaps[0];
137 } else {
138 15 return KiokuDB::TypeMap::Shadow->new( typemaps => \@typemaps );
139 }
140 }
141  
142 12 has check_class_versions => (
143 isa => "Bool",
144 is => "ro",
145 default => 0,
146 );
147  
148 has class_version_table => (
149 isa => "HashRef[HashRef[Str|CodeRef|HashRef]]",
150 is => "ro",
151 55 ▶ default => sub { return {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
152 12 );
153  
154 12 has typemap_resolver => (
155 isa => "KiokuDB::TypeMap::Resolver",
156 is => "ro",
157 lazy_build => 1,
158 );
159  
160 sub _build_typemap_resolver {
161 57 ▶ my $self = shift;
Subroutine _build_typemap_resolver: called CC=1 SCAR=0.0
162  
163 57 KiokuDB::TypeMap::Resolver->new(
164 typemap => $self->merged_typemap,
165 fallback_entry => KiokuDB::TypeMap::Entry::MOP->new(
166 class_version_table => $self->class_version_table,
167 check_class_versions => $self->check_class_versions,
168 ),
169 );
170 }
171  
172 12 has live_objects => (
173 isa => "KiokuDB::LiveObjects",
174 is => "ro",
175 coerce => 1,
176 lazy => 1,
177 builder => "_build_live_objects", # lazy_build => 1 sets clearer
178 handles => {
179 clear_live_objects => "clear",
180 new_scope => "new_scope",
181 object_to_id => "object_to_id",
182 objects_to_ids => "objects_to_ids",
183 id_to_object => "id_to_object",
184 ids_to_objects => "ids_to_objects",
185 },
186 );
187  
188 23 ▶sub _build_live_objects { KiokuDB::LiveObjects->new }
Subroutine _build_live_objects: called CC=1 SCAR=0.0
189  
190 12 has collapser => (
191 isa => "KiokuDB::Collapser",
192 is => "ro",
193 lazy_build => 1,
194 );
195  
196 sub _build_collapser {
197 57 ▶ my $self = shift;
Subroutine _build_collapser: called CC=1 SCAR=0.0
198  
199 57 KiokuDB::Collapser->new(
200 backend => $self->backend,
201 live_objects => $self->live_objects,
202 typemap_resolver => $self->typemap_resolver,
203 );
204 }
205  
206 12 has backend => (
207 does => "KiokuDB::Backend",
208 is => "ro",
209 required => 1,
210 coerce => 1,
211 );
212  
213 12 has linker_queue => (
214 isa => "Bool",
215 is => "ro",
216 default => 1,
217 );
218  
219 12 has linker => (
220 isa => "KiokuDB::Linker",
221 is => "ro",
222 lazy_build => 1,
223 );
224  
225 sub _build_linker {
226 57 ▶ my $self = shift;
Subroutine _build_linker: called CC=1 SCAR=0.0
227  
228 57 KiokuDB::Linker->new(
229 backend => $self->backend,
230 live_objects => $self->live_objects,
231 typemap_resolver => $self->typemap_resolver,
232 queue => $self->linker_queue,
233 );
234 }
235  
236 sub BUILD {
237 57 ▶ my $self = shift;
Subroutine BUILD: called CC=2 SCAR=7.1
Pod undocumented
238  
239 57 my $backend = $self->backend;
240  
241 57 ▶ $backend->register_handle($self) if $backend->can("register_handle");
Branch: 1 branch
BranchTrueFalseTotal
if $backend->can("register_handle") 0 57 57
242 }
243  
244 12 with qw(KiokuDB::Role::API);
245  
246 sub exists {
247 361 ▶ my ( $self, @ids ) = @_;
Subroutine exists: called CC=15 SCAR=49.1
Pod undocumented
248  
249 361 ▶ return unless @ids;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids 0 361 361
250  
251 361 ▶ my @exists = map { $_ ? 1 : '' } $self->backend->exists(@ids);
Branch: 1 branch
BranchTrueFalseTotal
$_ ? : 141 253 394
252 361 ▶ return ( @ids == 1 ? $exists[0] : @exists );
Branch: 1 branch
BranchTrueFalseTotal
@ids == 1 ? : 328 33 361
253  
254 # FIXME fix for in_storage etc
255  
256 0 ▶ if ( @ids == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ids == 1) { } 0 0 0
257 0 my $id = $ids[0];
258  
259 0 ▶ if ( my $entry = $self->live_objects->id_to_entry($ids[0]) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $entry = $self->live_objects->id_to_entry($ids[0])) 0 0 0
260 0 return not $entry->deleted;
261 }
262  
263 0 ▶ if ( my $entry = ($self->backend->exists($id))[0] ) { # backend returns a list
Branch: 1 branch
BranchTrueFalseTotal
if (my $entry = ($self->backend->exists($id))[0]) { } 0 0 0
264 0 ▶ if ( ref $entry ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $entry) 0 0 0
265 0 $self->live_objects->register_entry( $id => $entry, in_storage => 1 );
266 }
267  
268 0 return 1;
269 } else {
270 0 return '';
271 }
272 } else {
273 0 my ( %entries, %exists );
274  
275 0 @entries{@ids} = $self->live_objects->ids_to_entries(@ids);
276  
277 0 my @missing;
278  
279 0 foreach my $id ( @ids ) {
280 0 ▶ if ( ref ( my $entry = $entries{$id} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref(my $entry = $entries{$id})) { } 0 0 0
281 0 $exists{$id} = not $entry->deleted;
282 } else {
283 0 push @missing, $id;
284 }
285 }
286  
287 0 ▶ if ( @missing ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@missing) 0 0 0
288 0 my @values = $self->backend->exists(@missing);
289  
290 0 ▶ if ( my @entries = grep { ref } @values ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@entries) = grep({ref $_;} @values)) 0 0 0
291 0 $self->live_objects->register_entry( $_->id => $_, in_storage => 1 ) for @entries;
292 }
293  
294 0 ▶ @exists{@missing} = map { ref($_) ? 1 : $_ } @values;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 0 0 0
295 }
296  
297 0 ▶ return @ids == 1 ? $exists{$ids[0]} : @exists{@ids};
Branch: 1 branch
BranchTrueFalseTotal
@ids == 1 ? : 0 0 0
298 }
299 }
300  
301 sub lookup {
302 1367 ▶ my ( $self, @ids ) = @_;
Subroutine lookup: called CC=2 SCAR=7.0
Pod documented
303  
304 1367 ▶ return unless @ids;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids 0 1367 1367
305  
306 1367 my $linker = $self->linker;
307  
308 try {
309 1367 ▶ my @objects = $linker->get_or_load_objects(@ids);
Subroutine __ANON__: called CC=2 SCAR=6.9
310  
311 1124 ▶ if ( @ids == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@ids == 1) { } 1032 92 1124
312 1032 return $objects[0];
313 } else {
314 92 return @objects;
315 }
316 } catch {
317 243 ▶ return if blessed($_)
Subroutine __ANON__: called CC=4 SCAR=14.2
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($_) and $_->isa("KiokuDB::Error::MissingObjects") and $_->missing_ids_are(@ids) 53 190 243
Condition66%4/6
builtin::blessed($_) and $_->isa("KiokuDB::Error::MissingObjects") and $_->missing_ids_are(@ids)
!ll&&!rl&&r
190053
builtin::blessed($_) and $_->isa("KiokuDB::Error::MissingObjects")
!ll&&!rl&&r
190053
MC/DC33%1/3
builtin::blessed($_) and $_->isa("KiokuDB::Error::MissingObjects") and $_->missing_ids_are(@ids)
builtin::blessed($_) $_->isa("KiokuDB::Error::MissingObjects") $_->missing_ids_are(@ids)
Truth table50%2/4
A and B and C
A= builtin::blessed($_)B= $_->isa("KiokuDB::Error::MissingObjects")C= $_->missing_ids_are(@ids)
ABCresult
0XX0
10X0
1100
1111
318 and $_->isa("KiokuDB::Error::MissingObjects")
319 and $_->missing_ids_are(@ids);
320  
321 190 die $_;
322 1367 };
323 }
324  
325 sub search {
326 61 ▶ my ( $self, @args ) = @_;
Subroutine search: called CC=3 SCAR=11.0
Pod documented
327  
328 61 ▶ if ( @args == 1 && ref $args[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args == 1 and ref $args[0] eq 'HASH') { } 58 3 61
Condition66%2/3
@args == 1 and ref $args[0] eq "HASH"
!ll&&!rl&&r
0358
MC/DC50%1/2
@args == 1 and ref $args[0] eq "HASH"
@args == 1 ref $args[0] eq "HASH"
Truth table66%2/3
A and B
A= @args == 1B= ref $args[0] eq "HASH"
ABresult
0X0
100
111
329 58 return $self->simple_search(@args);
330 } else {
331 3 return $self->backend_search(@args);
332 }
333 }
334  
335 sub _load_entry_stream {
336 471 ▶ my ( $self, $stream ) = @_;
Subroutine _load_entry_stream: called CC=1 SCAR=0.0
337  
338 471 KiokuDB::Stream::Objects->new(
339 directory => $self,
340 entry_stream => $stream,
341 );
342 }
343  
344 sub simple_search {
345 58 ▶ my ( $self, @args ) = @_;
Subroutine simple_search: called CC=1 SCAR=0.0
Pod undocumented
346  
347 58 my $b = $self->backend;
348  
349 58 my $entries = $b->simple_search( @args, live_objects => $self->live_objects );
350  
351 50 my $objects = $self->_load_entry_stream($entries);
352  
353 50 return $b->simple_search_filter($objects, @args);
354 }
355  
356 sub backend_search {
357 3 ▶ my ( $self, @args ) = @_;
Subroutine backend_search: called CC=1 SCAR=0.0
Pod undocumented
358  
359 3 my $b = $self->backend;
360  
361 3 my $entries = $b->search( @args, live_objects => $self->live_objects );
362  
363 3 my $objects = $self->_load_entry_stream($entries);
364  
365 3 return $b->search_filter($objects, @args);
366 }
367  
368 sub root_set {
369 257 ▶ my ( $self ) = @_;
Subroutine root_set: called CC=1 SCAR=0.0
Pod documented
370  
371 257 $self->_load_entry_stream( $self->backend->root_entries( live_objects => $self->live_objects ) );
372 }
373  
374 sub all_objects {
375 233 ▶ my ( $self ) = @_;
Subroutine all_objects: called CC=1 SCAR=0.0
Pod documented
376  
377 233 $self->_load_entry_stream( $self->backend->all_entries( live_objects => $self->live_objects ) );
378 }
379  
380 sub grep {
381 0 ▶ my ( $self, $filter ) = @_;
Subroutine grep: not called CC=1 SCAR=6.9
Pod documented
382  
383 0 my $stream = $self->root_set;
384  
385 0 ▶ $stream->filter(sub { [ grep { $filter->($_) } @$_ ] });
Subroutine __ANON__: not called CC=1 SCAR=6.9
386 }
387  
388 sub scan {
389 0 ▶ my ( $self, $filter ) = @_;
Subroutine scan: not called CC=3 SCAR=24.8
Pod documented
390  
391 0 my $stream = $self->root_set;
392  
393 0 ▶ while ( my $items = $stream->next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $items = $stream->next) 0 0 0
394 0 foreach my $item ( @$items ) {
395 0 $item->$filter();
396 }
397 }
398 }
399  
400 sub _parse_args {
401 1309 ▶ my ( $self, @args ) = @_;
Subroutine _parse_args: called CC=3 SCAR=11.0
402  
403 1309 my ( %ids, @ret );
404  
405 1309 ▶ while ( @args ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args) 2224 1309 3533
406 2224 my $next = shift @args;
407  
408 2224 ▶ unless ( ref $next ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $next) { } 1812 412 2224
409 412 my $obj = shift @args;
410  
411 412 $ids{$next} = $obj;
412  
413 412 push @ret, $obj;
414 } else {
415 1812 push @ret, $next;
416 }
417 }
418  
419 1309 return ( \%ids, @ret );
420 }
421  
422 sub _register {
423 1309 ▶ my ( $self, @args ) = @_;
Subroutine _register: called CC=2 SCAR=6.9
424  
425 1309 my ( $ids, @objs ) = $self->_parse_args(@args);
426  
427 1309 ▶ if ( scalar keys %$ids ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar keys %$ids) 214 1095 1309
428 214 $self->live_objects->insert(%$ids);
429 }
430  
431 1309 return @objs;
432 }
433  
434 sub refresh {
435 25 ▶ my ( $self, @objects ) = @_;
Subroutine refresh: called CC=5 SCAR=19.7
Pod undocumented
436  
437 25 ▶ return unless @objects;
Branch: 1 branch
BranchTrueFalseTotal
unless @objects 0 25 25
438  
439 25 my $l = $self->live_objects;
440  
441 croak "Object not in storage"
442 25 ▶ if grep { not $l->object_in_storage($_) } @objects;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $l->object_in_storage($_);} @objects 0 25 25
443  
444 25 $self->linker->refresh_objects(@objects);
445  
446 25 ▶ if ( defined wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) 0 25 25
447 0 ▶ if ( @objects == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@objects == 1) { } 0 0 0
448 0 return $objects[0];
449 } else {
450 0 return @objects;
451 }
452 }
453 }
454  
455 sub _store {
456 712 ▶ my ( $self, $root, @args ) = @_;
Subroutine _store: called CC=2 SCAR=7.0
457  
458 712 my @objects = $self->_register(@args);
459  
460 712 ▶ return unless @objects;
Branch: 1 branch
BranchTrueFalseTotal
unless @objects 0 712 712
461  
462 712 $self->store_objects( root_set => $root, objects => \@objects );
463 }
464  
465 712 ▶sub store { shift->_store( 1, @_ ) }
Subroutine store: called CC=1 SCAR=0.0
Pod documented
466 0 ▶sub store_nonroot { shift->_store( 0, @_ ) }
Subroutine store_nonroot: not called CC=1 SCAR=6.9
Pod documented
467  
468 sub _insert {
469 193 ▶ my ( $self, $root, @args ) = @_;
Subroutine _insert: called CC=4 SCAR=13.9
470  
471 193 my @objects = $self->_register(@args);
472  
473 193 ▶ return unless @objects;
Branch: 1 branch
BranchTrueFalseTotal
unless @objects 0 193 193
474  
475 193 my $l = $self->live_objects;
476  
477 # FIXME make optional?
478 193 ▶ if ( my @in_storage = grep { $l->object_in_storage($_) } @objects ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@in_storage) = grep({$l->object_in_storage($_);} @objects)) 4 189 193
479 4 croak "Objects already in database: @in_storage";
480 }
481  
482 189 $self->store_objects( root_set => $root, only_in_storage => 1, objects => \@objects );
483  
484 # return IDs only for unknown objects
485 189 ▶ if ( defined wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray) 182 7 189
486 182 return $self->live_objects->objects_to_ids(@objects);
487 }
488 }
489  
490 191 ▶sub insert { shift->_insert( 1, @_ ) }
Subroutine insert: called CC=1 SCAR=0.0
Pod documented
491 2 ▶sub insert_nonroot { shift->_insert( 0, @_ ) }
Subroutine insert_nonroot: called CC=1 SCAR=0.0
Pod documented
492  
493 sub update {
494 404 ▶ my ( $self, @args ) = @_;
Subroutine update: called CC=2 SCAR=7.0
Pod documented
495  
496 404 my @objects = $self->_register(@args);
497  
498 404 my $l = $self->live_objects;
499  
500 croak "Object not in storage"
501 404 ▶ if grep { not $l->object_in_storage($_) } @objects;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $l->object_in_storage($_);} @objects 0 404 404
502  
503 404 $self->store_objects( shallow => 1, only_known => 1, objects => \@objects );
504 }
505  
506 sub deep_update {
507 0 ▶ my ( $self, @args ) = @_;
Subroutine deep_update: not called CC=2 SCAR=17.9
Pod documented
508  
509 0 my @objects = $self->_register(@args);
510  
511 0 my $l = $self->live_objects;
512  
513 croak "Object not in storage"
514 0 ▶ if grep { not $l->object_in_storage($_) } @objects;
Branch: 1 branch
BranchTrueFalseTotal
if grep {not $l->object_in_storage($_);} @objects 0 0 0
515  
516 0 $self->store_objects( only_known => 1, objects => \@objects );
517 }
518  
519 sub _derive_entries {
520 75 ▶ my ( $self, %args ) = @_;
Subroutine _derive_entries: called CC=4 SCAR=14.0
521  
522 75 my @objects = @{ $args{objects} };
523  
524 75 my $l = $self->live_objects;
525  
526 75 my @entries = $l->objects_to_entries( @{ $args{objects} } );
527  
528 75 ▶ my $method = $args{method} || "derive";
Condition50%1/2
$args{'method'} || 'derive'
l!l
075
MC/DC0%0/1
$args{'method'} || 'derive'
$args{'method'}
Truth table50%1/2
A
A= $args{'method'}
Aresult
11
00
529  
530 75 ▶ my $derive_args = $args{args} || [];
Condition50%1/2
$args{'args'} || []
l!l
750
MC/DC0%0/1
$args{'args'} || []
$args{'args'}
Truth table50%1/2
A
A= $args{'args'}
Aresult
11
00
531  
532 75 ▶ my @args = ref($derive_args) eq 'HASH' ? %$derive_args : @$derive_args;
Branch: 1 branch
BranchTrueFalseTotal
ref $derive_args eq 'HASH' ? : 75 0 75
533  
534 $l->update_entries(map {
535 75 my $obj = shift @objects;
536 75 $obj => $_->$method( object => $obj, @args );
537 } @entries);
538 }
539  
540 sub set_root {
541 50 ▶ my ( $self, @objects ) = @_;
Subroutine set_root: called CC=1 SCAR=0.0
Pod documented
542  
543 50 $self->_derive_entries( objects => \@objects, args => { root => 1 } );
544 }
545  
546 sub unset_root {
547 25 ▶ my ( $self, @objects ) = @_;
Subroutine unset_root: called CC=1 SCAR=0.0
Pod documented
548  
549 25 $self->_derive_entries( objects => \@objects, args => { root => 0 } );
550 }
551  
552 sub is_root {
553 486 ▶ my ( $self, @objects ) = @_;
Subroutine is_root: called CC=2 SCAR=6.9
Pod undocumented
554  
555 486 my $l = $self->live_objects;
556  
557 486 my @is_root = map { $l->id_in_root_set($_) } $l->objects_to_ids(@objects);
558  
559 486 ▶ return @objects == 1 ? $is_root[0] : @is_root;
Branch: 1 branch
BranchTrueFalseTotal
@objects == 1 ? : 386 100 486
560 }
561  
562 sub store_objects {
563 1305 ▶ my ( $self, %args ) = @_;
Subroutine store_objects: called CC=3 SCAR=11.0
Pod undocumented
564  
565 1305 my $objects = $args{objects};
566  
567 1305 my ( $buffer, @ids ) = $self->collapser->collapse(%args);
568  
569 1292 ▶ $buffer->imply_root(@ids) if $args{root_set};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"root_set"} 888 404 1292
570  
571 1292 $buffer->commit($self->backend);
572  
573 1292 ▶ if ( @$objects == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$objects == 1) { } 910 382 1292
574 910 return $ids[0];
575 } else {
576 382 return @ids;
577 }
578 }
579  
580 sub delete {
581 138 ▶ my ( $self, @ids_or_objects ) = @_;
Subroutine delete: called CC=7 SCAR=19.5
Pod documented
582  
583 138 ▶ return unless @ids_or_objects;
Branch: 1 branch
BranchTrueFalseTotal
unless @ids_or_objects 0 138 138
584  
585 138 my $l = $self->live_objects;
586  
587 138 my @ids = grep { not ref } @ids_or_objects;
588 138 my @objects = grep { ref } @ids_or_objects;
589  
590 # FIXME requires 'deleted' flag or somesuch
591 138 ▶ unless ( $l->keep_entries ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($l->keep_entries) 65 73 138
592 65 push @ids, $l->objects_to_ids(@objects);
593 65 @objects = ();
594 }
595  
596 138 my @entries;
597  
598 138 for ( @objects ) {
599 30 ▶ croak "Object not in storage" unless $l->object_in_storage($_);
Branch: 1 branch
BranchTrueFalseTotal
unless $l->object_in_storage($_) 0 30 30
600 }
601  
602 138 ▶ push @entries, $l->objects_to_entries(@objects) if @objects;
Branch: 1 branch
BranchTrueFalseTotal
if @objects 29 109 138
603  
604 138 @entries = map { $_->deletion_entry } @entries;
605  
606 # FIXME ideally if ID is pointing at a live object we should use its entry
607 #push @entries, $l->ids_to_entries(@ids) if @ids;
608 138 my @ids_or_entries = ( @entries, @ids );
609  
610 138 ▶ if ( my @new_entries = grep { ref } $self->backend->delete(@ids_or_entries) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@new_entries) = grep({ref $_;} $self->backend->delete(@ids_or_entries))) 101 37 138
611 101 push @entries, @new_entries;
612 }
613  
614 138 $l->remove(@ids_or_objects);
615 }
616  
617 sub scoped_txn {
618 0 ▶ my ( $self, $body, @args ) = @_;
Subroutine scoped_txn: not called CC=1 SCAR=6.9
Pod documented
619  
620 0 $self->txn_do(body => $body, scope => 1, @args);
621 }
622  
623 sub txn_do {
624 2090 ▶ my ( $self, @args ) = @_;
Subroutine txn_do: called CC=4 SCAR=14.0
Pod documented
625  
626 2090 ▶ unshift @args, 'body' if @args % 2 == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 == 1 1943 147 2090
627  
628 2090 my %args = @args;
629  
630 2090 my $code = delete $args{body};
631  
632 2090 ▶ my $s = $args{scope} && $self->new_scope;
Condition66%2/3
$args{'scope'} && $self->new_scope
!ll&&!rl&&r
19430147
MC/DC50%1/2
$args{'scope'} && $self->new_scope
$args{'scope'} $self->new_scope
Truth table66%2/3
A && B
A= $args{'scope'}B= $self->new_scope
ABresult
0X0
100
111
633  
634 2090 my $backend = $self->backend;
635  
636 2090 ▶ if ( $backend->can("txn_do") ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($backend->can('txn_do')) { } 2090 0 2090
637 2090 my $scope = $self->live_objects->new_txn;
638  
639 2090 my $rollback = $args{rollback};
640 2090 ▶ $args{rollback} = sub { $scope && $scope->rollback; $rollback && $rollback->() };
Subroutine __ANON__: called CC=3 SCAR=11.1
Branch: 2 branches
BranchTrueFalseTotal
$scope and $scope->rollback 228 216 444
$rollback and &$rollback() 0 444 444
641  
642 2090 return $backend->txn_do( $code, %args );
643 } else {
644 0 return $code->();
645 }
646 }
647  
648 sub directory {
649 0 ▶ my $self = shift;
Subroutine directory: not called CC=1 SCAR=6.9
Pod documented
650 0 return $self;
651 }
652  
653 12 __PACKAGE__->meta->make_immutable;
654  
655 12 __PACKAGE__
656  
657 __END__
658  
659 =pod
660  
661 =head1 NAME
662  
663 KiokuDB - Object Graph storage engine
664  
665 =head1 TUTORIAL
666  
667 If you're new to L<KiokuDB> check out L<KiokuDB::Tutorial>.
668  
669 =head1 SYNOPSIS
670  
671 use KiokuDB;
672  
673 # use a DSN
674 my $d = KiokuDB->connect( $dsn, %args );
675  
676 # or manually instantiate a backend
677 my $d = KiokuDB->new(
678 backend => KiokuDB::Backend::Files->new(
679 dir => "/tmp/foo",
680 serializer => "yaml",
681 ),
682 );
683  
684  
685 # create a scope object
686 my $s = $d->new_scope;
687  
688  
689 # takes a snapshot of $some_object
690 my $uuid = $d->store($some_object);
691  
692 # or with a custom ID:
693 $d->store( $id => $some_object ); # $id can be any string
694  
695  
696 # retrieve by ID
697 my $some_object = $d->lookup($uuid);
698  
699  
700  
701 # some backends (like DBI) support simple searchs
702 $d->search({ name => "foo" });
703  
704  
705 # others use GIN queries (DBI supports both)
706 $d->search($gin_query);
707  
708 =head1 DESCRIPTION
709  
710 L<KiokuDB> is a Moose based frontend to various data stores, somewhere in
711 between L<Tangram> and L<Pixie>.
712  
713 Its purpose is to provide persistence for "regular" objects with as little
714 effort as possible, without sacrificing control over how persistence is
715 actually done, especially for harder to serialize objects.
716  
717 L<KiokuDB> is also non-invasive: it does not use ties, C<AUTOLOAD>, proxy
718 objects, C<sv_magic> or any other type of trickery.
719  
720 Many features important for proper Perl space semantics are supported,
721 including shared data, circular structures, weak references, tied structures,
722 etc.
723  
724 L<KiokuDB> is meant to solve two related persistence problems:
725  
726 =over 4
727  
728 =item Transparent persistence
729  
730 Store arbitrary objects without changing their class definitions or worrying
731 about schema details, and without needing to conform to the limitations of
732 a relational model.
733  
734 =item Interoperability
735  
736 Persisting arbitrary objects in a way that is compatible with existing
737 data/code (for example interoprating with another app using CouchDB with JSPON
738 semantics).
739  
740 =back
741  
742 =head1 FUNDAMENTAL CONCEPTS
743  
744 In order to use any persistence framework it is important to understand what it
745 does and how it does it.
746  
747 Systems like L<Tangram> or L<DBIx::Class> generally require explicit meta data
748 and use a schema, which makes them fairly predictable.
749  
750 When using transparent systems like L<KiokuDB> or L<Pixie> it is more important
751 to understand what's going on behind the scenes in order to avoid surprises and
752 limitations.
753  
754 An architectural overview is available on the website:
755 L<http://www.iinteractive.com/kiokudb/arch.html>
756  
757 The process is explained here and in the various component documentation in
758 more detail.
759  
760 =head2 Collapsing
761  
762 When an object is stored using L<KiokuDB> it's collapsed into an
763 L<KiokDB::Entry|Entry>.
764  
765 An entry is a simplified representation of the object, allowing the data to be
766 saved in formats as simple as JSON.
767  
768 References to other objects are converted to symbolic references in the entry,
769 so objects can be saved independently of each other.
770  
771 The entries are given to the L<KiokuDB::Backend|Backend> for actual storage.
772  
773 Collapsing is explained in detail in L<KiokuDB::Collapser>. The way an entry is
774 created varies with the object's class.
775  
776 =head2 Linking
777  
778 When objects are loaded, entries are retrieved from the backend using their
779 UIDs.
780  
781 When a UID is already loaded (in the live object set of a L<KiokuDB> instance,
782 see L<KiokuDB::LiveObjects>) the live object is used. This way references to
783 shared objects are shared in memory regardless of the order the objects were
784 stored or loaded.
785  
786 This process is explained in detail in L<KiokuDB::Linker>.
787  
788 =head1 ROOT SET MEMBERSHIP
789  
790 Any object that is passed to C<store> or C<insert> directly is implicitly
791 considered a member of the root set.
792  
793 This flag implies that the object is an identified resource and should not be
794 garbage collected with any of the proposed garbage collection schemes.
795  
796 The root flag may be modified explicitly:
797  
798 $kiokudb->set_root(@objects); # or unset_root
799  
800 $kiokudb->update(@objects);
801  
802 Lastly, root set membership may also be specified explicitly by the typemap.
803  
804 A root set member must be explicitly removed using C<delete> or by
805 removing it from the root set. Only non-members of the root set will be
806 purged with any garbage collection scheme.
807  
808 =head1 TRANSACTIONS
809  
810 On supporting backends the C<txn_do> method will execute a block and commit the
811 transaction at its end.
812  
813 Nesting of C<txn_do> blocks is always supported, though rolling back a nested
814 transaction may produce different results on different backends.
815  
816 If the backend does not support transactions C<txn_do> simply executes the code
817 block normally.
818  
819 =head1 CONCURRENCY
820  
821 Most transactional backends are also concurrent.
822  
823 L<KiokuDB::Backend::BDB> and L<KiokuDB::Backend::CouchDB> default to
824 serializable transaction isolation and do not suffer from deadlocks, but
825 serialization errors may occur, aborting the transaction (in which case the
826 transaction should be tried again).
827  
828 L<KiokuDB::Backend::Files> provides good concurrency support but will only
829 detect deadlocks on platforms which return C<EDEADLK> from C<flock>.
830 L<Directory::Transactional> may provide alternative mechanisms in the future.
831  
832 Concurrency support in L<KiokuDB::Backend::DBI> depends on the database. SQLite
833 defaults to serializable transaction isolation out of the box, wheras MySQL and
834 PostgreSQL default to read committed.
835  
836 Depending on your application read committed isolation may be sufficient, but
837 due to the graph structure nature of the data repeatable reads or serializable
838 level isolation is highly reccomended. Read committed isolation generally works
839 well when each row in the database is more or less independent of others, and
840 various constraints ensure integrity. Unfortunately this is not the case with
841 the graph layout.
842  
843 To enable stronger isolation guarantees see
844 L<KiokuDB::Backend::DBI/Transactions> for per-database pointers.
845  
846 =head1 ATTRIBUTES
847  
848 L<KiokuDB> uses a number of delegates which do the actual work.
849  
850 Of these only C<backend> is required, the rest have default definitions.
851  
852 Additional attributes that are not commonly used are listed in L</"INTERNAL
853 ATTRIBUTES">.
854  
855 =over 4
856  
857 =item backend
858  
859 This attribute is required.
860  
861 This must be an object that does L<KiokuDB::Backend>.
862  
863 The backend handles storage and retrieval of entries.
864  
865 =item typemap
866  
867 This is an instance L<KiokuDB::TypeMap>.
868  
869 The typemap contains entries which control how L<KiokuDB::Collapser> and
870 L<KiokuDB::Linker> handle different types of objects.
871  
872 =item allow_classes
873  
874 An array references of extra classes to allow.
875  
876 Objects blessed into these classes will be collapsed using
877 L<KiokuDB::TypeMap::Entry:Naive>.
878  
879 =item allow_bases
880  
881 An array references of extra base classes to allow.
882  
883 Objects derived from these classes will be collapsed using
884 L<KiokuDB::TypeMap::Entry:Naive>.
885  
886 =item allow_class_builders
887  
888 If true adds L<KiokuDB::TypeMap::ClassBuilders> to the merged typemap.
889  
890 It's possible to provide a hash reference of options to give to
891 L<KiokuDB::TypeMap::ClassBuilders/new>.
892  
893 =item check_class_versions
894  
895 Controls whether or not the class versions of objects are checked on load.
896  
897 Defaults to true.
898  
899 =item class_version_table
900  
901 A table of classes and versions that is passed to the default typemap entry for
902 Moose/Class::MOP objects.
903  
904 When a class version has changed between the time that an object was stored and
905 the time it's being retrieved, the data must be converted.
906  
907 See L<KiokuDB::TypeMap::Entry::MOP> for more details.
908  
909 =back
910  
911 =head1 METHODS
912  
913 =over 4
914  
915 =item connect $dsn, %args
916  
917 DWIM wrapper for C<new>.
918  
919 C<$dsn> represents some sort of backend (much like L<DBI> dsns map to DBDs).
920  
921 An example DSN is:
922  
923 my $dir = KiokuDB->connect("bdb:dir=path/to/data/");
924  
925 The backend moniker name is extracted by splitting on the colon. The rest of
926 the string is passed to C<new_from_dsn>, which is documented in more detail in
927 L<KiokuDB::Backend>.
928  
929 Typically DSN arguments are separated by C<;>, with C<=> separating keys and
930 values. Arguments with no value are assumed to denote boolean truth (e.g.
931 C<jspon:dir=foo;pretty> means C<< dir => "foo", pretty => 1 >>). However, a
932 backend may override the default parsing, so this is not guaranteed.
933  
934 Extra arguments are passed both to the backend constructor, and the C<KiokuDB>
935 constructor.
936  
937 Note that if you need a typemap you still need to pass it in:
938  
939 KiokuDB->connect( $dsn, typemap => $typemap );
940  
941 The DSN can also be a valid L<JSON> string taking one of the following forms:
942  
943 dsn => '["dbi:SQLite:foo",{"schema":"MyApp::DB"}]'
944  
945 dsn => '{"dsn":"dbi:SQLite:foo","schema":"MyApp::DB"}'
946  
947 This allows more complicated arguments to be specified accurately, or arbitrary
948 options to be specified when the backend has nonstandard DSN parsing (for
949 instance L<KiokuDB::Backend::DBI> simply passes the string to L<DBI>, so this
950 is necessary in order to specify options on the command line).
951  
952 =item configure $config_file, %args
953  
954 TODO
955  
956 =item new %args
957  
958 Creates a new directory object.
959  
960 See L</ATTRIBUTES>
961  
962 =item new_scope
963  
964 Creates a new object scope. Handled by C<live_objects>.
965  
966 The object scope artificially bumps up the reference count of objects to ensure
967 that they live at least as long as the scope does.
968  
969 This ensures that weak references aren't deleted prematurely, and the object
970 graph doesn't get corrupted without needing to create circular structures and
971 cleaning up leaks manually.
972  
973 =item lookup @ids
974  
975 Fetches the objects for the specified IDs from the live object set or from
976 storage.
977  
978 =item store @objects
979  
980 =item store %objects
981  
982 =item store_nonroot @objects
983  
984 =item store_nonroot %objects
985  
986 Recursively collapses C<@objects> and inserts or updates the entries.
987  
988 This performs a full update of every reachable object from C<@objects>,
989 snapshotting everything.
990  
991 Strings found in the object list are assumed to be IDs for the following objects.
992  
993 The C<nonroot> variant will not mark the objects as members of the root set
994 (therefore they will be subject to garbage collection).
995  
996 =item update @objects
997  
998 Performs a shallow update of @objects (referants are not updated).
999  
1000 It is an error to update an object not in the database.
1001  
1002 =item deep_update @objects
1003  
1004 Update @objects and all of the objects they reference. All references
1005 objects must already be in the database.
1006  
1007 =item insert @objects
1008  
1009 =item insert %objects
1010  
1011 =item insert_nonroot @objects
1012  
1013 =item insert_nonroot %objects
1014  
1015 Inserts objects to the database.
1016  
1017 It is an error to insert objects that are already in the database, all elements
1018 of C<@objects> must be new, but their referants don't have to be.
1019  
1020 C<@objects> will be collapsed recursively, but the collapsing stops at known
1021 objects, which will not be updated.
1022  
1023 The C<nonroot> variant will not mark the objects as members of the root set
1024 (therefore they will be subject to garbage collection).
1025  
1026  
1027 =item delete @objects_or_ids
1028  
1029 Deletes the specified objects from the store.
1030  
1031 Note that this can cause lookup errors if the object you are deleting is
1032 referred to by another object, because that link will be broken.
1033  
1034 =item set_root @objects
1035  
1036 =item unset_root @objects
1037  
1038 Modify the C<root> flag on the associated entries.
1039  
1040 C<update> must be called for the change to take effect.
1041  
1042 =item txn_do $code, %args
1043  
1044 =item txn_do %args
1045  
1046 =item scoped_txn $code
1047  
1048 Executes $code within the scope of a transaction.
1049  
1050 This requires that the backend supports transactions
1051 (L<KiokuDB::Backend::Role::TXN>).
1052  
1053 If the backend does not support transactions, the code block will simply be
1054 invoked.
1055  
1056 Transactions may be nested.
1057  
1058 If the C<scope> argument is true an implicit call to C<new_scope> will be made,
1059 keeping the scope for the duration of the transaction.
1060  
1061 The return value is propagated from the code block, with handling of
1062 list/scalar/void context.
1063  
1064 C<scoped_txn> is like C<txn_do> but sets C<scope> to true.
1065  
1066 =item txn_begin
1067  
1068 =item txn_commit
1069  
1070 =item txn_rollback
1071  
1072 These methods simply call the corresponding methods on the backend.
1073  
1074 Like C<txn_do> these methods are no-ops if the backend does not support
1075 transactions.
1076  
1077 =item search \%proto
1078  
1079 =item search @args
1080  
1081 Searching requires a backend that supports querying.
1082  
1083 The C<\%proto> form is currently unspecified but in the future should provide a
1084 simple but consistent way of looking up objects by attributes.
1085  
1086 The second form is backend specific querying, for instance
1087 L<Search::GIN::Query> objects passed to L<KiokuDB::Backend::BDB::GIN> or
1088 the generic GIN backend wrapper L<KiokuDB::GIN>.
1089  
1090 Returns a L<Data::Stream::Bulk> of the results.
1091  
1092 =item root_set
1093  
1094 Returns a L<Data::Stream::Bulk> of all the root objects in the database.
1095  
1096 =item all_objects
1097  
1098 Returns a L<Data::Stream::Bulk> of all the objects in the database.
1099  
1100 =item grep $filter
1101  
1102 Returns a L<Data::Stream::Bulk> of the objects in C<root_set> filtered by
1103 C<$filter>.
1104  
1105 =item scan $callback
1106  
1107 Iterates the root set calling C<$callback> for each object.
1108  
1109 =item object_to_id
1110  
1111 =item objects_to_ids
1112  
1113 =item id_to_object
1114  
1115 =item ids_to_objects
1116  
1117 Delegates to L<KiokuDB::LiveObjects>
1118  
1119 =item directory
1120  
1121 Returns C<$self>.
1122  
1123 This is used when setting up L<KiokuDB::Role::API> delegation chains. Calling
1124 C<directory> on any level of delegator will always return the real L<KiokuDB>
1125 instance no matter how deep.
1126  
1127 =back
1128  
1129 =head1 GLOBALS
1130  
1131 =over 4
1132  
1133 =item C<$SERIAL_IDS>
1134  
1135 If set at compile time, the default UUID generation role will use serial IDs,
1136 instead of UUIDs.
1137  
1138 This is useful for testing, since the same IDs will be issued each run, but is
1139 utterly broken in the face of concurrency.
1140  
1141 =back
1142  
1143 =head1 INTERNAL ATTRIBUTES
1144  
1145 These attributes are documented for completeness and should typically not be
1146 needed.
1147  
1148 =over 4
1149  
1150 =item collapser
1151  
1152 L<KiokuDB::Collapser>
1153  
1154 The collapser prepares objects for storage, by creating L<KiokDB::Entry>
1155 objects to pass to the backend.
1156  
1157 =item linker
1158  
1159 L<KiokuDB::Linker>
1160  
1161 The linker links entries into functioning instances, loading necessary
1162 dependencies from the backend.
1163  
1164 =item live_objects
1165  
1166 L<KiokuDB::LiveObjects>
1167  
1168 The live object set keeps track of objects and entries for the linker and the
1169 resolver.
1170  
1171 It also creates scope objects that help ensure objects don't garbage collect
1172 too early (L<KiokuDB::LiveObjects/new_scope>, L<KiokuDB::LiveObjects::Scope>),
1173 and transaction scope objects used by C<txn_do>
1174 (L<KiokuDB::LiveObjects::TXNScope>).
1175  
1176 =item typemap_resolver
1177  
1178 An instance of L<KiokuDB::TypeMap::Resolver>. Handles actual lookup and
1179 compilation of typemap entries, using the user typemap.
1180  
1181 =back
1182  
1183 =head1 SEE ALSO
1184  
1185 =head2 Prior Art on the CPAN
1186  
1187 =over 4
1188  
1189 =item L<Pixie>
1190  
1191 =item L<DBM::Deep>
1192  
1193 =item L<OOPS>
1194  
1195 =item L<Tangram>
1196  
1197 =item L<DBIx::Class>
1198  
1199 Polymorphic retrieval is possible with L<DBIx::Class::DynamicSubclass>
1200  
1201 =item L<Fey::ORM>
1202  
1203 =item L<MooseX::Storage>
1204  
1205 =back
1206  
1207 =head1 VERSION CONTROL
1208  
1209 KiokuDB is maintained using Git. Information about the repository is available
1210 on L<http://www.iinteractive.com/kiokudb/>
1211  
1212 =head1 AUTHOR
1213  
1214 Yuval Kogman E<lt>nothingmuch@woobling.orgE<gt>
1215  
1216 =head1 COPYRIGHT
1217  
1218 Copyright (c) 2008, 2009 Yuval Kogman, Infinity Interactive. All
1219 rights reserved This program is free software; you can redistribute
1220 it and/or modify it under the same terms as Perl itself.
1221  
1222 =cut
« KiokuDB/Backend/Serialize/JSPON/Expander.pm ↑ Summary KiokuDB/Backend/Serialize/JSPON/Collapser.pm »