cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r893618 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: db/CompactionManager.java io/CompactionIterator.java
Date Wed, 23 Dec 2009 20:05:53 GMT
Author: jbellis
Date: Wed Dec 23 20:05:53 2009
New Revision: 893618

URL: http://svn.apache.org/viewvc?rev=893618&view=rev
Log:
fix bad merge; add overrideable CompactionIterator.getScanners for cleaner subclassing.  patch
by jbellis

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java?rev=893618&r1=893617&r2=893618&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactionManager.java Wed
Dec 23 20:05:53 2009
@@ -509,6 +509,8 @@
 
     private static class AntiCompactionIterator extends CompactionIterator
     {
+        private Set<SSTableScanner> scanners;
+
         public AntiCompactionIterator(Collection<SSTableReader> sstables, Collection<Range>
ranges, int gcBefore, boolean isMajor)
                 throws IOException
         {
@@ -534,12 +536,17 @@
             return iter;
         }
 
-        public void close() throws IOException
+        public Iterable<SSTableScanner> getScanners()
         {
-            for (Object o : ((CollatingIterator)source).getIterators())
+            if (scanners == null)
             {
-                ((SSTableScanner)((FilterIterator)o).getIterator()).close();
+                scanners = new HashSet<SSTableScanner>();
+                for (Object o : ((CollatingIterator)source).getIterators())
+                {
+                    scanners.add((SSTableScanner)((FilterIterator)o).getIterator());
+                }
             }
+            return scanners;
         }
     }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java?rev=893618&r1=893617&r2=893618&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/CompactionIterator.java Wed
Dec 23 20:05:53 2009
@@ -53,7 +53,6 @@
 
     public CompactionIterator(Iterable<SSTableReader> sstables, int gcBefore, boolean
major) throws IOException
     {
-<<<<<<< HEAD
         this(getCollatingIterator(sstables), gcBefore, major);
     }
 
@@ -61,15 +60,12 @@
     protected CompactionIterator(Iterator iter, int gcBefore, boolean major)
     {
         super(iter);
-=======
-        super(getCollatingIterator(sstables));
         row = 0;
         totalBytes = bytesRead = 0;
-        for (SSTableScanner iter : (List<SSTableScanner>)((CollatingIterator)source).getIterators())
+        for (SSTableScanner scanner : getScanners())
         {
-            totalBytes += iter.getFileLength();
+            totalBytes += scanner.getFileLength();
         }
->>>>>>> make estimation of pendingtasks for CompactionManager sane
         this.gcBefore = gcBefore;
         this.major = major;
     }
@@ -152,9 +148,9 @@
             if ((row++ % 1000) == 0)
             {
                 bytesRead = 0;
-                for (SSTableScanner iter : (List<SSTableScanner>)((CollatingIterator)source).getIterators())
+                for (SSTableScanner scanner : getScanners())
                 {
-                    bytesRead += iter.getFilePointer();
+                    bytesRead += scanner.getFilePointer();
                 }
             }
         }
@@ -163,12 +159,17 @@
 
     public void close() throws IOException
     {
-        for (Object o : ((CollatingIterator)source).getIterators())
+        for (SSTableScanner scanner : getScanners())
         {
-            ((SSTableScanner)o).close();
+            scanner.close();
         }
     }
 
+    protected Iterable<SSTableScanner> getScanners()
+    {
+        return ((CollatingIterator)source).getIterators();
+    }
+
     public long getTotalBytes()
     {
         return totalBytes;



Mime
View raw message