From: Shawn Boyette Date: Tue, 3 Feb 2009 17:21:49 +0000 (+0000) Subject: match_fingerprints autotesting X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=commitdiff_plain;h=4a0c4485708ab3696bb858a23a1598f3ceab717a;hp=9e42dbf33efb3dc9b2536308e2dcea0f56c258fb match_fingerprints autotesting --- diff --git a/match_fingerprints b/match_fingerprints index 4300429..c1dbcca 100755 --- a/match_fingerprints +++ b/match_fingerprints @@ -14,6 +14,9 @@ my @recs = (); # fingerprints belonging to each record my %seen = (); # records we've already seen my $lastscore = 0; # previous fingerprint's score +my %leads = (); # error-checking hashes +my %subs = (); + open FP, '<', $ARGV[0] or die "Can't open input file: $!\n"; print "Loading and ranking fingerprints\n"; @@ -85,8 +88,19 @@ sub dump_records { open OUT, '>', $conf->{output} or die "Can't open ", $conf->{output}, "$!\n"; for my $rec (@recs) { - print OUT $rec->{id}, "\t$_\n" - for ( @{ $fps{ $rec->{sha1} } } ); + for ( @{ $fps{ $rec->{sha1} } } ) { + # check for dupes and die if they exist + die "Collision: dupe sub record $_\n" if $subs{$_}; + $subs{$_} = 1; + die "Collision: dupe lead record ", $rec->{id}, "\n" + if $leads{ $rec->{id} }; + $leads{ $rec->{id} } = 1; + die "Collision: lead in sub list ", $rec->{id}, "\n" + if $subs{ $rec->{id} }; + + # still here? output. + print OUT $rec->{id}, "\t$_\n" + } } }