cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject [1/5] cassandra git commit: IndexSummary effective interval is a guideline, not a rule
Date Thu, 19 Mar 2015 20:13:13 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 763130bdb -> e8276aa53
  refs/heads/trunk 4597bb5b1 -> ce3053a23


IndexSummary effective interval is a guideline, not a rule

patch by benedict; reviewed by tyler for CASSANDRA-8993


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

Branch: refs/heads/cassandra-2.1
Commit: e8276aa539ae618a41acb8b0250886e773b73ef3
Parents: 763130b
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Thu Mar 19 20:09:29 2015 +0000
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Thu Mar 19 20:09:29 2015 +0000

----------------------------------------------------------------------
 CHANGES.txt                                            |  1 +
 .../org/apache/cassandra/io/sstable/SSTableReader.java |  8 ++++----
 .../apache/cassandra/io/sstable/IndexSummaryTest.java  | 13 ++++++++++---
 3 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8276aa5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 3f96330..14a45a3 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.4
+ * IndexSummary effectiveIndexInterval is now a guideline, not a rule (CASSANDRA-8993)
  * Use correct bounds for page cache eviction of compressed files (CASSANDRA-8746)
  * SSTableScanner enforces its bounds (CASSANDRA-8946)
  * Cleanup cell equality (CASSANDRA-8947)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8276aa5/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index e4a6e85..2bc32d3 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -1083,7 +1083,7 @@ public class SSTableReader extends SSTable implements SelfRefCounted<SSTableRead
             return referencedIndexSummary.getPosition(getIndexSummaryIndexFromBinarySearchResult(binarySearchResult));
     }
 
-    private static int getIndexSummaryIndexFromBinarySearchResult(int binarySearchResult)
+    public static int getIndexSummaryIndexFromBinarySearchResult(int binarySearchResult)
     {
         if (binarySearchResult < 0)
         {
@@ -1466,12 +1466,12 @@ public class SSTableReader extends SSTable implements SelfRefCounted<SSTableRead
         // of the next interval).
         int i = 0;
         Iterator<FileDataInput> segments = ifile.iterator(sampledPosition);
-        while (segments.hasNext() && i <= effectiveInterval)
+        while (segments.hasNext())
         {
             FileDataInput in = segments.next();
             try
             {
-                while (!in.isEOF() && i <= effectiveInterval)
+                while (!in.isEOF())
                 {
                     i++;
 
@@ -1481,7 +1481,7 @@ public class SSTableReader extends SSTable implements SelfRefCounted<SSTableRead
                     boolean exactMatch; // is the current position an exact match for the
key, suitable for caching
 
                     // Compare raw keys if possible for performance, otherwise compare decorated
keys.
-                    if (op == Operator.EQ)
+                    if (op == Operator.EQ && i <= effectiveInterval)
                     {
                         opSatisfied = exactMatch = indexKey.equals(((DecoratedKey) key).getKey());
                     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8276aa5/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
index 95183d4..0760aa3 100644
--- a/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/IndexSummaryTest.java
@@ -222,13 +222,20 @@ public class IndexSummaryTest
         original.close();
     }
 
-    private void testPosition(IndexSummary original, IndexSummary downsampled, Iterable<DecoratedKey>
keys)
+    private void testPosition(IndexSummary original, IndexSummary downsampled, List<DecoratedKey>
keys)
     {
         for (DecoratedKey key : keys)
         {
             long orig = SSTableReader.getIndexScanPositionFromBinarySearchResult(original.binarySearch(key),
original);
-            long down = SSTableReader.getIndexScanPositionFromBinarySearchResult(downsampled.binarySearch(key),
downsampled);
-            assert down <= orig;
+            int binarySearch = downsampled.binarySearch(key);
+            int index = SSTableReader.getIndexSummaryIndexFromBinarySearchResult(binarySearch);
+            int scanFrom = (int) SSTableReader.getIndexScanPositionFromBinarySearchResult(index,
downsampled);
+            assert scanFrom <= orig;
+            int effectiveInterval = downsampled.getEffectiveIndexIntervalAfterIndex(index);
+            DecoratedKey k = null;
+            for (int i = 0 ; k != key && i < effectiveInterval && scanFrom
< keys.size() ; i++, scanFrom ++)
+                k = keys.get(scanFrom);
+            assert k == key;
         }
     }
 


Mime
View raw message