KiokuD...lapser(3pm)
π KiokuD...lapser π
okay bestie, so this is the manual page for KiokuD...lapser, section 3pm, from the User Contributed Perl Documentation. it's literally all about KiokuDB::Collapser, and yes we are gonna get into it. grab a snack π
β¨ NAME β¨
KiokuDB::Collapser β collapse object hierarchies to entry data. that's the whole vibe. it takes your cute little object tree and squishes it down into entry data. periodt. π
π VERSION π
version 0.57. she's got a number, she's official. π
π¦ SYNOPSIS π¦
# mostly internal
that's it. that's the synopsis. she's mostly internal, okay?? she's not here for the public, she's here for the backend. iykyk. π
π DESCRIPTION π
so the collapser's whole job is taking real objects and simplifying them into KiokuDB::Entry objects, which then get handed off to the backend. that's the pipeline, bestie. β¨
non-object data gets collapsed by walking it with Data::Visitor β and fun fact, KiokuDB::Collapser actually inherits from Data::Visitor, so that's a whole family situation going on there. π«Ά
object collapsing specifically? that's got its own section, and it's called "COLLAPSING STRATEGIES". we'll get there, don't worry. π
the object's data gets copied into the KiokuDB::Entry, and any references to other data structures get translated into KiokuDB::Reference objects. so like, every reference gets a glow-up into something the backend can actually deal with. π«
reference addresses get mapped to unique identifiers, and those identifiers are generated as needed. no pre-planning, they just show up when the moment calls for them. main character energy fr. π¦
π§ Compacting π§
okay so this is the big one. listen up. π
if "compact" is disabled, then every single reference is symbolic, and every data structure gets its own entry. every one. no skipping. that's a LOT of entries, bestie.
if compacting is enabled β and heads up, that's the default π β then only the minimum number of entry objects required for consistency get created. efficient. slay. β¨
now, which things absolutely NEED an entry object? let's list them, because the list is the list:
- every blessed data structure
- every shared data structure
- every tied data structure
- every target of a weak reference
all of those require an entry object. no exceptions, no cap. π¨
but "Simple" structures β like plain hashes and arrays β they get left inline, as data intrinsic to the object where they were found. they're just chillin. they don't need their own entry. they're homebodies. π
compacting is usually what you want, but sometimes it isn't! for instance, with an RDF-like store. so like, know your context. π
πΈ COLLAPSING STRATEGIES πΈ
so how does she decide which strategy to use? based on the type of the object being collapsed, using KiokuDB::TypeMap::Resolver. it's giving matchmaking but for objects. π
the resolver consults the typemap (KiokuDB::TypeMap) and caches the results, keyed by "ref $object". so once she knows, she knows. memorized. π
the typemap contains two flavors of entries:
- normal entries, keyed by
"ref $object eq $class" - isa entries, filtered by
"$object->isa($class)"
and the rationale here? a typemap entry for a superclass might not support all its subclasses as well. so like, don't assume the parent's setup works for every child. rude but true. π
any strategy can be collapsed as a first class object, or intrinsically, inside its parent β and if it's intrinsic, it doesn't get assigned a UUID. no UUID for you, bestie. π
this is all determined based on the "intrinsic" attribute of the entry. for example: if Path::Class related objects should be collapsed as if they're values, you'd use this typemap entry:
isa_entries => {
'Path::Class::Entity' => KiokuDB::TypeMap::Entry::Callback->new(
intrinsic => 1,
collapse => "stringify",
expand => "new",
),
},
iconic. ate. π β¨
and if no typemap entry exists at all? then KiokuDB::TypeMap::Entry::MOP is used by default. see KiokuDB::TypeMap::Resolver for more details. π«Ά
okay here's the strategies in brief, and yes we're going through every single one:
π MOP
when the object has a Class::MOP registered metaclass β that means any Moose object, but not only Moose objects, so don't get it twisted β the MOP is used to walk the object's attributes and construct the simplified version without breaking encapsulation. respectful. π
see KiokuDB::TypeMap::Entry::MOP.
π Naive
this strategy just walks the object's data using Data::Visitor. straightforward. no thoughts, head empty, just walking. πΆ
this lets you collapse Class::Accessor based objects, for instance β but heads up, it should be used with care. β οΈ
see KiokuDB::TypeMap::Entry::Naive
π₯ Callback
this strategy lets callbacks be used to map the types. π―
it's more limited than the other strategies, but it's super convenient for simple values. lowkey the chill one. π
see KiokuDB::TypeMap::Entry::Callback for more details.
π Passthrough
this one delegates collapsing to the backend serialization. so it's not doing the work herself, she's outsourcing. π
this is convenient when a backend uses e.g. Storable to serialize entries, and the object in question already has a "STORABLE_freeze" and "STORABLE_thaw" method. like, if it already knows how to freeze and thaw itself, why would she interfere? let her cook. π©π³
π AUTHOR π
Yuval Kogman <nothingmuch@woobling.org>
π 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.
okay that's the whole page, you made it, i'm so proud of you π₯Ήπ«Ά this was KiokuD...lapser from perl v5.34.0, dated 2022-05-23, and remember β it's still KiokuD...lapser(3pm) at heart. go collapse some hierarchies, bestie. slay. π
β¨π
π¦ where this page comes from
- debian bookworm: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libkiokudb-perl 0.57-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libkiokudb-perl 0.57-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms