@@ -510,38 +510,38 @@ public Void call() {
510510
511511    private  Void  readColumnFamily (Table  table , ColumnFamilyDescriptor  column ) {
512512      byte [] startKey  = null ;
513-       Get  get  = null ;
514-       Scan  scan  = null ;
513+       Scan  scan  = new  Scan ();
515514      ResultScanner  rs  = null ;
516515      StopWatch  stopWatch  = new  StopWatch ();
517516      startKey  = region .getStartKey ();
518517      // Can't do a get on empty start row so do a Scan of first element if any instead. 
519518      if  (startKey .length  > 0 ) {
520-         get  = new  Get (startKey );
521-         get .setCacheBlocks (false );
522-         get .setFilter (new  FirstKeyOnlyFilter ());
523-         get .addFamily (column .getName ());
524-       } else  {
525-         scan  = new  Scan ();
526-         LOG .debug ("rawScan {} for {}" , rawScanEnabled , region .getTable ());
527-         scan .setRaw (rawScanEnabled );
528-         scan .setCaching (1 );
529-         scan .setCacheBlocks (false );
530-         scan .setFilter (new  FirstKeyOnlyFilter ());
531-         scan .addFamily (column .getName ());
532-         scan .setMaxResultSize (1L );
533-         scan .setOneRowLimit ();
519+         // There are 4 types of region for any table. 
520+         // 1. Start and End key are empty. (Table with Single region) 
521+         // 2. Start key is empty. (First region of the table) 
522+         // 3. End key is empty. (Last region of the table) 
523+         // 4. Region with Start & End key. (All the regions between first & last region of the 
524+         // table.) 
525+         // 
526+         // Since Scan only takes Start and/or End Row and doesn't accept the region ID, 
527+         // we set the start row when Regions are of type 3 OR 4 as mentioned above. 
528+         // For type 1 and 2, We don't need to set this option. 
529+         scan .withStartRow (startKey );
534530      }
531+       LOG .debug ("rawScan {} for {}" , rawScanEnabled , region .getTable ());
532+       scan .setRaw (rawScanEnabled );
533+       scan .setCaching (1 );
534+       scan .setCacheBlocks (false );
535+       scan .setFilter (new  FirstKeyOnlyFilter ());
536+       scan .addFamily (column .getName ());
537+       scan .setMaxResultSize (1L );
538+       scan .setOneRowLimit ();
535539      LOG .debug ("Reading from {} {} {} {}" , region .getTable (), region .getRegionNameAsString (),
536540        column .getNameAsString (), Bytes .toStringBinary (startKey ));
537541      try  {
538542        stopWatch .start ();
539-         if  (startKey .length  > 0 ) {
540-           table .get (get );
541-         } else  {
542-           rs  = table .getScanner (scan );
543-           rs .next ();
544-         }
543+         rs  = table .getScanner (scan );
544+         rs .next ();
545545        stopWatch .stop ();
546546        this .readWriteLatency .add (stopWatch .getTime ());
547547        sink .publishReadTiming (serverName , region , column , stopWatch .getTime ());
0 commit comments