You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/05/04 16:12:43 UTC

[GitHub] milleruntime closed pull request #460: Remove dead code in bcfile

milleruntime closed pull request #460: Remove dead code in bcfile
URL: https://github.com/apache/accumulo/pull/460
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 6a3bb43aed..fd4a55460e 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 void indexWeightChanged() {
     }
   }
 
-  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 CacheEntry getBlock(String blockName, Loader loader) {
     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 CacheEntry getBlock(String blockName, Loader loader) {
         // 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 27b262ff6d..3a4a26d998 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 long getStartPos() throws IOException {
         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 BlockRead getMetaBlock(String blockName) throws IOException {
       }
 
       BlockReader _currBlock = getBCFile(null).getMetaBlock(blockName);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -440,7 +440,7 @@ public ABlockReader getMetaBlock(long offset, long compressedSize, long rawSize)
       }
 
       BlockReader _currBlock = getBCFile(null).getDataBlock(offset, compressedSize, rawSize);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     /**
@@ -462,7 +462,7 @@ public BlockRead getDataBlock(int blockIndex) throws IOException {
       }
 
       BlockReader _currBlock = getBCFile().getDataBlock(blockIndex);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -478,7 +478,7 @@ public ABlockReader getDataBlock(long offset, long compressedSize, long rawSize)
       }
 
       BlockReader _currBlock = getBCFile().getDataBlock(offset, compressedSize, rawSize);
-      return new BlockRead(_currBlock, _currBlock.getRawSize());
+      return new BlockRead(_currBlock);
     }
 
     @Override
@@ -508,11 +508,11 @@ public synchronized void close() throws IOException {
     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 void indexWeightChanged() {
    */
   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 1424f0b2a0..4095dcf8a7 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 @@ FileSKVIterator getSample() {
       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 25462dbd3b..587176173f 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 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;
@@ -455,25 +454,6 @@ private BlockAppender prepareMetaBlock(String name, Algorithm compressAlgo)
       return ba;
     }
 
-    /**
-     * 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
@@ -646,7 +626,7 @@ public void read(DataInput in) throws IOException {
 
       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 InputStream getInputStream() {
         return in;
       }
 
-      public String getCompressionName() {
-        return compressAlgo.getName();
-      }
-
       public BlockRegion getBlockRegion() {
         return region;
       }
@@ -752,15 +728,6 @@ public void close() throws IOException {
         }
       }
 
-      /**
-       * 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.
        *
@@ -769,24 +736,6 @@ public String getCompressionName() {
       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 long getStartPos() {
     }
 
     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;
 
@@ -952,33 +900,6 @@ private void setupCryptoFromCachedData(DataInput cachedCryptoParams) throws IOEx
       }
     }
 
-    /**
-     * 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.
      */
@@ -1058,8 +979,7 @@ public long getDataBlockRawSize(int blockIndex) {
 
     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 static int size() {
   /**
    * 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 long getCompressedSize() {
     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 0d16cd967b..0000000000
--- 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 b930726019..0000000000
--- 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 51582a458b..b0d96eecd3 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 @@
 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;
 
@@ -308,24 +306,6 @@ public void write(DataOutput out) throws IOException {
       out.writeShort(minor);
     }
 
-    /**
-     * 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.
      *
@@ -374,34 +354,4 @@ public int hashCode() {
     }
   }
 
-  /**
-   * 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;
-  }
-
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services