cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r802953 - in /incubator/cassandra/trunk: interface/ interface/gen-java/org/apache/cassandra/service/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/filter/ src/java/org/apache/cassandra/io/ src/java/org/apache/cassandra/...
Date Mon, 10 Aug 2009 23:17:08 GMT
Author: jbellis
Date: Mon Aug 10 23:17:08 2009
New Revision: 802953

URL: http://svn.apache.org/viewvc?rev=802953&view=rev
Log:
switch "!isAscending" for "reversed."
patch by jbellis, Carl Bystrom, and Bill de hOra. reviewed by Eric Evans for CASSANDRA-311

Modified:
    incubator/cassandra/trunk/interface/cassandra.thrift
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java
    incubator/cassandra/trunk/test/system/test_server.py
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java

Modified: incubator/cassandra/trunk/interface/cassandra.thrift
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/cassandra.thrift?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/cassandra.thrift (original)
+++ incubator/cassandra/trunk/interface/cassandra.thrift Mon Aug 10 23:17:08 2009
@@ -93,11 +93,11 @@
 # service api
 #
 
-enum ConsistencyLevel { 
-    ZERO = 0, 
-    ONE = 1, 
-    QUORUM = 2, 
-    ALL = 3, 
+enum ConsistencyLevel {
+    ZERO = 0,
+    ONE = 1,
+    QUORUM = 2,
+    ALL = 3,
 }
 
 struct ColumnParent {
@@ -114,7 +114,7 @@
 struct SliceRange {
     1: binary          start,
     2: binary          finish,
-    3: bool            is_ascending=1,
+    3: bool            reversed=0,
     4: i32             count=100,
 }
 
@@ -152,7 +152,7 @@
   throws (1: InvalidRequestException ire, 2: UnavailableException ue),
 
   # range query: returns matching keys
-  list<string>   get_key_range(1:string keyspace, 2:string column_family, 3:string
start="", 4:string finish="", 5:i32 count=100) 
+  list<string>   get_key_range(1:string keyspace, 2:string column_family, 3:string
start="", 4:string finish="", 5:i32 count=100)
   throws (1: InvalidRequestException ire),
 
   /////////////////////////////////////////////////////////////////////////////////////

Modified: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
(original)
+++ incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SliceRange.java
Mon Aug 10 23:17:08 2009
@@ -22,21 +22,21 @@
   private static final TStruct STRUCT_DESC = new TStruct("SliceRange");
   private static final TField START_FIELD_DESC = new TField("start", TType.STRING, (short)1);
   private static final TField FINISH_FIELD_DESC = new TField("finish", TType.STRING, (short)2);
-  private static final TField IS_ASCENDING_FIELD_DESC = new TField("is_ascending", TType.BOOL,
(short)3);
+  private static final TField REVERSED_FIELD_DESC = new TField("reversed", TType.BOOL, (short)3);
   private static final TField COUNT_FIELD_DESC = new TField("count", TType.I32, (short)4);
 
   public byte[] start;
   public static final int START = 1;
   public byte[] finish;
   public static final int FINISH = 2;
-  public boolean is_ascending;
-  public static final int IS_ASCENDING = 3;
+  public boolean reversed;
+  public static final int REVERSED = 3;
   public int count;
   public static final int COUNT = 4;
 
   private final Isset __isset = new Isset();
   private static final class Isset implements java.io.Serializable {
-    public boolean is_ascending = false;
+    public boolean reversed = false;
     public boolean count = false;
   }
 
@@ -45,7 +45,7 @@
         new FieldValueMetaData(TType.STRING)));
     put(FINISH, new FieldMetaData("finish", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.STRING)));
-    put(IS_ASCENDING, new FieldMetaData("is_ascending", TFieldRequirementType.DEFAULT, 
+    put(REVERSED, new FieldMetaData("reversed", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.BOOL)));
     put(COUNT, new FieldMetaData("count", TFieldRequirementType.DEFAULT, 
         new FieldValueMetaData(TType.I32)));
@@ -56,7 +56,7 @@
   }
 
   public SliceRange() {
-    this.is_ascending = true;
+    this.reversed = false;
 
     this.count = 100;
 
@@ -65,14 +65,14 @@
   public SliceRange(
     byte[] start,
     byte[] finish,
-    boolean is_ascending,
+    boolean reversed,
     int count)
   {
     this();
     this.start = start;
     this.finish = finish;
-    this.is_ascending = is_ascending;
-    this.__isset.is_ascending = true;
+    this.reversed = reversed;
+    this.__isset.reversed = true;
     this.count = count;
     this.__isset.count = true;
   }
@@ -89,8 +89,8 @@
       this.finish = new byte[other.finish.length];
       System.arraycopy(other.finish, 0, finish, 0, other.finish.length);
     }
-    __isset.is_ascending = other.__isset.is_ascending;
-    this.is_ascending = other.is_ascending;
+    __isset.reversed = other.__isset.reversed;
+    this.reversed = other.reversed;
     __isset.count = other.__isset.count;
     this.count = other.count;
   }
@@ -148,27 +148,27 @@
     }
   }
 
-  public boolean isIs_ascending() {
-    return this.is_ascending;
+  public boolean isReversed() {
+    return this.reversed;
   }
 
-  public SliceRange setIs_ascending(boolean is_ascending) {
-    this.is_ascending = is_ascending;
-    this.__isset.is_ascending = true;
+  public SliceRange setReversed(boolean reversed) {
+    this.reversed = reversed;
+    this.__isset.reversed = true;
     return this;
   }
 
-  public void unsetIs_ascending() {
-    this.__isset.is_ascending = false;
+  public void unsetReversed() {
+    this.__isset.reversed = false;
   }
 
-  // Returns true if field is_ascending is set (has been asigned a value) and false otherwise
-  public boolean isSetIs_ascending() {
-    return this.__isset.is_ascending;
+  // Returns true if field reversed is set (has been asigned a value) and false otherwise
+  public boolean isSetReversed() {
+    return this.__isset.reversed;
   }
 
-  public void setIs_ascendingIsSet(boolean value) {
-    this.__isset.is_ascending = value;
+  public void setReversedIsSet(boolean value) {
+    this.__isset.reversed = value;
   }
 
   public int getCount() {
@@ -212,11 +212,11 @@
       }
       break;
 
-    case IS_ASCENDING:
+    case REVERSED:
       if (value == null) {
-        unsetIs_ascending();
+        unsetReversed();
       } else {
-        setIs_ascending((Boolean)value);
+        setReversed((Boolean)value);
       }
       break;
 
@@ -241,8 +241,8 @@
     case FINISH:
       return getFinish();
 
-    case IS_ASCENDING:
-      return new Boolean(isIs_ascending());
+    case REVERSED:
+      return new Boolean(isReversed());
 
     case COUNT:
       return new Integer(getCount());
@@ -259,8 +259,8 @@
       return isSetStart();
     case FINISH:
       return isSetFinish();
-    case IS_ASCENDING:
-      return isSetIs_ascending();
+    case REVERSED:
+      return isSetReversed();
     case COUNT:
       return isSetCount();
     default:
@@ -299,12 +299,12 @@
         return false;
     }
 
-    boolean this_present_is_ascending = true;
-    boolean that_present_is_ascending = true;
-    if (this_present_is_ascending || that_present_is_ascending) {
-      if (!(this_present_is_ascending && that_present_is_ascending))
+    boolean this_present_reversed = true;
+    boolean that_present_reversed = true;
+    if (this_present_reversed || that_present_reversed) {
+      if (!(this_present_reversed && that_present_reversed))
         return false;
-      if (this.is_ascending != that.is_ascending)
+      if (this.reversed != that.reversed)
         return false;
     }
 
@@ -350,10 +350,10 @@
             TProtocolUtil.skip(iprot, field.type);
           }
           break;
-        case IS_ASCENDING:
+        case REVERSED:
           if (field.type == TType.BOOL) {
-            this.is_ascending = iprot.readBool();
-            this.__isset.is_ascending = true;
+            this.reversed = iprot.readBool();
+            this.__isset.reversed = true;
           } else { 
             TProtocolUtil.skip(iprot, field.type);
           }
@@ -393,8 +393,8 @@
       oprot.writeBinary(this.finish);
       oprot.writeFieldEnd();
     }
-    oprot.writeFieldBegin(IS_ASCENDING_FIELD_DESC);
-    oprot.writeBool(this.is_ascending);
+    oprot.writeFieldBegin(REVERSED_FIELD_DESC);
+    oprot.writeBool(this.reversed);
     oprot.writeFieldEnd();
     oprot.writeFieldBegin(COUNT_FIELD_DESC);
     oprot.writeI32(this.count);
@@ -434,8 +434,8 @@
     }
     first = false;
     if (!first) sb.append(", ");
-    sb.append("is_ascending:");
-    sb.append(this.is_ascending);
+    sb.append("reversed:");
+    sb.append(this.reversed);
     first = false;
     if (!first) sb.append(", ");
     sb.append("count:");

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Mon
Aug 10 23:17:08 2009
@@ -1356,9 +1356,9 @@
         return writeStats_.mean();
     }
 
-    public ColumnFamily getColumnFamily(String key, QueryPath path, byte[] start, byte[]
finish, boolean isAscending, int limit) throws IOException
+    public ColumnFamily getColumnFamily(String key, QueryPath path, byte[] start, byte[]
finish, boolean reversed, int limit) throws IOException
     {
-        return getColumnFamily(new SliceQueryFilter(key, path, start, finish, isAscending,
limit));
+        return getColumnFamily(new SliceQueryFilter(key, path, start, finish, reversed, limit));
     }
 
     public ColumnFamily getColumnFamily(QueryFilter filter) throws IOException
@@ -1547,7 +1547,7 @@
                 }
                 // make sure there is actually non-tombstone content associated w/ this key
                 // TODO record the key source(s) somehow and only check that source (e.g.,
memtable or sstable)
-                QueryFilter filter = new SliceQueryFilter(current, new QueryPath(columnFamily_),
ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
+                QueryFilter filter = new SliceQueryFilter(current, new QueryPath(columnFamily_),
ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, 1);
                 if (getColumnFamily(filter, Integer.MAX_VALUE) != null)
                 {
                     keys.add(current);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Mon Aug 10 23:17:08
2009
@@ -267,7 +267,7 @@
 
         final IColumn columns[] = (cf == null ? columnFamily : cf).getSortedColumns().toArray(new
IColumn[columnFamily.getSortedColumns().size()]);
         // TODO if we are dealing with supercolumns, we need to clone them while we have
the read lock since they can be modified later
-        if (!filter.isAscending)
+        if (filter.reversed)
             ArrayUtils.reverse(columns);
         IColumn startIColumn;
         if (DatabaseDescriptor.getColumnFamilyType(table_, filter.getColumnFamilyName()).equals("Standard"))
@@ -279,7 +279,7 @@
         // our dummy column, since the time there is arbitrary).
         Comparator<IColumn> comparator = filter.getColumnComparator(typeComparator);
         int index;
-        if (filter.start.length == 0 && !filter.isAscending)
+        if (filter.start.length == 0 && filter.reversed)
         {
             /* scan from the largest column in descending order */
             index = 0;

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java Mon
Aug 10 23:17:08 2009
@@ -28,20 +28,20 @@
 public class SliceFromReadCommand extends ReadCommand
 {
     public final byte[] start, finish;
-    public final boolean isAscending;
+    public final boolean reversed;
     public final int count;
 
-    public SliceFromReadCommand(String table, String key, ColumnParent column_parent, byte[]
start, byte[] finish, boolean isAscending, int count)
+    public SliceFromReadCommand(String table, String key, ColumnParent column_parent, byte[]
start, byte[] finish, boolean reversed, int count)
     {
-        this(table, key, new QueryPath(column_parent), start, finish, isAscending, count);
+        this(table, key, new QueryPath(column_parent), start, finish, reversed, count);
     }
 
-    public SliceFromReadCommand(String table, String key, QueryPath path, byte[] start, byte[]
finish, boolean isAscending, int count)
+    public SliceFromReadCommand(String table, String key, QueryPath path, byte[] start, byte[]
finish, boolean reversed, int count)
     {
         super(table, key, path, CMD_TYPE_GET_SLICE);
         this.start = start;
         this.finish = finish;
-        this.isAscending = isAscending;
+        this.reversed = reversed;
         this.count = count;
     }
 
@@ -54,7 +54,7 @@
     @Override
     public ReadCommand copy()
     {
-        ReadCommand readCommand = new SliceFromReadCommand(table, key, queryPath, start,
finish, isAscending, count);
+        ReadCommand readCommand = new SliceFromReadCommand(table, key, queryPath, start,
finish, reversed, count);
         readCommand.setDigestQuery(isDigestQuery());
         return readCommand;
     }
@@ -62,7 +62,7 @@
     @Override
     public Row getRow(Table table) throws IOException
     {
-        return table.getRow(new SliceQueryFilter(key, queryPath, start, finish, isAscending,
count));
+        return table.getRow(new SliceQueryFilter(key, queryPath, start, finish, reversed,
count));
     }
 
     @Override
@@ -74,7 +74,7 @@
                ", column_parent='" + queryPath + '\'' +
                ", start='" + getComparator().getString(start) + '\'' +
                ", finish='" + getComparator().getString(finish) + '\'' +
-               ", isAscending=" + isAscending +
+               ", reversed=" + reversed +
                ", count=" + count +
                ')';
     }
@@ -92,7 +92,7 @@
         realRM.queryPath.serialize(dos);
         ColumnSerializer.writeName(realRM.start, dos);
         ColumnSerializer.writeName(realRM.finish, dos);
-        dos.writeBoolean(realRM.isAscending);
+        dos.writeBoolean(realRM.reversed);
         dos.writeInt(realRM.count);
     }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
Mon Aug 10 23:17:08 2009
@@ -11,7 +11,7 @@
      */
     public IdentityQueryFilter(String key, QueryPath path)
     {
-        super(key, path, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true,
Integer.MAX_VALUE);
+        super(key, path, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false,
Integer.MAX_VALUE);
     }
 
     public SuperColumn filterSuperColumn(SuperColumn superColumn, int gcBefore)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
Mon Aug 10 23:17:08 2009
@@ -14,16 +14,16 @@
  */
 class SSTableSliceIterator extends AbstractIterator<IColumn> implements ColumnIterator
 {
-    private final boolean isAscending;
+    private final boolean reversed;
     private final byte[] startColumn;
     private final AbstractType comparator;
     private ColumnGroupReader reader;
 
-    public SSTableSliceIterator(String filename, String key, AbstractType comparator, byte[]
startColumn, boolean isAscending)
+    public SSTableSliceIterator(String filename, String key, AbstractType comparator, byte[]
startColumn, boolean reversed)
     throws IOException
     {
         // TODO push finishColumn down here too, so we can tell when we're done and optimize
away the slice when the index + start/stop shows there's nothing to scan for
-        this.isAscending = isAscending;
+        this.reversed = reversed;
         SSTableReader ssTable = SSTableReader.open(filename);
 
         /* Morph key into actual key based on the partition type. */
@@ -37,9 +37,9 @@
 
     private boolean isColumnNeeded(IColumn column)
     {
-        return isAscending
-               ? comparator.compare(column.name(), startColumn) >= 0
-               : startColumn.length == 0 || comparator.compare(column.name(), startColumn)
<= 0;
+        return reversed
+               ? startColumn.length == 0 || comparator.compare(column.name(), startColumn)
<= 0
+               : comparator.compare(column.name(), startColumn) >= 0;
     }
 
     public ColumnFamily getColumnFamily()
@@ -100,8 +100,8 @@
             file.readInt(); // column count
 
             columnStartPosition = file.getFilePointer();
-            curRangeIndex = IndexHelper.indexFor(startColumn, indexes, comparator, isAscending);
-            if (!isAscending && curRangeIndex == indexes.size())
+            curRangeIndex = IndexHelper.indexFor(startColumn, indexes, comparator, reversed);
+            if (reversed && curRangeIndex == indexes.size())
                 curRangeIndex--;
         }
 
@@ -139,16 +139,16 @@
             while (file.getFilePointer() < columnStartPosition + curColPostion.offset
+ curColPostion.width)
             {
                 IColumn column = emptyColumnFamily.getColumnSerializer().deserialize(file);
-                if (isAscending)
-                    blockColumns.addLast(column);
-                else
+                if (reversed)
                     blockColumns.addFirst(column);
+                else
+                    blockColumns.addLast(column);
             }
 
-            if (isAscending)
-                curRangeIndex++;
-            else
+            if (reversed)
                 curRangeIndex--;
+            else
+                curRangeIndex++;
             return true;
         }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
Mon Aug 10 23:17:08 2009
@@ -16,15 +16,15 @@
 public class SliceQueryFilter extends QueryFilter
 {
     public final byte[] start, finish;
-    public final boolean isAscending;
+    public final boolean reversed;
     public final int count;
 
-    public SliceQueryFilter(String key, QueryPath columnParent, byte[] start, byte[] finish,
boolean ascending, int count)
+    public SliceQueryFilter(String key, QueryPath columnParent, byte[] start, byte[] finish,
boolean reversed, int count)
     {
         super(key, columnParent);
         this.start = start;
         this.finish = finish;
-        isAscending = ascending;
+        this.reversed = reversed;
         this.count = count;
     }
 
@@ -35,21 +35,21 @@
 
     public ColumnIterator getSSTableColumnIterator(SSTableReader sstable, AbstractType comparator)
throws IOException
     {
-        return new SSTableSliceIterator(sstable.getFilename(), key, comparator, start, isAscending);
+        return new SSTableSliceIterator(sstable.getFilename(), key, comparator, start, reversed);
     }
 
     public SuperColumn filterSuperColumn(SuperColumn superColumn, int gcBefore)
     {
         SuperColumn scFiltered = superColumn.cloneMeShallow();
         Iterator<IColumn> subcolumns;
-        if (isAscending)
+        if (reversed)
         {
-            subcolumns = superColumn.getSubColumns().iterator();
+            List<IColumn> columnsAsList = new ArrayList<IColumn>(superColumn.getSubColumns());
+            subcolumns = new ReverseListIterator(columnsAsList);
         }
         else
         {
-            List<IColumn> columnsAsList = new ArrayList<IColumn>(superColumn.getSubColumns());
-            subcolumns = new ReverseListIterator(columnsAsList);
+            subcolumns = superColumn.getSubColumns().iterator();
         }
         collectReducedColumns(scFiltered, subcolumns, gcBefore);
         return scFiltered;
@@ -58,7 +58,7 @@
     @Override
     public Comparator<IColumn> getColumnComparator(AbstractType comparator)
     {
-        return isAscending ? super.getColumnComparator(comparator) : new ReverseComparator(super.getColumnComparator(comparator));
+        return reversed ? new ReverseComparator(super.getColumnComparator(comparator)) :
super.getColumnComparator(comparator);
     }
 
     public void collectReducedColumns(IColumnContainer container, Iterator<IColumn>
reducedColumns, int gcBefore)
@@ -72,8 +72,8 @@
             if (liveColumns >= count)
                 break;
             if (finish.length > 0
-                && ((isAscending && comparator.compare(column.name(), finish)
> 0))
-                    || (!isAscending && comparator.compare(column.name(), finish)
< 0))
+                && ((!reversed && comparator.compare(column.name(), finish)
> 0))
+                    || (reversed && comparator.compare(column.name(), finish) <
0))
                 break;
 
             if (!column.isMarkedForDelete())

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java Mon Aug 10
23:17:08 2009
@@ -124,9 +124,9 @@
      * the index of the IndexInfo in which @name will be found.
      * If the index is @indexList.size(), the @name appears nowhere.
      */
-    public static int indexFor(byte[] name, List<IndexInfo> indexList, AbstractType
comparator, boolean ascending)
+    public static int indexFor(byte[] name, List<IndexInfo> indexList, AbstractType
comparator, boolean reversed)
     {
-        if (name.length == 0 && !ascending)
+        if (name.length == 0 && reversed)
             return indexList.size() - 1;
         IndexInfo target = new IndexInfo(name, name, 0, 0);
         int index = Collections.binarySearch(indexList, target, getComparator(comparator));

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/service/CassandraServer.java Mon
Aug 10 23:17:08 2009
@@ -171,12 +171,7 @@
     private List<ColumnOrSuperColumn> getSlice(ReadCommand command, int consistency_level)
throws InvalidRequestException
     {
         ColumnFamily cfamily = readColumnFamily(command, consistency_level);
-        boolean reverseOrder = false;
-
-        if (command instanceof SliceFromReadCommand)
-        {
-            reverseOrder = !((SliceFromReadCommand)command).isAscending;
-        }
+        boolean reverseOrder = command instanceof SliceFromReadCommand && ((SliceFromReadCommand)command).reversed;
 
         if (cfamily == null || cfamily.getColumnsMap().size() == 0)
         {

Modified: incubator/cassandra/trunk/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/test_server.py?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/test_server.py (original)
+++ incubator/cassandra/trunk/test/system/test_server.py Mon Aug 10 23:17:08 2009
@@ -53,7 +53,7 @@
     client.batch_insert('Keyspace1', BatchMutation(key='key1', cfmap=cfmap), consistencyLevel)
 
 def _big_slice(keyspace, key, column_parent):
-    p = SlicePredicate(slice_range=SliceRange('', '', True, 1000))
+    p = SlicePredicate(slice_range=SliceRange('', '', False, 1000))
     return client.get_slice(keyspace, key, column_parent, p, ConsistencyLevel.ONE)
 
 def _verify_batch():
@@ -81,23 +81,23 @@
     time.sleep(0.1)
 
 def _verify_range():
-    p = SlicePredicate(slice_range=SliceRange('c1', 'c2', True, 1000))
+    p = SlicePredicate(slice_range=SliceRange('c1', 'c2', False, 1000))
     result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), p, ConsistencyLevel.ONE)
     assert len(result) == 2
     assert result[0].column.name == 'c1'
     assert result[1].column.name == 'c2'
 
-    p = SlicePredicate(slice_range=SliceRange('c3', 'c2', False, 1000))
+    p = SlicePredicate(slice_range=SliceRange('c3', 'c2', True, 1000))
     result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), p, ConsistencyLevel.ONE)
     assert len(result) == 2
     assert result[0].column.name == 'c3'
     assert result[1].column.name == 'c2'
 
-    p = SlicePredicate(slice_range=SliceRange('a', 'z', True, 1000))
+    p = SlicePredicate(slice_range=SliceRange('a', 'z', False, 1000))
     result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), p, ConsistencyLevel.ONE)
     assert len(result) == 3, result
     
-    p = SlicePredicate(slice_range=SliceRange('a', 'z', True, 2))
+    p = SlicePredicate(slice_range=SliceRange('a', 'z', False, 2))
     result = client.get_slice('Keyspace1','key1', ColumnParent('Standard1'), p, ConsistencyLevel.ONE)
     assert len(result) == 2, result
 	 	
@@ -109,13 +109,13 @@
     time.sleep(0.1)
 
 def _verify_super_range():
-    p = SlicePredicate(slice_range=SliceRange('sc2', 'sc3', True, 2))
+    p = SlicePredicate(slice_range=SliceRange('sc2', 'sc3', False, 2))
     result = client.get_slice('Keyspace1', 'key1', ColumnParent('Super1'), p, ConsistencyLevel.ONE)
     assert len(result) == 2
     assert result[0].super_column.name == 'sc2'
     assert result[1].super_column.name == 'sc3'
 
-    p = SlicePredicate(slice_range=SliceRange('sc3', 'sc2', False, 2))
+    p = SlicePredicate(slice_range=SliceRange('sc3', 'sc2', True, 2))
     result = client.get_slice('Keyspace1', 'key1', ColumnParent('Super1'), p, ConsistencyLevel.ONE)
     assert len(result) == 2
     assert result[0].super_column.name == 'sc3'
@@ -169,12 +169,12 @@
 
     def test_super_subcolumn_limit(self):
         _insert_super()
-        p = SlicePredicate(slice_range=SliceRange('', '', True, 1))
+        p = SlicePredicate(slice_range=SliceRange('', '', False, 1))
         column_parent = ColumnParent('Super1', 'sc2')
         slice = [result.column
                  for result in client.get_slice('Keyspace1', 'key1', column_parent, p, ConsistencyLevel.ONE)]
         assert slice == [Column(_i64(5), 'value5', 0)], slice
-        p = SlicePredicate(slice_range=SliceRange('', '', False, 1))
+        p = SlicePredicate(slice_range=SliceRange('', '', True, 1))
         slice = [result.column
                  for result in client.get_slice('Keyspace1', 'key1', column_parent, p, ConsistencyLevel.ONE)]
         assert slice == [Column(_i64(6), 'value6', 0)], slice

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Mon Aug 10
23:17:08 2009
@@ -82,7 +82,7 @@
                 cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard3"),
new TreeSet<byte[]>()));
                 assertColumns(cf);
 
-                cf = cfStore.getColumnFamily(new SliceQueryFilter(TEST_KEY, new QueryPath("Standard3"),
ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 0));
+                cf = cfStore.getColumnFamily(new SliceQueryFilter(TEST_KEY, new QueryPath("Standard3"),
ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, 0));
                 assertColumns(cf);
 
                 cf = cfStore.getColumnFamily(new NamesQueryFilter(TEST_KEY, new QueryPath("Standard3"),
"col99".getBytes()));
@@ -137,16 +137,16 @@
         rm.add(cf);
         rm.apply();
         
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(),
true, 100);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(),
false, 100);
         assertEquals(2, cf.getColumnCount());
         
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "b".getBytes(),
true, 100);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "b".getBytes(),
false, 100);
         assertEquals(1, cf.getColumnCount());
         
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(),
true, 1);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "b".getBytes(), "c".getBytes(),
false, 1);
         assertEquals(1, cf.getColumnCount());
         
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "c".getBytes(), "b".getBytes(),
true, 1);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "c".getBytes(), "b".getBytes(),
false, 1);
         assertNull(cf);
     }
 
@@ -176,11 +176,11 @@
         ColumnFamily cf;
 
         // key before the rows that exists
-        cf = cfStore.getColumnFamily("a", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
+        cf = cfStore.getColumnFamily("a", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 1);
         assertColumns(cf);
 
         // key after the rows that exist
-        cf = cfStore.getColumnFamily("z", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, true, 1);
+        cf = cfStore.getColumnFamily("z", new QueryPath("Standard2"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 1);
         assertColumns(cf);
     }
 
@@ -213,26 +213,26 @@
             {
                 ColumnFamily cf;
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
                 assertColumns(cf, "col5", "col7");
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col4".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col4".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
                 assertColumns(cf, "col4", "col5", "col7");
                 assertColumns(ColumnFamilyStore.removeDeleted(cf, Integer.MAX_VALUE), "col5",
"col7");
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col5".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
                 assertColumns(cf, "col3", "col4", "col5");
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col6".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col6".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
                 assertColumns(cf, "col3", "col4", "col5");
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
                 assertColumns(cf, "col7", "col9");
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col95".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col95".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
                 assertColumns(cf);
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col0".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 2);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col0".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 2);
                 assertColumns(cf);
             }
         };
@@ -274,7 +274,7 @@
             {
                 ColumnFamily cf;
 
-                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col2".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+                cf = cfStore.getColumnFamily(ROW, new QueryPath("Standard1"), "col2".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
                 assertColumns(cf, "col2", "col3", "col4");
                 assertEquals(new String(cf.getColumn("col2".getBytes()).value()), "valx");
                 assertEquals(new String(cf.getColumn("col3".getBytes()).value()), "valx");
@@ -322,19 +322,19 @@
     {
         String key = "row3";
         ColumnFamily cf;
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
         assertColumns(cf, "col1000", "col1001", "col1002");
         assertEquals(new String(cf.getColumn("col1000".getBytes()).value()), "v1000");
         assertEquals(new String(cf.getColumn("col1001".getBytes()).value()), "v1001");
         assertEquals(new String(cf.getColumn("col1002".getBytes()).value()), "v1002");
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1195".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1195".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
         assertColumns(cf, "col1195", "col1196", "col1197");
         assertEquals(new String(cf.getColumn("col1195".getBytes()).value()), "v1195");
         assertEquals(new String(cf.getColumn("col1196".getBytes()).value()), "v1196");
         assertEquals(new String(cf.getColumn("col1197".getBytes()).value()), "v1197");
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1996".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1996".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 1000);
         IColumn[] columns = cf.getSortedColumns().toArray(new IColumn[0]);
         for (int i = 1000; i < 1996; i++)
         {
@@ -344,22 +344,22 @@
             assert Arrays.equals(column.value(), ("v" + i).getBytes());
         }
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1990".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col1990".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
         assertColumns(cf, "col1990", "col1991", "col1992");
         assertEquals(new String(cf.getColumn("col1990".getBytes()).value()), "v1990");
         assertEquals(new String(cf.getColumn("col1991".getBytes()).value()), "v1991");
         assertEquals(new String(cf.getColumn("col1992".getBytes()).value()), "v1992");
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
         assertColumns(cf, "col1997", "col1998", "col1999");
         assertEquals(new String(cf.getColumn("col1999".getBytes()).value()), "v1999");
         assertEquals(new String(cf.getColumn("col1998".getBytes()).value()), "v1998");
         assertEquals(new String(cf.getColumn("col1997".getBytes()).value()), "v1997");
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
         assertColumns(cf, "col1997", "col1998", "col1999");
 
-        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 3);
+        cf = cfStore.getColumnFamily(key, new QueryPath("Standard1"), "col9000".getBytes(),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 3);
         assertColumns(cf);
     }
 
@@ -383,7 +383,7 @@
         {
             public void run() throws Exception
             {
-                ColumnFamily cf = cfStore.getColumnFamily(ROW, new QueryPath("Super1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, true, 10);
+                ColumnFamily cf = cfStore.getColumnFamily(ROW, new QueryPath("Super1"), ArrayUtils.EMPTY_BYTE_ARRAY,
ArrayUtils.EMPTY_BYTE_ARRAY, false, 10);
                 assertColumns(cf, "sc1");
                 assertEquals(new String(cf.getColumn("sc1".getBytes()).getSubColumn(getBytes(1)).value()),
"val1");
             }

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java?rev=802953&r1=802952&r2=802953&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java Mon Aug
10 23:17:08 2009
@@ -50,7 +50,7 @@
         rm.add(new QueryPath("StandardLong1", null, getBytes(0)), "b".getBytes(), 0);
         rm.apply();
 
-        ColumnFamily cf = cfStore.getColumnFamily("key0", new QueryPath("StandardLong1"),
getBytes(10), ArrayUtils.EMPTY_BYTE_ARRAY, true, 1000);
+        ColumnFamily cf = cfStore.getColumnFamily("key0", new QueryPath("StandardLong1"),
getBytes(10), ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
         Collection<IColumn> columns = cf.getSortedColumns();
         assert columns.size() == 1;
     }
@@ -91,7 +91,7 @@
         rm.apply();
 
         // verify
-        ColumnFamily cf = cfStore.getColumnFamily(key, new QueryPath("StandardLong1"), getBytes(0),
ArrayUtils.EMPTY_BYTE_ARRAY, true, 1000);
+        ColumnFamily cf = cfStore.getColumnFamily(key, new QueryPath("StandardLong1"), getBytes(0),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
         Collection<IColumn> columns = cf.getSortedColumns();
         assertEquals(12, columns.size());
         Iterator<IColumn> iter = columns.iterator();
@@ -116,7 +116,7 @@
             String key = Integer.toString(i);
             for (int j = 0; j < 8; j += 3)
             {
-                ColumnFamily cf = table.getColumnFamilyStore("StandardLong1").getColumnFamily(key,
new QueryPath("StandardLong1"), getBytes(j * 2), ArrayUtils.EMPTY_BYTE_ARRAY, true, 1000);
+                ColumnFamily cf = table.getColumnFamilyStore("StandardLong1").getColumnFamily(key,
new QueryPath("StandardLong1"), getBytes(j * 2), ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
                 Collection<IColumn> columns = cf.getSortedColumns();
                 assert columns.size() == 8 - j;
                 int k = j;



Mime
View raw message