You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2013/09/19 23:54:36 UTC

[5/6] git commit: use non-pooling readers with openForBatch patch by jbellis; reviewed by yukim for CASSANDRA-6067

use non-pooling readers with openForBatch
patch by jbellis; reviewed by yukim for CASSANDRA-6067


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

Branch: refs/heads/trunk
Commit: 5a7cc11f29c69265d6302a54690476b7ef2de61a
Parents: b4bc50e
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Sep 19 16:49:15 2013 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Sep 19 16:50:17 2013 -0500

----------------------------------------------------------------------
 .../cassandra/io/sstable/SSTableReader.java     | 14 ++++++++++---
 .../io/util/BufferedSegmentedFile.java          | 21 +++++++++-----------
 2 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a7cc11f/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
index e0c096f..4da579c 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
@@ -160,8 +160,17 @@ public class SSTableReader extends SSTable implements Closeable
                                                   partitioner,
                                                   System.currentTimeMillis(),
                                                   sstableMetadata);
-        // don't save index summary to disk if we needed to build one
-        sstable.load(false, false);
+
+        // special implementation of load to use non-pooled SegmentedFile builders
+        SegmentedFile.Builder ibuilder = new BufferedSegmentedFile.Builder();
+        SegmentedFile.Builder dbuilder = sstable.compression
+                                       ? new CompressedSegmentedFile.Builder()
+                                       : new BufferedSegmentedFile.Builder();
+        if (!loadSummary(sstable, ibuilder, dbuilder, sstable.metadata))
+            sstable.buildSummary(false, ibuilder, dbuilder, false);
+        sstable.ifile = ibuilder.complete(sstable.descriptor.filenameFor(Component.PRIMARY_INDEX));
+        sstable.dfile = dbuilder.complete(sstable.descriptor.filenameFor(Component.DATA));
+
         sstable.bf = FilterFactory.AlwaysPresent;
         return sstable;
     }
@@ -411,7 +420,6 @@ public class SSTableReader extends SSTable implements Closeable
                                          ? SegmentedFile.getCompressedBuilder()
                                          : SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode());
 
-
         boolean summaryLoaded = loadSummary(this, ibuilder, dbuilder, metadata);
         if (recreateBloomFilter || !summaryLoaded)
             buildSummary(recreateBloomFilter, ibuilder, dbuilder, summaryLoaded);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5a7cc11f/src/java/org/apache/cassandra/io/util/BufferedSegmentedFile.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/BufferedSegmentedFile.java b/src/java/org/apache/cassandra/io/util/BufferedSegmentedFile.java
index 49972c8..790b42b 100644
--- a/src/java/org/apache/cassandra/io/util/BufferedSegmentedFile.java
+++ b/src/java/org/apache/cassandra/io/util/BufferedSegmentedFile.java
@@ -19,7 +19,7 @@ package org.apache.cassandra.io.util;
 
 import java.io.File;
 
-public class BufferedSegmentedFile extends PoolingSegmentedFile
+public class BufferedSegmentedFile extends SegmentedFile
 {
     public BufferedSegmentedFile(String path, long length)
     {
@@ -28,20 +28,11 @@ public class BufferedSegmentedFile extends PoolingSegmentedFile
 
     public static class Builder extends SegmentedFile.Builder
     {
-        /**
-         * Adds a position that would be a safe place for a segment boundary in the file. For a block/row based file
-         * format, safe boundaries are block/row edges.
-         * @param boundary The absolute position of the potential boundary in the file.
-         */
         public void addPotentialBoundary(long boundary)
         {
             // only one segment in a standard-io file
         }
 
-        /**
-         * Called after all potential boundaries have been added to apply this Builder to a concrete file on disk.
-         * @param path The file on disk.
-         */
         public SegmentedFile complete(String path)
         {
             long length = new File(path).length();
@@ -49,8 +40,14 @@ public class BufferedSegmentedFile extends PoolingSegmentedFile
         }
     }
 
-    protected RandomAccessReader createReader(String path)
+    public FileDataInput getSegment(long position)
+    {
+        RandomAccessReader reader = RandomAccessReader.open(new File(path));
+        reader.seek(position);
+        return reader;
+    }
+
+    public void cleanup()
     {
-        return RandomAccessReader.open(new File(path), this);
     }
 }