ibessonov commented on code in PR #1693:
URL: https://github.com/apache/ignite-3/pull/1693#discussion_r1182262461


##########
modules/core/src/main/java/org/apache/ignite/internal/hlc/HybridTimestamp.java:
##########
@@ -55,13 +64,54 @@ public final class HybridTimestamp implements 
Comparable<HybridTimestamp>, Seria
      * @param logical The logical time.
      */
     public HybridTimestamp(long physical, int logical) {
-        assert physical > 0 : physical;
-        // Value -1 is used in 
"org.apache.ignite.internal.hlc.HybridClock.update" to produce "0" after the 
increment.
-        // Real usable value cannot be negative.
-        assert logical >= -1 : logical;
+        if (physical < 0 || physical >= (1L << PHYSICAL_TIME_BITS_SIZE)) {
+            throw new IllegalArgumentException("Physical time is out of 
bounds: " + physical);
+        }
+
+        if (logical < 0 || logical >= (1L << LOGICAL_TIME_BITS_SIZE)) {
+            throw new IllegalArgumentException("Logical time is out of bounds: 
" + logical);
+        }
+
+        time = (physical << LOGICAL_TIME_BITS_SIZE) | logical;
 
-        this.physical = physical;
-        this.logical = logical;
+        if (time <= 0) {
+            throw new IllegalArgumentException("Time is out of bounds: " + 
time);
+        }
+    }
+
+    private HybridTimestamp(long time) {
+        if (time <= 0) {
+            throw new IllegalArgumentException("Time is out of bounds: " + 
time);
+        }
+
+        this.time = time;
+    }
+
+    /**
+     * Converts primitive {@code long} representation into a hybrid timestamp 
instance.
+     * {@link #NULL_HYBRID_TIMESTAMP} is interpreted as {@code null}.
+     *
+     * @throws IllegalArgumentException If timestamp is negative.
+     */
+    public static @Nullable HybridTimestamp ofNullable(long time) {

Review Comment:
   Yes, I changed the naming



-- 
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]

Reply via email to