cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbros...@apache.org
Subject [1/2] git commit: buffer writing of compression meta data, and make sure stream is closed
Date Sat, 26 Apr 2014 02:57:24 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk ca9c4b468 -> 7000efa21


buffer writing of compression meta data, and make sure stream is closed


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/fccc123a
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/fccc123a
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/fccc123a

Branch: refs/heads/trunk
Commit: fccc123af1a1f120fd86db65dfa09fe4c85a18d6
Parents: a6efffe
Author: Dave Brosius <dbrosius@mebigfatguy.com>
Authored: Fri Apr 25 22:56:12 2014 -0400
Committer: Dave Brosius <dbrosius@mebigfatguy.com>
Committed: Fri Apr 25 22:56:12 2014 -0400

----------------------------------------------------------------------
 .../io/compress/CompressionMetadata.java        | 23 ++++++++++++++------
 1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fccc123a/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java b/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
index 8cd8c9f..abb067f 100644
--- a/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
+++ b/src/java/org/apache/cassandra/io/compress/CompressionMetadata.java
@@ -17,6 +17,7 @@
  */
 package org.apache.cassandra.io.compress;
 
+import java.io.BufferedOutputStream;
 import java.io.DataInput;
 import java.io.DataInputStream;
 import java.io.DataOutput;
@@ -49,6 +50,7 @@ import org.apache.cassandra.io.sstable.Descriptor;
 import org.apache.cassandra.io.util.DataOutputPlus;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.Memory;
+import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.Pair;
 
 /**
@@ -329,7 +331,7 @@ public class CompressionMetadata
          */
         public long chunkOffsetBy(int chunkIndex)
         {
-            return offsets.getLong(chunkIndex * 8);
+            return offsets.getLong(chunkIndex * 8L);
         }
 
         /**
@@ -343,12 +345,19 @@ public class CompressionMetadata
 
         public void close(long dataLength, int chunks) throws IOException
         {
-            final DataOutputStream out = new DataOutputStream(new FileOutputStream(filePath));
-            assert chunks == count;
-            writeHeader(out, dataLength, chunks);
-            for (int i = 0 ; i < count ; i++)
-                out.writeLong(offsets.getLong(i * 8));
-            out.close();
+            DataOutputStream out = null;
+            try
+            {
+            	out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(filePath)));
+	            assert chunks == count;
+	            writeHeader(out, dataLength, chunks);
+	            for (int i = 0 ; i < count ; i++)
+	                out.writeLong(offsets.getLong(i * 8));
+            }
+            finally
+            {
+                FileUtils.closeQuietly(out);
+            }
         }
     }
 


Mime
View raw message