AMashenkov commented on code in PR #5838: URL: https://github.com/apache/ignite-3/pull/5838#discussion_r2095372195
########## modules/binary-tuple/src/main/java/org/apache/ignite/internal/binarytuple/BinaryTupleParser.java: ########## @@ -524,12 +525,24 @@ public final Instant timestampValue(int begin, int end) { * @param end End offset of the element. * @return Element value. */ - public final Duration durationValue(int begin, int end) { + final Duration durationValue(int begin, int end) { int len = end - begin; - if (len != 8 && len != 12) { + + if (len != 2 && len != 4 && len != 8 && len != 12) { throw new BinaryTupleFormatException("Invalid length for a tuple element: " + len); } + if (len == 2) { + long seconds = buffer.getShort(begin); + return Duration.ofSeconds(seconds / 1000); + } + + if (len == 4) { + long millis = buffer.getInt(begin); + long seconds = millis / 1000; + return Duration.ofSeconds(seconds, TimeUnit.MILLISECONDS.toNanos(millis - (seconds * 1000))); + } + Review Comment: Let's rewrite this to switch ``` switch (len) { case 2: .... case 12: .... default: throw new BinaryTupleFormatException("Invalid length for a tuple element: " + len); } ``` -- 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