cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r813543 - /incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
Date Thu, 10 Sep 2009 18:48:27 GMT
Author: jbellis
Date: Thu Sep 10 18:48:26 2009
New Revision: 813543

URL: http://svn.apache.org/viewvc?rev=813543&view=rev
Log:
convert ssTables_ to a Set, since the filename is encapsulated in the SSTR object now
patch by jbellis; reviewed by Chris Goffinet for CASSANDRA-414

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=813543&r1=813542&r2=813543&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Thu
Sep 10 18:48:26 2009
@@ -77,7 +77,7 @@
     private AtomicReference<BinaryMemtable> binaryMemtable_;
 
     /* SSTables on disk for this column family */
-    private Map<String, SSTableReader> ssTables_ = new HashMap<String, SSTableReader>();
+    private Set<SSTableReader> ssTables_ = new HashSet<SSTableReader>();
 
     /* Modification lock used for protecting reads from compactions. */
     private ReentrantReadWriteLock sstableLock_ = new ReentrantReadWriteLock(true);
@@ -182,7 +182,7 @@
                 logger_.error("Corrupt file " + filename + "; skipped", ex);
                 continue;
             }
-            ssTables_.put(filename, sstable);
+            ssTables_.add(sstable);
         }
 
         // submit initial check-for-compaction request
@@ -226,7 +226,7 @@
         sb.append("Number of files on disk : " + ssTables_.size());
         sb.append(newLineSeparator);
         double totalSpace = 0d;
-        for (SSTableReader sstable: ssTables_.values())
+        for (SSTableReader sstable: ssTables_)
         {
             File f = new File(sstable.getFilename());
             totalSpace += f.length();
@@ -573,7 +573,7 @@
         sstableLock_.writeLock().lock();
         try
         {
-            ssTables_.put(sstable.getFilename(), sstable);
+            ssTables_.add(sstable);
             ssTableCount = ssTables_.size();
         }
         finally
@@ -660,7 +660,7 @@
     {
         logger_.debug("Checking to see if compaction of " + columnFamily_ + " would be useful");
         int filesCompacted = 0;
-        for (List<SSTableReader> sstables : getCompactionBuckets(ssTables_.values(),
50L * 1024L * 1024L))
+        for (List<SSTableReader> sstables : getCompactionBuckets(ssTables_, 50L * 1024L
* 1024L))
         {
             if (sstables.size() < minThreshold)
             {
@@ -692,7 +692,7 @@
         if (skip > 0L)
         {
             sstables = new ArrayList<SSTableReader>();
-            for (SSTableReader sstable : ssTables_.values())
+            for (SSTableReader sstable : ssTables_)
             {
                 if (sstable.length() < skip * 1024L * 1024L * 1024L)
                 {
@@ -702,7 +702,7 @@
         }
         else
         {
-            sstables = new ArrayList<SSTableReader>(ssTables_.values());
+            sstables = new ArrayList<SSTableReader>(ssTables_);
         }
         doFileCompaction(sstables);
     }
@@ -742,7 +742,7 @@
 
     boolean doAntiCompaction(List<Range> ranges, EndPoint target, List<String>
fileList) throws IOException
     {
-        return doFileAntiCompaction(new ArrayList<SSTableReader>(ssTables_.values()),
ranges, target, fileList);
+        return doFileAntiCompaction(new ArrayList<SSTableReader>(ssTables_), ranges,
target, fileList);
     }
 
     void forceCleanup()
@@ -758,7 +758,7 @@
      */
     void doCleanupCompaction() throws IOException
     {
-        List<SSTableReader> sstables = new ArrayList<SSTableReader>(ssTables_.values());
+        List<SSTableReader> sstables = new ArrayList<SSTableReader>(ssTables_);
         for (SSTableReader sstable : sstables)
         {
             doCleanup(sstable);
@@ -783,7 +783,7 @@
         sstableLock_.writeLock().lock();
         try
         {
-            ssTables_.remove(sstable.getFilename());
+            ssTables_.remove(sstable);
             sstable.delete();
         }
         finally
@@ -1098,12 +1098,12 @@
         {
             if (newfile != null)
             {
-                ssTables_.put(newfile, ssTable);
+                ssTables_.add(ssTable);
                 totalBytesWritten += (new File(newfile)).length();
             }
             for (SSTableReader sstable : sstables)
             {
-                ssTables_.remove(sstable.getFilename());
+                ssTables_.remove(sstable);
                 sstable.delete();
             }
         }
@@ -1240,7 +1240,7 @@
     /** not threadsafe.  caller must have lock_ acquired. */
     public Collection<SSTableReader> getSSTables()
     {
-        return Collections.unmodifiableCollection(ssTables_.values());
+        return Collections.unmodifiableCollection(ssTables_);
     }
 
     public ReentrantReadWriteLock.ReadLock getReadLock()
@@ -1346,7 +1346,7 @@
             }
 
             /* add the SSTables on disk */
-            List<SSTableReader> sstables = new ArrayList<SSTableReader>(ssTables_.values());
+            List<SSTableReader> sstables = new ArrayList<SSTableReader>(ssTables_);
             for (SSTableReader sstable : sstables)
             {
                 iter = filter.getSSTableColumnIterator(sstable);
@@ -1512,7 +1512,7 @@
         sstableLock_.readLock().lock();
         try
         {
-            for (SSTableReader ssTable : new ArrayList<SSTableReader>(ssTables_.values()))
+            for (SSTableReader ssTable : new ArrayList<SSTableReader>(ssTables_))
             {
                 // mkdir
                 File sourceFile = new File(ssTable.getFilename());



Mime
View raw message