Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 6BB0D200D61 for ; Tue, 19 Dec 2017 16:17:45 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 68DC4160C30; Tue, 19 Dec 2017 15:17:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0FB99160C18 for ; Tue, 19 Dec 2017 16:17:42 +0100 (CET) Received: (qmail 88584 invoked by uid 500); 19 Dec 2017 15:17:42 -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 88575 invoked by uid 99); 19 Dec 2017 15:17:42 -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; Tue, 19 Dec 2017 15:17:42 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0E012DFF73; Tue, 19 Dec 2017 15:17:42 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: git-site-role@apache.org To: commits@hbase.apache.org Date: Tue, 19 Dec 2017 15:17:42 -0000 Message-Id: <022114e334ce44daad39f9a9ee1acb2f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/51] [partial] hbase-site git commit: Published site at . archived-at: Tue, 19 Dec 2017 15:17:45 -0000 Repository: hbase-site Updated Branches: refs/heads/asf-site 277e911c8 -> dad9a249f http://git-wip-us.apache.org/repos/asf/hbase-site/blob/dad9a249/devapidocs/src-html/org/apache/hadoop/hbase/IndividualBytesFieldCell.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/IndividualBytesFieldCell.html b/devapidocs/src-html/org/apache/hadoop/hbase/IndividualBytesFieldCell.html index d6a8ea3..242f82e 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/IndividualBytesFieldCell.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/IndividualBytesFieldCell.html @@ -26,286 +26,319 @@ 018 019package org.apache.hadoop.hbase; 020 -021import org.apache.commons.lang3.ArrayUtils; -022import org.apache.hadoop.hbase.util.Bytes; -023import org.apache.hadoop.hbase.util.ClassSize; -024import org.apache.yetus.audience.InterfaceAudience; -025 -026@InterfaceAudience.Private -027public class IndividualBytesFieldCell implements ExtendedCell { -028 -029 private static final long FIXED_OVERHEAD = ClassSize.align( // do alignment(padding gap) -030 ClassSize.OBJECT // object header -031 + KeyValue.TIMESTAMP_TYPE_SIZE // timestamp and type -032 + Bytes.SIZEOF_LONG // sequence id -033 + 5 * ClassSize.REFERENCE); // references to all byte arrays: row, family, qualifier, value, tags -034 -035 // The following fields are backed by individual byte arrays -036 private final byte[] row; -037 private final int rOffset; -038 private final int rLength; -039 private final byte[] family; -040 private final int fOffset; -041 private final int fLength; -042 private final byte[] qualifier; -043 private final int qOffset; -044 private final int qLength; -045 private final byte[] value; -046 private final int vOffset; -047 private final int vLength; -048 private final byte[] tags; // A byte array, rather than an array of org.apache.hadoop.hbase.Tag -049 private final int tagsOffset; -050 private final int tagsLength; -051 -052 // Other fields -053 private long timestamp; -054 private final byte type; // A byte, rather than org.apache.hadoop.hbase.KeyValue.Type -055 private long seqId; -056 -057 public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, -058 long timestamp, KeyValue.Type type, byte[] value) { -059 this(row, family, qualifier, timestamp, type, 0L /* sequence id */, value, null /* tags */); -060 } -061 -062 public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, -063 long timestamp, KeyValue.Type type, long seqId, byte[] value, byte[] tags) { -064 this(row, 0, ArrayUtils.getLength(row), -065 family, 0, ArrayUtils.getLength(family), -066 qualifier, 0, ArrayUtils.getLength(qualifier), -067 timestamp, type, seqId, -068 value, 0, ArrayUtils.getLength(value), -069 tags, 0, ArrayUtils.getLength(tags)); -070 } -071 -072 public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength, -073 byte[] family, int fOffset, int fLength, -074 byte[] qualifier, int qOffset, int qLength, -075 long timestamp, KeyValue.Type type, long seqId, -076 byte[] value, int vOffset, int vLength, -077 byte[] tags, int tagsOffset, int tagsLength) { +021import static org.apache.hadoop.hbase.Tag.TAG_LENGTH_SIZE; +022 +023import java.util.ArrayList; +024import java.util.Iterator; +025import java.util.List; +026import java.util.Optional; +027 +028import org.apache.commons.lang3.ArrayUtils; +029import org.apache.hadoop.hbase.util.Bytes; +030import org.apache.hadoop.hbase.util.ClassSize; +031import org.apache.yetus.audience.InterfaceAudience; +032 +033@InterfaceAudience.Private +034public class IndividualBytesFieldCell implements ExtendedCell { +035 +036 private static final long FIXED_OVERHEAD = ClassSize.align( // do alignment(padding gap) +037 ClassSize.OBJECT // object header +038 + KeyValue.TIMESTAMP_TYPE_SIZE // timestamp and type +039 + Bytes.SIZEOF_LONG // sequence id +040 + 5 * ClassSize.REFERENCE); // references to all byte arrays: row, family, qualifier, value, tags +041 +042 // The following fields are backed by individual byte arrays +043 private final byte[] row; +044 private final int rOffset; +045 private final int rLength; +046 private final byte[] family; +047 private final int fOffset; +048 private final int fLength; +049 private final byte[] qualifier; +050 private final int qOffset; +051 private final int qLength; +052 private final byte[] value; +053 private final int vOffset; +054 private final int vLength; +055 private final byte[] tags; // A byte array, rather than an array of org.apache.hadoop.hbase.Tag +056 private final int tagsOffset; +057 private final int tagsLength; +058 +059 // Other fields +060 private long timestamp; +061 private final byte type; // A byte, rather than org.apache.hadoop.hbase.KeyValue.Type +062 private long seqId; +063 +064 public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, +065 long timestamp, KeyValue.Type type, byte[] value) { +066 this(row, family, qualifier, timestamp, type, 0L /* sequence id */, value, null /* tags */); +067 } +068 +069 public IndividualBytesFieldCell(byte[] row, byte[] family, byte[] qualifier, +070 long timestamp, KeyValue.Type type, long seqId, byte[] value, byte[] tags) { +071 this(row, 0, ArrayUtils.getLength(row), +072 family, 0, ArrayUtils.getLength(family), +073 qualifier, 0, ArrayUtils.getLength(qualifier), +074 timestamp, type, seqId, +075 value, 0, ArrayUtils.getLength(value), +076 tags, 0, ArrayUtils.getLength(tags)); +077 } 078 -079 // Check row, family, qualifier and value -080 KeyValue.checkParameters(row, rLength, // row and row length -081 family, fLength, // family and family length -082 qLength, // qualifier length -083 vLength); // value length -084 -085 // Check timestamp -086 if (timestamp < 0) { -087 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp); -088 } -089 -090 // Check tags -091 RawCell.checkForTagsLength(tagsLength); -092 checkArrayBounds(row, rOffset, rLength); -093 checkArrayBounds(family, fOffset, fLength); -094 checkArrayBounds(qualifier, qOffset, qLength); -095 checkArrayBounds(value, vOffset, vLength); -096 checkArrayBounds(tags, tagsOffset, tagsLength); -097 // No local copy is made, but reference to the input directly -098 this.row = row; -099 this.rOffset = rOffset; -100 this.rLength = rLength; -101 this.family = family; -102 this.fOffset = fOffset; -103 this.fLength = fLength; -104 this.qualifier = qualifier; -105 this.qOffset = qOffset; -106 this.qLength = qLength; -107 this.value = value; -108 this.vOffset = vOffset; -109 this.vLength = vLength; -110 this.tags = tags; -111 this.tagsOffset = tagsOffset; -112 this.tagsLength = tagsLength; -113 -114 // Set others -115 this.timestamp = timestamp; -116 this.type = type.getCode(); -117 this.seqId = seqId; -118 } -119 -120 private void checkArrayBounds(byte[] bytes, int offset, int length) { -121 if (offset < 0 || length < 0) { -122 throw new IllegalArgumentException("Negative number! offset=" + offset + "and length=" + length); -123 } -124 if (bytes == null && (offset != 0 || length != 0)) { -125 throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length=" + length); -126 } -127 if (bytes != null && bytes.length < offset + length) { -128 throw new IllegalArgumentException("Out of bounds! bytes.length=" + bytes.length -129 + ", offset=" + offset + ", length=" + length); +079 public IndividualBytesFieldCell(byte[] row, int rOffset, int rLength, +080 byte[] family, int fOffset, int fLength, +081 byte[] qualifier, int qOffset, int qLength, +082 long timestamp, KeyValue.Type type, long seqId, +083 byte[] value, int vOffset, int vLength, +084 byte[] tags, int tagsOffset, int tagsLength) { +085 +086 // Check row, family, qualifier and value +087 KeyValue.checkParameters(row, rLength, // row and row length +088 family, fLength, // family and family length +089 qLength, // qualifier length +090 vLength); // value length +091 +092 // Check timestamp +093 if (timestamp < 0) { +094 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp); +095 } +096 +097 // Check tags +098 RawCell.checkForTagsLength(tagsLength); +099 checkArrayBounds(row, rOffset, rLength); +100 checkArrayBounds(family, fOffset, fLength); +101 checkArrayBounds(qualifier, qOffset, qLength); +102 checkArrayBounds(value, vOffset, vLength); +103 checkArrayBounds(tags, tagsOffset, tagsLength); +104 // No local copy is made, but reference to the input directly +105 this.row = row; +106 this.rOffset = rOffset; +107 this.rLength = rLength; +108 this.family = family; +109 this.fOffset = fOffset; +110 this.fLength = fLength; +111 this.qualifier = qualifier; +112 this.qOffset = qOffset; +113 this.qLength = qLength; +114 this.value = value; +115 this.vOffset = vOffset; +116 this.vLength = vLength; +117 this.tags = tags; +118 this.tagsOffset = tagsOffset; +119 this.tagsLength = tagsLength; +120 +121 // Set others +122 this.timestamp = timestamp; +123 this.type = type.getCode(); +124 this.seqId = seqId; +125 } +126 +127 private void checkArrayBounds(byte[] bytes, int offset, int length) { +128 if (offset < 0 || length < 0) { +129 throw new IllegalArgumentException("Negative number! offset=" + offset + "and length=" + length); 130 } -131 } -132 -133 private long heapOverhead() { -134 return FIXED_OVERHEAD -135 + ClassSize.ARRAY // row , can not be null -136 + ((family == null) ? 0 : ClassSize.ARRAY) // family , can be null -137 + ((qualifier == null) ? 0 : ClassSize.ARRAY) // qualifier, can be null -138 + ((value == null) ? 0 : ClassSize.ARRAY) // value , can be null -139 + ((tags == null) ? 0 : ClassSize.ARRAY); // tags , can be null -140 } -141 -142 /** -143 * Implement Cell interface -144 */ -145 // 1) Row -146 @Override -147 public byte[] getRowArray() { -148 // If row is null, the constructor will reject it, by {@link KeyValue#checkParameters()}, -149 // so it is safe to return row without checking. -150 return row; -151 } -152 +131 if (bytes == null && (offset != 0 || length != 0)) { +132 throw new IllegalArgumentException("Null bytes array but offset=" + offset + "and length=" + length); +133 } +134 if (bytes != null && bytes.length < offset + length) { +135 throw new IllegalArgumentException("Out of bounds! bytes.length=" + bytes.length +136 + ", offset=" + offset + ", length=" + length); +137 } +138 } +139 +140 private long heapOverhead() { +141 return FIXED_OVERHEAD +142 + ClassSize.ARRAY // row , can not be null +143 + ((family == null) ? 0 : ClassSize.ARRAY) // family , can be null +144 + ((qualifier == null) ? 0 : ClassSize.ARRAY) // qualifier, can be null +145 + ((value == null) ? 0 : ClassSize.ARRAY) // value , can be null +146 + ((tags == null) ? 0 : ClassSize.ARRAY); // tags , can be null +147 } +148 +149 /** +150 * Implement Cell interface +151 */ +152 // 1) Row 153 @Override -154 public int getRowOffset() { -155 return rOffset; -156 } -157 -158 @Override -159 public short getRowLength() { -160 // If row is null or rLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()}, -161 // so it is safe to call rLength and make the type conversion. -162 return (short)(rLength); -163 } +154 public byte[] getRowArray() { +155 // If row is null, the constructor will reject it, by {@link KeyValue#checkParameters()}, +156 // so it is safe to return row without checking. +157 return row; +158 } +159 +160 @Override +161 public int getRowOffset() { +162 return rOffset; +163 } 164 -165 // 2) Family -166 @Override -167 public byte[] getFamilyArray() { -168 // Family could be null -169 return (family == null) ? HConstants.EMPTY_BYTE_ARRAY : family; +165 @Override +166 public short getRowLength() { +167 // If row is null or rLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()}, +168 // so it is safe to call rLength and make the type conversion. +169 return (short)(rLength); 170 } 171 -172 @Override -173 public int getFamilyOffset() { -174 return fOffset; -175 } -176 -177 @Override -178 public byte getFamilyLength() { -179 // If fLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()}, -180 // so it is safe to make the type conversion. -181 return (byte)(fLength); +172 // 2) Family +173 @Override +174 public byte[] getFamilyArray() { +175 // Family could be null +176 return (family == null) ? HConstants.EMPTY_BYTE_ARRAY : family; +177 } +178 +179 @Override +180 public int getFamilyOffset() { +181 return fOffset; 182 } 183 -184 // 3) Qualifier -185 @Override -186 public byte[] getQualifierArray() { -187 // Qualifier could be null -188 return (qualifier == null) ? HConstants.EMPTY_BYTE_ARRAY : qualifier; +184 @Override +185 public byte getFamilyLength() { +186 // If fLength is invalid, the constructor will reject it, by {@link KeyValue#checkParameters()}, +187 // so it is safe to make the type conversion. +188 return (byte)(fLength); 189 } 190 -191 @Override -192 public int getQualifierOffset() { -193 return qOffset; -194 } -195 -196 @Override -197 public int getQualifierLength() { -198 return qLength; -199 } -200 -201 // 4) Timestamp -202 @Override -203 public long getTimestamp() { -204 return timestamp; -205 } -206 -207 //5) Type -208 @Override -209 public byte getTypeByte() { -210 return type; -211 } -212 -213 //6) Sequence id -214 @Override -215 public long getSequenceId() { -216 return seqId; -217 } -218 -219 //7) Value -220 @Override -221 public byte[] getValueArray() { -222 // Value could be null -223 return (value == null) ? HConstants.EMPTY_BYTE_ARRAY : value; +191 // 3) Qualifier +192 @Override +193 public byte[] getQualifierArray() { +194 // Qualifier could be null +195 return (qualifier == null) ? HConstants.EMPTY_BYTE_ARRAY : qualifier; +196 } +197 +198 @Override +199 public int getQualifierOffset() { +200 return qOffset; +201 } +202 +203 @Override +204 public int getQualifierLength() { +205 return qLength; +206 } +207 +208 // 4) Timestamp +209 @Override +210 public long getTimestamp() { +211 return timestamp; +212 } +213 +214 //5) Type +215 @Override +216 public byte getTypeByte() { +217 return type; +218 } +219 +220 //6) Sequence id +221 @Override +222 public long getSequenceId() { +223 return seqId; 224 } 225 -226 @Override -227 public int getValueOffset() { -228 return vOffset; -229 } -230 -231 @Override -232 public int getValueLength() { -233 return vLength; -234 } -235 -236 // 8) Tags -237 @Override -238 public byte[] getTagsArray() { -239 // Tags can could null -240 return (tags == null) ? HConstants.EMPTY_BYTE_ARRAY : tags; +226 //7) Value +227 @Override +228 public byte[] getValueArray() { +229 // Value could be null +230 return (value == null) ? HConstants.EMPTY_BYTE_ARRAY : value; +231 } +232 +233 @Override +234 public int getValueOffset() { +235 return vOffset; +236 } +237 +238 @Override +239 public int getValueLength() { +240 return vLength; 241 } 242 -243 @Override -244 public int getTagsOffset() { -245 return tagsOffset; -246 } -247 -248 @Override -249 public int getTagsLength() { -250 return tagsLength; -251 } -252 -253 /** -254 * Implement HeapSize interface -255 */ -256 @Override -257 public long heapSize() { -258 // Size of array headers are already included into overhead, so do not need to include it for each byte array -259 return heapOverhead() // overhead, with array headers included -260 + ClassSize.align(getRowLength()) // row -261 + ClassSize.align(getFamilyLength()) // family -262 + ClassSize.align(getQualifierLength()) // qualifier -263 + ClassSize.align(getValueLength()) // value -264 + ClassSize.align(getTagsLength()); // tags -265 } -266 -267 /** -268 * Implement Cloneable interface -269 */ -270 @Override -271 public Object clone() throws CloneNotSupportedException { -272 return super.clone(); // only a shadow copy -273 } -274 -275 @Override -276 public void setSequenceId(long seqId) { -277 if (seqId < 0) { -278 throw new IllegalArgumentException("Sequence Id cannot be negative. ts=" + seqId); -279 } -280 this.seqId = seqId; -281 } -282 -283 @Override -284 public void setTimestamp(long ts) { -285 if (ts < 0) { -286 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -287 } -288 this.timestamp = ts; -289 } -290 -291 @Override -292 public void setTimestamp(byte[] ts) { -293 setTimestamp(Bytes.toLong(ts, 0)); -294 } -295 -296 @Override -297 public String toString() { -298 return CellUtil.toString(this, true); -299 } -300} +243 // 8) Tags +244 @Override +245 public byte[] getTagsArray() { +246 // Tags can could null +247 return (tags == null) ? HConstants.EMPTY_BYTE_ARRAY : tags; +248 } +249 +250 @Override +251 public int getTagsOffset() { +252 return tagsOffset; +253 } +254 +255 @Override +256 public int getTagsLength() { +257 return tagsLength; +258 } +259 +260 /** +261 * Implement HeapSize interface +262 */ +263 @Override +264 public long heapSize() { +265 // Size of array headers are already included into overhead, so do not need to include it for each byte array +266 return heapOverhead() // overhead, with array headers included +267 + ClassSize.align(getRowLength()) // row +268 + ClassSize.align(getFamilyLength()) // family +269 + ClassSize.align(getQualifierLength()) // qualifier +270 + ClassSize.align(getValueLength()) // value +271 + ClassSize.align(getTagsLength()); // tags +272 } +273 +274 /** +275 * Implement Cloneable interface +276 */ +277 @Override +278 public Object clone() throws CloneNotSupportedException { +279 return super.clone(); // only a shadow copy +280 } +281 +282 @Override +283 public void setSequenceId(long seqId) { +284 if (seqId < 0) { +285 throw new IllegalArgumentException("Sequence Id cannot be negative. ts=" + seqId); +286 } +287 this.seqId = seqId; +288 } +289 +290 @Override +291 public void setTimestamp(long ts) { +292 if (ts < 0) { +293 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +294 } +295 this.timestamp = ts; +296 } +297 +298 @Override +299 public void setTimestamp(byte[] ts) { +300 setTimestamp(Bytes.toLong(ts, 0)); +301 } +302 +303 @Override +304 public String toString() { +305 return CellUtil.toString(this, true); +306 } +307 +308 @Override +309 public Optional<Tag> getTag(byte type) { +310 int length = getTagsLength(); +311 int offset = getTagsOffset(); +312 int pos = offset; +313 while (pos < offset + length) { +314 int tagLen = Bytes.readAsInt(getTagsArray(), pos, TAG_LENGTH_SIZE); +315 if (getTagsArray()[pos + TAG_LENGTH_SIZE] == type) { +316 return Optional +317 .ofNullable(new ArrayBackedTag(getTagsArray(), pos, tagLen + TAG_LENGTH_SIZE)); +318 } +319 pos += TAG_LENGTH_SIZE + tagLen; +320 } +321 return Optional.ofNullable(null); +322 } +323 +324 @Override +325 public List<Tag> getTags() { +326 List<Tag> tags = new ArrayList<>(); +327 Iterator<Tag> tagsItr = PrivateCellUtil.tagsIterator(this); +328 while (tagsItr.hasNext()) { +329 tags.add(tagsItr.next()); +330 } +331 return tags; +332 } +333}