cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1100471 - in /cassandra/trunk: ./ contrib/ drivers/py/cql/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/locator/ src/java/org/a...
Date Sat, 07 May 2011 07:13:21 GMT
Author: jbellis
Date: Sat May  7 07:13:21 2011
New Revision: 1100471

URL: http://svn.apache.org/viewvc?rev=1100471&view=rev
Log:
merge from 0.8

Removed:
    cassandra/trunk/drivers/py/cql/results.py
Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/   (props changed)
    cassandra/trunk/drivers/py/cql/cursor.py
    cassandra/trunk/drivers/py/cql/decoders.py
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java 
 (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java   (props
changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/trunk/src/java/org/apache/cassandra/config/ColumnDefinition.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
    cassandra/trunk/test/system/test_cql.py
    cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7:1026516-1099892
+/cassandra/branches/cassandra-0.7:1026516-1100465
 /cassandra/branches/cassandra-0.7.0:1053690-1055654
-/cassandra/branches/cassandra-0.8:1090935-1100274
+/cassandra/branches/cassandra-0.8:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3:774578-796573
 /incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Sat May  7 07:13:21 2011
@@ -35,6 +35,8 @@
  * remove unframed Thrift transport option
  * include indexes in snapshots (CASSANDRA-2596)
  * improve ignoring of obsolete mutations in index maintenance (CASSANDRA-2401)
+ * recognize attempt to drop just the index while leaving the column
+   definition alone (CASSANDRA-2619)
 
 
 0.8.0-beta1

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/contrib:922689-1052356,1052358-1053452,1053454,1053456-1068009
-/cassandra/branches/cassandra-0.7/contrib:1026516-1099892
+/cassandra/branches/cassandra-0.7/contrib:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/contrib:1053690-1055654
-/cassandra/branches/cassandra-0.8/contrib:1090935-1100274
+/cassandra/branches/cassandra-0.8/contrib:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/contrib:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/contrib:810145-810987,810994-834239,834349-834350

Modified: cassandra/trunk/drivers/py/cql/cursor.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/cursor.py?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/cursor.py (original)
+++ cassandra/trunk/drivers/py/cql/cursor.py Sat May  7 07:13:21 2011
@@ -21,7 +21,6 @@ import zlib
 import cql
 from cql.marshal import prepare
 from cql.decoders import SchemaDecoder
-from cql.results import ResultSet
 from cql.cassandra.ttypes import (
     Compression, 
     CqlResultType, 
@@ -31,6 +30,8 @@ from cql.cassandra.ttypes import (
     TApplicationException,
     SchemaDisagreementException)
 
+_COUNT_DESCRIPTION = (None, None, None, None, None, None, None)
+
 class Cursor:
 
     _keyspace_re = re.compile("USE (\w+);?", re.I | re.M)
@@ -41,7 +42,6 @@ class Cursor:
         self.open_socket = True
         self.parent_connection = parent_connection
 
-        self.result = None      # Populate on execute()
         self.description = None # A list of 7-tuples: 
                                 #  (column_name, type_code, none, none,
                                 #   none, none, nulls_ok=True)
@@ -145,20 +145,18 @@ class Cursor:
             self.decoder.schema = self.__get_schema()
 
         if response.type == CqlResultType.ROWS:
-            self.result = ResultSet(response.rows,
-                                    self._query_ks,
-                                    self._query_cf,
-                                    self.decoder)
+            self.result = response.rows
             self.rs_idx = 0
             self.rowcount = len(self.result)
-            self.description = self.result.description
+            if self.result:
+                self.description = self.decoder.decode_description(self._query_ks, self._query_cf,
self.result[0])
 
         if response.type == CqlResultType.INT:
             self.result = [(response.num,)]
             self.rs_idx = 0
             self.rowcount = 1
             # TODO: name could be the COUNT expression
-            self.description = (None, None, None, None, None, None, None)
+            self.description = _COUNT_DESCRIPTION
 
         # 'Return values are not defined.'
         return True
@@ -178,27 +176,28 @@ class Cursor:
 
     def fetchone(self):
         self.__checksock()
-        ret = self.result[self.rs_idx]
+        row = self.result[self.rs_idx]
         self.rs_idx += 1
-        self.description = getattr(self.result, 'description', self.description)
-        return ret
+        if self.description != _COUNT_DESCRIPTION:
+            self.description = self.decoder.decode_description(self._query_ks, self._query_cf,
row)
+            return self.decoder.decode_row(self._query_ks, self._query_cf, row)
+        else:
+            return row
 
     def fetchmany(self, size=None):
         self.__checksock()
         if size is None:
             size = self.arraysize
-        end = self.rs_idx + size
-        ret = self.result[self.rs_idx:end]
-        self.rs_idx = end
-        self.description = getattr(self.result, 'description', self.description)
-        return ret
+        # we avoid leveraging fetchone here to avoid calling decode_description unnecessarily
+        L = []
+        while len(L) < size and self.rs_idx < len(self.result):
+            row = self.result[self.rs_idx]
+            self.rs_idx += 1
+            L.append(self.decoder.decode_row(self._query_ks, self._query_cf, row))
+        return L
 
     def fetchall(self):
-        self.__checksock()
-        ret = self.result[self.rs_idx:]
-        self.rs_idx = len(self.result)
-        self.description = self.result.description
-        return ret
+        return self.fetchmany(len(self.result) - self.rs_idx)
 
     ###
     # Iterator extension

Modified: cassandra/trunk/drivers/py/cql/decoders.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/drivers/py/cql/decoders.py?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/drivers/py/cql/decoders.py (original)
+++ cassandra/trunk/drivers/py/cql/decoders.py Sat May  7 07:13:21 2011
@@ -50,20 +50,27 @@ class SchemaDecoder(object):
             return cfam["key_validation_class"]
         return None
 
-    def decode_row(self, keyspace, column_family, row):
+    def decode_description(self, keyspace, column_family, row):
         key_type = self.__keytype_for(keyspace, column_family)
-        key = unmarshallers.get(key_type, unmarshal_noop)(row.key)
         description = [(cql.ROW_KEY, key_type, None, None, None, None, None, False)]
+        comparator = self.__comparator_for(keyspace, column_family)
+        unmarshal = unmarshallers.get(comparator, unmarshal_noop)
+        for column in row.columns:
+            description.append((unmarshal(column.name), comparator, None, None, None, None,
True))
 
+        return description
+
+    def decode_row(self, keyspace, column_family, row):
+        key_type = self.__keytype_for(keyspace, column_family)
+        key = unmarshallers.get(key_type, unmarshal_noop)(row.key)
         comparator = self.__comparator_for(keyspace, column_family)
         unmarshal = unmarshallers.get(comparator, unmarshal_noop)
         values = [key]
         for column in row.columns:
-            description.append((unmarshal(column.name), comparator, None, None, None, None,
True))
             validator = self.__validator_for(keyspace, column_family, column.name)
             if column.value is None:
                 values.append(None)
             else:
                 values.append(unmarshallers.get(validator, unmarshal_noop)(column.value))
 
-        return description, values
+        return values

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1099892
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090935-1100274
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/Cassandra.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Cassandra.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1099892
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090935-1100274
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/column_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Column.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1099892
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090935-1100274
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1099892
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090935-1100274
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:810145-834239,834349-834350

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:13:21 2011
@@ -1,7 +1,7 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1099892
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1053690-1055654
-/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090935-1100274
+/cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090935-1100470
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/superColumn_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:810145-834239,834349-834350

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Sat May  7 07:13:21
2011
@@ -179,7 +179,7 @@ public final class CFMetaData
     public CFMetaData mergeShardsChance(double prop) {mergeShardsChance = prop; return this;}
     public CFMetaData keyAlias(ByteBuffer prop) {keyAlias = prop; return this;}
     public CFMetaData columnMetadata(Map<ByteBuffer,ColumnDefinition> prop) {column_metadata
= prop; return this;}
-    public CFMetaData rowCacheProvider(IRowCacheProvider prop) { rowCacheProvider = prop;
return this;};
+    public CFMetaData rowCacheProvider(IRowCacheProvider prop) { rowCacheProvider = prop;
return this;}
 
     public CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType comp,
AbstractType subcc)
     {
@@ -718,19 +718,19 @@ public final class CFMetaData
             rowCacheProvider = FBUtilities.newCacheProvider(cf_def.row_cache_provider.toString());
         keyAlias = cf_def.key_alias;
 
-        // adjust secondary indexes. figure out who is coming and going.
+        // adjust column definitions. figure out who is coming and going.
         Set<ByteBuffer> toRemove = new HashSet<ByteBuffer>();
-        Set<ByteBuffer> newIndexNames = new HashSet<ByteBuffer>();
+        Set<ByteBuffer> newColumns = new HashSet<ByteBuffer>();
         Set<org.apache.cassandra.db.migration.avro.ColumnDef> toAdd = new HashSet<org.apache.cassandra.db.migration.avro.ColumnDef>();
         for (org.apache.cassandra.db.migration.avro.ColumnDef def : cf_def.column_metadata)
         {
-            newIndexNames.add(def.name);
+            newColumns.add(def.name);
             if (!column_metadata.containsKey(def.name))
                 toAdd.add(def);
         }
-        for (ByteBuffer indexName : column_metadata.keySet())
-            if (!newIndexNames.contains(indexName))
-                toRemove.add(indexName);
+        for (ByteBuffer name : column_metadata.keySet())
+            if (!newColumns.contains(name))
+                toRemove.add(name);
         
         // remove the ones leaving.
         for (ByteBuffer indexName : toRemove)

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/ColumnDefinition.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/ColumnDefinition.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/ColumnDefinition.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/ColumnDefinition.java Sat May  7
07:13:21 2011
@@ -130,21 +130,6 @@ public class ColumnDefinition
         return cds;
     }
     
-    public static Map<ByteBuffer, ColumnDefinition> fromColumnDefs(Iterable<org.apache.cassandra.db.migration.avro.ColumnDef>
avroDefs) throws ConfigurationException
-    {
-        if (avroDefs == null)
-            return Collections.emptyMap();
-
-        Map<ByteBuffer, ColumnDefinition> cds = new TreeMap<ByteBuffer, ColumnDefinition>();
-        for (org.apache.cassandra.db.migration.avro.ColumnDef avroColumnDef : avroDefs)
-        {
-            validateIndexType(avroColumnDef);
-            cds.put(avroColumnDef.name, fromColumnDef(avroColumnDef));
-        }
-
-        return Collections.unmodifiableMap(cds);
-    }
-
     public static void validateIndexType(org.apache.cassandra.db.migration.avro.ColumnDef
avroColumnDef) throws ConfigurationException
     {
         if ((avroColumnDef.index_name != null) && (avroColumnDef.index_type == null))

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Sat May  7 07:13:21
2011
@@ -219,7 +219,8 @@ public class ColumnFamilyStore implement
         // future: if/when we have modifiable settings for secondary indexes, they'll need
to be handled here.
         for (ByteBuffer indexedColumn : indexedColumns.keySet())
         {
-            if (!metadata.getColumn_metadata().containsKey(indexedColumn))
+            ColumnDefinition def = metadata.getColumn_metadata().get(indexedColumn);
+            if (def == null || def.getIndexType() == null)
                 removeIndex(indexedColumn);
         }
 

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Sat May  7 07:13:21 2011
@@ -186,17 +186,15 @@ public class Table
     }
 
     /**
-     * Take a snapshot of the entire set of column families with a given timestamp.
+     * Take a snapshot of the entire set of column families with a given timestamp
      * 
-     * @param clientSuppliedName the tag associated with the name of the snapshot.  This
-     *                           value can be null.
+     * @param snapshotName the tag associated with the name of the snapshot.  This value
may not be null
      */
     public void snapshot(String snapshotName)
     {
+        assert snapshotName != null;
         for (ColumnFamilyStore cfStore : columnFamilyStores.values())
-        {
             cfStore.snapshot(snapshotName);
-        }
     }
 
     /**
@@ -213,7 +211,7 @@ public class Table
         return snapshotName;
     }
 
-    /**
+    /**?
      * Clear snapshots for this table. If no tag is given we will clear all
      * snapshots
      *
@@ -503,6 +501,8 @@ public class Table
                                                            || (oldColumn != null &&
oldColumn.reconcile(newColumn) == oldColumn));
             if (bothDeleted || obsoleteRowTombstone || obsoleteColumn)
             {
+                if (logger.isDebugEnabled())
+                    logger.debug("skipping index update for obsolete mutation of " + cf.getComparator().getString(name));
                 iter.remove();
                 oldIndexedColumns.remove(name);
             }

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java Sat May
 7 07:13:21 2011
@@ -285,7 +285,14 @@ class AdaptiveLatencyTracker extends Abs
     {
         if (!latencies.offer(i))
         {
-            latencies.remove();
+            try
+            {
+                latencies.remove();
+            }
+            catch (NoSuchElementException e)
+            {
+                // oops, clear() beat us to it
+            }
             latencies.offer(i);
         }
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Sat May  7 07:13:21
2011
@@ -188,7 +188,7 @@ public class StorageProxy implements Sto
      * said write endpoint (deletaged to the actual WritePerformer) and wait for the
      * responses based on consistency level.
      *
-     * @param mutations the mutations to be applied
+     * @param mutation the mutation to be applied
      * @param consistency_level the consistency level for the write operation
      * @param performer the WritePerformer in charge of appliying the mutation
      * given the list of write endpoints (either standardWritePerformer for

Modified: cassandra/trunk/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/system/test_cql.py?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/test/system/test_cql.py (original)
+++ cassandra/trunk/test/system/test_cql.py Sat May  7 07:13:21 2011
@@ -125,7 +125,7 @@ def init(keyspace="Keyspace1"):
 
 class TestCql(ThriftTester):
     def test_select_simple(self):
-        "retrieve a column"
+        "single-row named column queries"
         cursor = init()
         cursor.execute("SELECT 'ca1' FROM StandardString1 WHERE KEY='ka'")
         r = cursor.fetchone()
@@ -137,10 +137,8 @@ class TestCql(ThriftTester):
         assert d[1][0] == 'ca1'
         assert r[1] == 'va1'
 
-    def test_select_columns(self):
-        "retrieve multiple columns"
-        cursor = init()
-        # we deliberately request columns in non-comparator order
+        # retrieve multiple columns
+        # (we deliberately request columns in non-comparator order)
         cursor.execute("""
             SELECT ca1, col, cd1 FROM StandardString1 WHERE KEY = 'kd'
         """)
@@ -157,12 +155,8 @@ class TestCql(ThriftTester):
         cursor.execute("""
             SELECT 4 FROM StandardLongA WHERE KEY > 'ad' AND KEY < 'ag';
         """)
-        keys = ['ad', 'ae', 'af']
-        assert cursor.rowcount == 4
-        for i in range(3):
-            r = cursor.fetchone()
-            assert len(r) == 2
-            assert r[0] == keys[i]
+        rows = [row[0] for row in cursor.fetchall()]
+        assert ['ad', 'ae', 'af', 'ag'] == rows, rows
 
     def test_select_row_range_with_limit(self):
         "retrieve a limited range of rows with columns"
@@ -183,9 +177,18 @@ class TestCql(ThriftTester):
             assert r[0] == "k%d" % (i+1)
 
     def test_select_columns_slice(self):
-        "range of columns (slice) by row"
+        "column slice tests"
         cursor = init()
 
+        # all columns
+        cursor.execute("SELECT * FROM StandardString1 WHERE KEY = 'ka';")
+        r = cursor.fetchone()
+        assert len(r) == 3
+        cursor.execute("SELECT ''..'' FROM StandardString1 WHERE KEY = 'ka';")
+        r = cursor.fetchone()
+        assert len(r) == 3
+
+        # column subsets
         cursor.execute("SELECT 1..3 FROM StandardLongA WHERE KEY = 'aa';")
         assert cursor.rowcount == 1
         r = cursor.fetchone()
@@ -193,7 +196,7 @@ class TestCql(ThriftTester):
         assert r[1] == "1"
         assert r[2] == "2"
         assert r[3] == "3"
-
+        
         cursor.execute("SELECT 10..30 FROM StandardIntegerA WHERE KEY='k1'")
         assert cursor.rowcount == 1
         r = cursor.fetchone()
@@ -202,19 +205,7 @@ class TestCql(ThriftTester):
         assert r[2] == "b"
         assert r[3] == "c"
 
-    def test_select_columns_slice_all(self):
-        "slice all columns in a row"
-        cursor = init()
-        cursor.execute("SELECT * FROM StandardString1 WHERE KEY = 'ka';")
-        r = cursor.fetchone()
-        assert len(r) == 3
-        cursor.execute("SELECT ''..'' FROM StandardString1 WHERE KEY = 'ka';")
-        r = cursor.fetchone()
-        assert len(r) == 3
-
-    def test_select_columns_slice_with_limit(self):
-        "range of columns (slice) by row with limit"
-        cursor = init()
+        # range of columns (slice) by row with FIRST
         cursor.execute("""
             SELECT FIRST 1 1..3 FROM StandardLongA WHERE KEY = 'aa';
         """)
@@ -224,6 +215,17 @@ class TestCql(ThriftTester):
         assert r[0] == "aa"
         assert r[1] == "1"
 
+        # range of columns (slice) by row reversed
+        cursor.execute("""
+            SELECT FIRST 2 REVERSED 3..1 FROM StandardLongA WHERE KEY = 'aa';
+        """)
+        assert cursor.rowcount == 1, "%d != 1" % cursor.rowcount
+        r = cursor.fetchone()
+        assert len(r) == 3
+        assert r[0] == 'aa'
+        assert r[1] == "3"
+        assert r[2] == "2"
+
     def test_select_range_with_single_column_results(self):
         "range should not fail when keys were not set"
         cursor = init()
@@ -253,19 +255,6 @@ class TestCql(ThriftTester):
         assert r[0] == "user3"
         assert r[1] == None
 
-    def test_select_columns_slice_reversed(self):
-        "range of columns (slice) by row reversed"
-        cursor= init()
-        cursor.execute("""
-            SELECT FIRST 2 REVERSED 3..1 FROM StandardLongA WHERE KEY = 'aa';
-        """)
-        assert cursor.rowcount == 1, "%d != 1" % cursor.rowcount
-        r = cursor.fetchone()
-        assert len(r) == 3
-        assert r[0] == 'aa'
-        assert r[1] == "3"
-        assert r[2] == "2"
-
     def test_index_scan_equality(self):
         "indexed scan where column equals value"
         cursor = init()

Modified: cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java Sat May  7 07:13:21 2011
@@ -64,6 +64,7 @@ public class SchemaLoader
         String ks3 = "Keyspace3";
         String ks4 = "Keyspace4";
         String ks5 = "Keyspace5";
+        String ks6 = "Keyspace6";
         String ks_kcs = "KeyCacheSpace";
         String ks_rcs = "RowCacheSpace";
 
@@ -181,6 +182,12 @@ public class SchemaLoader
                                   standardCFMD(ks5, "Counter1")
                                                .defaultValidator(CounterColumnType.instance)));
 
+        // Keyspace 6
+        schema.add(new KSMetaData(ks6,
+                                  simple,
+                                  opts_rf1,
+                                  indexCFMD(ks6, "Indexed1", true)));
+
         // KeyCacheSpace
         schema.add(new KSMetaData(ks_kcs,
                                   simple,
@@ -214,13 +221,12 @@ public class SchemaLoader
     private static CFMetaData indexCFMD(String ksName, String cfName, final Boolean withIdxType)
     {
         return standardCFMD(ksName, cfName)
-                .columnMetadata(Collections.unmodifiableMap(new HashMap<ByteBuffer, ColumnDefinition>()
+                .columnMetadata(new HashMap<ByteBuffer, ColumnDefinition>()
                     {{
                         ByteBuffer cName = ByteBuffer.wrap("birthdate".getBytes(Charsets.UTF_8));
                         IndexType keys = withIdxType ? IndexType.KEYS : null;
-                        put(cName,
-                            new ColumnDefinition(cName, LongType.instance, keys, null));
-                    }}));
+                        put(cName, new ColumnDefinition(cName, LongType.instance, keys, null));
+                    }});
     }
     private static CFMetaData jdbcCFMD(String ksName, String cfName, AbstractType comp)
     {

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java?rev=1100471&r1=1100470&r2=1100471&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java Sat May  7 07:13:21 2011
@@ -23,14 +23,7 @@ import static org.junit.Assert.assertEqu
 import java.io.File;
 import java.io.IOException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import java.util.UUID;
+import java.util.*;
 import java.util.concurrent.ExecutionException;
 
 import org.apache.avro.util.Utf8;
@@ -55,6 +48,7 @@ import org.apache.cassandra.db.migration
 import org.apache.cassandra.db.migration.UpdateColumnFamily;
 import org.apache.cassandra.db.migration.UpdateKeyspace;
 import org.apache.cassandra.io.SerDeUtils;
+import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.locator.OldNetworkTopologyStrategy;
 import org.apache.cassandra.locator.SimpleStrategy;
@@ -795,6 +789,33 @@ public class DefsTest extends CleanupHel
         }
     }
 
+    @Test
+    public void testDropIndex() throws IOException, ExecutionException, InterruptedException,
ConfigurationException
+    {
+        // insert some data.  save the sstable descriptor so we can make sure it's marked
for delete after the drop
+        RowMutation rm = new RowMutation("Keyspace6", ByteBufferUtil.bytes("k1"));
+        rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("notbirthdate")), ByteBufferUtil.bytes(1L),
0);
+        rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")), ByteBufferUtil.bytes(1L),
0);
+        rm.apply();
+        ColumnFamilyStore cfs = Table.open("Keyspace6").getColumnFamilyStore("Indexed1");
+        cfs.forceBlockingFlush();
+        ColumnFamilyStore indexedCfs = cfs.getIndexedColumnFamilyStore(cfs.getIndexedColumns().iterator().next());
+        Descriptor desc = indexedCfs.getSSTables().iterator().next().descriptor;
+
+        // drop the index
+        CFMetaData meta = CFMetaData.rename(cfs.metadata, cfs.metadata.cfName); // abusing
rename to clone
+        ColumnDefinition cdOld = meta.getColumn_metadata().values().iterator().next();
+        ColumnDefinition cdNew = new ColumnDefinition(cdOld.name, cdOld.getValidator(), null,
null);
+        meta.columnMetadata(Collections.singletonMap(cdOld.name, cdNew));
+        UpdateColumnFamily update = new UpdateColumnFamily(CFMetaData.convertToAvro(meta));
+        update.apply();
+
+        // check
+        assert cfs.getIndexedColumns().isEmpty();
+        ColumnFamilyStore.scrubDataDirectories("Keyspace6", "Indexed1");
+        assert !new File(desc.filenameFor(Component.DATA)).exists();
+    }
+
     private CFMetaData addTestCF(String ks, String cf, String comment)
     {
         CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, UTF8Type.instance,
null);



Mime
View raw message