cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/2] git commit: cleanup
Date Fri, 31 Aug 2012 13:44:44 GMT
Updated Branches:
  refs/heads/trunk bd2752721 -> d7468ea14


cleanup


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

Branch: refs/heads/trunk
Commit: d7468ea1444ddf9e1616050e46d4832f0a66290d
Parents: fd2ddb5
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Fri Aug 31 08:39:00 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Fri Aug 31 08:44:26 2012 -0500

----------------------------------------------------------------------
 .../apache/cassandra/cache/AutoSavingCache.java    |    3 +--
 .../db/compaction/AbstractCompactionStrategy.java  |    2 +-
 .../compaction/SizeTieredCompactionStrategy.java   |    2 +-
 .../cassandra/db/index/SecondaryIndexSearcher.java |    2 +-
 .../db/marshal/AbstractCompositeType.java          |    2 +-
 .../org/apache/cassandra/db/marshal/BytesType.java |    6 ++----
 .../cassandra/db/marshal/CounterColumnType.java    |    2 +-
 .../org/apache/cassandra/hadoop/ConfigHelper.java  |    2 +-
 .../apache/cassandra/io/sstable/SSTableWriter.java |    8 ++++----
 .../org/apache/cassandra/locator/Ec2Snitch.java    |    2 +-
 .../service/SocketSessionManagementService.java    |    9 ++-------
 src/java/org/apache/cassandra/tools/NodeProbe.java |    2 +-
 .../org/apache/cassandra/db/CounterColumnTest.java |    4 ++--
 .../service/AntiEntropyServiceTestAbstract.java    |    4 ++--
 .../cassandra/streaming/StreamingTransferTest.java |   11 +++++------
 .../org/apache/cassandra/utils/MerkleTreeTest.java |    2 +-
 16 files changed, 27 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/cache/AutoSavingCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
index d7c1cf7..7805340 100644
--- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java
+++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
@@ -232,7 +232,7 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
             logger.debug("Deleting old {} files.", cacheType);
             deleteOldCacheFiles();
 
-            if (keys.size() == 0 || keys.size() == 0)
+            if (keys.isEmpty())
             {
                 logger.debug("Skipping {} save, cache is empty.", cacheType);
                 return;
@@ -248,7 +248,6 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
                 {
                     Pair<String, String> path = key.getPathInfo();
                     SequentialWriter writer = writers.get(path);
-
                     if (writer == null)
                     {
                         writer = tempCacheFile(path);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
index d1160d2..12fdaf3 100644
--- a/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java
@@ -52,7 +52,7 @@ public abstract class AbstractCompactionStrategy
         this.options = options;
 
         String optionValue = options.get(TOMBSTONE_THRESHOLD_KEY);
-        tombstoneThreshold = (null != optionValue) ? Float.parseFloat(optionValue) : DEFAULT_TOMBSTONE_THRESHOLD;
+        tombstoneThreshold = optionValue == null ? DEFAULT_TOMBSTONE_THRESHOLD : Float.parseFloat(optionValue);
 
         // start compactions in five minutes (if no flushes have occurred by then to do so)
         Runnable runnable = new Runnable()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index 3c0c98c..67bdcb4 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -41,7 +41,7 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
         super(cfs, options);
         this.estimatedRemainingTasks = 0;
         String optionValue = options.get(MIN_SSTABLE_SIZE_KEY);
-        minSSTableSize = (null != optionValue) ? Long.parseLong(optionValue) : DEFAULT_MIN_SSTABLE_SIZE;
+        minSSTableSize = optionValue == null ? DEFAULT_MIN_SSTABLE_SIZE : Long.parseLong(optionValue);
         cfs.setCompactionThresholds(cfs.metadata.getMinCompactionThreshold(), cfs.metadata.getMaxCompactionThreshold());
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/index/SecondaryIndexSearcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/SecondaryIndexSearcher.java b/src/java/org/apache/cassandra/db/index/SecondaryIndexSearcher.java
index 1938773..6140a01 100644
--- a/src/java/org/apache/cassandra/db/index/SecondaryIndexSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/SecondaryIndexSearcher.java
@@ -48,7 +48,7 @@ public abstract class SecondaryIndexSearcher
     protected boolean isIndexValueStale(ColumnFamily liveData, ByteBuffer indexedColumnName,
ByteBuffer indexedValue)
     {
         IColumn liveColumn = liveData.getColumn(indexedColumnName);
-        if (null == liveColumn || liveColumn.isMarkedForDelete())
+        if (liveColumn == null || liveColumn.isMarkedForDelete())
             return true;
         
         ByteBuffer liveValue = liveColumn.value();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
index ea24ab1..91b56bd 100644
--- a/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
+++ b/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java
@@ -62,7 +62,7 @@ public abstract class AbstractCompositeType extends AbstractType<ByteBuffer>
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1 == null)
-            return null == o2 ? 0 : -1;
+            return o2 == null ? 0 : -1;
 
         ByteBuffer bb1 = o1.duplicate();
         ByteBuffer bb2 = o2.duplicate();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/marshal/BytesType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/BytesType.java b/src/java/org/apache/cassandra/db/marshal/BytesType.java
index 80c8269..b429b7d 100644
--- a/src/java/org/apache/cassandra/db/marshal/BytesType.java
+++ b/src/java/org/apache/cassandra/db/marshal/BytesType.java
@@ -46,10 +46,8 @@ public class BytesType extends AbstractType<ByteBuffer>
 
     public static int bytesCompare(ByteBuffer o1, ByteBuffer o2)
     {
-        if(null == o1){
-            if(null == o2) return 0;
-            else return -1;
-        }
+        if (o1 == null)
+            return o2 == null ? 0 : -1;
 
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java b/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
index 21cd1af..d4b0384 100644
--- a/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
+++ b/src/java/org/apache/cassandra/db/marshal/CounterColumnType.java
@@ -31,7 +31,7 @@ public class CounterColumnType extends AbstractCommutativeType
     public int compare(ByteBuffer o1, ByteBuffer o2)
     {
         if (o1 == null)
-            return null == o2 ?  0 : -1;
+            return o2 == null ?  0 : -1;
 
         return ByteBufferUtil.compareUnsigned(o1, o2);
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/ConfigHelper.java b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
index 1646635..1374162 100644
--- a/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
+++ b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java
@@ -266,7 +266,7 @@ public class ConfigHelper
     public static KeyRange getInputKeyRange(Configuration conf)
     {
         String str = conf.get(INPUT_KEYRANGE_CONFIG);
-        return null != str ? keyRangeFromString(str) : null;
+        return str == null ? null : keyRangeFromString(str);
     }
 
     private static KeyRange keyRangeFromString(String st)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/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 2ea71d8..898ef4a 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
@@ -135,9 +135,9 @@ public class SSTableWriter extends SSTable
     private RowIndexEntry afterAppend(DecoratedKey decoratedKey, long dataPosition, DeletionInfo
delInfo, ColumnIndex index)
     {
         lastWrittenKey = decoratedKey;
-        this.last = lastWrittenKey;
-        if(null == this.first)
-            this.first = lastWrittenKey;
+        last = lastWrittenKey;
+        if (first == null)
+            first = lastWrittenKey;
 
         if (logger.isTraceEnabled())
             logger.trace("wrote " + decoratedKey + " at " + dataPosition);
@@ -156,7 +156,7 @@ public class SSTableWriter extends SSTable
             long dataStart = dataFile.getFilePointer();
             long dataSize = row.write(dataFile.stream);
             assert dataSize == dataFile.getFilePointer() - (dataStart + 8)
-                    : "incorrect row data size " + dataSize + " written to " + dataFile.getPath()
+ "; correct is " + (dataFile.getFilePointer() - (dataStart + 8));
+                   : "incorrect row data size " + dataSize + " written to " + dataFile.getPath()
+ "; correct is " + (dataFile.getFilePointer() - (dataStart + 8));
         }
         catch (IOException e)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/locator/Ec2Snitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/Ec2Snitch.java b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
index 5eb15a5..729121d 100644
--- a/src/java/org/apache/cassandra/locator/Ec2Snitch.java
+++ b/src/java/org/apache/cassandra/locator/Ec2Snitch.java
@@ -101,7 +101,7 @@ public class Ec2Snitch extends AbstractNetworkTopologySnitch
         if (endpoint.equals(FBUtilities.getBroadcastAddress()))
             return ec2region;
         EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
-        if (null == state || null == state.getApplicationState(ApplicationState.DC))
+        if (state == null || state.getApplicationState(ApplicationState.DC) == null)
             return DEFAULT_DC;
         return state.getApplicationState(ApplicationState.DC).value;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/SocketSessionManagementService.java b/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
index 7cf1703..423d454 100644
--- a/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
+++ b/src/java/org/apache/cassandra/service/SocketSessionManagementService.java
@@ -47,13 +47,8 @@ public class SocketSessionManagementService
 
     public boolean remove(SocketAddress key)
     {
-        assert null != key;
-        boolean retval = false;
-        if (null != activeSocketSessions.remove(key))
-        {
-            retval = true;
-        }
-        return retval;
+        assert key != null;
+        return activeSocketSessions.remove(key) != null;
     }
 
     public void clear()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index 2d57911..c3db63c 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -86,7 +86,7 @@ public class NodeProbe
      */
     public NodeProbe(String host, int port, String username, String password) throws IOException,
InterruptedException
     {
-        assert username != null && !username.isEmpty() && null != password
&& !password.isEmpty()
+        assert username != null && !username.isEmpty() && password != null
&& !password.isEmpty()
                : "neither username nor password can be blank";
 
         this.host = host;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/test/unit/org/apache/cassandra/db/CounterColumnTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/CounterColumnTest.java b/test/unit/org/apache/cassandra/db/CounterColumnTest.java
index 5eda279..85a2325 100644
--- a/test/unit/org/apache/cassandra/db/CounterColumnTest.java
+++ b/test/unit/org/apache/cassandra/db/CounterColumnTest.java
@@ -231,7 +231,7 @@ public class CounterColumnTest extends SchemaLoader
 
         leftCol  = new CounterColumn(ByteBufferUtil.bytes("x"), left.context,  1L);
         rightCol = new CounterColumn(ByteBufferUtil.bytes("x"), right.context, 1L);
-        assert null == leftCol.diff(rightCol);
+        assert leftCol.diff(rightCol) == null;
 
         // greater than: left has superset of nodes (counts equal)
         left = ContextState.allocate(4, 0, allocator);
@@ -247,7 +247,7 @@ public class CounterColumnTest extends SchemaLoader
 
         leftCol  = new CounterColumn(ByteBufferUtil.bytes("x"), left.context,  1L);
         rightCol = new CounterColumn(ByteBufferUtil.bytes("x"), right.context, 1L);
-        assert null == leftCol.diff(rightCol);
+        assert leftCol.diff(rightCol) == null;
 
         // less than: right has subset of nodes (counts equal)
         assert leftCol == rightCol.diff(leftCol);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/test/unit/org/apache/cassandra/service/AntiEntropyServiceTestAbstract.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/service/AntiEntropyServiceTestAbstract.java b/test/unit/org/apache/cassandra/service/AntiEntropyServiceTestAbstract.java
index 68b34b4..acf5173 100644
--- a/test/unit/org/apache/cassandra/service/AntiEntropyServiceTestAbstract.java
+++ b/test/unit/org/apache/cassandra/service/AntiEntropyServiceTestAbstract.java
@@ -139,7 +139,7 @@ public abstract class AntiEntropyServiceTestAbstract extends SchemaLoader
 
         // confirm that the tree was validated
         Token min = validator.tree.partitioner().getMinimumToken();
-        assert null != validator.tree.hash(new Range<Token>(min, min));
+        assert validator.tree.hash(new Range<Token>(min, min)) != null;
     }
 
     @Test
@@ -156,7 +156,7 @@ public abstract class AntiEntropyServiceTestAbstract extends SchemaLoader
         validator.completeTree();
 
         // confirm that the tree was validated
-        assert null != validator.tree.hash(local_range);
+        assert validator.tree.hash(local_range) != null;
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
index 1be057e..390dcbb 100644
--- a/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
+++ b/test/unit/org/apache/cassandra/streaming/StreamingTransferTest.java
@@ -96,8 +96,7 @@ public class StreamingTransferTest extends SchemaLoader
         {
             String key = "key" + offs[i];
             String col = "col" + offs[i];
-            assert null != cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk(key),
-                                               new QueryPath(cfs.columnFamily)));
+            assert cfs.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk(key), new QueryPath(cfs.columnFamily)))
!= null;
             assert rows.get(i).key.key.equals(ByteBufferUtil.bytes(key));
             assert rows.get(i).cf.getColumn(ByteBufferUtil.bytes(col)) != null;
         }
@@ -275,10 +274,10 @@ public class StreamingTransferTest extends SchemaLoader
         assert rows.get(1).cf.getColumnCount() == 1;
 
         // these keys fall outside of the ranges and should not be transferred
-        assert null == cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("transfer1"),
new QueryPath("Standard1")));
-        assert null == cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("transfer2"),
new QueryPath("Standard1")));
-        assert null == cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("test2"),
new QueryPath("Standard1")));
-        assert null == cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("test3"),
new QueryPath("Standard1")));
+        assert cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("transfer1"),
new QueryPath("Standard1"))) == null;
+        assert cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("transfer2"),
new QueryPath("Standard1"))) == null;
+        assert cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("test2"), new
QueryPath("Standard1"))) == null;
+        assert cfstore.getColumnFamily(QueryFilter.getIdentityFilter(Util.dk("test3"), new
QueryPath("Standard1"))) == null;
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d7468ea1/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
index abf8630..d117426 100644
--- a/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
+++ b/test/unit/org/apache/cassandra/utils/MerkleTreeTest.java
@@ -332,7 +332,7 @@ public class MerkleTreeTest
         for (TreeRange range : ranges)
             range.addHash(new RowHash(range.right, new byte[0]));
 
-        assert null != mt.hash(new Range(tok(-1), tok(-1))) :
+        assert mt.hash(new Range(tok(-1), tok(-1))) != null :
             "Could not hash tree " + mt;
     }
 


Mime
View raw message