VERSION
version 0.57SYNOPSIS
# mostly internal
DESCRIPTION
The collapser simplifies real objects into KiokuDB::Entry objects to pass to the backend.Non object data is collapsed by walking it with Data::Visitor (which KiokuDB::Collapser inherits from).
Object collapsing is detailed in ``COLLAPSING STRATEGIES''.
The object's data will be copied into the KiokuDB::Entry with references to other data structures translated into KiokuDB::Reference objects.
Reference addresses are mapped to unique identifiers, which are generated as necessary.
Compacting
If "compact" is disabled then every reference is symbolic, and every data structure has an entry.If compacting is enabled (the default) the minimum number of entry objects required for consistency is created.
Every blessed, shared or tied data structure requires an entry object, as does every target of a weak reference. ``Simple'' structures, such as plain hashes/arrays will be left inline as data intrinsic to the object it was found in.
Compacting is usually desirable, but sometimes isn't (for instance with an RDF like store).
COLLAPSING STRATEGIES
Collapsing strategies are chosen based on the type of the object being collapsed, using KiokuDB::TypeMap::Resolver.The resolver consults the typemap (KiokuDB::TypeMap), and caches the results as keyed by "ref $object".
The typemap contains normal entries (keyed by "ref $object eq $class") or isa entries (filtered by "$object->isa($class)"). The rationale is that a typemap entry for a superclass might not support all subclasses as well.
Any strategy may be collapsed as a first class object, or intrinsically, inside its parent (in which case it isn't assigned a UUID). This is determined based on the "intrinsic" attribute to the entry. For instance, if Path::Class related objects should be collapsed as if they are values, the following typemap entry can be used:
isa_entries => { 'Path::Class::Entity' => KiokuDB::TypeMap::Entry::Callback->new( intrinsic => 1, collapse => "stringify", expand => "new", ), },
If no typemap entry exists, KiokuDB::TypeMap::Entry::MOP is used by default. See KiokuDB::TypeMap::Resolver for more details.
These are the strategies in brief:
MOP
When the object has a Class::MOP registered metaclass (any Moose object, but not only), the MOP is used to walk the object's attributes and construct the simplified version without breaking encapsulation.See KiokuDB::TypeMap::Entry::MOP.
Naive
This collapsing strategy simply walks the object's data using Data::Visitor.This allows collapsing of Class::Accessor based objects, for instance, but should be used with care.
See KiokuDB::TypeMap::Entry::Naive
Callback
This collapsing strategy allows callbacks to be used to map the types.It is more limited than the other strategies, but very convenient for simple values.
See KiokuDB::TypeMap::Entry::Callback for more details.
Passthrough
This delegates collapsing to the backend serialization. This is convenient for when a backend uses e.g. Storable to serialize entries, and the object in question already has a "STORABLE_freeze" and "STORABLE_thaw" method.AUTHOR
Yuval Kogman <[email protected]>COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Yuval Kogman, Infinity Interactive.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.