public static List < Scan > scansThisCubeOnly ( byte [ ] keyPrefix , byte [ ] [ ] splitKeys ) throws IOException { Scan copyScan = new Scan ( ) ; copyScan . setCaching ( 5000 ) ; copyScan . setCacheBlocks ( false ) ; // Hack: generate a key that probably comes after all this cube's keys but doesn't include any // keys not belonging to this cube. byte [ ] keyAfterCube = ArrayUtils . addAll ( keyPrefix , fiftyBytesFF ) ; List < Scan > scans = new ArrayList < Scan > ( ) ; Scan scanUnderConstruction = new Scan ( copyScan ) ; for ( byte [ ] splitKey : splitKeys ) { scanUnderConstruction . setStopRow ( splitKey ) ; // Coerce scan to only touch keys belonging to this cube Scan truncated = truncateScan ( scanUnderConstruction , keyPrefix , keyAfterCube ) ; if ( truncated != null ) { scans . add ( truncated ) ; } scanUnderConstruction = new Scan ( copyScan ) ; scanUnderConstruction . setStartRow ( splitKey ) ; } // There's another region from last split key to the end of the table. Scan truncated = truncateScan ( scanUnderConstruction , keyPrefix , keyAfterCube ) ; if ( truncated != null ) { scans . add ( truncated ) ; } return scans ; }
Get a collection of Scans one per region that cover the range of the table having the given key prefix . Thes will be used as the map task input splits .