Dont forget that the schema is like this:
TERM1 -> Docid1PositionsDocid2Positions......
so you have to separate the values as tachyon-II said by use the MSB as flag or somehow else if you like...
Tachyon-II code:
########################### PACK with W*
my $MSB = 1 << 31;
my $tests = 250_000;
my $DEBUG =1;
print "Doing $tests tests\n";
my $pack = time();
my $str = '';
for my $doc_id( 1 .. $tests ) {
#printf "Doc id: %d\n", $doc_id if $DEBUG;
$str .= pack "w", $doc_id+$MSB;
for my $pos ( 0 .. 2 ) {
$str .= pack "w", $pos;
}
}
printf "pack time %d\n", time()-$pack;
printf "length %d\n", length $str;
print "PAck w*'s size: " .
size( $str) . " bytes\n";
my $unpack = time();
my $dat = {};
my $doc_id = undef;
for my $int (unpack "w*", $str) {
if ( $int > $MSB )
{
$doc_id = $int - $MSB;
#printf "\nDoc id: %d\t", $doc_id if $DEBUG;
}
else
{
push @{$dat->{$doc_id}}, $int;
#print "$int\t" if $DEBUG;
}
}
printf "\n\nunpack time %d\n",time()-$unpack;
In while you will have my own benchmarks too...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.