risdenk commented on a change in pull request #602:
URL: https://github.com/apache/lucene/pull/602#discussion_r785341932
##########
File path: lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java
##########
@@ -109,55 +110,24 @@ public long readLong() {
@Override
public int readVInt() {
- byte b = bytes[pos++];
- if (b >= 0) return b;
- int i = b & 0x7F;
- b = bytes[pos++];
- i |= (b & 0x7F) << 7;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7F) << 14;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7F) << 21;
- if (b >= 0) return i;
- b = bytes[pos++];
- // Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors:
- i |= (b & 0x0F) << 28;
- if ((b & 0xF0) == 0) return i;
- throw new RuntimeException("Invalid vInt detected (too many bits)");
+ try {
+ return super.readVInt();
+ } catch (
+ @SuppressWarnings("unused")
+ IOException e) {
+ throw new AssertionError("ByteArrayDataInput#readByte should not throw
IOException");
+ }
}
@Override
public long readVLong() {
- byte b = bytes[pos++];
- if (b >= 0) return b;
- long i = b & 0x7FL;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 7;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 14;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 21;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 28;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 35;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 42;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 49;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7FL) << 56;
- if (b >= 0) return i;
- throw new RuntimeException("Invalid vLong detected (negative values
disallowed)");
+ try {
+ return super.readVLong();
Review comment:
Oops misread how this flows through DataInput.
##########
File path: lucene/core/src/java/org/apache/lucene/store/BufferedIndexInput.java
##########
@@ -159,67 +159,6 @@ public final long readLong() throws IOException {
}
}
- @Override
- public final int readVInt() throws IOException {
Review comment:
Oops misread how this flows through DataInput.
##########
File path: lucene/core/src/java/org/apache/lucene/store/ByteArrayDataInput.java
##########
@@ -109,55 +110,24 @@ public long readLong() {
@Override
public int readVInt() {
- byte b = bytes[pos++];
- if (b >= 0) return b;
- int i = b & 0x7F;
- b = bytes[pos++];
- i |= (b & 0x7F) << 7;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7F) << 14;
- if (b >= 0) return i;
- b = bytes[pos++];
- i |= (b & 0x7F) << 21;
- if (b >= 0) return i;
- b = bytes[pos++];
- // Warning: the next ands use 0x0F / 0xF0 - beware copy/paste errors:
- i |= (b & 0x0F) << 28;
- if ((b & 0xF0) == 0) return i;
- throw new RuntimeException("Invalid vInt detected (too many bits)");
+ try {
+ return super.readVInt();
Review comment:
Oops misread how this flows through DataInput.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]