Author: jbellis
Date: Sat Nov 7 23:21:02 2009
New Revision: 833777
URL: http://svn.apache.org/viewvc?rev=833777&view=rev
Log:
close bloom filter, index files when done reading them. patch by Tim Freeman;
reviewed by jbellis for CASSANDRA-533
Modified:
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/io/SSTableReader.java
Modified:
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/io/SSTableReader.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/io/SSTableReader.java?rev=833777&r1=833776&r2=833777&view=diff
==============================================================================
---
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/io/SSTableReader.java
(original)
+++
incubator/cassandra/branches/cassandra-0.4/src/java/org/apache/cassandra/io/SSTableReader.java
Sat Nov 7 23:21:02 2009
@@ -135,30 +135,44 @@
private void loadBloomFilter() throws IOException
{
DataInputStream stream = new DataInputStream(new
FileInputStream(filterFilename()));
- bf = BloomFilter.serializer().deserialize(stream);
+ try
+ {
+ bf = BloomFilter.serializer().deserialize(stream);
+ }
+ finally
+ {
+ stream.close();
+ }
}
private void loadIndexFile() throws IOException
{
BufferedRandomAccessFile input = new
BufferedRandomAccessFile(indexFilename(), "r");
- indexPositions = new ArrayList<KeyPosition>();
-
- int i = 0;
- long indexSize = input.length();
- while (true)
+ try
{
- long indexPosition = input.getFilePointer();
- if (indexPosition == indexSize)
- {
- break;
- }
- String decoratedKey = input.readUTF();
- input.readLong();
- if (i++ % INDEX_INTERVAL == 0)
+ indexPositions = new ArrayList<KeyPosition>();
+
+ int i = 0;
+ long indexSize = input.length();
+ while (true)
{
- indexPositions.add(new KeyPosition(decoratedKey,
indexPosition));
+ long indexPosition = input.getFilePointer();
+ if (indexPosition == indexSize)
+ {
+ break;
+ }
+ String decoratedKey = input.readUTF();
+ input.readLong();
+ if (i++ % INDEX_INTERVAL == 0)
+ {
+ indexPositions.add(new KeyPosition(decoratedKey,
indexPosition));
+ }
}
}
+ finally
+ {
+ input.close();
+ }
}
/** get the position in the index file to start scanning to find the given
key (at most indexInterval keys away) */