Return-Path: Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: (qmail 40003 invoked from network); 10 Jun 2010 22:36:55 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 10 Jun 2010 22:36:55 -0000 Received: (qmail 33461 invoked by uid 500); 10 Jun 2010 22:36:55 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 33434 invoked by uid 500); 10 Jun 2010 22:36:55 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 33426 invoked by uid 99); 10 Jun 2010 22:36:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 22:36:55 +0000 X-ASF-Spam-Status: No, hits=-1491.5 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jun 2010 22:36:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 89E45238897A; Thu, 10 Jun 2010 22:36:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r953486 - /cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java Date: Thu, 10 Jun 2010 22:36:12 -0000 To: commits@cassandra.apache.org From: jbellis@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100610223612.89E45238897A@eris.apache.org> 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 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 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;