From: Matt S Trout Date: Mon, 9 Sep 2013 23:53:19 +0000 (+0000) Subject: Force ::Collation objects to be serialized en bloc, "fixing" GC. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e9c4d7be791f99add6e4522a0de7c96e73e95be;p=scpubgit%2Fstemmatology.git Force ::Collation objects to be serialized en bloc, "fixing" GC. By using the Text::Tradition::TypeMap::Entry for Text::Tradition::Collation, KiokuDB is forced to turn the entire collation into a single YAML blob, which provided none of the collation's sub-objects are shared between collations, is probably going to be faster. Also, because it appears that GC is mistakenly eating the ::Collation's sub-objects rather than the collation itself, this appears to make the GC code do the right thing. I've added an extra test to ensure that the reading keys remain the same, which is hopefully sufficient to imply that the sub-objects have been restored appropriately. --- diff --git a/lib/Text/Tradition/Directory.pm b/lib/Text/Tradition/Directory.pm index 0d7a2f9..98f4204 100644 --- a/lib/Text/Tradition/Directory.pm +++ b/lib/Text/Tradition/Directory.pm @@ -191,8 +191,8 @@ has +typemap => ( isa_entries => { "Text::Tradition" => KiokuDB::TypeMap::Entry::Naive->new(), + "Text::Tradition::Collation" => Text::Tradition::TypeMap::Entry->new(), "Graph" => Text::Tradition::TypeMap::Entry->new(), - "Graph::AdjacencyMap" => Text::Tradition::TypeMap::Entry->new(), } ); }, diff --git a/t/text_tradition_directory.t b/t/text_tradition_directory.t index 3b5d693..8a3deba 100644 --- a/t/text_tradition_directory.t +++ b/t/text_tradition_directory.t @@ -107,6 +107,12 @@ my %second_counts; my @w1 = sort { $a->sigil cmp $b->sigil } $ntobj->witnesses; my @w2 = sort{ $a->sigil cmp $b->sigil } $nt->witnesses; is_deeply( \@w1, \@w2, "Looked up remaining tradition by name" ); + + is_deeply( + [ sort keys %{$nt->collation->{readings}} ], + [ sort keys %{$ntobj->collation->{readings}} ], + 'Same reading keys between original and re-look-up' + ); } my %final_counts = get_counts();