bereng commented on code in PR #1891:
URL: https://github.com/apache/cassandra/pull/1891#discussion_r1106804057


##########
src/java/org/apache/cassandra/db/rows/Cell.java:
##########
@@ -59,14 +68,24 @@
 
     public interface Factory<V>
     {
-        Cell<V> create(ColumnMetadata column, long timestamp, int ttl, int 
localDeletionTime, V value, CellPath path);
+        Cell<V> create(ColumnMetadata column, long timestamp, int ttl, long 
localDeletionTime, V value, CellPath path);
     }
 
     protected Cell(ColumnMetadata column)
     {
         super(column);
     }
 
+    public static int deletionTimeLongToGuavaUint(long deletionTime)
+    {
+        return deletionTime == NO_DELETION_TIME ? 
UnsignedInteger.MAX_VALUE.intValue() : 
UnsignedInteger.valueOf(deletionTime).intValue();
+    }
+
+    public static long deletionTimeGuavaUintToLong(int deletionTimeGuavaUint)
+    {
+        return deletionTimeGuavaUint == UnsignedInteger.MAX_VALUE.intValue() ? 
NO_DELETION_TIME : 
UnsignedInteger.fromIntBits(deletionTimeGuavaUint).longValue();

Review Comment:
   And I totally agree bitwise operations are not dangerous or exotic. But I'd 
rather run hot needles through my eyes than removing that and have to deal with 
such bugs in the future I've had to deal with when it wasn't present. 
   
   It does provide protection which has proven invaluable.
   ```
   java.lang.IllegalArgumentException: value (-207332) is outside the range for 
an unsigned integer value
   [junit-timeout]      at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:202)
   [junit-timeout]      at 
com.google.common.primitives.UnsignedInteger.valueOf(UnsignedInteger.java:75)
   [junit-timeout]      at 
org.apache.cassandra.db.rows.Cell.deletionTimeLongToGuavaUint(Cell.java:81)
   ```
   It's an accident waiting to happen, we're shooting ourselves in the foot imo.



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

Reply via email to