cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject [1/2] git commit: Add optimized CF.hasColumns() implementations
Date Thu, 27 Mar 2014 16:44:47 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk fc75fc2e4 -> 516e232c3


Add optimized CF.hasColumns() implementations

patch by Aleksey Yeschenko; reviewed by Benedict Elliott Smith for
CASSANDRA-6941


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

Branch: refs/heads/trunk
Commit: 48e8dcc8f0f15864c2ffafd41f54d713dd5e2f3e
Parents: 1f397a3
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Thu Mar 27 19:33:50 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Thu Mar 27 19:36:36 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/config/CFMetaData.java |  2 +-
 .../org/apache/cassandra/config/Schema.java     |  2 +-
 .../cassandra/db/ArrayBackedSortedColumns.java  |  7 ++++++-
 .../apache/cassandra/db/AtomicBTreeColumns.java |  5 +++++
 .../org/apache/cassandra/db/ColumnFamily.java   |  7 ++++++-
 .../apache/cassandra/db/ColumnFamilyStore.java  |  2 +-
 .../org/apache/cassandra/db/DefsTables.java     | 22 ++++++++++----------
 src/java/org/apache/cassandra/db/Memtable.java  |  7 ++++---
 .../org/apache/cassandra/db/SystemKeyspace.java |  2 +-
 .../cassandra/db/filter/SliceQueryFilter.java   |  2 +-
 .../db/index/composites/CompositesSearcher.java |  2 +-
 .../cassandra/io/sstable/SSTableWriter.java     |  2 +-
 .../service/pager/AbstractQueryPager.java       |  4 ++--
 .../cassandra/thrift/CassandraServer.java       |  2 +-
 .../cassandra/db/ColumnFamilyStoreTest.java     | 10 ++++-----
 test/unit/org/apache/cassandra/db/RowTest.java  | 13 ++++++------
 .../db/compaction/CompactionsTest.java          |  6 +++---
 18 files changed, 58 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7f88d0f..196fa0d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -33,6 +33,7 @@
  * Remove sync repair JMX interface (CASSANDRA-6900)
  * Add multiple memory allocation options for memtables (CASSANDRA-6689)
  * Remove adjusted op rate from stress output (CASSANDRA-6921)
+ * Add optimized CF.hasColumns() implementations (CASSANDRA-6941)
 Merged from 2.0:
  * Restrict Windows to parallel repairs (CASSANDRA-6907)
  * (Hadoop) Allow manually specifying start/end tokens in CFIF (CASSANDRA-6436)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 9c8ceaf..8a4f147 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -1089,7 +1089,7 @@ public final class CFMetaData
     {
         Row cfDefRow = SystemKeyspace.readSchemaRow(SystemKeyspace.SCHEMA_COLUMNFAMILIES_CF,
ksName, cfName);
 
-        if (cfDefRow.cf == null || cfDefRow.cf.getColumnCount() == 0)
+        if (cfDefRow.cf == null || !cfDefRow.cf.hasColumns())
             throw new RuntimeException(String.format("%s not found in the schema definitions
keyspace.", ksName + ":" + cfName));
 
         try

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/config/Schema.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/Schema.java b/src/java/org/apache/cassandra/config/Schema.java
index 5c38a78..c606388 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -398,7 +398,7 @@ public class Schema
 
     public static boolean invalidSchemaRow(Row row)
     {
-        return row.cf == null || (row.cf.isMarkedForDelete() && row.cf.getColumnCount()
== 0);
+        return row.cf == null || (row.cf.isMarkedForDelete() && !row.cf.hasColumns());
     }
 
     public static boolean ignoredSchemaRow(Row row)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
index dcdffc8..e04867a 100644
--- a/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
+++ b/src/java/org/apache/cassandra/db/ArrayBackedSortedColumns.java
@@ -248,7 +248,7 @@ public class ArrayBackedSortedColumns extends ColumnFamily
     {
         delete(other.deletionInfo());
 
-        if (other.getColumnCount() == 0)
+        if (!other.hasColumns())
             return;
 
         // In reality, with ABSC being the only remaining container (aside from ABTC), other
will aways be ABSC.
@@ -365,6 +365,11 @@ public class ArrayBackedSortedColumns extends ColumnFamily
         return size;
     }
 
+    public boolean hasColumns()
+    {
+        return size > 0;
+    }
+
     public void clear()
     {
         setDeletionInfo(DeletionInfo.live());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
index a99057f..8cbeb83 100644
--- a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
+++ b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
@@ -347,6 +347,11 @@ public class AtomicBTreeColumns extends ColumnFamily
         return BTree.slice(ref.tree, true).count();
     }
 
+    public boolean hasColumns()
+    {
+        return !BTree.isEmpty(ref.tree);
+    }
+
     public Iterator<Cell> iterator(ColumnSlice[] slices)
     {
         return new ColumnSlice.NavigableSetIterator(new BTreeSet<>(ref.tree, getComparator().columnComparator()),
slices);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/ColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamily.java b/src/java/org/apache/cassandra/db/ColumnFamily.java
index 55315ee..e7aab37 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamily.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamily.java
@@ -245,11 +245,16 @@ public abstract class ColumnFamily implements Iterable<Cell>,
IRowCacheEntry
     public abstract int getColumnCount();
 
     /**
+     * Returns whether or not there are any columns present.
+     */
+    public abstract boolean hasColumns();
+
+    /**
      * Returns true if this contains no columns or deletion info
      */
     public boolean isEmpty()
     {
-        return deletionInfo().isLive() && getColumnCount() == 0;
+        return deletionInfo().isLive() && !hasColumns();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 0a2eb14..d66c501 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1166,7 +1166,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         cf.purgeTombstones(gcBefore);
 
         // if there are no columns or tombstones left, return null
-        return cf.getColumnCount() == 0 && !cf.isMarkedForDelete() ? null : cf;
+        return !cf.hasColumns() && !cf.isMarkedForDelete() ? null : cf;
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/DefsTables.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/DefsTables.java b/src/java/org/apache/cassandra/db/DefsTables.java
index 1a49192..6f1cc69 100644
--- a/src/java/org/apache/cassandra/db/DefsTables.java
+++ b/src/java/org/apache/cassandra/db/DefsTables.java
@@ -201,7 +201,7 @@ public class DefsTables
             ColumnFamily ksAttrs = entry.getValue();
 
             // we don't care about nested ColumnFamilies here because those are going to
be processed separately
-            if (!(ksAttrs.getColumnCount() == 0))
+            if (ksAttrs.hasColumns())
                 addKeyspace(KSMetaData.fromSchema(new Row(entry.getKey(), entry.getValue()),
Collections.<CFMetaData>emptyList(), new UTMetaData()));
         }
 
@@ -221,7 +221,7 @@ public class DefsTables
             ColumnFamily prevValue = entry.getValue().leftValue();
             ColumnFamily newValue = entry.getValue().rightValue();
 
-            if (prevValue.getColumnCount() == 0)
+            if (!prevValue.hasColumns())
             {
                 addKeyspace(KSMetaData.fromSchema(new Row(entry.getKey(), newValue), Collections.<CFMetaData>emptyList(),
new UTMetaData()));
                 continue;
@@ -245,10 +245,10 @@ public class DefsTables
 
             ColumnFamily newState = valueDiff.rightValue();
 
-            if (newState.getColumnCount() == 0)
-                keyspacesToDrop.add(AsciiType.instance.getString(key.key));
-            else
+            if (newState.hasColumns())
                 updateKeyspace(KSMetaData.fromSchema(new Row(key, newState), Collections.<CFMetaData>emptyList(),
new UTMetaData()));
+            else
+                keyspacesToDrop.add(AsciiType.instance.getString(key.key));
         }
 
         return keyspacesToDrop;
@@ -264,7 +264,7 @@ public class DefsTables
         {
             ColumnFamily cfAttrs = entry.getValue();
 
-            if (!(cfAttrs.getColumnCount() == 0))
+            if (cfAttrs.hasColumns())
             {
                Map<String, CFMetaData> cfDefs = KSMetaData.deserializeColumnFamilies(new
Row(entry.getKey(), cfAttrs));
 
@@ -285,12 +285,12 @@ public class DefsTables
 
             Row newRow = new Row(keyspace, newValue);
 
-            if (prevValue.getColumnCount() == 0) // whole keyspace was deleted and now it's
re-created
+            if (!prevValue.hasColumns()) // whole keyspace was deleted and now it's re-created
             {
                 for (CFMetaData cfm : KSMetaData.deserializeColumnFamilies(newRow).values())
                     addColumnFamily(cfm);
             }
-            else if (newValue.getColumnCount() == 0) // whole keyspace is deleted
+            else if (!newValue.hasColumns()) // whole keyspace is deleted
             {
                 for (CFMetaData cfm : KSMetaData.deserializeColumnFamilies(new Row(keyspace,
prevValue)).values())
                     dropColumnFamily(cfm.ksName, cfm.cfName);
@@ -327,7 +327,7 @@ public class DefsTables
         for (Map.Entry<DecoratedKey, ColumnFamily> entry : diff.entriesOnlyOnRight().entrySet())
         {
             ColumnFamily cfTypes = entry.getValue();
-            if (cfTypes.getColumnCount() == 0)
+            if (!cfTypes.hasColumns())
                 continue;
 
             for (UserType ut : UTMetaData.fromSchema(new Row(entry.getKey(), cfTypes)).values())
@@ -340,12 +340,12 @@ public class DefsTables
             ColumnFamily prevCFTypes = modifiedEntry.getValue().leftValue(); // state before
external modification
             ColumnFamily newCFTypes = modifiedEntry.getValue().rightValue(); // updated state
 
-            if (prevCFTypes.getColumnCount() == 0) // whole keyspace was deleted and now
it's re-created
+            if (!prevCFTypes.hasColumns()) // whole keyspace was deleted and now it's re-created
             {
                 for (UserType ut : UTMetaData.fromSchema(new Row(keyspace, newCFTypes)).values())
                     addType(ut);
             }
-            else if (newCFTypes.getColumnCount() == 0) // whole keyspace is deleted
+            else if (!newCFTypes.hasColumns()) // whole keyspace is deleted
             {
                 for (UserType ut : UTMetaData.fromSchema(new Row(keyspace, prevCFTypes)).values())
                     dropType(ut);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/Memtable.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java
index 85ab3df..4cf6654 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -353,18 +353,19 @@ public class Memtable
                 for (Map.Entry<RowPosition, AtomicBTreeColumns> entry : rows.entrySet())
                 {
                     ColumnFamily cf = entry.getValue();
-                    if (cf.isMarkedForDelete())
+
+                    if (cf.isMarkedForDelete() && cf.hasColumns())
                     {
                         // When every node is up, there's no reason to write batchlog data
out to sstables
                         // (which in turn incurs cost like compaction) since the BL write
+ delete cancel each other out,
                         // and BL data is strictly local, so we don't need to preserve tombstones
for repair.
                         // If we have a data row + row level tombstone, then writing it is
effectively an expensive no-op so we skip it.
                         // See CASSANDRA-4667.
-                        if (cfs.name.equals(SystemKeyspace.BATCHLOG_CF) && cfs.keyspace.getName().equals(Keyspace.SYSTEM_KS)
&& !(cf.getColumnCount() == 0))
+                        if (cfs.name.equals(SystemKeyspace.BATCHLOG_CF) && cfs.keyspace.getName().equals(Keyspace.SYSTEM_KS))
                             continue;
                     }
 
-                    if (cf.getColumnCount() > 0 || cf.isMarkedForDelete())
+                    if (!cf.isEmpty())
                         writer.append((DecoratedKey)entry.getKey(), cf);
                 }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/SystemKeyspace.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/SystemKeyspace.java b/src/java/org/apache/cassandra/db/SystemKeyspace.java
index 0273341..a4072d1 100644
--- a/src/java/org/apache/cassandra/db/SystemKeyspace.java
+++ b/src/java/org/apache/cassandra/db/SystemKeyspace.java
@@ -734,7 +734,7 @@ public class SystemKeyspace
                                                         1,
                                                         System.currentTimeMillis());
         ColumnFamily cf = keyspace.getColumnFamilyStore(COUNTER_ID_CF).getColumnFamily(filter);
-        if (cf != null && cf.getColumnCount() != 0)
+        if (cf != null && cf.hasColumns())
             return CounterId.wrap(cf.iterator().next().name().toByteBuffer());
         else
             return null;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
index cd283f0..7add2b8 100644
--- a/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
+++ b/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
@@ -381,7 +381,7 @@ public class SliceQueryFilter implements IDiskAtomFilter
         if (isHeadFilter() && count <= getLiveCount(cf, now))
             return true;
 
-        if (start().isEmpty() || finish().isEmpty() || cf.getColumnCount() == 0)
+        if (start().isEmpty() || finish().isEmpty() || !cf.hasColumns())
             return false;
 
         Composite low = isReversed() ? finish() : start();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java b/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
index e52ab17..9de2bd0 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
@@ -184,7 +184,7 @@ public class CompositesSearcher extends SecondaryIndexSearcher
                                                                              rowsPerQuery,
                                                                              filter.timestamp);
                         ColumnFamily indexRow = index.getIndexCfs().getColumnFamily(indexFilter);
-                        if (indexRow == null || indexRow.getColumnCount() == 0)
+                        if (indexRow == null || !indexRow.hasColumns())
                             return makeReturn(currentKey, data);
 
                         Collection<Cell> sortedCells = indexRow.getSortedColumns();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
index 3ed129f..e93deb5 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
@@ -203,7 +203,7 @@ public class SSTableWriter extends SSTable
 
     public static RowIndexEntry rawAppend(ColumnFamily cf, long startPosition, DecoratedKey
key, DataOutputPlus out) throws IOException
     {
-        assert cf.getColumnCount() > 0 || cf.isMarkedForDelete();
+        assert cf.hasColumns() || cf.isMarkedForDelete();
 
         ColumnIndex.Builder builder = new ColumnIndex.Builder(cf, key.key, out);
         ColumnIndex index = builder.build(cf);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
index 9a94944..6fe47cf 100644
--- a/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
+++ b/src/java/org/apache/cassandra/service/pager/AbstractQueryPager.java
@@ -134,12 +134,12 @@ abstract class AbstractQueryPager implements QueryPager
     {
         for (Row row : result)
         {
-            if (row.cf == null || row.cf.getColumnCount() == 0)
+            if (row.cf == null || !row.cf.hasColumns())
             {
                 List<Row> newResult = new ArrayList<Row>(result.size() - 1);
                 for (Row row2 : result)
                 {
-                    if (row2.cf == null || row2.cf.getColumnCount() == 0)
+                    if (row2.cf == null || !row2.cf.hasColumns())
                         continue;
 
                     newResult.add(row2);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 59578de..b1ad77e 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -285,7 +285,7 @@ public class CassandraServer implements Cassandra.Iface
 
     private List<ColumnOrSuperColumn> thriftifyColumnFamily(ColumnFamily cf, boolean
subcolumnsOnly, boolean reverseOrder, long now)
     {
-        if (cf == null || cf.getColumnCount() == 0)
+        if (cf == null || !cf.hasColumns())
             return EMPTY_COLUMNS;
 
         if (cf.metadata().isSuper())

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index 21f715c..b3f7429 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -140,13 +140,13 @@ public class ColumnFamilyStoreTest extends SchemaLoader
             {
                 QueryFilter sliceFilter = QueryFilter.getSliceFilter(Util.dk("key1"), "Standard2",
Composites.EMPTY, Composites.EMPTY, false, 1, System.currentTimeMillis());
                 ColumnFamily cf = store.getColumnFamily(sliceFilter);
-                assert cf.isMarkedForDelete();
-                assert cf.getColumnCount() == 0;
+                assertTrue(cf.isMarkedForDelete());
+                assertFalse(cf.hasColumns());
 
                 QueryFilter namesFilter = Util.namesQueryFilter(store, Util.dk("key1"), "a");
                 cf = store.getColumnFamily(namesFilter);
-                assert cf.isMarkedForDelete();
-                assert cf.getColumnCount() == 0;
+                assertTrue(cf.isMarkedForDelete());
+                assertFalse(cf.hasColumns());
             }
         };
 
@@ -240,7 +240,7 @@ public class ColumnFamilyStoreTest extends SchemaLoader
         key = new String(rows.get(0).key.key.array(),rows.get(0).key.key.position(),rows.get(0).key.key.remaining());
         assert "k3".equals( key );
 
-        assert rows.get(0).cf.getColumnCount() == 0;
+        assertFalse(rows.get(0).cf.hasColumns());
 
         // query with index hit but rejected by secondary clause, with a small enough count
that just checking count
         // doesn't tell the scan loop that it's done

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/test/unit/org/apache/cassandra/db/RowTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowTest.java b/test/unit/org/apache/cassandra/db/RowTest.java
index 9a91285..f024c44 100644
--- a/test/unit/org/apache/cassandra/db/RowTest.java
+++ b/test/unit/org/apache/cassandra/db/RowTest.java
@@ -20,17 +20,18 @@ package org.apache.cassandra.db;
 
 import java.util.Arrays;
 import java.util.concurrent.TimeUnit;
-
-import org.apache.cassandra.SchemaLoader;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.apache.cassandra.Util.column;
+import com.google.common.util.concurrent.Uninterruptibles;
+
+import org.apache.cassandra.SchemaLoader;
 import org.apache.cassandra.db.composites.*;
 import org.apache.cassandra.utils.ByteBufferUtil;
 
-import com.google.common.util.concurrent.Uninterruptibles;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 
+import static org.apache.cassandra.Util.column;
 
 public class RowTest extends SchemaLoader
 {
@@ -45,7 +46,7 @@ public class RowTest extends SchemaLoader
         cf2.delete(delInfo);
 
         ColumnFamily cfDiff = cf1.diff(cf2);
-        assertEquals(cfDiff.getColumnCount(), 0);
+        assertFalse(cfDiff.hasColumns());
         assertEquals(cfDiff.deletionInfo(), delInfo);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48e8dcc8/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
index 1497b3a..a1679f5 100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
@@ -316,7 +316,7 @@ public class CompactionsTest extends SchemaLoader
         Collection<SSTableReader> sstablesBefore = cfs.getSSTables();
 
         QueryFilter filter = QueryFilter.getIdentityFilter(key, cfname, System.currentTimeMillis());
-        assert !(cfs.getColumnFamily(filter).getColumnCount() == 0);
+        assertTrue(cfs.getColumnFamily(filter).hasColumns());
 
         // Remove key
         rm = new Mutation(KEYSPACE1, key.key);
@@ -324,7 +324,7 @@ public class CompactionsTest extends SchemaLoader
         rm.apply();
 
         ColumnFamily cf = cfs.getColumnFamily(filter);
-        assert cf == null || cf.getColumnCount() == 0 : "should be empty: " + cf;
+        assertTrue("should be empty: " + cf, cf == null || !cf.hasColumns());
 
         // Sleep one second so that the removal is indeed purgeable even with gcgrace ==
0
         Thread.sleep(1000);
@@ -340,7 +340,7 @@ public class CompactionsTest extends SchemaLoader
         Util.compact(cfs, toCompact);
 
         cf = cfs.getColumnFamily(filter);
-        assert cf == null || cf.getColumnCount() == 0 : "should be empty: " + cf;
+        assertTrue("should be empty: " + cf, cf == null || !cf.hasColumns());
     }
 
     private static Range<Token> rangeFor(int start, int end)


Mime
View raw message