lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley" <ysee...@gmail.com>
Subject Re: VInt's as prefix. Was: bytecount as prefix
Date Thu, 11 May 2006 15:02:22 GMT
On 5/11/06, Marvin Humphrey <marvin@rectangular.com> wrote:
> 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"

Great idea Marvin!  The decoding could be slightly faster with
reverse-byte order since you don't have to maintain a shift-count:

  public int readVInt() throws IOException {
    byte b = readByte();
    int i = b & 0x7F;
    while ((b & 0x80)!=0)
      b = readByte();
      i = (i<<7) | (b & 0x7F);
    }
    return i;
  }

Of course there is that *little* detail of backward compatability ;-)

-Yonik

---------------------------------------------------------------------
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