mirror of https://github.com/apache/lucene.git
LUCENE-6591: never write a negative vlong
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1686495 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b68d571781
commit
c9e267f948
|
@ -158,6 +158,9 @@ Bug fixes
|
||||||
* LUCENE-6593: Fixed ToChildBlockJoinQuery's scorer to not refuse to advance
|
* LUCENE-6593: Fixed ToChildBlockJoinQuery's scorer to not refuse to advance
|
||||||
to a document that belongs to the parent space. (Adrien Grand)
|
to a document that belongs to the parent space. (Adrien Grand)
|
||||||
|
|
||||||
|
* LUCENE-6591: Never write a negative vLong (Robert Muir, Ryan Ernst,
|
||||||
|
Adrien Grand, Mike McCandless)
|
||||||
|
|
||||||
Changes in Runtime Behavior
|
Changes in Runtime Behavior
|
||||||
|
|
||||||
* LUCENE-6501: The subreader structure in ParallelCompositeReader
|
* LUCENE-6501: The subreader structure in ParallelCompositeReader
|
||||||
|
|
|
@ -221,12 +221,14 @@ public abstract class DataOutput {
|
||||||
* @see DataInput#readVLong()
|
* @see DataInput#readVLong()
|
||||||
*/
|
*/
|
||||||
public final void writeVLong(long i) throws IOException {
|
public final void writeVLong(long i) throws IOException {
|
||||||
assert i >= 0L;
|
if (i < 0) {
|
||||||
writeNegativeVLong(i);
|
throw new IllegalArgumentException("cannot write negative vLong (got: " + i + ")");
|
||||||
|
}
|
||||||
|
writeSignedVLong(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write a pontentially negative vLong
|
// write a potentially negative vLong
|
||||||
private void writeNegativeVLong(long i) throws IOException {
|
private void writeSignedVLong(long i) throws IOException {
|
||||||
while ((i & ~0x7FL) != 0L) {
|
while ((i & ~0x7FL) != 0L) {
|
||||||
writeByte((byte)((i & 0x7FL) | 0x80L));
|
writeByte((byte)((i & 0x7FL) | 0x80L));
|
||||||
i >>>= 7;
|
i >>>= 7;
|
||||||
|
@ -241,7 +243,7 @@ public abstract class DataOutput {
|
||||||
* @see DataInput#readZLong()
|
* @see DataInput#readZLong()
|
||||||
*/
|
*/
|
||||||
public final void writeZLong(long i) throws IOException {
|
public final void writeZLong(long i) throws IOException {
|
||||||
writeNegativeVLong(BitUtil.zigZagEncode(i));
|
writeSignedVLong(BitUtil.zigZagEncode(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes a string.
|
/** Writes a string.
|
||||||
|
|
Loading…
Reference in New Issue