Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

kiokudb::collapser(3pm) [debian man page]

KiokuDB::Collapser(3pm) 				User Contributed Perl Documentation				   KiokuDB::Collapser(3pm)

NAME
KiokuDB::Collapser - Collapse object hierarchies to entry data SYNOPSIS
# 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. perl v5.12.4 2011-03-31 KiokuDB::Collapser(3pm)

Check Out this Related Man Page

DBIx::Class::Schema::KiokuDB(3pm)			User Contributed Perl Documentation			 DBIx::Class::Schema::KiokuDB(3pm)

NAME
DBIx::Class::Schema::KiokuDB - Hybrid KiokuDB/DBIx::Class::Schema schema support. SYNOPSIS
Load this component into the schema: package MyApp::DB; use base qw(DBIx::Class::Schema); __PACKAGE__->load_components(qw(Schema::KiokuDB)); __PAKCAGE__->load_namespaces; Then load the DBIx::Class::KiokuDB component into every table that wants to refer to arbitrary KiokuDB objects: package MyApp::DB::Result::Album; use base qw(DBIx::Class::Core); __PACKAGE__->load_components(qw(KiokuDB)); __PACKAGE__->table('album'); __PACKAGE__->add_columns( id => { data_type => "integer" }, title => { data_type => "varchar" }, # the foreign key for the KiokuDB object: metadata => { data_type => "varchar" }, ); __PACKAGE__->set_primary_key('id'); # enable a KiokuDB rel on the column: __PACKAGE__->kiokudb_column('metadata'); Connect to the DSN: my $dir = KiokuDB->connect( 'dbi:SQLite:dbname=:memory:', schema => "MyApp::DB", create => 1, ); # get the connect DBIC schema instance my $schema = $dir->backend->schema; Then you can freely refer to KiokuDB objects from your "Album" class: $dir->txn_do(scope => 1, body => sub { $schema->resultset("Album")->create({ title => "Blah blah", metadata => $any_object, }); }); DESCRIPTION
This class provides the schema definition support code required for integrating an arbitrary DBIx::Class::Schema with KiokuDB::Backend::DBI. REUSING AN EXISTING DBIx::Class SCHEMA The example in the Synopis assumes that you want to first set up a KiokuDB and than link that to some DBIx::Class classes. Another use case is that you already have a configured DBIx::Class Schema and want to tack KiokuDB onto it. The trick here is to make sure to load the KiokuDB schema using "__PACKAGE__->define_kiokudb_schema()" in your Schema class: package MyApp::DB; use base qw(DBIx::Class::Schema); __PACKAGE__->load_components(qw(Schema::KiokuDB)); __PACKAGE__->define_kiokudb_schema(); __PAKCAGE__->load_namespaces; You can now get the KiokuDB directory handle like so: my $dir = $schema->kiokudb_handle; For a complete example take a look at t/autovivify_handle.t. USAGE AND LIMITATIONS
KiokuDB managed objects may hold references to row objects, resultsets (treated as saved searches, or results or cursor state is saved), result source handles, and the schema. Foreign DBIx::Class objects, that is ones that originated from a schema that isn't the underlying schema are currently not supported, but this limitation may be lifted in the future. All DBIC operations which may implicitly cause a lookup of a KIokuDB managed object require live object scope management, just as normal. It is reccomended to use "txn_do" in KiokuDB because that will invoke the appropriate transaction hooks on both layers, as opposed to just in DBIx::Class. SEE ALSO
DBIx::Class::KiokuDB, KiokuDB::Backend::DBI. perl v5.12.4 2011-10-04 DBIx::Class::Schema::KiokuDB(3pm)
Man Page