cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject git commit: replace "new Pair with Pair.create to take advantage of type inference
Date Mon, 03 Sep 2012 15:35:41 GMT
Updated Branches:
  refs/heads/trunk 94b3d2601 -> 7af7eb31e


replace "new Pair with Pair.create to take advantage of type inference


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

Branch: refs/heads/trunk
Commit: 7af7eb31ef98f33a0c6864586ff91cdef669afdb
Parents: 94b3d26
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Mon Sep 3 10:35:27 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Mon Sep 3 10:35:27 2012 -0500

----------------------------------------------------------------------
 .../org/apache/cassandra/cache/KeyCacheKey.java    |    2 +-
 src/java/org/apache/cassandra/config/Schema.java   |    6 ++--
 .../compaction/SizeTieredCompactionStrategy.java   |    2 +-
 src/java/org/apache/cassandra/dht/Bounds.java      |    2 +-
 .../org/apache/cassandra/dht/ExcludingBounds.java  |    2 +-
 .../cassandra/dht/IncludingExcludingBounds.java    |    2 +-
 src/java/org/apache/cassandra/dht/Range.java       |    2 +-
 .../cassandra/hadoop/ColumnFamilyRecordReader.java |    2 +-
 .../cassandra/hadoop/ColumnFamilyRecordWriter.java |    2 +-
 .../org/apache/cassandra/io/sstable/Component.java |    2 +-
 .../apache/cassandra/io/sstable/Descriptor.java    |    2 +-
 .../apache/cassandra/io/sstable/SSTableReader.java |    4 +-
 .../apache/cassandra/locator/TokenMetadata.java    |    4 +-
 .../org/apache/cassandra/service/CacheService.java |    2 +-
 .../service/RangeSliceResponseResolver.java        |    2 +-
 .../apache/cassandra/service/StorageService.java   |    3 +-
 .../apache/cassandra/streaming/PendingFile.java    |    2 +-
 .../cassandra/streaming/StreamInSession.java       |    4 +-
 .../cassandra/streaming/StreamOutSession.java      |    4 +-
 .../compress/CompressedFileStreamTask.java         |    6 ++--
 src/java/org/apache/cassandra/tools/NodeCmd.java   |   18 +++++++-------
 .../org/apache/cassandra/utils/ExpiringMap.java    |    2 +-
 .../org/apache/cassandra/utils/FBUtilities.java    |    3 +-
 src/java/org/apache/cassandra/utils/Pair.java      |    2 +-
 .../SizeTieredCompactionStrategyTest.java          |    6 ++--
 .../apache/cassandra/streaming/BootstrapTest.java  |    2 +-
 .../cassandra/streaming/SerializationsTest.java    |    2 +-
 27 files changed, 45 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/cache/KeyCacheKey.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/KeyCacheKey.java b/src/java/org/apache/cassandra/cache/KeyCacheKey.java
index bee88e8..a553ba9 100644
--- a/src/java/org/apache/cassandra/cache/KeyCacheKey.java
+++ b/src/java/org/apache/cassandra/cache/KeyCacheKey.java
@@ -39,7 +39,7 @@ public class KeyCacheKey implements CacheKey
 
     public Pair<String, String> getPathInfo()
     {
-        return new Pair<String, String>(desc.ksname, desc.cfname);
+        return Pair.create(desc.ksname, desc.cfname);
     }
 
     public String toString()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/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 d4ace31..dd16b4b 100644
--- a/src/java/org/apache/cassandra/config/Schema.java
+++ b/src/java/org/apache/cassandra/config/Schema.java
@@ -379,7 +379,7 @@ public class Schema
      */
     public UUID getId(String ksName, String cfName)
     {
-        return cfIdMap.get(new Pair<String, String>(ksName, cfName));
+        return cfIdMap.get(Pair.create(ksName, cfName));
     }
 
     /**
@@ -392,7 +392,7 @@ public class Schema
      */
     public void load(CFMetaData cfm)
     {
-        Pair<String, String> key = new Pair<String, String>(cfm.ksName, cfm.cfName);
+        Pair<String, String> key = Pair.create(cfm.ksName, cfm.cfName);
 
         if (cfIdMap.containsKey(key))
             throw new RuntimeException(String.format("Attempting to load already loaded column
family %s.%s", cfm.ksName, cfm.cfName));
@@ -408,7 +408,7 @@ public class Schema
      */
     public void purge(CFMetaData cfm)
     {
-        cfIdMap.remove(new Pair<String, String>(cfm.ksName, cfm.cfName));
+        cfIdMap.remove(Pair.create(cfm.ksName, cfm.cfName));
     }
 
     /* Version control */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/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 67bdcb4..6b9715e 100644
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@ -134,7 +134,7 @@ public class SizeTieredCompactionStrategy extends AbstractCompactionStrategy
     {
         List<Pair<SSTableReader, Long>> tableLengthPairs = new ArrayList<Pair<SSTableReader,
Long>>(collection.size());
         for(SSTableReader table: collection)
-            tableLengthPairs.add(new Pair<SSTableReader, Long>(table, table.onDiskLength()));
+            tableLengthPairs.add(Pair.create(table, table.onDiskLength()));
         return tableLengthPairs;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/dht/Bounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Bounds.java b/src/java/org/apache/cassandra/dht/Bounds.java
index 5a6cdb9..7da30bc 100644
--- a/src/java/org/apache/cassandra/dht/Bounds.java
+++ b/src/java/org/apache/cassandra/dht/Bounds.java
@@ -58,7 +58,7 @@ public class Bounds<T extends RingPosition> extends AbstractBounds<T>
 
         AbstractBounds<T> lb = new Bounds<T>(left, position, partitioner);
         AbstractBounds<T> rb = new Range<T>(position, right, partitioner);
-        return new Pair<AbstractBounds<T>, AbstractBounds<T>>(lb, rb);
+        return Pair.create(lb, rb);
     }
 
     public boolean intersects(Bounds<T> that)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/dht/ExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/ExcludingBounds.java b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
index cbe5f9b..0bde8f1 100644
--- a/src/java/org/apache/cassandra/dht/ExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/ExcludingBounds.java
@@ -53,7 +53,7 @@ public class ExcludingBounds<T extends RingPosition> extends AbstractBounds<T>
             return null;
         AbstractBounds<T> lb = new Range<T>(left, position, partitioner);
         AbstractBounds<T> rb = new ExcludingBounds<T>(position, right, partitioner);
-        return new Pair<AbstractBounds<T>, AbstractBounds<T>>(lb, rb);
+        return Pair.create(lb, rb);
     }
 
     public List<? extends AbstractBounds<T>> unwrap()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
index a4d0de3..9c0f6dd 100644
--- a/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
+++ b/src/java/org/apache/cassandra/dht/IncludingExcludingBounds.java
@@ -52,7 +52,7 @@ public class IncludingExcludingBounds<T extends RingPosition> extends
AbstractBo
         assert contains(position);
         AbstractBounds<T> lb = new Bounds<T>(left, position, partitioner);
         AbstractBounds<T> rb = new ExcludingBounds<T>(position, right, partitioner);
-        return new Pair<AbstractBounds<T>, AbstractBounds<T>>(lb, rb);
+        return Pair.create(lb, rb);
     }
 
     public List<? extends AbstractBounds<T>> unwrap()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/dht/Range.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/dht/Range.java b/src/java/org/apache/cassandra/dht/Range.java
index eaa9e95..f32c938 100644
--- a/src/java/org/apache/cassandra/dht/Range.java
+++ b/src/java/org/apache/cassandra/dht/Range.java
@@ -224,7 +224,7 @@ public class Range<T extends RingPosition> extends AbstractBounds<T>
implements
 
         AbstractBounds<T> lb = new Range<T>(left, position, partitioner);
         AbstractBounds<T> rb = new Range<T>(position, right, partitioner);
-        return new Pair<AbstractBounds<T>, AbstractBounds<T>>(lb, rb);
+        return Pair.create(lb, rb);
     }
 
     public List<Range<T>> unwrap()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
index c23f290..db284ec 100644
--- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
+++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
@@ -406,7 +406,7 @@ public class ColumnFamilyRecordReader extends RecordReader<ByteBuffer,
SortedMap
                 IColumn column = unthriftify(cosc);
                 map.put(column.name(), column);
             }
-            return new Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>>(ks.key,
map);
+            return Pair.create(ks.key, map);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java
index 74fde20..3b66976 100644
--- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java
+++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordWriter.java
@@ -137,7 +137,7 @@ implements org.apache.hadoop.mapred.RecordWriter<ByteBuffer,List<Mutation>>
         }
 
         for (Mutation amut : value)
-            client.put(new Pair<ByteBuffer,Mutation>(keybuff, amut));
+            client.put(Pair.create(keybuff, amut));
             progressable.progress();
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/io/sstable/Component.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Component.java b/src/java/org/apache/cassandra/io/sstable/Component.java
index 7da961b..7a001ab 100644
--- a/src/java/org/apache/cassandra/io/sstable/Component.java
+++ b/src/java/org/apache/cassandra/io/sstable/Component.java
@@ -132,7 +132,7 @@ public class Component
                  throw new IllegalStateException();
         }
 
-        return new Pair<Descriptor,Component>(path.left, component);
+        return Pair.create(path.left, component);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/io/sstable/Descriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Descriptor.java b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
index 4f776d6..b173bac 100644
--- a/src/java/org/apache/cassandra/io/sstable/Descriptor.java
+++ b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
@@ -277,7 +277,7 @@ public class Descriptor
         // component suffix
         String component = st.nextToken();
         directory = directory != null ? directory : new File(".");
-        return new Pair<Descriptor,String>(new Descriptor(version, directory, ksname,
cfname, generation, temporary), component);
+        return Pair.create(new Descriptor(version, directory, ksname, cfname, generation,
temporary), component);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index 0968e12..ae49928 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -589,7 +589,7 @@ public class SSTableReader extends SSTable
             if (left > right)
                 // empty range
                 continue;
-            positions.add(new Pair(Integer.valueOf(left), Integer.valueOf(right)));
+            positions.add(Pair.create(Integer.valueOf(left), Integer.valueOf(right)));
         }
         return positions;
     }
@@ -670,7 +670,7 @@ public class SSTableReader extends SSTable
             if (left == right)
                 // empty range
                 continue;
-            positions.add(new Pair(Long.valueOf(left), Long.valueOf(right)));
+            positions.add(Pair.create(Long.valueOf(left), Long.valueOf(right)));
         }
         return positions;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/locator/TokenMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java
index f606475..582ad10 100644
--- a/src/java/org/apache/cassandra/locator/TokenMetadata.java
+++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java
@@ -340,7 +340,7 @@ public class TokenMetadata
 
         try
         {
-            movingEndpoints.add(new Pair<Token, InetAddress>(token, endpoint));
+            movingEndpoints.add(Pair.create(token, endpoint));
         }
         finally
         {
@@ -959,7 +959,7 @@ public class TokenMetadata
                 dcRacks.put(dc, HashMultimap.<String, InetAddress>create());
             dcRacks.get(dc).put(rack, ep);
 
-            currentLocations.put(ep, new Pair<String, String>(dc, rack));
+            currentLocations.put(ep, Pair.create(dc, rack));
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/service/CacheService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CacheService.java b/src/java/org/apache/cassandra/service/CacheService.java
index 0ed8002..2342cac 100644
--- a/src/java/org/apache/cassandra/service/CacheService.java
+++ b/src/java/org/apache/cassandra/service/CacheService.java
@@ -331,7 +331,7 @@ public class CacheService implements CacheServiceMBean
                 {
                     DecoratedKey key = cfs.partitioner.decorateKey(buffer);
                     ColumnFamily data = cfs.getTopLevelColumns(QueryFilter.getIdentityFilter(key,
new QueryPath(cfs.columnFamily)), Integer.MIN_VALUE, true);
-                    return new Pair<RowCacheKey, IRowCacheEntry>(new RowCacheKey(cfs.metadata.cfId,
key), data);
+                    return Pair.create(new RowCacheKey(cfs.metadata.cfId, key), data);
                 }
             });
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java b/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
index 20ebddd..456dff7 100644
--- a/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
+++ b/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
@@ -111,7 +111,7 @@ public class RangeSliceResponseResolver implements IResponseResolver<RangeSliceR
 
         protected Pair<Row,InetAddress> computeNext()
         {
-            return iter.hasNext() ? new Pair<Row, InetAddress>(iter.next(), source)
: endOfData();
+            return iter.hasNext() ? Pair.create(iter.next(), source) : endOfData();
         }
 
         public void close() {}

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 9d7b481..0c6e7df 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -49,7 +49,6 @@ import org.apache.cassandra.io.sstable.SSTableDeletingTask;
 import org.apache.cassandra.io.sstable.SSTableLoader;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.locator.*;
-import org.apache.cassandra.metrics.ClientRequestMetrics;
 import org.apache.cassandra.metrics.StorageMetrics;
 import org.apache.cassandra.net.IAsyncResult;
 import org.apache.cassandra.net.MessageOut;
@@ -3219,7 +3218,7 @@ public class StorageService implements IEndpointStateChangeSubscriber,
StorageSe
             }
         }
 
-        return new Pair<Set<Range<Token>>, Set<Range<Token>>>(toStream,
toFetch);
+        return Pair.create(toStream, toFetch);
     }
 
     public void bulkLoad(String directory)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/streaming/PendingFile.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/PendingFile.java b/src/java/org/apache/cassandra/streaming/PendingFile.java
index 880eed9..3597b6c 100644
--- a/src/java/org/apache/cassandra/streaming/PendingFile.java
+++ b/src/java/org/apache/cassandra/streaming/PendingFile.java
@@ -153,7 +153,7 @@ public class PendingFile
             int count = dis.readInt();
             List<Pair<Long,Long>> sections = new ArrayList<Pair<Long,Long>>(count);
             for (int i = 0; i < count; i++)
-                sections.add(new Pair<Long,Long>(dis.readLong(), dis.readLong()));
+                sections.add(Pair.create(dis.readLong(), dis.readLong()));
             // this controls the way indexes are rebuilt when streaming in.
             OperationType type = OperationType.RESTORE_REPLICA_COUNT;
             type = OperationType.valueOf(dis.readUTF());

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/streaming/StreamInSession.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamInSession.java b/src/java/org/apache/cassandra/streaming/StreamInSession.java
index cfa7d0b..47a8896 100644
--- a/src/java/org/apache/cassandra/streaming/StreamInSession.java
+++ b/src/java/org/apache/cassandra/streaming/StreamInSession.java
@@ -82,7 +82,7 @@ public class StreamInSession extends AbstractStreamSession
 
     public static StreamInSession create(InetAddress host, IStreamCallback callback)
     {
-        Pair<InetAddress, Long> context = new Pair<InetAddress, Long>(host, nextSessionId());
+        Pair<InetAddress, Long> context = Pair.create(host, nextSessionId());
         StreamInSession session = new StreamInSession(context, callback);
         sessions.put(context, session);
         return session;
@@ -90,7 +90,7 @@ public class StreamInSession extends AbstractStreamSession
 
     public static StreamInSession get(InetAddress host, long sessionId)
     {
-        Pair<InetAddress, Long> context = new Pair<InetAddress, Long>(host, sessionId);
+        Pair<InetAddress, Long> context = Pair.create(host, sessionId);
         StreamInSession session = sessions.get(context);
         if (session == null)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/streaming/StreamOutSession.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamOutSession.java b/src/java/org/apache/cassandra/streaming/StreamOutSession.java
index 504c15d..e1f42dc 100644
--- a/src/java/org/apache/cassandra/streaming/StreamOutSession.java
+++ b/src/java/org/apache/cassandra/streaming/StreamOutSession.java
@@ -71,7 +71,7 @@ public class StreamOutSession extends AbstractStreamSession
 
     public static StreamOutSession create(String table, InetAddress host, long sessionId,
IStreamCallback callback)
     {
-        Pair<InetAddress, Long> context = new Pair<InetAddress, Long>(host, sessionId);
+        Pair<InetAddress, Long> context = Pair.create(host, sessionId);
         StreamOutSession session = new StreamOutSession(table, context, callback);
         streams.put(context, session);
         return session;
@@ -79,7 +79,7 @@ public class StreamOutSession extends AbstractStreamSession
 
     public static StreamOutSession get(InetAddress host, long sessionId)
     {
-        return streams.get(new Pair<InetAddress, Long>(host, sessionId));
+        return streams.get(Pair.create(host, sessionId));
     }
 
     private final Map<String, PendingFile> files = new NonBlockingHashMap<String,
PendingFile>();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/streaming/compress/CompressedFileStreamTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/compress/CompressedFileStreamTask.java
b/src/java/org/apache/cassandra/streaming/compress/CompressedFileStreamTask.java
index 398599f..dda9d7d 100644
--- a/src/java/org/apache/cassandra/streaming/compress/CompressedFileStreamTask.java
+++ b/src/java/org/apache/cassandra/streaming/compress/CompressedFileStreamTask.java
@@ -134,17 +134,17 @@ public class CompressedFileStreamTask extends FileStreamTask
                 if (chunk.offset == lastSection.right)
                 {
                     // extend previous section to end of this chunk
-                    lastSection = new Pair<Long, Long>(lastSection.left, chunk.offset
+ chunk.length + 4); // 4 bytes for CRC
+                    lastSection = Pair.create(lastSection.left, chunk.offset + chunk.length
+ 4); // 4 bytes for CRC
                 }
                 else
                 {
                     transferSections.add(lastSection);
-                    lastSection = new Pair<Long, Long>(chunk.offset, chunk.offset +
chunk.length + 4);
+                    lastSection = Pair.create(chunk.offset, chunk.offset + chunk.length +
4);
                 }
             }
             else
             {
-                lastSection = new Pair<Long, Long>(chunk.offset, chunk.offset + chunk.length
+ 4);
+                lastSection = Pair.create(chunk.offset, chunk.offset + chunk.length + 4);
             }
         }
         if (lastSection != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index 554fba2..409716a 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -49,15 +49,15 @@ import org.apache.cassandra.utils.Pair;
 
 public class NodeCmd
 {
-    private static final Pair<String, String> SNAPSHOT_COLUMNFAMILY_OPT = new Pair<String,
String>("cf", "column-family");
-    private static final Pair<String, String> HOST_OPT = new Pair<String, String>("h",
"host");
-    private static final Pair<String, String> PORT_OPT = new Pair<String, String>("p",
"port");
-    private static final Pair<String, String> USERNAME_OPT = new Pair<String, String>("u",
 "username");
-    private static final Pair<String, String> PASSWORD_OPT = new Pair<String, String>("pw",
"password");
-    private static final Pair<String, String> TAG_OPT = new Pair<String, String>("t",
"tag");
-    private static final Pair<String, String> TOKENS_OPT = new Pair<String, String>("T",
"tokens");
-    private static final Pair<String, String> PRIMARY_RANGE_OPT = new Pair<String,
String>("pr", "partitioner-range");
-    private static final Pair<String, String> SNAPSHOT_REPAIR_OPT = new Pair<String,
String>("snapshot", "with-snapshot");
+    private static final Pair<String, String> SNAPSHOT_COLUMNFAMILY_OPT = Pair.create("cf",
"column-family");
+    private static final Pair<String, String> HOST_OPT = Pair.create("h", "host");
+    private static final Pair<String, String> PORT_OPT = Pair.create("p", "port");
+    private static final Pair<String, String> USERNAME_OPT = Pair.create("u", "username");
+    private static final Pair<String, String> PASSWORD_OPT = Pair.create("pw", "password");
+    private static final Pair<String, String> TAG_OPT = Pair.create("t", "tag");
+    private static final Pair<String, String> TOKENS_OPT = Pair.create("T", "tokens");
+    private static final Pair<String, String> PRIMARY_RANGE_OPT = Pair.create("pr",
"partitioner-range");
+    private static final Pair<String, String> SNAPSHOT_REPAIR_OPT = Pair.create("snapshot",
"with-snapshot");
 
     private static final String DEFAULT_HOST = "127.0.0.1";
     private static final int DEFAULT_PORT = 7199;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/utils/ExpiringMap.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/ExpiringMap.java b/src/java/org/apache/cassandra/utils/ExpiringMap.java
index d561fc9..2eade07 100644
--- a/src/java/org/apache/cassandra/utils/ExpiringMap.java
+++ b/src/java/org/apache/cassandra/utils/ExpiringMap.java
@@ -91,7 +91,7 @@ public class ExpiringMap<K, V>
                         cache.remove(entry.getKey());
                         n++;
                         if (postExpireHook != null)
-                            postExpireHook.apply(new Pair<K, CacheableObject<V>>(entry.getKey(),
entry.getValue()));
+                            postExpireHook.apply(Pair.create(entry.getKey(), entry.getValue()));
                     }
                 }
                 logger.trace("Expired {} entries", n);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/utils/FBUtilities.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/FBUtilities.java b/src/java/org/apache/cassandra/utils/FBUtilities.java
index 04a832a..fcfdd2b 100644
--- a/src/java/org/apache/cassandra/utils/FBUtilities.java
+++ b/src/java/org/apache/cassandra/utils/FBUtilities.java
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
 import com.google.common.base.Joiner;
-import com.google.common.base.Throwables;
 import com.google.common.collect.AbstractIterator;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
@@ -175,7 +174,7 @@ public class FBUtilities
             remainder = distance.testBit(0);
             midpoint = distance.shiftRight(1).add(left).mod(max);
         }
-        return new Pair<BigInteger, Boolean>(midpoint, remainder);
+        return Pair.create(midpoint, remainder);
     }
 
     public static int compareUnsigned(byte[] bytes1, byte[] bytes2, int offset1, int offset2,
int len1, int len2)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/src/java/org/apache/cassandra/utils/Pair.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/Pair.java b/src/java/org/apache/cassandra/utils/Pair.java
index a14a9b8..c654176 100644
--- a/src/java/org/apache/cassandra/utils/Pair.java
+++ b/src/java/org/apache/cassandra/utils/Pair.java
@@ -24,7 +24,7 @@ public class Pair<T1, T2>
     public final T1 left;
     public final T2 right;
 
-    public Pair(T1 left, T2 right)
+    private Pair(T1 left, T2 right)
     {
         this.left = left;
         this.right = right;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/test/unit/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyTest.java
b/test/unit/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyTest.java
index e1ded7c..89e0a6a 100644
--- a/test/unit/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyTest.java
@@ -33,7 +33,7 @@ public class SizeTieredCompactionStrategyTest
         String[] strings = { "a", "bbbb", "cccccccc", "cccccccc", "bbbb", "a" };
         for (String st : strings)
         {
-            Pair<String, Long> pair = new Pair<String, Long>(st, new Long(st.length()));
+            Pair<String, Long> pair = Pair.create(st, new Long(st.length()));
             pairs.add(pair);
         }
 
@@ -53,7 +53,7 @@ public class SizeTieredCompactionStrategyTest
         String[] strings2 = { "aaa", "bbbbbbbb", "aaa", "bbbbbbbb", "bbbbbbbb", "aaa" };
         for (String st : strings2)
         {
-            Pair<String, Long> pair = new Pair<String, Long>(st, new Long(st.length()));
+            Pair<String, Long> pair = Pair.create(st, new Long(st.length()));
             pairs.add(pair);
         }
 
@@ -74,7 +74,7 @@ public class SizeTieredCompactionStrategyTest
         String[] strings3 = { "aaa", "bbbbbbbb", "aaa", "bbbbbbbb", "bbbbbbbb", "aaa" };
         for (String st : strings3)
         {
-            Pair<String, Long> pair = new Pair<String, Long>(st, new Long(st.length()));
+            Pair<String, Long> pair = Pair.create(st, new Long(st.length()));
             pairs.add(pair);
         }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/BootstrapTest.java b/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
index 20313f0..83e0470 100644
--- a/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
+++ b/test/unit/org/apache/cassandra/streaming/BootstrapTest.java
@@ -38,7 +38,7 @@ public class BootstrapTest extends SchemaLoader
     {
         Descriptor desc = Descriptor.fromFilename(new File("Keyspace1", "Keyspace1-Standard1-ia-500-Data.db").toString());
         // assert !desc.isLatestVersion; // minimum compatible version -- for now it is the
latest as well
-        PendingFile inContext = new PendingFile(null, desc, "Data.db", Arrays.asList(new
Pair<Long,Long>(0L, 1L)), OperationType.BOOTSTRAP);
+        PendingFile inContext = new PendingFile(null, desc, "Data.db", Arrays.asList(Pair.create(0L,
1L)), OperationType.BOOTSTRAP);
 
         PendingFile outContext = StreamIn.getContextMapping(inContext);
         // filename and generation are expected to have changed

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7af7eb31/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/streaming/SerializationsTest.java b/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
index 13493f9..95a7d8b 100644
--- a/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
+++ b/test/unit/org/apache/cassandra/streaming/SerializationsTest.java
@@ -153,7 +153,7 @@ public class SerializationsTest extends AbstractSerializationsTester
         Descriptor desc = new Descriptor("z", new File("path/doesn't/matter"), "Keyspace1",
"Standard1", 23, false);
         List<Pair<Long, Long>> sections = new ArrayList<Pair<Long, Long>>();
         for (int i = 0; i < numSecs; i++)
-            sections.add(new Pair<Long, Long>(new Long(i), new Long(i * i)));
+            sections.add(Pair.create(new Long(i), new Long(i * i)));
         return new PendingFile(sst ? makeSSTable() : null, desc, SSTable.COMPONENT_DATA,
sections, op);
     }
 


Mime
View raw message