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


##########
src/java/org/apache/cassandra/db/DeletionTime.java:
##########
@@ -195,42 +195,100 @@ public static Serializer getSerializer(Version version)
             return legacySerializer;
     }
 
-    // Serializer for Usigned Integer ldt
+    /* Serializer for Usigned Integer ldt
+     *
+     * ldt is encoded as a uint in seconds since unix epoch, it can go up o 
2106-02-07T06:28:13+00:00 only. 
+     * Since mfda is micros since the Unix Epoch with 7 bytes we can encode 
2^56 ~= 1142 years. That leaves 
+     * 1 free byte we can use to store flags for sentinel values with some 
space saving.
+     *
+     * Currently only a flag for the LIVE ldt is being used.
+     */
     public static class Serializer implements ISerializer<DeletionTime>
     {
+        private final static int IS_LIVE_DELETION = 0x01;
+        // Long.MAX_VALUE sentinel value equivalent in 7bytes
+        public final static long MAX_MFDA = (1L << (7 * 8)) - 1;
+
         public void serialize(DeletionTime delTime, DataOutputPlus out) throws 
IOException
         {
-            out.writeInt(delTime.localDeletionTimeUnsignedInteger);
-            out.writeLong(delTime.markedForDeleteAt());
+            if (delTime.equals(LIVE))
+                out.writeByte(IS_LIVE_DELETION);
+            else
+            {
+                if (delTime.markedForDeleteAt() > MAX_MFDA && 
delTime.markedForDeleteAt() != Long.MAX_VALUE)
+                    throw new IOException("Value too high for markForDeleteAt 
to encode in 7 bytes: " + delTime.markedForDeleteAt());
+                // The flags byte is all zeros atm here, so we can write a 
long directly
+                out.writeLong(delTime.markedForDeleteAt() == Long.MAX_VALUE ? 
MAX_MFDA : delTime.markedForDeleteAt());

Review Comment:
   jmh looked good so you'll find the changes in the latest commit :-)
   
   ```
        [java] Benchmark                                    (diskRAMParam)  
(liveDTPcParam)  (sstableParam)  Mode  Cnt        Score        Error  Units
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   70PcLive              NC  avgt   15   667672.766 ±   9373.015  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   70PcLive              OA  avgt   15   664025.516 ±   9940.654  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   30PcLive              NC  avgt   15   962307.068 ±  15941.703  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   30PcLive              OA  avgt   15   971137.196 ±  15428.975  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   70PcLive              NC  avgt   15  1392247.306 ±  82162.975  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   70PcLive              OA  avgt   15  1044635.877 ±  20614.003  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   30PcLive              NC  avgt   15  1719827.358 ± 117661.536  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   30PcLive              OA  avgt   15  1507395.582 ±  36998.279  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   70PcLive              NC  avgt   15   332001.653 ±   2247.707  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   70PcLive              OA  avgt   15   337418.362 ±   4235.931  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   30PcLive              NC  avgt   15   460708.379 ±   3550.575  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   30PcLive              OA  avgt   15   498494.239 ±   5669.185  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   70PcLive              NC  avgt   15  1688473.271 ± 255780.071  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   70PcLive              OA  avgt   15   832362.512 ±  91935.451  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   30PcLive              NC  avgt   15  1765952.897 ± 172248.680  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   30PcLive              OA  avgt   15  1326467.617 ± 139599.811  ns/op
   ```



##########
src/java/org/apache/cassandra/db/DeletionTime.java:
##########
@@ -195,42 +195,100 @@ public static Serializer getSerializer(Version version)
             return legacySerializer;
     }
 
-    // Serializer for Usigned Integer ldt
+    /* Serializer for Usigned Integer ldt
+     *
+     * ldt is encoded as a uint in seconds since unix epoch, it can go up o 
2106-02-07T06:28:13+00:00 only. 
+     * Since mfda is micros since the Unix Epoch with 7 bytes we can encode 
2^56 ~= 1142 years. That leaves 
+     * 1 free byte we can use to store flags for sentinel values with some 
space saving.
+     *
+     * Currently only a flag for the LIVE ldt is being used.
+     */
     public static class Serializer implements ISerializer<DeletionTime>
     {
+        private final static int IS_LIVE_DELETION = 0x01;
+        // Long.MAX_VALUE sentinel value equivalent in 7bytes
+        public final static long MAX_MFDA = (1L << (7 * 8)) - 1;
+
         public void serialize(DeletionTime delTime, DataOutputPlus out) throws 
IOException
         {
-            out.writeInt(delTime.localDeletionTimeUnsignedInteger);
-            out.writeLong(delTime.markedForDeleteAt());
+            if (delTime.equals(LIVE))
+                out.writeByte(IS_LIVE_DELETION);
+            else
+            {
+                if (delTime.markedForDeleteAt() > MAX_MFDA && 
delTime.markedForDeleteAt() != Long.MAX_VALUE)
+                    throw new IOException("Value too high for markForDeleteAt 
to encode in 7 bytes: " + delTime.markedForDeleteAt());
+                // The flags byte is all zeros atm here, so we can write a 
long directly
+                out.writeLong(delTime.markedForDeleteAt() == Long.MAX_VALUE ? 
MAX_MFDA : delTime.markedForDeleteAt());

Review Comment:
   jmh looked good so you'll find the changes in the latest commit :-)
   
   ```
        [java] Benchmark                                    (diskRAMParam)  
(liveDTPcParam)  (sstableParam)  Mode  Cnt        Score        Error  Units
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   70PcLive              NC  avgt   15   667672.766 ±   9373.015  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   70PcLive              OA  avgt   15   664025.516 ±   9940.654  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   30PcLive              NC  avgt   15   962307.068 ±  15941.703  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT             RAM      
   30PcLive              OA  avgt   15   971137.196 ±  15428.975  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   70PcLive              NC  avgt   15  1392247.306 ±  82162.975  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   70PcLive              OA  avgt   15  1044635.877 ±  20614.003  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   30PcLive              NC  avgt   15  1719827.358 ± 117661.536  ns/op
        [java] DeletionTimeDeSerBench.testE2EDeSerializeDT            Disk      
   30PcLive              OA  avgt   15  1507395.582 ±  36998.279  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   70PcLive              NC  avgt   15   332001.653 ±   2247.707  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   70PcLive              OA  avgt   15   337418.362 ±   4235.931  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   30PcLive              NC  avgt   15   460708.379 ±   3550.575  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT               RAM      
   30PcLive              OA  avgt   15   498494.239 ±   5669.185  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   70PcLive              NC  avgt   15  1688473.271 ± 255780.071  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   70PcLive              OA  avgt   15   832362.512 ±  91935.451  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   30PcLive              NC  avgt   15  1765952.897 ± 172248.680  ns/op
        [java] DeletionTimeDeSerBench.testE2ESerializeDT              Disk      
   30PcLive              OA  avgt   15  1326467.617 ± 139599.811  ns/op
   ```



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