-
Notifications
You must be signed in to change notification settings - Fork 4
/
Prj2Cmt2Prj.perl
executable file
·98 lines (81 loc) · 2.12 KB
/
Prj2Cmt2Prj.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/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 $split = 32;
my %p2c;
for my $sec (0..($split-1)){
my $fname = "p2cFullN.$sec.tch";
tie %{$p2c{$sec}}, "TokyoCabinet::HDB", "$fname", TokyoCabinet::HDB::OREADER,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $fname\n";
}
my %c2p;
for my $sec (0..($split-1)){
my $fname = "c2pFullN.$sec.tch";
tie %{$c2p{$sec}}, "TokyoCabinet::HDB", "$fname", TokyoCabinet::HDB::OREADER,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $fname\n";
}
while (<STDIN>){
chop();
my ($p, $p1) = split(/\;/, $_, -1);
#my $sec = (unpack "C", substr ($p, 0, 1))%$split;
my $sec = 0;
$sec = sHash ($p, $split) if $split > 1;
#print "$sec;$p\n";
if (defined $p2c{$sec}{$p}){
my %cs = ();
list ($p2c{$sec}{$p}, \%cs);
my %ps = ();
my @cs1 = keys %cs;
my $ncs = $#cs1+1;
if (defined $p1){
my $sec1 = sHash ($p1, $split) if $split > 1;
if (defined $p2c{$sec1}{$p1}){
my %cs2 = ();
list ($p2c{$sec1}{$p1}, \%cs2);
my $shared = 0;
for my $c (@cs1){
$shared++ if defined $cs2{$c};
}
my $ncs2 = scalar(keys %cs2);
print "$p;$ncs;$p1;$ncs2;$shared\n";
}
next;
}
for my $c (@cs1){
my $sc = (unpack "C", substr ($c, 0, 1))%32;
list1 ($c2p{$sc}{$c}, \%ps);
}
my @ps1 = keys %ps;
my $np = $#ps1+1;
#print "$p;$np";
for my $p0 (@ps1) { print "$p;$ncs;$p0;$ps{$p0}\n";}
#print "\n";
}else{
print STDERR "no $p in $sec\n";
}
}
for my $sec (0..($split-1)){
untie %{$p2c{$sec}};
untie %{$c2p{$sec}};
}
sub list {
my ($v, $cs) = @_;
my $ns = length($v)/20;
for my $i (0..($ns-1)){
my $c = substr ($v, 20*$i, 20);
$cs ->{$c}++;
}
}
sub list1 {
my ($v, $p) = @_;
my $v1 = safeDecomp ($v);
my @ps = split(/\;/, $v1, -1);
for my $p0 (@ps) { $p ->{$p0}++; };
}