cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject cassandra git commit: Forward-compatible check for row overlap in pages
Date Fri, 24 Jul 2015 07:23:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 1c80b04be -> b087897ef


Forward-compatible check for row overlap in pages

patch by thobbs; reviewed by slebresne for CASSANDRA-9849


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

Branch: refs/heads/cassandra-2.1
Commit: b087897efff811950afd38bd88c08806e2933c38
Parents: 1c80b04
Author: Tyler Hobbs <tylerlhobbs@gmail.com>
Authored: Thu Jul 16 11:01:25 2015 -0500
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Fri Jul 24 09:22:40 2015 +0200

----------------------------------------------------------------------
 .../cassandra/service/pager/RangeSliceQueryPager.java   |  5 ++++-
 .../apache/cassandra/service/pager/SliceQueryPager.java | 12 ++++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b087897e/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
index c9a28e8..e02bb46 100644
--- a/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/RangeSliceQueryPager.java
@@ -19,6 +19,8 @@ package org.apache.cassandra.service.pager;
 
 import java.util.List;
 
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.composites.CellName;
 import org.apache.cassandra.db.composites.Composite;
@@ -96,9 +98,10 @@ public class RangeSliceQueryPager extends AbstractQueryPager
 
         // Same as SliceQueryPager, we ignore a deleted column
         Cell firstCell = isReversed() ? lastCell(first.cf) : firstNonStaticCell(first.cf);
+        CFMetaData metadata = Schema.instance.getCFMetaData(command.keyspace, command.columnFamily);
         return !first.cf.deletionInfo().isDeleted(firstCell)
             && firstCell.isLive(timestamp())
-            && lastReturnedName.equals(firstCell.name());
+            && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturnedName);
     }
 
     protected boolean recordLast(Row last)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b087897e/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java b/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java
index 18045fe..520fc34 100644
--- a/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/SliceQueryPager.java
@@ -21,9 +21,10 @@ import java.nio.ByteBuffer;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cassandra.config.CFMetaData;
+import org.apache.cassandra.config.Schema;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.composites.CellName;
-import org.apache.cassandra.db.composites.Composite;
 import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.exceptions.RequestValidationException;
 import org.apache.cassandra.exceptions.RequestExecutionException;
@@ -42,7 +43,7 @@ public class SliceQueryPager extends AbstractQueryPager implements SinglePartiti
     private final SliceFromReadCommand command;
     private final ClientState cstate;
 
-    private volatile Composite lastReturned;
+    private volatile CellName lastReturned;
 
     // Don't use directly, use QueryPagers method instead
     SliceQueryPager(SliceFromReadCommand command, ConsistencyLevel consistencyLevel, ClientState
cstate, boolean localQuery)
@@ -58,7 +59,9 @@ public class SliceQueryPager extends AbstractQueryPager implements SinglePartiti
 
         if (state != null)
         {
-            lastReturned = cfm.comparator.fromByteBuffer(state.cellName);
+            // The only case where this could be a non-CellName Composite is if it's Composites.EMPTY,
but that's not
+            // valid for PagingState.cellName, so we can safely cast to CellName.
+            lastReturned = (CellName) cfm.comparator.fromByteBuffer(state.cellName);
             restoreState(state.remaining, true);
         }
     }
@@ -98,11 +101,12 @@ public class SliceQueryPager extends AbstractQueryPager implements SinglePartiti
             return false;
 
         Cell firstCell = isReversed() ? lastCell(first.cf) : firstNonStaticCell(first.cf);
+        CFMetaData metadata = Schema.instance.getCFMetaData(command.getKeyspace(), command.getColumnFamilyName());
         // Note: we only return true if the column is the lastReturned *and* it is live.
If it is deleted, it is ignored by the
         // rest of the paging code (it hasn't been counted as live in particular) and we
want to act as if it wasn't there.
         return !first.cf.deletionInfo().isDeleted(firstCell)
             && firstCell.isLive(timestamp())
-            && lastReturned.equals(firstCell.name());
+            && firstCell.name().isSameCQL3RowAs(metadata.comparator, lastReturned);
     }
 
     protected boolean recordLast(Row last)


Mime
View raw message