diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java index ce4518b54263..190ad5627bc6 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreFile.java @@ -135,4 +135,9 @@ public interface StoreFile { * Get the max timestamp of all the cells in the store file. */ OptionalLong getMaximumTimestamp(); + + /** + * Get the reader for this store file + */ + StoreFileReader getReader(); } diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreUtils.java index dd1772979694..b87d26c8cc42 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreUtils.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreUtils.java @@ -42,7 +42,7 @@ public class StoreUtils { /** * Creates a deterministic hash code for store file collection. */ - public static OptionalInt getDeterministicRandomSeed(Collection files) { + public static OptionalInt getDeterministicRandomSeed(Collection files) { return files.stream().mapToInt(f -> f.getPath().getName().hashCode()).findFirst(); } @@ -50,17 +50,17 @@ public static OptionalInt getDeterministicRandomSeed(Collection file * Determines whether any files in the collection are references. * @param files The files. */ - public static boolean hasReferences(Collection files) { + public static boolean hasReferences(Collection files) { // TODO: make sure that we won't pass null here in the future. - return files != null ? files.stream().anyMatch(HStoreFile::isReference) : false; + return files != null ? files.stream().anyMatch(sf -> sf.isReference()) : false; } /** * Gets lowest timestamp from candidate StoreFiles */ - public static long getLowestTimestamp(Collection candidates) throws IOException { + public static long getLowestTimestamp(Collection candidates) throws IOException { long minTs = Long.MAX_VALUE; - for (HStoreFile storeFile : candidates) { + for (StoreFile storeFile : candidates) { minTs = Math.min(minTs, storeFile.getModificationTimestamp()); } return minTs; @@ -71,7 +71,7 @@ public static long getLowestTimestamp(Collection candidates) throws * @param candidates The files to choose from. * @return The largest file; null if no file has a reader. */ - static Optional getLargestFile(Collection candidates) { + static Optional getLargestFile(Collection candidates) { return candidates.stream().filter(f -> f.getReader() != null) .max((f1, f2) -> Long.compare(f1.getReader().length(), f2.getReader().length())); } @@ -81,16 +81,16 @@ static Optional getLargestFile(Collection candidates) { * were created by a mapreduce bulk load are ignored, as they do not correspond to any specific * put operation, and thus do not have a memstoreTS associated with them. */ - public static OptionalLong getMaxMemStoreTSInList(Collection sfs) { - return sfs.stream().filter(sf -> !sf.isBulkLoadResult()).mapToLong(HStoreFile::getMaxMemStoreTS) + public static OptionalLong getMaxMemStoreTSInList(Collection sfs) { + return sfs.stream().filter(sf -> !sf.isBulkLoadResult()).mapToLong(sf -> sf.getMaxMemStoreTS()) .max(); } /** * Return the highest sequence ID found across all storefiles in the given list. */ - public static OptionalLong getMaxSequenceIdInList(Collection sfs) { - return sfs.stream().mapToLong(HStoreFile::getMaxSequenceId).max(); + public static OptionalLong getMaxSequenceIdInList(Collection sfs) { + return sfs.stream().mapToLong(sf -> sf.getMaxSequenceId()).max(); } /** @@ -99,7 +99,7 @@ public static OptionalLong getMaxSequenceIdInList(Collection sfs) { * @param comparator Comparator used to compare KVs. * @return The split point row, or null if splitting is not possible, or reader is null. */ - static Optional getFileSplitPoint(HStoreFile file, CellComparator comparator) + static Optional getFileSplitPoint(StoreFile file, CellComparator comparator) throws IOException { StoreFileReader reader = file.getReader(); if (reader == null) { @@ -130,9 +130,9 @@ static Optional getFileSplitPoint(HStoreFile file, CellComparator compar /** * Gets the mid point of the largest file passed in as split point. */ - static Optional getSplitPoint(Collection storefiles, + static Optional getSplitPoint(Collection storefiles, CellComparator comparator) throws IOException { - Optional largestFile = StoreUtils.getLargestFile(storefiles); + Optional largestFile = StoreUtils.getLargestFile(storefiles); return largestFile.isPresent() ? StoreUtils.getFileSplitPoint(largestFile.get(), comparator) : Optional.empty(); }