lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: VInt's as prefix. Was: bytecount as prefix
Date Thu, 11 May 2006 13:21:54 GMT

On May 11, 2006, at 3:24 AM, Ben van Klinken wrote:

> Here is where the problem is, though: this
> is not possible currently because we are using a VInt for the field
> data length.

What we really need is the ability to add "leading zeroes" to a VInt.

I believe that this is possible if we change the definition of VInt  
so that the high bytes are written first, rather than the low bytes.   
The "BER compressed integer", used by Perl's pack() function, is  
defined this way.  A proof-of-concept Perl script is below.

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/

#-------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my $pad        = pack( 'C', 128 );    # "leading zero": 1000 0000
my $serialized = pack( 'wwawaaw', 127, 128, $pad, 129, $pad, $pad,  
154 );

my @numbers = unpack( 'w*', $serialized );
print "@numbers\n";      # prints "127 128 129 154"

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message