cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1100470 - in /cassandra/branches/cassandra-0.8: ./ contrib/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/config/ src/java/org/apache/cassandra/db/ test/unit/org/apache/cassandra/ test/unit/org/apache...
Date Sat, 07 May 2011 07:12:32 GMT
Author: jbellis
Date: Sat May  7 07:12:31 2011
New Revision: 1100470

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

Modified:
    cassandra/branches/cassandra-0.8/   (props changed)
    cassandra/branches/cassandra-0.8/CHANGES.txt
    cassandra/branches/cassandra-0.8/contrib/   (props changed)
    cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
  (props changed)
    cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
  (props changed)
    cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/ColumnDefinition.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/SchemaLoader.java
    cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/db/DefsTest.java

Propchange: cassandra/branches/cassandra-0.8/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6:922689-1052356,1052358-1053452,1053454,1053456-1081914,1083000
-/cassandra/branches/cassandra-0.7:1026516-1100448
+/cassandra/branches/cassandra-0.7:1026516-1100465
 /cassandra/branches/cassandra-0.7.0:1053690-1055654
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689
 /cassandra/trunk:1090978-1090979

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Sat May  7 07:12:31 2011
@@ -28,6 +28,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/branches/cassandra-0.8/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/contrib:922689-1052356,1052358-1053452,1053454,1053456-1068009
-/cassandra/branches/cassandra-0.7/contrib:1026516-1100448
+/cassandra/branches/cassandra-0.7/contrib:1026516-1100465
 /cassandra/branches/cassandra-0.7.0/contrib:1053690-1055654
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689
 /cassandra/trunk/contrib:1090978-1090979

Propchange: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /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-1100448
+/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/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090978-1090979

Propchange: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /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-1100448
+/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/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090978-1090979

Propchange: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /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-1100448
+/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/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090978-1090979

Propchange: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /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-1100448
+/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/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090978-1090979

Propchange: cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat May  7 07:12:31 2011
@@ -1,5 +1,5 @@
 /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-1100448
+/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/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090978-1090979

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/CFMetaData.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/CFMetaData.java
Sat May  7 07:12:31 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/branches/cassandra-0.8/src/java/org/apache/cassandra/config/ColumnDefinition.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/ColumnDefinition.java?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/ColumnDefinition.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/config/ColumnDefinition.java
Sat May  7 07:12:31 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/branches/cassandra-0.8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Sat May  7 07:12:31 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/branches/cassandra-0.8/test/unit/org/apache/cassandra/SchemaLoader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/SchemaLoader.java?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/SchemaLoader.java (original)
+++ cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/SchemaLoader.java Sat
May  7 07:12:31 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/branches/cassandra-0.8/test/unit/org/apache/cassandra/db/DefsTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/db/DefsTest.java?rev=1100470&r1=1100469&r2=1100470&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/db/DefsTest.java (original)
+++ cassandra/branches/cassandra-0.8/test/unit/org/apache/cassandra/db/DefsTest.java Sat May
 7 07:12:31 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