Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C697619932 for ; Fri, 1 Apr 2016 15:16:55 +0000 (UTC) Received: (qmail 46541 invoked by uid 500); 1 Apr 2016 15:16:46 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 46474 invoked by uid 500); 1 Apr 2016 15:16:46 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 44915 invoked by uid 99); 1 Apr 2016 15:16:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Apr 2016 15:16:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E3EA1E0593; Fri, 1 Apr 2016 15:16:45 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: misty@apache.org To: commits@hbase.apache.org Date: Fri, 01 Apr 2016 15:17:26 -0000 Message-Id: In-Reply-To: <98bc15aea5de4805abe6023b9a6c76af@git.apache.org> References: <98bc15aea5de4805abe6023b9a6c76af@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/51] [partial] hbase-site git commit: Published site at 25419d8b18dd8f35a102614cd31b274659f747ef. http://git-wip-us.apache.org/repos/asf/hbase-site/blob/ce2de59a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableSplit.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableSplit.html b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableSplit.html index ab01266..343c259 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableSplit.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/mapreduce/TableSplit.html @@ -60,312 +60,349 @@ 052 enum Version { 053 UNVERSIONED(0), 054 // Initial number we put on TableSplit when we introduced versioning. -055 INITIAL(-1); -056 -057 final int code; -058 static final Version[] byCode; -059 static { -060 byCode = Version.values(); -061 for (int i = 0; i < byCode.length; i++) { -062 if (byCode[i].code != -1 * i) { -063 throw new AssertionError("Values in this enum should be descending by one"); -064 } -065 } -066 } -067 -068 Version(int code) { -069 this.code = code; -070 } -071 -072 boolean atLeast(Version other) { -073 return code <= other.code; -074 } -075 -076 static Version fromCode(int code) { -077 return byCode[code * -1]; -078 } -079 } -080 -081 private static final Version VERSION = Version.INITIAL; -082 private TableName tableName; -083 private byte [] startRow; -084 private byte [] endRow; -085 private String regionLocation; -086 private String scan = ""; // stores the serialized form of the Scan -087 private long length; // Contains estimation of region size in bytes -088 -089 /** Default constructor. */ -090 public TableSplit() { -091 this((TableName)null, null, HConstants.EMPTY_BYTE_ARRAY, -092 HConstants.EMPTY_BYTE_ARRAY, ""); -093 } -094 -095 /** -096 * Creates a new instance while assigning all variables. -097 * Length of region is set to 0 -098 * -099 * @param tableName The name of the current table. -100 * @param scan The scan associated with this split. -101 * @param startRow The start row of the split. -102 * @param endRow The end row of the split. -103 * @param location The location of the region. -104 */ -105 public TableSplit(TableName tableName, Scan scan, byte [] startRow, byte [] endRow, -106 final String location) { -107 this(tableName, scan, startRow, endRow, location, 0L); -108 } -109 -110 /** -111 * Creates a new instance while assigning all variables. -112 * -113 * @param tableName The name of the current table. -114 * @param scan The scan associated with this split. -115 * @param startRow The start row of the split. -116 * @param endRow The end row of the split. -117 * @param location The location of the region. -118 */ -119 public TableSplit(TableName tableName, Scan scan, byte [] startRow, byte [] endRow, -120 final String location, long length) { -121 this.tableName = tableName; -122 try { -123 this.scan = -124 (null == scan) ? "" : TableMapReduceUtil.convertScanToString(scan); -125 } catch (IOException e) { -126 LOG.warn("Failed to convert Scan to String", e); -127 } -128 this.startRow = startRow; -129 this.endRow = endRow; -130 this.regionLocation = location; -131 this.length = length; -132 } -133 -134 /** -135 * Creates a new instance without a scanner. -136 * -137 * @param tableName The name of the current table. -138 * @param startRow The start row of the split. -139 * @param endRow The end row of the split. -140 * @param location The location of the region. -141 */ -142 public TableSplit(TableName tableName, byte[] startRow, byte[] endRow, -143 final String location) { -144 this(tableName, null, startRow, endRow, location); -145 } -146 -147 /** -148 * Creates a new instance without a scanner. -149 * -150 * @param tableName The name of the current table. -151 * @param startRow The start row of the split. -152 * @param endRow The end row of the split. -153 * @param location The location of the region. -154 * @param length Size of region in bytes -155 */ -156 public TableSplit(TableName tableName, byte[] startRow, byte[] endRow, -157 final String location, long length) { -158 this(tableName, null, startRow, endRow, location, length); -159 } -160 -161 /** -162 * Returns a Scan object from the stored string representation. -163 * -164 * @return Returns a Scan object based on the stored scanner. -165 * @throws IOException -166 */ -167 public Scan getScan() throws IOException { -168 return TableMapReduceUtil.convertStringToScan(this.scan); -169 } -170 -171 /** -172 * Returns the table name converted to a byte array. -173 * @see #getTable() -174 * @return The table name. -175 */ -176 public byte [] getTableName() { -177 return tableName.getName(); -178 } -179 -180 /** -181 * Returns the table name. -182 * -183 * @return The table name. -184 */ -185 public TableName getTable() { -186 // It is ugly that usually to get a TableName, the method is called getTableName. We can't do -187 // that in here though because there was an existing getTableName in place already since -188 // deprecated. -189 return tableName; -190 } -191 -192 /** -193 * Returns the start row. -194 * -195 * @return The start row. -196 */ -197 public byte [] getStartRow() { -198 return startRow; -199 } -200 -201 /** -202 * Returns the end row. -203 * -204 * @return The end row. -205 */ -206 public byte [] getEndRow() { -207 return endRow; -208 } -209 -210 /** -211 * Returns the region location. -212 * -213 * @return The region's location. -214 */ -215 public String getRegionLocation() { -216 return regionLocation; -217 } -218 -219 /** -220 * Returns the region's location as an array. -221 * -222 * @return The array containing the region location. -223 * @see org.apache.hadoop.mapreduce.InputSplit#getLocations() -224 */ -225 @Override -226 public String[] getLocations() { -227 return new String[] {regionLocation}; -228 } -229 -230 /** -231 * Returns the length of the split. -232 * -233 * @return The length of the split. -234 * @see org.apache.hadoop.mapreduce.InputSplit#getLength() -235 */ -236 @Override -237 public long getLength() { -238 return length; +055 INITIAL(-1), +056 // Added an encoded region name field for easier identification of split -> region +057 WITH_ENCODED_REGION_NAME(-2); +058 +059 final int code; +060 static final Version[] byCode; +061 static { +062 byCode = Version.values(); +063 for (int i = 0; i < byCode.length; i++) { +064 if (byCode[i].code != -1 * i) { +065 throw new AssertionError("Values in this enum should be descending by one"); +066 } +067 } +068 } +069 +070 Version(int code) { +071 this.code = code; +072 } +073 +074 boolean atLeast(Version other) { +075 return code <= other.code; +076 } +077 +078 static Version fromCode(int code) { +079 return byCode[code * -1]; +080 } +081 } +082 +083 private static final Version VERSION = Version.WITH_ENCODED_REGION_NAME; +084 private TableName tableName; +085 private byte [] startRow; +086 private byte [] endRow; +087 private String regionLocation; +088 private String encodedRegionName = ""; +089 private String scan = ""; // stores the serialized form of the Scan +090 private long length; // Contains estimation of region size in bytes +091 +092 /** Default constructor. */ +093 public TableSplit() { +094 this((TableName)null, null, HConstants.EMPTY_BYTE_ARRAY, +095 HConstants.EMPTY_BYTE_ARRAY, ""); +096 } +097 +098 /** +099 * Creates a new instance while assigning all variables. +100 * Length of region is set to 0 +101 * Encoded name of the region is set to blank +102 * +103 * @param tableName The name of the current table. +104 * @param scan The scan associated with this split. +105 * @param startRow The start row of the split. +106 * @param endRow The end row of the split. +107 * @param location The location of the region. +108 */ +109 public TableSplit(TableName tableName, Scan scan, byte [] startRow, byte [] endRow, +110 final String location) { +111 this(tableName, scan, startRow, endRow, location, 0L); +112 } +113 +114 /** +115 * Creates a new instance while assigning all variables. +116 * Encoded name of region is set to blank +117 * +118 * @param tableName The name of the current table. +119 * @param scan The scan associated with this split. +120 * @param startRow The start row of the split. +121 * @param endRow The end row of the split. +122 * @param location The location of the region. +123 */ +124 public TableSplit(TableName tableName, Scan scan, byte [] startRow, byte [] endRow, +125 final String location, long length) { +126 this(tableName, scan, startRow, endRow, location, "", length); +127 } +128 +129 /** +130 * Creates a new instance while assigning all variables. +131 * +132 * @param tableName The name of the current table. +133 * @param scan The scan associated with this split. +134 * @param startRow The start row of the split. +135 * @param endRow The end row of the split. +136 * @param encodedRegionName The region ID. +137 * @param location The location of the region. +138 */ +139 public TableSplit(TableName tableName, Scan scan, byte [] startRow, byte [] endRow, +140 final String location, final String encodedRegionName, long length) { +141 this.tableName = tableName; +142 try { +143 this.scan = +144 (null == scan) ? "" : TableMapReduceUtil.convertScanToString(scan); +145 } catch (IOException e) { +146 LOG.warn("Failed to convert Scan to String", e); +147 } +148 this.startRow = startRow; +149 this.endRow = endRow; +150 this.regionLocation = location; +151 this.encodedRegionName = encodedRegionName; +152 this.length = length; +153 } +154 +155 /** +156 * Creates a new instance without a scanner. +157 * Length of region is set to 0 +158 * +159 * @param tableName The name of the current table. +160 * @param startRow The start row of the split. +161 * @param endRow The end row of the split. +162 * @param location The location of the region. +163 */ +164 public TableSplit(TableName tableName, byte[] startRow, byte[] endRow, +165 final String location) { +166 this(tableName, null, startRow, endRow, location); +167 } +168 +169 /** +170 * Creates a new instance without a scanner. +171 * +172 * @param tableName The name of the current table. +173 * @param startRow The start row of the split. +174 * @param endRow The end row of the split. +175 * @param location The location of the region. +176 * @param length Size of region in bytes +177 */ +178 public TableSplit(TableName tableName, byte[] startRow, byte[] endRow, +179 final String location, long length) { +180 this(tableName, null, startRow, endRow, location, length); +181 } +182 +183 /** +184 * Returns a Scan object from the stored string representation. +185 * +186 * @return Returns a Scan object based on the stored scanner. +187 * @throws IOException +188 */ +189 public Scan getScan() throws IOException { +190 return TableMapReduceUtil.convertStringToScan(this.scan); +191 } +192 +193 /** +194 * Returns the table name converted to a byte array. +195 * @see #getTable() +196 * @return The table name. +197 */ +198 public byte [] getTableName() { +199 return tableName.getName(); +200 } +201 +202 /** +203 * Returns the table name. +204 * +205 * @return The table name. +206 */ +207 public TableName getTable() { +208 // It is ugly that usually to get a TableName, the method is called getTableName. We can't do +209 // that in here though because there was an existing getTableName in place already since +210 // deprecated. +211 return tableName; +212 } +213 +214 /** +215 * Returns the start row. +216 * +217 * @return The start row. +218 */ +219 public byte [] getStartRow() { +220 return startRow; +221 } +222 +223 /** +224 * Returns the end row. +225 * +226 * @return The end row. +227 */ +228 public byte [] getEndRow() { +229 return endRow; +230 } +231 +232 /** +233 * Returns the region location. +234 * +235 * @return The region's location. +236 */ +237 public String getRegionLocation() { +238 return regionLocation; 239 } 240 241 /** -242 * Reads the values of each field. +242 * Returns the region's location as an array. 243 * -244 * @param in The input to read from. -245 * @throws IOException When reading the input fails. +244 * @return The array containing the region location. +245 * @see org.apache.hadoop.mapreduce.InputSplit#getLocations() 246 */ 247 @Override -248 public void readFields(DataInput in) throws IOException { -249 Version version = Version.UNVERSIONED; -250 // TableSplit was not versioned in the beginning. -251 // In order to introduce it now, we make use of the fact -252 // that tableName was written with Bytes.writeByteArray, -253 // which encodes the array length as a vint which is >= 0. -254 // Hence if the vint is >= 0 we have an old version and the vint -255 // encodes the length of tableName. -256 // If < 0 we just read the version and the next vint is the length. -257 // @see Bytes#readByteArray(DataInput) -258 int len = WritableUtils.readVInt(in); -259 if (len < 0) { -260 // what we just read was the version -261 version = Version.fromCode(len); -262 len = WritableUtils.readVInt(in); -263 } -264 byte[] tableNameBytes = new byte[len]; -265 in.readFully(tableNameBytes); -266 tableName = TableName.valueOf(tableNameBytes); -267 startRow = Bytes.readByteArray(in); -268 endRow = Bytes.readByteArray(in); -269 regionLocation = Bytes.toString(Bytes.readByteArray(in)); -270 if (version.atLeast(Version.INITIAL)) { -271 scan = Bytes.toString(Bytes.readByteArray(in)); -272 } -273 length = WritableUtils.readVLong(in); -274 } -275 -276 /** -277 * Writes the field values to the output. -278 * -279 * @param out The output to write to. -280 * @throws IOException When writing the values to the output fails. -281 */ -282 @Override -283 public void write(DataOutput out) throws IOException { -284 WritableUtils.writeVInt(out, VERSION.code); -285 Bytes.writeByteArray(out, tableName.getName()); -286 Bytes.writeByteArray(out, startRow); -287 Bytes.writeByteArray(out, endRow); -288 Bytes.writeByteArray(out, Bytes.toBytes(regionLocation)); -289 Bytes.writeByteArray(out, Bytes.toBytes(scan)); -290 WritableUtils.writeVLong(out, length); -291 } -292 -293 /** -294 * Returns the details about this instance as a string. -295 * -296 * @return The values of this instance as a string. -297 * @see java.lang.Object#toString() -298 */ -299 @Override -300 public String toString() { -301 StringBuilder sb = new StringBuilder(); -302 sb.append("HBase table split("); -303 sb.append("table name: ").append(tableName); -304 // null scan input is represented by "" -305 String printScan = ""; -306 if (!scan.equals("")) { -307 try { -308 // get the real scan here in toString, not the Base64 string -309 printScan = TableMapReduceUtil.convertStringToScan(scan).toString(); -310 } -311 catch (IOException e) { -312 printScan = ""; -313 } -314 } -315 sb.append(", scan: ").append(printScan); -316 sb.append(", start row: ").append(Bytes.toStringBinary(startRow)); -317 sb.append(", end row: ").append(Bytes.toStringBinary(endRow)); -318 sb.append(", region location: ").append(regionLocation); -319 sb.append(")"); -320 return sb.toString(); -321 } -322 -323 /** -324 * Compares this split against the given one. -325 * -326 * @param split The split to compare to. -327 * @return The result of the comparison. -328 * @see java.lang.Comparable#compareTo(java.lang.Object) -329 */ -330 @Override -331 public int compareTo(TableSplit split) { -332 // If The table name of the two splits is the same then compare start row -333 // otherwise compare based on table names -334 int tableNameComparison = -335 getTable().compareTo(split.getTable()); -336 return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo( -337 getStartRow(), split.getStartRow()); -338 } -339 -340 @Override -341 public boolean equals(Object o) { -342 if (o == null || !(o instanceof TableSplit)) { -343 return false; -344 } -345 return tableName.equals(((TableSplit)o).tableName) && -346 Bytes.equals(startRow, ((TableSplit)o).startRow) && -347 Bytes.equals(endRow, ((TableSplit)o).endRow) && -348 regionLocation.equals(((TableSplit)o).regionLocation); -349 } -350 -351 @Override -352 public int hashCode() { -353 int result = tableName != null ? tableName.hashCode() : 0; -354 result = 31 * result + (scan != null ? scan.hashCode() : 0); -355 result = 31 * result + (startRow != null ? Arrays.hashCode(startRow) : 0); -356 result = 31 * result + (endRow != null ? Arrays.hashCode(endRow) : 0); -357 result = 31 * result + (regionLocation != null ? regionLocation.hashCode() : 0); -358 return result; -359 } -360} +248 public String[] getLocations() { +249 return new String[] {regionLocation}; +250 } +251 +252 /** +253 * Returns the region's encoded name. +254 * +255 * @return The region's encoded name. +256 */ +257 public String getEncodedRegionName() { +258 return encodedRegionName; +259 } +260 +261 /** +262 * Returns the length of the split. +263 * +264 * @return The length of the split. +265 * @see org.apache.hadoop.mapreduce.InputSplit#getLength() +266 */ +267 @Override +268 public long getLength() { +269 return length; +270 } +271 +272 /** +273 * Reads the values of each field. +274 * +275 * @param in The input to read from. +276 * @throws IOException When reading the input fails. +277 */ +278 @Override +279 public void readFields(DataInput in) throws IOException { +280 Version version = Version.UNVERSIONED; +281 // TableSplit was not versioned in the beginning. +282 // In order to introduce it now, we make use of the fact +283 // that tableName was written with Bytes.writeByteArray, +284 // which encodes the array length as a vint which is >= 0. +285 // Hence if the vint is >= 0 we have an old version and the vint +286 // encodes the length of tableName. +287 // If < 0 we just read the version and the next vint is the length. +288 // @see Bytes#readByteArray(DataInput) +289 int len = WritableUtils.readVInt(in); +290 if (len < 0) { +291 // what we just read was the version +292 version = Version.fromCode(len); +293 len = WritableUtils.readVInt(in); +294 } +295 byte[] tableNameBytes = new byte[len]; +296 in.readFully(tableNameBytes); +297 tableName = TableName.valueOf(tableNameBytes); +298 startRow = Bytes.readByteArray(in); +299 endRow = Bytes.readByteArray(in); +300 regionLocation = Bytes.toString(Bytes.readByteArray(in)); +301 if (version.atLeast(Version.INITIAL)) { +302 scan = Bytes.toString(Bytes.readByteArray(in)); +303 } +304 length = WritableUtils.readVLong(in); +305 if (version.atLeast(Version.WITH_ENCODED_REGION_NAME)) { +306 encodedRegionName = Bytes.toString(Bytes.readByteArray(in)); +307 } +308 } +309 +310 /** +311 * Writes the field values to the output. +312 * +313 * @param out The output to write to. +314 * @throws IOException When writing the values to the output fails. +315 */ +316 @Override +317 public void write(DataOutput out) throws IOException { +318 WritableUtils.writeVInt(out, VERSION.code); +319 Bytes.writeByteArray(out, tableName.getName()); +320 Bytes.writeByteArray(out, startRow); +321 Bytes.writeByteArray(out, endRow); +322 Bytes.writeByteArray(out, Bytes.toBytes(regionLocation)); +323 Bytes.writeByteArray(out, Bytes.toBytes(scan)); +324 WritableUtils.writeVLong(out, length); +325 Bytes.writeByteArray(out, Bytes.toBytes(encodedRegionName)); +326 } +327 +328 /** +329 * Returns the details about this instance as a string. +330 * +331 * @return The values of this instance as a string. +332 * @see java.lang.Object#toString() +333 */ +334 @Override +335 public String toString() { +336 StringBuilder sb = new StringBuilder(); +337 sb.append("HBase table split("); +338 sb.append("table name: ").append(tableName); +339 // null scan input is represented by "" +340 String printScan = ""; +341 if (!scan.equals("")) { +342 try { +343 // get the real scan here in toString, not the Base64 string +344 printScan = TableMapReduceUtil.convertStringToScan(scan).toString(); +345 } +346 catch (IOException e) { +347 printScan = ""; +348 } +349 } +350 sb.append(", scan: ").append(printScan); +351 sb.append(", start row: ").append(Bytes.toStringBinary(startRow)); +352 sb.append(", end row: ").append(Bytes.toStringBinary(endRow)); +353 sb.append(", region location: ").append(regionLocation); +354 sb.append(", encoded region name: ").append(encodedRegionName); +355 sb.append(")"); +356 return sb.toString(); +357 } +358 +359 /** +360 * Compares this split against the given one. +361 * +362 * @param split The split to compare to. +363 * @return The result of the comparison. +364 * @see java.lang.Comparable#compareTo(java.lang.Object) +365 */ +366 @Override +367 public int compareTo(TableSplit split) { +368 // If The table name of the two splits is the same then compare start row +369 // otherwise compare based on table names +370 int tableNameComparison = +371 getTable().compareTo(split.getTable()); +372 return tableNameComparison != 0 ? tableNameComparison : Bytes.compareTo( +373 getStartRow(), split.getStartRow()); +374 } +375 +376 @Override +377 public boolean equals(Object o) { +378 if (o == null || !(o instanceof TableSplit)) { +379 return false; +380 } +381 return tableName.equals(((TableSplit)o).tableName) && +382 Bytes.equals(startRow, ((TableSplit)o).startRow) && +383 Bytes.equals(endRow, ((TableSplit)o).endRow) && +384 regionLocation.equals(((TableSplit)o).regionLocation); +385 } +386 +387 @Override +388 public int hashCode() { +389 int result = tableName != null ? tableName.hashCode() : 0; +390 result = 31 * result + (scan != null ? scan.hashCode() : 0); +391 result = 31 * result + (startRow != null ? Arrays.hashCode(startRow) : 0); +392 result = 31 * result + (endRow != null ? Arrays.hashCode(endRow) : 0); +393 result = 31 * result + (regionLocation != null ? regionLocation.hashCode() : 0); +394 result = 31 * result + (encodedRegionName != null ? encodedRegionName.hashCode() : 0); +395 return result; +396 } +397}