cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r960269 - in /cassandra/trunk/src/java/org/apache/cassandra: config/ db/ db/commitlog/ db/migration/ utils/
Date Sat, 03 Jul 2010 20:59:04 GMT
Author: jbellis
Date: Sat Jul  3 20:59:04 2010
New Revision: 960269

URL: http://svn.apache.org/viewvc?rev=960269&view=rev
Log:
avoid frequent autoboxing by leaving cfId an Integer, and similar optimizations.  patch by
Folke Behrens; reviewed by jbellis for CASSANDRA-1247

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
    cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
    cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogHeader.java
    cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
    cassandra/trunk/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/CFMetaData.java Sat Jul  3 20:59:04
2010
@@ -83,9 +83,9 @@ public final class CFMetaData
     /**
      * @return The (ksname,cfname) pair for the given id, or null if it has been dropped.
      */
-    public static final Pair<String,String> getCF(int id)
+    public static final Pair<String,String> getCF(Integer cfId)
     {
-        return cfIdMap.inverse().get(Integer.valueOf(id));
+        return cfIdMap.inverse().get(cfId);
     }
     
     /**
@@ -114,13 +114,13 @@ public final class CFMetaData
     public final double rowCacheSize; // default 0
     public final double keyCacheSize; // default 0.01
     public final double readRepairChance; //chance 0 to 1, of doing a read repair; defaults
1.0 (always)
-    public final int cfId;
+    public final Integer cfId;
     public boolean preloadRowCache;
 
     // BytesToken because byte[].hashCode|equals is inherited from Object.  gggrrr...
     public final Map<ByteArrayKey, ColumnDefinition> column_metadata;
 
-    private CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, ClockType
clockType, AbstractType comparator, AbstractType subcolumnComparator, AbstractReconciler reconciler,
String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double
readRepairChance, int cfId, Map<ByteArrayKey, ColumnDefinition> column_metadata)
+    private CFMetaData(String tableName, String cfName, ColumnFamilyType cfType, ClockType
clockType, AbstractType comparator, AbstractType subcolumnComparator, AbstractReconciler reconciler,
String comment, double rowCacheSize, boolean preloadRowCache, double keyCacheSize, double
readRepairChance, Integer cfId, Map<ByteArrayKey, ColumnDefinition> column_metadata)
     {
         assert column_metadata != null;
         this.tableName = tableName;
@@ -283,7 +283,7 @@ public final class CFMetaData
             .append(rowCacheSize, rhs.rowCacheSize)
             .append(keyCacheSize, rhs.keyCacheSize)
             .append(readRepairChance, rhs.readRepairChance)
-            .append(cfId, rhs.cfId)
+            .append(cfId.intValue(), rhs.cfId.intValue())
             .append(column_metadata, rhs.column_metadata)
             .isEquals();
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Sat Jul 
3 20:59:04 2010
@@ -761,9 +761,9 @@ public class DatabaseDescriptor
         return ksm.cfMetaData().get(cfName);
     }
     
-    public static CFMetaData getCFMetaData(int cfid)
+    public static CFMetaData getCFMetaData(Integer cfId)
     {
-        Pair<String,String> cf = CFMetaData.getCF(cfid);
+        Pair<String,String> cf = CFMetaData.getCF(cfId);
         if (cf == null)
             return null;
         return getCFMetaData(cf.left, cf.right);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java Sat Jul  3 20:59:04
2010
@@ -46,9 +46,9 @@ public class ColumnFamily implements ICo
         return serializer;
     }
 
-    public static ColumnFamily create(int cfid)
+    public static ColumnFamily create(Integer cfId)
     {
-        return create(DatabaseDescriptor.getCFMetaData(cfid));
+        return create(DatabaseDescriptor.getCFMetaData(cfId));
     }
 
     public static ColumnFamily create(String tableName, String cfName)
@@ -63,7 +63,7 @@ public class ColumnFamily implements ICo
         return new ColumnFamily(cfm.cfType, cfm.clockType, cfm.comparator, cfm.subcolumnComparator,
cfm.reconciler, cfm.cfId);
     }
 
-    private final int cfid;
+    private final Integer cfid;
     private final ColumnFamilyType type;
     private final ClockType clockType;
     private final AbstractReconciler reconciler;
@@ -73,7 +73,7 @@ public class ColumnFamily implements ICo
     final AtomicInteger localDeletionTime = new AtomicInteger(Integer.MIN_VALUE);
     private ConcurrentSkipListMap<byte[], IColumn> columns;
 
-    public ColumnFamily(ColumnFamilyType type, ClockType clockType, AbstractType comparator,
AbstractType subcolumnComparator, AbstractReconciler reconciler, int cfid)
+    public ColumnFamily(ColumnFamilyType type, ClockType clockType, AbstractType comparator,
AbstractType subcolumnComparator, AbstractReconciler reconciler, Integer cfid)
     {
         this.type = type;
         this.clockType = clockType;
@@ -119,7 +119,7 @@ public class ColumnFamily implements ICo
         return cf;
     }
 
-    public int id()
+    public Integer id()
     {
         return cfid;
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Sat Jul  3 20:59:04
2010
@@ -107,7 +107,7 @@ public class ColumnFamilyStore implement
     private final String table_;
     public final String columnFamily_;
 
-    private volatile Integer memtableSwitchCount = 0;
+    private volatile int memtableSwitchCount = 0;
 
     /* This is used to generate the next index for a SSTable */
     private AtomicInteger fileIndexGenerator_ = new AtomicInteger(0);
@@ -210,7 +210,7 @@ public class ColumnFamilyStore implement
         ssTables_.add(sstables);
     }
 
-    public void addToCompactedRowStats(Long rowsize)
+    public void addToCompactedRowStats(long rowsize)
     {
         if (minRowCompactedSize < 1 || rowsize < minRowCompactedSize)
             minRowCompactedSize = rowsize;
@@ -379,7 +379,7 @@ public class ColumnFamilyStore implement
                     {
                         // if we're not writing to the commit log, we are replaying the log,
so marking
                         // the log header with "you can discard anything written before the
context" is not valid
-                        final int cfId = DatabaseDescriptor.getTableMetaData(table_).get(columnFamily_).cfId;
+                        final Integer cfId = DatabaseDescriptor.getTableMetaData(table_).get(columnFamily_).cfId;
                         logger_.debug("Discarding {}", cfId);
                         CommitLog.instance().discardCompletedSegments(cfId, ctx);
                     }
@@ -1203,29 +1203,29 @@ public class ColumnFamilyStore implement
 
     public double getBloomFilterFalseRatio()
     {
-        Long falseCount = 0L;
-        Long trueCount = 0L;
+        long falseCount = 0L;
+        long trueCount = 0L;
         for (SSTableReader sstable: getSSTables())
         {
             falseCount += sstable.getBloomFilterFalsePositiveCount();
             trueCount += sstable.getBloomFilterTruePositiveCount();
         }
-        if (falseCount.equals(0L) && trueCount.equals(0L))
+        if (falseCount == 0L && trueCount == 0L)
             return 0d;
-        return falseCount.doubleValue() / (trueCount.doubleValue() + falseCount.doubleValue());
+        return (double) falseCount / (trueCount + falseCount);
     }
 
     public double getRecentBloomFilterFalseRatio()
     {
-        Long falseCount = 0L;
-        Long trueCount = 0L;
+        long falseCount = 0L;
+        long trueCount = 0L;
         for (SSTableReader sstable: getSSTables())
         {
             falseCount += sstable.getRecentBloomFilterFalsePositiveCount();
             trueCount += sstable.getRecentBloomFilterTruePositiveCount();
         }
-        if (falseCount.equals(0L) && trueCount.equals(0L))
+        if (falseCount == 0L && trueCount == 0L)
             return 0d;
-        return falseCount.doubleValue() / (trueCount.doubleValue() + falseCount.doubleValue());
+        return (double) falseCount / (trueCount + falseCount);
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Sat Jul  3 20:59:04 2010
@@ -257,7 +257,7 @@ public class Table 
     }
     
     /** removes a cf from internal structures (doesn't change disk files). */
-    public void dropCf(int cfId) throws IOException
+    public void dropCf(Integer cfId) throws IOException
     {
         assert columnFamilyStores.containsKey(cfId);
         ColumnFamilyStore cfs = columnFamilyStores.remove(cfId);
@@ -279,14 +279,14 @@ public class Table 
     }
     
     /** adds a cf to internal structures, ends up creating disk files). */
-    public void initCf(int cfId, String cfName)
+    public void initCf(Integer cfId, String cfName)
     {
         assert !columnFamilyStores.containsKey(cfId) : cfId;
         columnFamilyStores.put(cfId, ColumnFamilyStore.createColumnFamilyStore(name, cfName));
     }
     
     /** basically a combined drop and add */
-    public void renameCf(int cfId, String newName) throws IOException
+    public void renameCf(Integer cfId, String newName) throws IOException
     {
         dropCf(cfId);
         initCf(cfId, newName);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLog.java Sat Jul  3 20:59:04
2010
@@ -366,7 +366,7 @@ public class CommitLog
      * The bit flag associated with this column family is set in the
      * header and this is used to decide if the log file can be deleted.
     */
-    public void discardCompletedSegments(final int cfId, final CommitLogSegment.CommitLogContext
context) throws IOException
+    public void discardCompletedSegments(final Integer cfId, final CommitLogSegment.CommitLogContext
context) throws IOException
     {
         Callable task = new Callable()
         {
@@ -397,7 +397,7 @@ public class CommitLog
      * param @ id id of the columnFamily being flushed to disk.
      *
     */
-    private void discardCompletedSegmentsInternal(CommitLogSegment.CommitLogContext context,
int id) throws IOException
+    private void discardCompletedSegmentsInternal(CommitLogSegment.CommitLogContext context,
Integer id) throws IOException
     {
         if (logger.isDebugEnabled())
             logger.debug("discard completed log segments for " + context + ", column family
" + id + ".");

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogHeader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogHeader.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogHeader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogHeader.java Sat Jul
 3 20:59:04 2010
@@ -62,23 +62,24 @@ public class CommitLogHeader
         assert cfDirtiedAt.size() <= cfCount;
     }
         
-    boolean isDirty(int cfId)
+    boolean isDirty(Integer cfId)
     {
         return cfDirtiedAt.containsKey(cfId);
     } 
     
-    int getPosition(int index)
+    int getPosition(Integer cfId)
     {
-        Integer x = cfDirtiedAt.get(index);
+        Integer x = cfDirtiedAt.get(cfId);
         return x == null ? 0 : x;
     }
     
-    void turnOn(int cfId, long position)
+    void turnOn(Integer cfId, long position)
     {
+        assert position >= 0 && position <= Integer.MAX_VALUE;
         cfDirtiedAt.put(cfId, (int)position);
     }
 
-    void turnOff(int cfId)
+    void turnOff(Integer cfId)
     {
         cfDirtiedAt.remove(cfId);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/commitlog/CommitLogSegment.java Sat Jul
 3 20:59:04 2010
@@ -96,7 +96,7 @@ public class CommitLogSegment
                 }
                 else
                 {
-                    int id = cfm.cfId;
+                    Integer id = cfm.cfId;
                     if (!header.isDirty(id))
                     {
                         header.turnOn(id, logWriter.getFilePointer());

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/migration/RenameColumnFamily.java Sat
Jul  3 20:59:04 2010
@@ -47,7 +47,7 @@ public class RenameColumnFamily extends 
     private String tableName;
     private String oldName;
     private String newName;
-    private int cfId;
+    private Integer cfId;
     
     RenameColumnFamily(DataInputStream din) throws IOException
     {

Modified: cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java?rev=960269&r1=960268&r2=960269&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/utils/EstimatedHistogram.java Sat Jul  3
20:59:04 2010
@@ -62,7 +62,7 @@ public class EstimatedHistogram
         buckets.incrementAndGet(index);
     }
 
-    public long[] get(Boolean reset)
+    public long[] get(boolean reset)
     {
         long[] rv = new long[numBuckets];
         for (int i = 0; i < numBuckets; i++)



Mime
View raw message