-
Notifications
You must be signed in to change notification settings - Fork 4
/
Cmt2Cont.perl
executable file
·46 lines (38 loc) · 1001 Bytes
/
Cmt2Cont.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
use strict;
use warnings;
use Error qw(:try);
use TokyoCabinet;
use Compress::LZF;
sub toHex {
return unpack "H*", $_[0];
}
sub fromHex {
return pack "H*", $_[0];
}
my $sections = 128;
my $fbase="All.sha1c/commit_";
my $fbasei ="/data/All.blobs/commit_";
my (%fhos);
my $sec = $ARGV[0];
{
my $pre = "/fast1";
tie %{$fhos{$sec}}, "TokyoCabinet::HDB", "$pre/${fbase}$sec.tch", TokyoCabinet::HDB::OWRITER | TokyoCabinet::HDB::OCREAT,
16777213, -1, -1, TokyoCabinet::TDB::TLARGE, 100000
or die "cant open $pre/$fbase$sec.tch\n";
open (FD, "$fbasei$sec.bin") or die "$!";
binmode(FD);
if ( -f "$fbasei$sec.idx"){
open A, "$fbasei$sec.idx" or die ($!);
while (<A>){
chop ();
my ($nn, $of, $len, $hash) = split (/\;/, $_, -1);
my $h = fromHex ($hash);
my $codeC = "";
my $rl = read (FD, $codeC, $len);
$fhos{$sec}{$h} = $codeC;
}
}else{
die "no $fbasei$sec.idx\n";
}
untie %{$fhos{$sec}};
}