Force ::Collation objects to be serialized en bloc, "fixing" GC. deletion
Matt S Trout [Mon, 9 Sep 2013 23:53:19 +0000 (23:53 +0000)]
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.

lib/Text/Tradition/Directory.pm
t/text_tradition_directory.t

index 0d7a2f9..98f4204 100644 (file)
@@ -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(),
       }
     );
   },
index 3b5d693..8a3deba 100644 (file)
@@ -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();