Author: slebresne
Date: Mon Oct 10 13:44:59 2011
New Revision: 1180958

URL: http://svn.apache.org/viewvc?rev=1180958&view=rev
Log:
Make SSTW.RowIndexer.iwriter a final field to avoid NPE
patch by slebresne; reviewed by jbellis for CASSANDRA-2863

Modified:
    cassandra/branches/cassandra-0.8/CHANGES.txt
    
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1180958&r1=1180957&r2=1180958&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Mon Oct 10 13:44:59 2011
@@ -1,5 +1,6 @@
 0.8.8
  * fix truncate allowing data to be replayed post-restart (CASSANDRA-3297)
+ * make iwriter final in IndexWriter to avoid NPE (CASSANDRA-2863)
 
 
 0.8.7

Modified: 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=1180958&r1=1180957&r2=1180958&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
 (original)
+++ 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
 Mon Oct 10 13:44:59 2011
@@ -302,19 +302,18 @@ public class SSTableWriter extends SSTab
         {
             if (cfs.isInvalid())
                 return null;
-            maybeOpenIndexer();
 
             File ifile = new File(desc.filenameFor(SSTable.COMPONENT_INDEX));
             File ffile = new File(desc.filenameFor(SSTable.COMPONENT_FILTER));
             assert !ifile.exists();
             assert !ffile.exists();
 
-            long estimatedRows = indexer.prepareIndexing();
+            maybeOpenIndexer();
 
             // build the index and filter
             long rows = indexer.index();
 
-            logger.debug("estimated row count was {} of real count", 
((double)estimatedRows) / rows);
+            logger.debug("estimated row count was {} of real count", 
((double)indexer.estimatedRows) / rows);
             return SSTableReader.open(rename(desc, SSTable.componentsFor(desc, 
false)));
         }
     }
@@ -324,8 +323,9 @@ public class SSTableWriter extends SSTab
         protected final Descriptor desc;
         public final BufferedRandomAccessFile dfile;
         private final OperationType type;
+        protected final IndexWriter iwriter;
+        public final long estimatedRows;
 
-        protected IndexWriter iwriter;
         protected ColumnFamilyStore cfs;
 
         RowIndexer(Descriptor desc, ColumnFamilyStore cfs, OperationType type) 
throws IOException
@@ -339,16 +339,11 @@ public class SSTableWriter extends SSTab
             this.dfile = dfile;
             this.type = type;
             this.cfs = cfs;
-        }
 
-        long prepareIndexing() throws IOException
-        {
-            long estimatedRows;
             try
             {
-                estimatedRows = SSTable.estimateRowsFromData(desc, dfile);
-                iwriter = new IndexWriter(desc, 
StorageService.getPartitioner(), estimatedRows);
-                return estimatedRows;
+                this.estimatedRows = SSTable.estimateRowsFromData(desc, dfile);
+                this.iwriter = new IndexWriter(desc, 
StorageService.getPartitioner(), estimatedRows);
             }
             catch(IOException e)
             {


Reply via email to