MimisIVI has asked for the wisdom of the Perl Monks concerning the following question:
my $posting; for my $docid(1 .. 20) { $posting. = ByteEncode($docid); } #At the end i pack the whole bit string my $compressed = pack "b*",$posting; # i am not sure if its the best f +ormat... #Decode the compressed Bit string my $df = 20; #number of compressed docs.. my $bits=7; my $decode = unpack "b*",$posting; my @w;my $nr=0; my $binary=''; my $start=0; while() { #ckeck the MSB, if it is 1 then its the last byte for +the current Docid my $temp = substr($decode,0,$bits+1,''); # its the last one... if($temp=~ m/^1/) { substr($temp,0,1,''); $binary.=$temp; push @w,bin2dec($binary); undef $binary; $nr++; last if($nr==$df); } #else remove the MSB and keep the rest and go to the n +ext byte else { substr($temp,0,1,''); $binary.=$temp; } } return @w;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Byte allign compression in Perl..
by tachyon-II (Chaplain) on Apr 11, 2008 at 16:32 UTC | |
by MimisIVI (Acolyte) on Apr 11, 2008 at 17:18 UTC | |
by tachyon-II (Chaplain) on Apr 11, 2008 at 17:34 UTC | |
by MimisIVI (Acolyte) on Apr 11, 2008 at 17:51 UTC | |
by tachyon-II (Chaplain) on Apr 11, 2008 at 19:11 UTC | |
by tachyon-II (Chaplain) on Apr 12, 2008 at 03:43 UTC | |
| |
|
Re: Byte allign compression in Perl..
by BrowserUk (Patriarch) on Apr 11, 2008 at 19:07 UTC | |
by tachyon-II (Chaplain) on Apr 12, 2008 at 03:54 UTC | |
by MimisIVI (Acolyte) on Apr 12, 2008 at 16:49 UTC | |
by tachyon-II (Chaplain) on Apr 13, 2008 at 04:56 UTC | |
|
Re: Byte allign compression in Perl..
by pc88mxer (Vicar) on Apr 11, 2008 at 16:37 UTC |