Search in sources :

Example 6 with CompactionDelPartition

use of org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionDelPartition in project hbase by apache.

the class PartitionedMobCompactor method getListOfDelFilesForPartition.

@VisibleForTesting
List<StoreFile> getListOfDelFilesForPartition(final CompactionPartition partition, final List<CompactionDelPartition> delPartitions) {
    // Binary search for startKey and endKey
    List<StoreFile> result = new ArrayList<>();
    DelPartitionComparator comparator = new DelPartitionComparator(false);
    CompactionDelPartitionId id = new CompactionDelPartitionId(null, partition.getStartKey());
    CompactionDelPartition target = new CompactionDelPartition(id);
    int start = Collections.binarySearch(delPartitions, target, comparator);
    // Get the start index for partition
    if (start < 0) {
        // Calculate the insert point
        start = (start + 1) * (-1);
        if (start == delPartitions.size()) {
            // no overlap
            return result;
        } else {
            // Check another case which has no overlap
            if (Bytes.compareTo(partition.getEndKey(), delPartitions.get(start).getId().getStartKey()) < 0) {
                return result;
            }
        }
    }
    // Search for end index for the partition
    comparator.setCompareStartKey(true);
    id.setStartKey(partition.getEndKey());
    int end = Collections.binarySearch(delPartitions, target, comparator);
    if (end < 0) {
        end = (end + 1) * (-1);
        if (end == 0) {
            return result;
        } else {
            --end;
            if (Bytes.compareTo(partition.getStartKey(), delPartitions.get(end).getId().getEndKey()) > 0) {
                return result;
            }
        }
    }
    for (int i = start; i <= end; ++i) {
        result.addAll(delPartitions.get(i).getStoreFiles());
    }
    return result;
}
Also used : CompactionDelPartitionId(org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionDelPartitionId) ArrayList(java.util.ArrayList) StoreFile(org.apache.hadoop.hbase.regionserver.StoreFile) CompactionDelPartition(org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionDelPartition) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

CompactionDelPartition (org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionDelPartition)6 Path (org.apache.hadoop.fs.Path)4 ArrayList (java.util.ArrayList)2 CompactionDelPartitionId (org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionDelPartitionId)2 CompactionPartition (org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionPartition)2 StoreFile (org.apache.hadoop.hbase.regionserver.StoreFile)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 IOException (java.io.IOException)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 TreeMap (java.util.TreeMap)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 MobCompactPartitionPolicy (org.apache.hadoop.hbase.client.MobCompactPartitionPolicy)1 HFileLink (org.apache.hadoop.hbase.io.HFileLink)1 Reader (org.apache.hadoop.hbase.io.hfile.HFile.Reader)1 CompactionPartitionId (org.apache.hadoop.hbase.mob.compactions.PartitionedMobCompactionRequest.CompactionPartitionId)1