ibessonov commented on code in PR #1693:
URL: https://github.com/apache/ignite-3/pull/1693#discussion_r1182255612
##########
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) {
Review Comment:
Yes, negatives are excluded because of comparisons. 0 is excluded, because
it's the way to encode `NULL_HYBRID_TIMESTAMP`
##########
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) {
Review Comment:
Yes, negatives are excluded because of comparisons. 0 is excluded, because
it's the way to encode `NULL_HYBRID_TIMESTAMP`. I'll comment on it
--
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]