cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [3/6] cassandra git commit: Fix SStable ordering by max timestamp in SinglePartitionReadCommand
Date Thu, 07 Dec 2017 22:13:11 GMT
Fix SStable ordering by max timestamp in SinglePartitionReadCommand

Patch by Zhao Yang; Reviewed by Benjamin Lerer for CASSANDRA-14010


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/a9225f90
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/a9225f90
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/a9225f90

Branch: refs/heads/trunk
Commit: a9225f90e205a7c2b24a4ad4a32d0961067005b0
Parents: f9de26a
Author: Zhao Yang <zhaoyangsingapore@gmail.com>
Authored: Wed Dec 6 16:17:26 2017 +0800
Committer: Paulo Motta <paulo@apache.org>
Committed: Fri Dec 8 09:01:56 2017 +1100

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../io/sstable/format/SSTableReader.java        |  3 ++-
 .../apache/cassandra/cql3/SimpleQueryTest.java  | 23 +++++++++++++++++---
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9225f90/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4a415eb..a5a97db 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.16
+ * Fix SStable ordering by max timestamp in SinglePartitionReadCommand (CASSANDRA-14010)
  * Accept role names containing forward-slash (CASSANDRA-14088)
  * Optimize CRC check chance probability calculations (CASSANDRA-14094)
  * Fix cleanup on keyspace with no replicas (CASSANDRA-13526)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9225f90/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index fb9343f..7e1bc1a 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -140,7 +140,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
     }
     private static final RateLimiter meterSyncThrottle = RateLimiter.create(100.0);
 
-    public static final Comparator<SSTableReader> maxTimestampComparator = (o1, o2)
-> Long.compare(o1.getMaxTimestamp(), o2.getMaxTimestamp());
+    // Descending order
+    public static final Comparator<SSTableReader> maxTimestampComparator = (o1, o2)
-> Long.compare(o2.getMaxTimestamp(), o1.getMaxTimestamp());
 
     // it's just an object, which we use regular Object equality on; we introduce a special
class just for easy recognition
     public static final class UniqueIdentifier {}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a9225f90/test/unit/org/apache/cassandra/cql3/SimpleQueryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/SimpleQueryTest.java b/test/unit/org/apache/cassandra/cql3/SimpleQueryTest.java
index 052b53d..f32bcc6 100644
--- a/test/unit/org/apache/cassandra/cql3/SimpleQueryTest.java
+++ b/test/unit/org/apache/cassandra/cql3/SimpleQueryTest.java
@@ -17,11 +17,8 @@
  */
 package org.apache.cassandra.cql3;
 
-import java.util.*;
 import org.junit.Test;
 
-import static junit.framework.Assert.*;
-
 public class SimpleQueryTest extends CQLTester
 {
     @Test
@@ -529,4 +526,24 @@ public class SimpleQueryTest extends CQLTester
             row(0, 0, 0, 0)
         );
     }
+
+    @Test
+    public void testSStableTimestampOrdering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (k1 int, v1 int, v2 int, PRIMARY KEY (k1))");
+        disableCompaction();
+
+        // sstable1
+        execute("INSERT INTO %s(k1,v1,v2) VALUES(1,1,1)  USING TIMESTAMP 5");
+        flush();
+
+        // sstable2
+        execute("INSERT INTO %s(k1,v1,v2) VALUES(1,1,2)  USING TIMESTAMP 8");
+        flush();
+
+        execute("INSERT INTO %s(k1) VALUES(1)  USING TIMESTAMP 7");
+        execute("DELETE FROM %s USING TIMESTAMP 6 WHERE k1 = 1");
+
+        assertRows(execute("SELECT * FROM %s WHERE k1=1"), row(1, 1, 2));
+    } 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message