Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
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.hadoop.hbase.regionserver;
 
 import java.util.Map;
 
 
A split policy determines when a region should be split.

See also:
IncreasingToUpperBoundRegionSplitPolicy Default split policy since 0.94.0
ConstantSizeRegionSplitPolicy Default split policy before 0.94.0
 
 public abstract class RegionSplitPolicy extends Configured {
   private static final Class<? extends RegionSplitPolicy>
The region configured for this split policy.
 
   protected HRegion region;

  
Upon construction, this method will be called with the region to be governed. It will be called once and only once.
 
   protected void configureForRegion(HRegion region) {
     Preconditions.checkState(
         this. == null,
         "Policy already configured for region {}",
         this.);
 
     this. = region;
   }

  

Returns:
true if the specified region should be split.
 
   protected abstract boolean shouldSplit();

  

Returns:
the key at which the region should be split, or null if it cannot be split. This will only be called if shouldSplit previously returned true.
 
   protected byte[] getSplitPoint() {
     byte[] explicitSplitPoint = this..getExplicitSplitPoint();
     if (explicitSplitPoint != null) {
       return explicitSplitPoint;
     }
     Map<byte[], Storestores = .getStores();
 
     byte[] splitPointFromLargestStore = null;
     long largestStoreSize = 0;
     for (Store s : stores.values()) {
       byte[] splitPoint = s.getSplitPoint();
       long storeSize = s.getSize();
       if (splitPoint != null && largestStoreSize < storeSize) {
         splitPointFromLargestStore = splitPoint;
         largestStoreSize = storeSize;
       }
     }
 
     return splitPointFromLargestStore;
   }

  
Create the RegionSplitPolicy configured for the given table.

Parameters:
region
conf
Returns:
a RegionSplitPolicy
Throws:
java.io.IOException
 
  public static RegionSplitPolicy create(HRegion region,
      Configuration confthrows IOException {
    Class<? extends RegionSplitPolicyclazz = getSplitPolicyClass(
        region.getTableDesc(), conf);
    RegionSplitPolicy policy = ReflectionUtils.newInstance(clazzconf);
    policy.configureForRegion(region);
    return policy;
  }
  public static Class<? extends RegionSplitPolicygetSplitPolicyClass(
      HTableDescriptor htdConfiguration confthrows IOException {
    String className = htd.getRegionSplitPolicyClassName();
    if (className == null) {
      className = conf.get(.,
          .getName());
    }
    try {
      Class<? extends RegionSplitPolicyclazz =
        Class.forName(className).asSubclass(RegionSplitPolicy.class);
      return clazz;
    } catch (Exception  e) {
      throw new IOException(
          "Unable to load configured region split policy '" +
          className + "' for table '" + htd.getTableName() + "'",
          e);
    }
  }

  
In HRegionFileSystem.splitStoreFile(org.apache.hadoop.hbase.HRegionInfo,java.lang.String,org.apache.hadoop.hbase.regionserver.StoreFile,byte[],boolean,org.apache.hadoop.hbase.regionserver.RegionSplitPolicy) we are not creating the split reference if split row not lies in the StoreFile range. But in some use cases we may need to create the split reference even when the split row not lies in the range. This method can be used to decide, whether to skip the the StoreFile range check or not.

Returns:
whether to skip the StoreFile range check or not
  protected boolean skipStoreFileRangeCheck() {
    return false;
  }
New to GrepCode? Check out our FAQ X