X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=match_fingerprints;h=33919c60d0fe3872a692627568bbf2bd8f851c11;hp=4300429df383a55416d9cbd59479b92aab83c387;hb=6a858397936095b56100e4ad41374f166a20375a;hpb=3ec4fd758b018abda104bbeffa5ebf02b832030b diff --git a/match_fingerprints b/match_fingerprints index 4300429..33919c6 100755 --- a/match_fingerprints +++ b/match_fingerprints @@ -14,6 +14,8 @@ my @recs = (); # fingerprints belonging to each record my %seen = (); # records we've already seen my $lastscore = 0; # previous fingerprint's score +my %subs = (); # error-checking hashe + open FP, '<', $ARGV[0] or die "Can't open input file: $!\n"; print "Loading and ranking fingerprints\n"; @@ -85,8 +87,16 @@ 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: lead in sub list ", $rec->{id}, "\n" + if $subs{ $rec->{id} }; + + # still here? output. + print OUT $rec->{id}, "\t$_\n" + } } }