cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r819121 - in /incubator/cassandra/branches/cassandra-0.4: src/java/org/apache/cassandra/db/ColumnIndexer.java test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java test/unit/org/apache/cassandra/db/TableTest.java
Date Sat, 26 Sep 2009 12:46:21 GMT
Author: jbellis
Date: Sat Sep 26 12:46:20 2009
New Revision: 819121

URL: http://svn.apache.org/viewvc?rev=819121&view=rev
Log:
columns may be empty if the only pre-flush op was a CF-level remove op. fix (to allow this),
with test.  patch by jbellis; reviewed by Teodor Sigaev for CASSANDRA-458

Modified:
    incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/db/ColumnIndexer.java
    incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
    incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/TableTest.java

Modified: incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/db/ColumnIndexer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/db/ColumnIndexer.java?rev=819121&r1=819120&r2=819121&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/db/ColumnIndexer.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/db/ColumnIndexer.java
Sat Sep 26 12:46:20 2009
@@ -104,7 +104,11 @@
      */
     private static void doIndexing(AbstractType comparator, Collection<IColumn> columns,
DataOutput dos) throws IOException
     {
-        assert !columns.isEmpty();
+        if (columns.isEmpty())
+        {
+            dos.writeInt(0);
+            return;            
+        }
 
         /*
          * Maintains a list of ColumnIndexInfo objects for the columns in this

Modified: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=819121&r1=819120&r2=819121&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Sat Sep 26 12:46:20 2009
@@ -25,6 +25,7 @@
 import java.util.concurrent.ExecutionException;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.ArrayUtils;
 import static org.junit.Assert.assertNull;
 import org.junit.Test;
 
@@ -32,6 +33,8 @@
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.db.filter.IdentityQueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.db.filter.SliceQueryFilter;
+import org.apache.cassandra.db.filter.NamesQueryFilter;
 import org.apache.cassandra.io.SSTableReader;
 
 public class ColumnFamilyStoreTest extends CleanupHelper
@@ -120,4 +123,29 @@
         ColumnFamily cf = store.getColumnFamily(new IdentityQueryFilter("key2", new QueryPath("Standard1",
null, "Column1".getBytes())));
         assertNull(cf);
     }
+
+    @Test
+    public void testEmptyRow() throws Exception
+    {
+        Table table = Table.open("Keyspace1");
+        final ColumnFamilyStore store = table.getColumnFamilyStore("Standard2");
+        RowMutation rm;
+
+        rm = new RowMutation("Keyspace1", "key1");
+        rm.delete(new QueryPath("Standard2", null, null), System.currentTimeMillis());
+        rm.apply();
+
+        TableTest.Runner r = new TableTest.Runner()
+        {
+            public void run() throws IOException
+            {
+                SliceQueryFilter sliceFilter = new SliceQueryFilter("key1", new QueryPath("Standard2",
null, null), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, false, 1);
+                assertNull(store.getColumnFamily(sliceFilter));
+                NamesQueryFilter namesFilter = new NamesQueryFilter("key1", new QueryPath("Standard2",
null, null), "a".getBytes());
+                assertNull(store.getColumnFamily(namesFilter));
+            }
+        };
+
+        TableTest.reTest(store, r);
+    }
 }

Modified: incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/TableTest.java?rev=819121&r1=819120&r2=819121&view=diff
==============================================================================
--- incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/TableTest.java
(original)
+++ incubator/cassandra/branches/cassandra-0.4/test/unit/org/apache/cassandra/db/TableTest.java
Sat Sep 26 12:46:20 2009
@@ -42,12 +42,12 @@
     private static final String KEY2 = "key2";
     private static final String TEST_KEY = "key1";
 
-    interface Runner
+    public interface Runner
     {
         public void run() throws Exception;
     }
 
-    private void reTest(ColumnFamilyStore cfs, Runner verify) throws Exception
+    public static void reTest(ColumnFamilyStore cfs, Runner verify) throws Exception
     {
         verify.run();
         cfs.forceBlockingFlush();



Mime
View raw message