rpuch commented on code in PR #4562:
URL: https://github.com/apache/ignite-3/pull/4562#discussion_r1802469363


##########
modules/core/src/main/java/org/apache/ignite/internal/util/io/IgniteDataInput.java:
##########
@@ -95,6 +95,35 @@ public interface IgniteDataInput extends DataInput {
      */
     int read(byte[] b, int off, int len) throws IOException;
 
+    /**
+     * Reads a length (that is, a non-negative integer that will most likely 
be small).
+     *
+     * @throws IOException If something goes wrong.
+     */
+    int readLength() throws IOException;
+
+    /**
+     * Reads a long value as a varint.
+     *
+     * @throws IOException If something goes wrong.
+     * @see IgniteDataOutput#writeVarInt(long)
+     */
+    long readVarInt() throws IOException;
+
+    /**
+     * Reads an int value as a varint.
+     *
+     * @throws IOException If something goes wrong.
+     * @see IgniteDataOutput#writeVarInt(long)
+     */
+    default int readVarIntAsInt() throws IOException {
+        long val = readVarInt();
+        if (val < Integer.MIN_VALUE || val > Integer.MAX_VALUE) {
+            throw new IOException("The value is expected to fit into int 
range, but it doesn't: " + val);
+        }
+        return (int) val;

Review Comment:
   `Math#toExactInt()` does not include information about the exact value in 
the error message, so explicit handling seems better



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to