cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject cassandra git commit: Remove ternary construction of SegmentedFile.Builder in SSTableReader
Date Fri, 03 Apr 2015 21:23:23 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 1dff098e4 -> 1007ba59a


Remove ternary construction of SegmentedFile.Builder in SSTableReader

patch by benedict; reviewed by zanson for CASSANDRA-9112


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

Branch: refs/heads/trunk
Commit: 1007ba59a918d94c0e4fcdce4094ebeef6aabec3
Parents: 1dff098
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Fri Apr 3 22:22:31 2015 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Fri Apr 3 22:22:31 2015 +0100

----------------------------------------------------------------------
 .../io/sstable/format/SSTableReader.java          | 18 ++++++------------
 .../io/sstable/format/big/BigTableWriter.java     |  4 ++--
 .../apache/cassandra/io/util/SegmentedFile.java   | 11 ++++-------
 .../cassandra/io/sstable/SSTableReaderTest.java   |  6 ++----
 4 files changed, 14 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1007ba59/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
index a761e6a..24540b8 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/SSTableReader.java
@@ -643,10 +643,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
      */
     private void load(boolean recreateBloomFilter, boolean saveSummaryIfCreated) throws IOException
     {
-        try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
-            SegmentedFile.Builder dbuilder = compression
-                ? SegmentedFile.getCompressedBuilder()
-                : SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode()))
+        try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode(),
false);
+            SegmentedFile.Builder dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode(),
compression))
         {
             boolean summaryLoaded = loadSummary(ibuilder, dbuilder);
             boolean builtSummary = false;
@@ -670,10 +668,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
                 logger.info("Detected erroneously downsampled index summary; will rebuild
summary at full sampling");
                 FileUtils.deleteWithConfirm(new File(descriptor.filenameFor(Component.SUMMARY)));
 
-                try(SegmentedFile.Builder ibuilderRebuild = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
-                    SegmentedFile.Builder dbuilderRebuild = compression
-                        ? SegmentedFile.getCompressedBuilder()
-                        : SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode()))
+                try(SegmentedFile.Builder ibuilderRebuild = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode(),
false);
+                    SegmentedFile.Builder dbuilderRebuild = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode(),
compression))
                 {
                     buildSummary(false, ibuilderRebuild, dbuilderRebuild, false, Downsampling.BASE_SAMPLING_LEVEL);
                     ifile = ibuilderRebuild.complete(descriptor.filenameFor(Component.PRIMARY_INDEX));
@@ -998,10 +994,8 @@ public abstract class SSTableReader extends SSTable implements SelfRefCounted<SS
                 // we can use the existing index summary to make a smaller one
                 newSummary = IndexSummaryBuilder.downsample(indexSummary, samplingLevel,
minIndexInterval, partitioner);
 
-                try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
-                    SegmentedFile.Builder dbuilder = compression
-                        ? SegmentedFile.getCompressedBuilder()
-                        : SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode()))
+                try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode(),
false);
+                    SegmentedFile.Builder dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode(),
compression))
                 {
                     saveSummary(ibuilder, dbuilder, newSummary);
                 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1007ba59/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java b/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java
index 1f1c42c..087e57a 100644
--- a/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/format/big/BigTableWriter.java
@@ -78,7 +78,7 @@ public class BigTableWriter extends SSTableWriter
         else
         {
             dataFile = SequentialWriter.open(new File(getFilename()), new File(descriptor.filenameFor(Component.CRC)));
-            dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode());
+            dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode(), false);
         }
         iwriter = new IndexWriter(keyCount, dataFile);
     }
@@ -487,7 +487,7 @@ public class BigTableWriter extends SSTableWriter
         IndexWriter(long keyCount, final SequentialWriter dataFile)
         {
             indexFile = SequentialWriter.open(new File(descriptor.filenameFor(Component.PRIMARY_INDEX)));
-            builder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
+            builder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode(), false);
             summary = new IndexSummaryBuilder(keyCount, metadata.getMinIndexInterval(), Downsampling.BASE_SAMPLING_LEVEL);
             bf = FilterFactory.getFilter(keyCount, metadata.getBloomFilterFpChance(), true);
             // register listeners to be alerted when the data files are flushed

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1007ba59/src/java/org/apache/cassandra/io/util/SegmentedFile.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/util/SegmentedFile.java b/src/java/org/apache/cassandra/io/util/SegmentedFile.java
index dbf2228..98548e1 100644
--- a/src/java/org/apache/cassandra/io/util/SegmentedFile.java
+++ b/src/java/org/apache/cassandra/io/util/SegmentedFile.java
@@ -131,16 +131,13 @@ public abstract class SegmentedFile extends SharedCloseableImpl
     /**
      * @return A SegmentedFile.Builder.
      */
-    public static Builder getBuilder(Config.DiskAccessMode mode)
+    public static Builder getBuilder(Config.DiskAccessMode mode, boolean compressed)
     {
+        assert !compressed || mode != Config.DiskAccessMode.mmap;
         return mode == Config.DiskAccessMode.mmap
                ? new MmappedSegmentedFile.Builder()
-               : new BufferedPoolingSegmentedFile.Builder();
-    }
-
-    public static Builder getCompressedBuilder()
-    {
-        return getCompressedBuilder(null);
+               : compressed ? new CompressedSegmentedFile.Builder(null)
+                            : new BufferedPoolingSegmentedFile.Builder();
     }
 
     public static Builder getCompressedBuilder(CompressedSequentialWriter writer)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1007ba59/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
index 2cb451e..82cb8d5 100644
--- a/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
@@ -376,10 +376,8 @@ public class SSTableReaderTest
         SSTableReader sstable = indexCfs.getSSTables().iterator().next();
         assert sstable.first.getToken() instanceof LocalToken;
 
-        try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode());
-            SegmentedFile.Builder dbuilder = sstable.compression
-                                          ? SegmentedFile.getCompressedBuilder()
-                                          : SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode()))
+        try(SegmentedFile.Builder ibuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getIndexAccessMode(),
false);
+            SegmentedFile.Builder dbuilder = SegmentedFile.getBuilder(DatabaseDescriptor.getDiskAccessMode(),
sstable.compression))
         {
             sstable.saveSummary(ibuilder, dbuilder);
         }


Mime
View raw message