Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ public class StoreUtils {
/**
* Creates a deterministic hash code for store file collection.
*/
public static OptionalInt getDeterministicRandomSeed(Collection<HStoreFile> files) {
public static OptionalInt getDeterministicRandomSeed(Collection<? extends StoreFile> files) {
return files.stream().mapToInt(f -> f.getPath().getName().hashCode()).findFirst();
}

/**
* Determines whether any files in the collection are references.
* @param files The files.
*/
public static boolean hasReferences(Collection<HStoreFile> files) {
public static boolean hasReferences(Collection<? extends StoreFile> 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<HStoreFile> candidates) throws IOException {
public static long getLowestTimestamp(Collection<? extends StoreFile> candidates) throws IOException {
long minTs = Long.MAX_VALUE;
for (HStoreFile storeFile : candidates) {
for (StoreFile storeFile : candidates) {
minTs = Math.min(minTs, storeFile.getModificationTimestamp());
}
return minTs;
Expand All @@ -71,7 +71,7 @@ public static long getLowestTimestamp(Collection<HStoreFile> candidates) throws
* @param candidates The files to choose from.
* @return The largest file; null if no file has a reader.
*/
static Optional<HStoreFile> getLargestFile(Collection<HStoreFile> candidates) {
static Optional<? extends StoreFile> getLargestFile(Collection<? extends StoreFile> candidates) {
return candidates.stream().filter(f -> f.getReader() != null)
.max((f1, f2) -> Long.compare(f1.getReader().length(), f2.getReader().length()));
}
Expand All @@ -81,16 +81,16 @@ static Optional<HStoreFile> getLargestFile(Collection<HStoreFile> 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<HStoreFile> sfs) {
return sfs.stream().filter(sf -> !sf.isBulkLoadResult()).mapToLong(HStoreFile::getMaxMemStoreTS)
public static OptionalLong getMaxMemStoreTSInList(Collection<? extends StoreFile> 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<HStoreFile> sfs) {
return sfs.stream().mapToLong(HStoreFile::getMaxSequenceId).max();
public static OptionalLong getMaxSequenceIdInList(Collection<? extends StoreFile> sfs) {
return sfs.stream().mapToLong(sf -> sf.getMaxSequenceId()).max();
}

/**
Expand All @@ -99,7 +99,7 @@ public static OptionalLong getMaxSequenceIdInList(Collection<HStoreFile> 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<byte[]> getFileSplitPoint(HStoreFile file, CellComparator comparator)
static Optional<byte[]> getFileSplitPoint(StoreFile file, CellComparator comparator)
throws IOException {
StoreFileReader reader = file.getReader();
if (reader == null) {
Expand Down Expand Up @@ -130,9 +130,9 @@ static Optional<byte[]> getFileSplitPoint(HStoreFile file, CellComparator compar
/**
* Gets the mid point of the largest file passed in as split point.
*/
static Optional<byte[]> getSplitPoint(Collection<HStoreFile> storefiles,
static Optional<byte[]> getSplitPoint(Collection<? extends StoreFile> storefiles,
CellComparator comparator) throws IOException {
Optional<HStoreFile> largestFile = StoreUtils.getLargestFile(storefiles);
Optional<? extends StoreFile> largestFile = StoreUtils.getLargestFile(storefiles);
return largestFile.isPresent() ? StoreUtils.getFileSplitPoint(largestFile.get(), comparator)
: Optional.empty();
}
Expand Down