Author: jbellis
Date: Thu Jun 10 22:36:12 2010
New Revision: 953486

URL: http://svn.apache.org/viewvc?rev=953486&view=rev
Log:
fix FD leak.  patch by mdennis; reviewed by jbellis for CASSANDRA-1178

Modified:
    
cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?rev=953486&r1=953485&r2=953486&view=diff
==============================================================================
--- 
cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
 (original)
+++ 
cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
 Thu Jun 10 22:36:12 2010
@@ -51,12 +51,25 @@ class SSTableSliceIterator extends Abstr
     private ColumnGroupReader reader;
     private boolean closeFileWhenDone = false;
     private DecoratedKey decoratedKey;
-    
+
     public SSTableSliceIterator(SSTableReader ssTable, DecoratedKey key, 
byte[] startColumn, byte[] finishColumn, Predicate<IColumn> predicate, boolean 
reversed)
     {
         this(ssTable, null, key, startColumn, finishColumn, predicate, 
reversed); 
     }
-    
+
+    /**
+     * An iterator for a slice within an SSTable
+     * @param ssTable The SSTable to iterate over
+     * @param file Optional parameter that input is read from.  If null is 
passed, this class creates an appropriate one automatically.
+     * If this class creates, it will close the underlying file when #close() 
is called.
+     * If a caller passes a non-null argument, this class will NOT close the 
underlying file when the iterator is closed (i.e. the caller is responsible for 
closing the file)
+     * In all cases the caller should explicitly #close() this iterator.
+     * @param key The key the requested slice resides under
+     * @param startColumn The start of the slice
+     * @param finishColumn The end of the slice
+     * @param predicate The predicate used for filtering columns
+     * @param reversed Results are returned in reverse order iff reversed is 
true.
+     */
     public SSTableSliceIterator(SSTableReader ssTable, FileDataInput file, 
DecoratedKey key, byte[] startColumn, byte[] finishColumn, Predicate<IColumn> 
predicate, boolean reversed) 
     {
         this.reversed = reversed;
@@ -68,6 +81,7 @@ class SSTableSliceIterator extends Abstr
 
         if (file == null)
         {
+            closeFileWhenDone = true; //if we create it, we close it
             file = ssTable.getFileDataInput(decoratedKey, 
DatabaseDescriptor.getSlicedReadBufferSizeInKB() * 1024);
             if (file == null)
                 return;


Reply via email to