[
https://issues.apache.org/jira/browse/LUCENE-3738?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13196918#comment-13196918
]
Robert Muir commented on LUCENE-3738:
-------------------------------------
{quote}
As the code is written by a loop, we would write 10 bytes, of course the last
one only with 1 bit.
{quote}
I think this is ok: otherwise its not a variable-length integer but something
else
(with a special case where 9th byte high bit means sign bit instead of
continuation bit).
Either way we should either fix it to assert value >=0 in the writer, or make
it work.
Ideally we would do that for both vint and vlong, but the problem is some
things like term vectors
sometimes write negative vints (since it does startOffset - lastEndOffset, if
you have any synonyms
you get tons of huge 5-byte vints in your term vectors)
But currently its inconsistent: negatives don't trip any assert for either
vint/vlong at write-time,
but at read-time for vlong *only*.
> Be consistent about negative vInt/vLong
> ---------------------------------------
>
> Key: LUCENE-3738
> URL: https://issues.apache.org/jira/browse/LUCENE-3738
> Project: Lucene - Java
> Issue Type: Bug
> Reporter: Michael McCandless
> Fix For: 3.6, 4.0
>
>
> Today, write/readVInt "allows" a negative int, in that it will encode and
> decode correctly, just horribly inefficiently (5 bytes).
> However, read/writeVLong fails (trips an assert).
> I'd prefer that both vInt/vLong trip an assert if you ever try to write a
> negative number... it's badly trappy today. But, unfortunately, we sometimes
> rely on this... had we had this assert in 'since the beginning' we could have
> avoided that.
> So, if we can't add that assert in today, I think we should at least fix
> readVLong to handle negative longs... but then you quietly spend 9 bytes
> (even more trappy!).
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]