You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mm...@apache.org on 2018/05/04 16:12:45 UTC

[accumulo] branch master updated: Remove dead code in bcfile (#460)

This is an automated email from the ASF dual-hosted git repository.

mmiller pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/master by this push:
     new ffbd8c7  Remove dead code in bcfile (#460)
ffbd8c7 is described below

commit ffbd8c759300eaad92b834ec26a2aa47e7378492
Author: Mike Miller <mm...@apache.org>
AuthorDate: Fri May 4 12:12:41 2018 -0400

    Remove dead code in bcfile (#460)
---
 .../blockfile/cache/tinylfu/TinyLfuBlockCache.java |  7 +-
 .../file/blockfile/impl/CachableBlockFile.java     | 18 ++---
 .../org/apache/accumulo/core/file/rfile/RFile.java |  4 -
 .../accumulo/core/file/rfile/bcfile/BCFile.java    | 93 +---------------------
 .../core/file/rfile/bcfile/CompareUtils.java       | 64 ---------------
 .../core/file/rfile/bcfile/RawComparable.java      | 55 -------------
 .../accumulo/core/file/rfile/bcfile/Utils.java     | 50 ------------
 7 files changed, 16 insertions(+), 275 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
index 6a3bb43..fd4a554 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
@@ -200,7 +200,7 @@ public final class TinyLfuBlockCache implements BlockCache {
     }
   }
 
-  private Block load(String key, Loader loader, Map<String,byte[]> resolvedDeps) {
+  private Block load(Loader loader, Map<String,byte[]> resolvedDeps) {
     byte[] data = loader.load((int) Math.min(Integer.MAX_VALUE, policy.getMaximum()), resolvedDeps);
     if (data == null) {
       return null;
@@ -235,7 +235,7 @@ public final class TinyLfuBlockCache implements BlockCache {
     Map<String,Loader> deps = loader.getDependencies();
     Block block;
     if (deps.size() == 0) {
-      block = cache.get(blockName, k -> load(blockName, loader, Collections.emptyMap()));
+      block = cache.get(blockName, k -> load(loader, Collections.emptyMap()));
     } else {
       // This code path exist to handle the case where dependencies may need to be loaded. Loading
       // dependencies will access the cache. Cache load functions
@@ -252,8 +252,7 @@ public final class TinyLfuBlockCache implements BlockCache {
         // Use asMap because it will not increment stats, getIfPresent recorded a miss above. Use
         // computeIfAbsent because it is possible another thread loaded
         // the data since this thread called getIfPresent.
-        block = cache.asMap().computeIfAbsent(blockName,
-            k -> load(blockName, loader, resolvedDeps));
+        block = cache.asMap().computeIfAbsent(blockName, k -> load(loader, resolvedDeps));
       }
     }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
index 27b262f..3a4a26d 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/impl/CachableBlockFile.java
@@ -189,7 +189,7 @@ public class CachableBlockFile {
         if (serializedMetadata == null) {
           tmpReader = new BCFile.Reader(fsIn, lengthSupplier.get(), conf, accumuloConfiguration);
         } else {
-          tmpReader = new BCFile.Reader(serializedMetadata, fsIn, conf, accumuloConfiguration);
+          tmpReader = new BCFile.Reader(serializedMetadata, fsIn, conf);
         }
 
         if (!bcfr.compareAndSet(null, tmpReader)) {
@@ -424,7 +424,7 @@ public class CachableBlockFile {
       }
 
       BlockReader _currBlock = getBCFile(null).getMetaBlock(blockName);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -440,7 +440,7 @@ public class CachableBlockFile {
       }
 
       BlockReader _currBlock = getBCFile(null).getDataBlock(offset, compressedSize, rawSize);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     /**
@@ -462,7 +462,7 @@ public class CachableBlockFile {
       }
 
       BlockReader _currBlock = getBCFile().getDataBlock(blockIndex);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -478,7 +478,7 @@ public class CachableBlockFile {
       }
 
       BlockReader _currBlock = getBCFile().getDataBlock(offset, compressedSize, rawSize);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -508,11 +508,11 @@ public class CachableBlockFile {
     private final CacheEntry cb;
 
     public CachedBlockRead(CacheEntry cb, byte buf[]) {
-      this(new SeekableByteArrayInputStream(buf), buf.length, cb);
+      this(new SeekableByteArrayInputStream(buf), cb);
     }
 
-    private CachedBlockRead(SeekableByteArrayInputStream seekableInput, long size, CacheEntry cb) {
-      super(seekableInput, size);
+    private CachedBlockRead(SeekableByteArrayInputStream seekableInput, CacheEntry cb) {
+      super(seekableInput);
       this.seekableInput = seekableInput;
       this.cb = cb;
     }
@@ -558,7 +558,7 @@ public class CachableBlockFile {
    */
   public static class BlockRead extends DataInputStream implements ABlockReader {
 
-    public BlockRead(InputStream in, long size) {
+    public BlockRead(InputStream in) {
       super(in);
     }
 
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
index 1424f0b..4095dcf 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
@@ -1470,10 +1470,6 @@ public class RFile {
       return getSample(this.samplerConfig);
     }
 
-    public void printInfo() throws IOException {
-      printInfo(false);
-    }
-
     public void printInfo(boolean includeIndexDetails) throws IOException {
 
       System.out.printf("%-24s : %d\n", "RFile Version", rfileVersion);
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
index 25462db..5871761 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/BCFile.java
@@ -39,7 +39,6 @@ import java.util.TreeMap;
 
 import org.apache.accumulo.core.conf.AccumuloConfiguration;
 import org.apache.accumulo.core.conf.Property;
-import org.apache.accumulo.core.file.rfile.bcfile.CompareUtils.Scalar;
 import org.apache.accumulo.core.file.rfile.bcfile.Compression.Algorithm;
 import org.apache.accumulo.core.file.rfile.bcfile.Utils.Version;
 import org.apache.accumulo.core.file.streams.BoundedRangeFileInputStream;
@@ -456,25 +455,6 @@ public final class BCFile {
     }
 
     /**
-     * Create a Meta Block and obtain an output stream for adding data into the block. There can
-     * only be one BlockAppender stream active at any time. Regular Blocks may not be created after
-     * the first Meta Blocks. The caller must call BlockAppender.close() to conclude the block
-     * creation.
-     *
-     * @param name
-     *          The name of the Meta Block. The name must not conflict with existing Meta Blocks.
-     * @param compressionName
-     *          The name of the compression algorithm to be used.
-     * @return The BlockAppender stream
-     * @throws MetaBlockAlreadyExists
-     *           If the meta block with the name already exists.
-     */
-    public BlockAppender prepareMetaBlock(String name, String compressionName)
-        throws IOException, MetaBlockAlreadyExists {
-      return prepareMetaBlock(name, Compression.getCompressionAlgorithmByName(compressionName));
-    }
-
-    /**
      * Create a Meta Block and obtain an output stream for adding data into the block. The Meta
      * Block will be compressed with the same compression algorithm as data blocks. There can only
      * be one BlockAppender stream active at any time. Regular Blocks may not be created after the
@@ -646,7 +626,7 @@ public final class BCFile {
 
       public <InputStreamType extends InputStream & Seekable> RBlockState(Algorithm compressionAlgo,
           InputStreamType fsin, BlockRegion region, Configuration conf, CryptoModule cryptoModule,
-          Version bcFileVersion, CryptoModuleParameters cryptoParams) throws IOException {
+          CryptoModuleParameters cryptoParams) throws IOException {
         this.compressAlgo = compressionAlgo;
         this.region = region;
         this.decompressor = compressionAlgo.getDecompressor();
@@ -695,10 +675,6 @@ public final class BCFile {
         return in;
       }
 
-      public String getCompressionName() {
-        return compressAlgo.getName();
-      }
-
       public BlockRegion getBlockRegion() {
         return region;
       }
@@ -753,15 +729,6 @@ public final class BCFile {
       }
 
       /**
-       * Get the name of the compression algorithm used to compress the block.
-       *
-       * @return name of the compression algorithm.
-       */
-      public String getCompressionName() {
-        return rBlkState.getCompressionName();
-      }
-
-      /**
        * Get the uncompressed size of the block.
        *
        * @return uncompressed size of the block.
@@ -769,24 +736,6 @@ public final class BCFile {
       public long getRawSize() {
         return rBlkState.getBlockRegion().getRawSize();
       }
-
-      /**
-       * Get the compressed size of the block.
-       *
-       * @return compressed size of the block.
-       */
-      public long getCompressedSize() {
-        return rBlkState.getBlockRegion().getCompressedSize();
-      }
-
-      /**
-       * Get the starting position of the block in the file.
-       *
-       * @return the starting position of the block in the file.
-       */
-      public long getStartPos() {
-        return rBlkState.getBlockRegion().getOffset();
-      }
     }
 
     public byte[] serializeMetadata(int maxSize) {
@@ -914,8 +863,7 @@ public final class BCFile {
     }
 
     public <InputStreamType extends InputStream & Seekable> Reader(byte[] serializedMetadata,
-        InputStreamType fin, Configuration conf, AccumuloConfiguration accumuloConfiguration)
-        throws IOException {
+        InputStreamType fin, Configuration conf) throws IOException {
       this.in = new SeekableDataInputStream(fin);
       this.conf = conf;
 
@@ -953,33 +901,6 @@ public final class BCFile {
     }
 
     /**
-     * Get the name of the default compression algorithm.
-     *
-     * @return the name of the default compression algorithm.
-     */
-    public String getDefaultCompressionName() {
-      return dataIndex.getDefaultCompressionAlgorithm().getName();
-    }
-
-    /**
-     * Get version of BCFile file being read.
-     *
-     * @return version of BCFile file being read.
-     */
-    public Version getBCFileVersion() {
-      return version;
-    }
-
-    /**
-     * Get version of BCFile API.
-     *
-     * @return version of BCFile API.
-     */
-    public Version getAPIVersion() {
-      return API_VERSION;
-    }
-
-    /**
      * Finishing reading the BCFile. Release all resources.
      */
     @Override
@@ -1058,8 +979,7 @@ public final class BCFile {
 
     private BlockReader createReader(Algorithm compressAlgo, BlockRegion region)
         throws IOException {
-      RBlockState rbs = new RBlockState(compressAlgo, in, region, conf, cryptoModule, version,
-          cryptoParams);
+      RBlockState rbs = new RBlockState(compressAlgo, in, region, conf, cryptoModule, cryptoParams);
       return new BlockReader(rbs);
     }
   }
@@ -1244,7 +1164,7 @@ public final class BCFile {
   /**
    * Block region.
    */
-  static final class BlockRegion implements Scalar {
+  static final class BlockRegion {
     private final long offset;
     private final long compressedSize;
     private final long rawSize;
@@ -1278,10 +1198,5 @@ public final class BCFile {
     public long getRawSize() {
       return rawSize;
     }
-
-    @Override
-    public long magnitude() {
-      return offset;
-    }
   }
 }
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
deleted file mode 100644
index 0d16cd9..0000000
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/CompareUtils.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package org.apache.accumulo.core.file.rfile.bcfile;
-
-import java.io.Serializable;
-import java.util.Comparator;
-
-class CompareUtils {
-  /**
-   * Prevent the instantiation of class.
-   */
-  private CompareUtils() {
-    // nothing
-  }
-
-  /**
-   * Interface for all objects that has a single integer magnitude.
-   */
-  interface Scalar {
-    long magnitude();
-  }
-
-  static final class ScalarLong implements Scalar {
-    private long magnitude;
-
-    public ScalarLong(long m) {
-      magnitude = m;
-    }
-
-    @Override
-    public long magnitude() {
-      return magnitude;
-    }
-  }
-
-  public static final class ScalarComparator implements Comparator<Scalar>, Serializable {
-    private static final long serialVersionUID = 1L;
-
-    @Override
-    public int compare(Scalar o1, Scalar o2) {
-      long diff = o1.magnitude() - o2.magnitude();
-      if (diff < 0)
-        return -1;
-      if (diff > 0)
-        return 1;
-      return 0;
-    }
-  }
-
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/RawComparable.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/RawComparable.java
deleted file mode 100644
index b930726..0000000
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/RawComparable.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with this
- * work for additional information regarding copyright ownership. The ASF
- * licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package org.apache.accumulo.core.file.rfile.bcfile;
-
-import java.util.Collections;
-import java.util.Comparator;
-
-import org.apache.hadoop.io.RawComparator;
-
-/**
- * Interface for objects that can be compared through {@link RawComparator}. This is useful in
- * places where we need a single object reference to specify a range of bytes in a byte array, such
- * as {@link Comparable} or {@link Collections#binarySearch(java.util.List, Object, Comparator)}
- *
- * The actual comparison among RawComparable's requires an external RawComparator and it is
- * applications' responsibility to ensure two RawComparable are supposed to be semantically
- * comparable with the same RawComparator.
- */
-public interface RawComparable {
-  /**
-   * Get the underlying byte array.
-   *
-   * @return The underlying byte array.
-   */
-  byte[] buffer();
-
-  /**
-   * Get the offset of the first byte in the byte array.
-   *
-   * @return The offset of the first byte in the byte array.
-   */
-  int offset();
-
-  /**
-   * Get the size of the byte range in the byte array.
-   *
-   * @return The size of the byte range in the byte array.
-   */
-  int size();
-}
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Utils.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Utils.java
index 51582a4..b0d96ee 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Utils.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/bcfile/Utils.java
@@ -20,8 +20,6 @@ package org.apache.accumulo.core.file.rfile.bcfile;
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.util.Comparator;
-import java.util.List;
 
 import org.apache.hadoop.io.Text;
 
@@ -309,24 +307,6 @@ public final class Utils {
     }
 
     /**
-     * Get the major version.
-     *
-     * @return Major version.
-     */
-    public int getMajor() {
-      return major;
-    }
-
-    /**
-     * Get the minor version.
-     *
-     * @return The minor version.
-     */
-    public int getMinor() {
-      return minor;
-    }
-
-    /**
      * Get the size of the serialized Version object.
      *
      * @return serialized size of the version object.
@@ -374,34 +354,4 @@ public final class Utils {
     }
   }
 
-  /**
-   * Lower bound binary search. Find the index to the first element in the list that compares
-   * greater than or equal to key.
-   *
-   * @param <T>
-   *          Type of the input key.
-   * @param list
-   *          The list
-   * @param key
-   *          The input key.
-   * @param cmp
-   *          Comparator for the key.
-   * @return The index to the desired element if it exists; or list.size() otherwise.
-   */
-  public static <T> int lowerBound(List<? extends T> list, T key, Comparator<? super T> cmp) {
-    int low = 0;
-    int high = list.size();
-
-    while (low < high) {
-      int mid = (low + high) >>> 1;
-      T midVal = list.get(mid);
-      int ret = cmp.compare(midVal, key);
-      if (ret < 0)
-        low = mid + 1;
-      else
-        high = mid;
-    }
-    return low;
-  }
-
 }

-- 
To stop receiving notification emails like this one, please contact
mmiller@apache.org.