@@ -141,6 +141,9 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
141141    BulkLoadHFiles .IGNORE_UNMATCHED_CF_CONF_KEY ;
142142  public  final  static  String  ALWAYS_COPY_FILES  = BulkLoadHFiles .ALWAYS_COPY_FILES ;
143143
144+   public  static  final  String  FAIL_IF_NEED_SPLIT_HFILE  =
145+     "hbase.loadincremental.fail.if.need.split.hfile" ;
146+ 
144147  // We use a '.' prefix which is ignored when walking directory trees 
145148  // above. It is invalid family name. 
146149  static  final  String  TMP_DIR  = ".tmp" ;
@@ -162,6 +165,8 @@ public class LoadIncrementalHFiles extends Configured implements Tool {
162165
163166  private  boolean  replicate  = true ;
164167
168+   private  boolean  failIfNeedSplitHFile  = false ;
169+ 
165170  /** 
166171   * Represents an HFile waiting to be loaded. An queue is used in this class in order to support 
167172   * the case where a region has split during the process of the load. When this happens, the HFile 
@@ -195,6 +200,7 @@ public void initialize() {
195200    assignSeqIds  = conf .getBoolean (ASSIGN_SEQ_IDS , true );
196201    maxFilesPerRegionPerFamily  = conf .getInt (MAX_FILES_PER_REGION_PER_FAMILY , 32 );
197202    bulkLoadByFamily  = conf .getBoolean (BulkLoadHFiles .BULK_LOAD_HFILES_BY_FAMILY , false );
203+     failIfNeedSplitHFile  = conf .getBoolean (FAIL_IF_NEED_SPLIT_HFILE , false );
198204    nrThreads  =
199205      conf .getInt ("hbase.loadincremental.threads.max" , Runtime .getRuntime ().availableProcessors ());
200206    numRetries  = new  AtomicInteger (0 );
@@ -803,6 +809,11 @@ CacheConfig.DISABLED, true, getConf())) {
803809      Bytes .compareTo (last .get (), startEndKeys .getSecond ()[firstKeyRegionIdx ]) < 0 
804810        || Bytes .equals (startEndKeys .getSecond ()[firstKeyRegionIdx ], HConstants .EMPTY_BYTE_ARRAY );
805811    if  (!lastKeyInRange ) {
812+       if  (failIfNeedSplitHFile ) {
813+         throw  new  IOException (
814+           "The key range of hfile="  + hfilePath  + " fits into no region. "  + "And because " 
815+             + FAIL_IF_NEED_SPLIT_HFILE  + " was set to true, we just skip the next steps." );
816+       }
806817      int  lastKeyRegionIdx  = getRegionIndex (startEndKeys , last .get ());
807818      int  splitIdx  = (firstKeyRegionIdx  + lastKeyRegionIdx ) >>> 1 ;
808819      // make sure the splitPoint is valid in case region overlap occur, maybe the splitPoint bigger 
0 commit comments