-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathAuth2File.perl
executable file
·78 lines (67 loc) · 1.92 KB
/
Auth2File.perl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/perl
use lib ("$ENV{HOME}/lookup", "$ENV{HOME}/lib64/perl5", "/home/audris/lib64/perl5","$ENV{HOME}/lib/perl5", "$ENV{HOME}/lib/x86_64-linux-gnu/perl", "$ENV{HOME}/share/perl5");
use strict;
use warnings;
use Error qw(:try);
use TokyoCabinet;
use Compress::LZF;
use cmt;
my $sections = 32;
my $a2cf = $ARGV[0];
my %a2c;
tie %a2c, "TokyoCabinet::HDB", "$a2cf", TokyoCabinet::HDB::OREADER | TokyoCabinet::HDB::ONOLCK,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $a2cf\n";
my $c2ff = $ARGV[1];
my %c2f;
for my $sec (0..($sections-1)){
tie %{$c2f{$sec}}, "TokyoCabinet::HDB", "$c2ff.$sec.tch", TokyoCabinet::HDB::OREADER | TokyoCabinet::HDB::ONOLCK,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $c2ff.$sec.tch\n";
}
my %a2f1;
tie %a2f1, "TokyoCabinet::HDB", "$ARGV[2]", TokyoCabinet::HDB::OWRITER | TokyoCabinet::HDB::OCREAT,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $ARGV[0]\n";
my %badC;
for my $c (keys %badCmt){
$badC{fromHex ($c)}++;
}
my $line = 0;
my %a2f;
while (my ($a, $v) = each %a2c){
$a2f{$a}{"."}++;
my $ns = length ($v)/20;
for my $i (0..($ns-1)){
my $c = substr ($v, $i*20, 20);
next if defined $badC{$c}; #ignore humongous commits
my $sec = hex (unpack "H*", substr($c, 0, 1)) % $sections;
if (defined $c2f{$sec}{$c}){
my @fs = split(/\;/, safeDecomp ($c2f{$sec}{$c}, $a), -1);
for my $f (@fs){
$a2f{$a}{$f}++;
}
}else{
#my $c1 = toHex($c);
#print STDERR "no commit $c1 for $a\n";
}
}
$line ++;
if (!($line%100000)){
print STDERR "dumping $line\n";
dumpData();
%a2f = ();
}
}
untie %a2c;
for my $sec (0..($sections-1)){
untie %{$c2f{$sec}};
}
sub dumpData {
while (my ($a, $v) = each %a2f){
delete $v ->{"."};
my $v1 = safeComp (join ";", sort keys %{$v}, $a);
$a2f1{$a}=$v1;
}
}
untie %a2f1;