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 A7C98200D4F for ; Wed, 6 Dec 2017 16:18:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id A662D160BFD; Wed, 6 Dec 2017 15:18:08 +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 13BBF160C1E for ; Wed, 6 Dec 2017 16:18:02 +0100 (CET) Received: (qmail 19682 invoked by uid 500); 6 Dec 2017 15:17:57 -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 18884 invoked by uid 99); 6 Dec 2017 15:17:57 -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; Wed, 06 Dec 2017 15:17:57 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 89720F6138; Wed, 6 Dec 2017 15:17:55 +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: Wed, 06 Dec 2017 15:18:35 -0000 Message-Id: <9cdbf081d593409fab1d4ba20062ecc1@git.apache.org> In-Reply-To: <1df36c265a214b94b8ce0df79e3f7e2d@git.apache.org> References: <1df36c265a214b94b8ce0df79e3f7e2d@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/51] [partial] hbase-site git commit: Published site at . archived-at: Wed, 06 Dec 2017 15:18:08 -0000 http://git-wip-us.apache.org/repos/asf/hbase-site/blob/d171b896/apidocs/src-html/org/apache/hadoop/hbase/client/Put.html ---------------------------------------------------------------------- diff --git a/apidocs/src-html/org/apache/hadoop/hbase/client/Put.html b/apidocs/src-html/org/apache/hadoop/hbase/client/Put.html index 7d3d133..75a155d 100644 --- a/apidocs/src-html/org/apache/hadoop/hbase/client/Put.html +++ b/apidocs/src-html/org/apache/hadoop/hbase/client/Put.html @@ -35,487 +35,355 @@ 027import java.util.NavigableMap; 028import java.util.TreeMap; 029import java.util.UUID; -030 -031import org.apache.hadoop.hbase.Cell; -032import org.apache.hadoop.hbase.CellUtil; -033import org.apache.hadoop.hbase.HConstants; +030import org.apache.hadoop.hbase.Cell; +031import org.apache.hadoop.hbase.CellUtil; +032import org.apache.hadoop.hbase.HConstants; +033import org.apache.hadoop.hbase.IndividualBytesFieldCell; 034import org.apache.hadoop.hbase.KeyValue; -035import org.apache.hadoop.hbase.IndividualBytesFieldCell; -036import org.apache.hadoop.hbase.Tag; -037import org.apache.yetus.audience.InterfaceAudience; -038import org.apache.hadoop.hbase.io.HeapSize; -039import org.apache.hadoop.hbase.security.access.Permission; -040import org.apache.hadoop.hbase.security.visibility.CellVisibility; -041import org.apache.hadoop.hbase.util.Bytes; -042 -043/** -044 * Used to perform Put operations for a single row. -045 * <p> -046 * To perform a Put, instantiate a Put object with the row to insert to, and -047 * for each column to be inserted, execute {@link #addColumn(byte[], byte[], -048 * byte[]) add} or {@link #addColumn(byte[], byte[], long, byte[]) add} if -049 * setting the timestamp. -050 */ -051@InterfaceAudience.Public -052public class Put extends Mutation implements HeapSize, Comparable<Row> { -053 /** -054 * Create a Put operation for the specified row. -055 * @param row row key -056 */ -057 public Put(byte [] row) { -058 this(row, HConstants.LATEST_TIMESTAMP); -059 } -060 -061 /** -062 * Create a Put operation for the specified row, using a given timestamp. -063 * -064 * @param row row key; we make a copy of what we are passed to keep local. -065 * @param ts timestamp -066 */ -067 public Put(byte[] row, long ts) { -068 this(row, 0, row.length, ts); -069 } -070 -071 /** -072 * We make a copy of the passed in row key to keep local. -073 * @param rowArray -074 * @param rowOffset -075 * @param rowLength -076 */ -077 public Put(byte [] rowArray, int rowOffset, int rowLength) { -078 this(rowArray, rowOffset, rowLength, HConstants.LATEST_TIMESTAMP); -079 } -080 -081 /** -082 * @param row row key; we make a copy of what we are passed to keep local. -083 * @param ts timestamp -084 */ -085 public Put(ByteBuffer row, long ts) { -086 if (ts < 0) { -087 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -088 } -089 checkRow(row); -090 this.row = new byte[row.remaining()]; -091 row.get(this.row); -092 this.ts = ts; -093 } -094 -095 /** -096 * @param row row key; we make a copy of what we are passed to keep local. -097 */ -098 public Put(ByteBuffer row) { -099 this(row, HConstants.LATEST_TIMESTAMP); -100 } -101 -102 /** -103 * We make a copy of the passed in row key to keep local. -104 * @param rowArray -105 * @param rowOffset -106 * @param rowLength -107 * @param ts -108 */ -109 public Put(byte [] rowArray, int rowOffset, int rowLength, long ts) { -110 checkRow(rowArray, rowOffset, rowLength); -111 this.row = Bytes.copy(rowArray, rowOffset, rowLength); -112 this.ts = ts; -113 if (ts < 0) { -114 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -115 } -116 } -117 -118 /** -119 * Create a Put operation for an immutable row key. -120 * -121 * @param row row key -122 * @param rowIsImmutable whether the input row is immutable. -123 * Set to true if the caller can guarantee that -124 * the row will not be changed for the Put duration. -125 */ -126 public Put(byte [] row, boolean rowIsImmutable) { -127 this(row, HConstants.LATEST_TIMESTAMP, rowIsImmutable); -128 } -129 -130 /** -131 * Create a Put operation for an immutable row key, using a given timestamp. -132 * -133 * @param row row key -134 * @param ts timestamp -135 * @param rowIsImmutable whether the input row is immutable. -136 * Set to true if the caller can guarantee that -137 * the row will not be changed for the Put duration. -138 */ -139 public Put(byte[] row, long ts, boolean rowIsImmutable) { -140 // Check and set timestamp -141 if (ts < 0) { -142 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -143 } -144 this.ts = ts; -145 -146 // Deal with row according to rowIsImmutable -147 checkRow(row); -148 if (rowIsImmutable) { // Row is immutable -149 this.row = row; // Do not make a local copy, but point to the provided byte array directly -150 } else { // Row is not immutable -151 this.row = Bytes.copy(row, 0, row.length); // Make a local copy -152 } -153 } -154 -155 /** -156 * Copy constructor. Creates a Put operation cloned from the specified Put. -157 * @param putToCopy put to copy -158 */ -159 public Put(Put putToCopy) { -160 this(putToCopy.getRow(), putToCopy.ts); -161 this.familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); -162 for(Map.Entry<byte [], List<Cell>> entry: putToCopy.getFamilyCellMap().entrySet()) { -163 this.familyMap.put(entry.getKey(), new ArrayList<>(entry.getValue())); -164 } -165 this.durability = putToCopy.durability; -166 for (Map.Entry<String, byte[]> entry : putToCopy.getAttributesMap().entrySet()) { -167 this.setAttribute(entry.getKey(), entry.getValue()); -168 } -169 } -170 -171 /** -172 * Add the specified column and value to this Put operation. -173 * @param family family name -174 * @param qualifier column qualifier -175 * @param value column value -176 * @return this -177 */ -178 public Put addColumn(byte [] family, byte [] qualifier, byte [] value) { -179 return addColumn(family, qualifier, this.ts, value); -180 } -181 -182 /** -183 * See {@link #addColumn(byte[], byte[], byte[])}. This version expects -184 * that the underlying arrays won't change. It's intended -185 * for usage internal HBase to and for advanced client applications. -186 */ -187 public Put addImmutable(byte [] family, byte [] qualifier, byte [] value) { -188 return addImmutable(family, qualifier, this.ts, value); -189 } -190 -191 /** -192 * This expects that the underlying arrays won't change. It's intended -193 * for usage internal HBase to and for advanced client applications. -194 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail -195 * that should not be exposed publicly. -196 */ -197 @InterfaceAudience.Private -198 public Put addImmutable(byte[] family, byte [] qualifier, byte [] value, Tag[] tag) { -199 return addImmutable(family, qualifier, this.ts, value, tag); -200 } -201 -202 /** -203 * Add the specified column and value, with the specified timestamp as -204 * its version to this Put operation. -205 * @param family family name -206 * @param qualifier column qualifier -207 * @param ts version timestamp -208 * @param value column value -209 * @return this -210 */ -211 public Put addColumn(byte [] family, byte [] qualifier, long ts, byte [] value) { -212 if (ts < 0) { -213 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -214 } -215 List<Cell> list = getCellList(family); -216 KeyValue kv = createPutKeyValue(family, qualifier, ts, value); -217 list.add(kv); -218 return this; -219 } -220 -221 /** -222 * See {@link #addColumn(byte[], byte[], long, byte[])}. This version expects -223 * that the underlying arrays won't change. It's intended -224 * for usage internal HBase to and for advanced client applications. -225 */ -226 public Put addImmutable(byte [] family, byte [] qualifier, long ts, byte [] value) { -227 // Family can not be null, otherwise NullPointerException is thrown when putting the cell into familyMap -228 if (family == null) { -229 throw new IllegalArgumentException("Family cannot be null"); -230 } -231 -232 // Check timestamp -233 if (ts < 0) { -234 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -235 } -236 -237 List<Cell> list = getCellList(family); -238 list.add(new IndividualBytesFieldCell(this.row, family, qualifier, ts, KeyValue.Type.Put, value)); -239 return this; -240 } -241 -242 /** -243 * This expects that the underlying arrays won't change. It's intended -244 * for usage internal HBase to and for advanced client applications. -245 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail -246 * that should not be exposed publicly. -247 */ -248 @InterfaceAudience.Private -249 public Put addImmutable(byte[] family, byte[] qualifier, long ts, byte[] value, Tag[] tag) { -250 List<Cell> list = getCellList(family); -251 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); -252 list.add(kv); -253 return this; -254 } -255 -256 /** -257 * This expects that the underlying arrays won't change. It's intended -258 * for usage internal HBase to and for advanced client applications. -259 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail -260 * that should not be exposed publicly. -261 */ -262 @InterfaceAudience.Private -263 public Put addImmutable(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value, -264 Tag[] tag) { -265 if (ts < 0) { -266 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -267 } -268 List<Cell> list = getCellList(family); -269 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); -270 list.add(kv); -271 return this; -272 } +035import org.apache.hadoop.hbase.Tag; +036import org.apache.hadoop.hbase.io.HeapSize; +037import org.apache.hadoop.hbase.security.access.Permission; +038import org.apache.hadoop.hbase.security.visibility.CellVisibility; +039import org.apache.hadoop.hbase.util.Bytes; +040import org.apache.yetus.audience.InterfaceAudience; +041 +042/** +043 * Used to perform Put operations for a single row. +044 * <p> +045 * To perform a Put, instantiate a Put object with the row to insert to, and +046 * for each column to be inserted, execute {@link #addColumn(byte[], byte[], +047 * byte[]) add} or {@link #addColumn(byte[], byte[], long, byte[]) add} if +048 * setting the timestamp. +049 */ +050@InterfaceAudience.Public +051public class Put extends Mutation implements HeapSize, Comparable<Row> { +052 /** +053 * Create a Put operation for the specified row. +054 * @param row row key +055 */ +056 public Put(byte [] row) { +057 this(row, HConstants.LATEST_TIMESTAMP); +058 } +059 +060 /** +061 * Create a Put operation for the specified row, using a given timestamp. +062 * +063 * @param row row key; we make a copy of what we are passed to keep local. +064 * @param ts timestamp +065 */ +066 public Put(byte[] row, long ts) { +067 this(row, 0, row.length, ts); +068 } +069 +070 /** +071 * We make a copy of the passed in row key to keep local. +072 * @param rowArray +073 * @param rowOffset +074 * @param rowLength +075 */ +076 public Put(byte [] rowArray, int rowOffset, int rowLength) { +077 this(rowArray, rowOffset, rowLength, HConstants.LATEST_TIMESTAMP); +078 } +079 +080 /** +081 * @param row row key; we make a copy of what we are passed to keep local. +082 * @param ts timestamp +083 */ +084 public Put(ByteBuffer row, long ts) { +085 if (ts < 0) { +086 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +087 } +088 checkRow(row); +089 this.row = new byte[row.remaining()]; +090 row.get(this.row); +091 this.ts = ts; +092 } +093 +094 /** +095 * @param row row key; we make a copy of what we are passed to keep local. +096 */ +097 public Put(ByteBuffer row) { +098 this(row, HConstants.LATEST_TIMESTAMP); +099 } +100 +101 /** +102 * We make a copy of the passed in row key to keep local. +103 * @param rowArray +104 * @param rowOffset +105 * @param rowLength +106 * @param ts +107 */ +108 public Put(byte [] rowArray, int rowOffset, int rowLength, long ts) { +109 checkRow(rowArray, rowOffset, rowLength); +110 this.row = Bytes.copy(rowArray, rowOffset, rowLength); +111 this.ts = ts; +112 if (ts < 0) { +113 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +114 } +115 } +116 +117 /** +118 * Create a Put operation for an immutable row key. +119 * +120 * @param row row key +121 * @param rowIsImmutable whether the input row is immutable. +122 * Set to true if the caller can guarantee that +123 * the row will not be changed for the Put duration. +124 */ +125 public Put(byte [] row, boolean rowIsImmutable) { +126 this(row, HConstants.LATEST_TIMESTAMP, rowIsImmutable); +127 } +128 +129 /** +130 * Create a Put operation for an immutable row key, using a given timestamp. +131 * +132 * @param row row key +133 * @param ts timestamp +134 * @param rowIsImmutable whether the input row is immutable. +135 * Set to true if the caller can guarantee that +136 * the row will not be changed for the Put duration. +137 */ +138 public Put(byte[] row, long ts, boolean rowIsImmutable) { +139 // Check and set timestamp +140 if (ts < 0) { +141 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +142 } +143 this.ts = ts; +144 +145 // Deal with row according to rowIsImmutable +146 checkRow(row); +147 if (rowIsImmutable) { // Row is immutable +148 this.row = row; // Do not make a local copy, but point to the provided byte array directly +149 } else { // Row is not immutable +150 this.row = Bytes.copy(row, 0, row.length); // Make a local copy +151 } +152 } +153 +154 /** +155 * Copy constructor. Creates a Put operation cloned from the specified Put. +156 * @param putToCopy put to copy +157 */ +158 public Put(Put putToCopy) { +159 this(putToCopy.getRow(), putToCopy.ts); +160 this.familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR); +161 for(Map.Entry<byte [], List<Cell>> entry: putToCopy.getFamilyCellMap().entrySet()) { +162 this.familyMap.put(entry.getKey(), new ArrayList<>(entry.getValue())); +163 } +164 this.durability = putToCopy.durability; +165 for (Map.Entry<String, byte[]> entry : putToCopy.getAttributesMap().entrySet()) { +166 this.setAttribute(entry.getKey(), entry.getValue()); +167 } +168 } +169 +170 /** +171 * Add the specified column and value to this Put operation. +172 * @param family family name +173 * @param qualifier column qualifier +174 * @param value column value +175 * @return this +176 */ +177 public Put addColumn(byte [] family, byte [] qualifier, byte [] value) { +178 return addColumn(family, qualifier, this.ts, value); +179 } +180 +181 /** +182 * See {@link #addColumn(byte[], byte[], byte[])}. This version expects +183 * that the underlying arrays won't change. It's intended +184 * for usage internal HBase to and for advanced client applications. +185 */ +186 public Put addImmutable(byte [] family, byte [] qualifier, byte [] value) { +187 return addImmutable(family, qualifier, this.ts, value); +188 } +189 +190 /** +191 * This expects that the underlying arrays won't change. It's intended +192 * for usage internal HBase to and for advanced client applications. +193 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail +194 * that should not be exposed publicly. +195 */ +196 @InterfaceAudience.Private +197 public Put addImmutable(byte[] family, byte [] qualifier, byte [] value, Tag[] tag) { +198 return addImmutable(family, qualifier, this.ts, value, tag); +199 } +200 +201 /** +202 * Add the specified column and value, with the specified timestamp as +203 * its version to this Put operation. +204 * @param family family name +205 * @param qualifier column qualifier +206 * @param ts version timestamp +207 * @param value column value +208 * @return this +209 */ +210 public Put addColumn(byte [] family, byte [] qualifier, long ts, byte [] value) { +211 if (ts < 0) { +212 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +213 } +214 List<Cell> list = getCellList(family); +215 KeyValue kv = createPutKeyValue(family, qualifier, ts, value); +216 list.add(kv); +217 return this; +218 } +219 +220 /** +221 * See {@link #addColumn(byte[], byte[], long, byte[])}. This version expects +222 * that the underlying arrays won't change. It's intended +223 * for usage internal HBase to and for advanced client applications. +224 */ +225 public Put addImmutable(byte [] family, byte [] qualifier, long ts, byte [] value) { +226 // Family can not be null, otherwise NullPointerException is thrown when putting the cell into familyMap +227 if (family == null) { +228 throw new IllegalArgumentException("Family cannot be null"); +229 } +230 +231 // Check timestamp +232 if (ts < 0) { +233 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +234 } +235 +236 List<Cell> list = getCellList(family); +237 list.add(new IndividualBytesFieldCell(this.row, family, qualifier, ts, KeyValue.Type.Put, value)); +238 return this; +239 } +240 +241 /** +242 * This expects that the underlying arrays won't change. It's intended +243 * for usage internal HBase to and for advanced client applications. +244 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail +245 * that should not be exposed publicly. +246 */ +247 @InterfaceAudience.Private +248 public Put addImmutable(byte[] family, byte[] qualifier, long ts, byte[] value, Tag[] tag) { +249 List<Cell> list = getCellList(family); +250 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); +251 list.add(kv); +252 return this; +253 } +254 +255 /** +256 * This expects that the underlying arrays won't change. It's intended +257 * for usage internal HBase to and for advanced client applications. +258 * <p>Marked as audience Private as of 1.2.0. {@link Tag} is an internal implementation detail +259 * that should not be exposed publicly. +260 */ +261 @InterfaceAudience.Private +262 public Put addImmutable(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value, +263 Tag[] tag) { +264 if (ts < 0) { +265 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +266 } +267 List<Cell> list = getCellList(family); +268 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, tag); +269 list.add(kv); +270 return this; +271 } +272 273 -274 -275 /** -276 * Add the specified column and value, with the specified timestamp as -277 * its version to this Put operation. -278 * @param family family name -279 * @param qualifier column qualifier -280 * @param ts version timestamp -281 * @param value column value -282 * @return this -283 */ -284 public Put addColumn(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) { -285 if (ts < 0) { -286 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -287 } -288 List<Cell> list = getCellList(family); -289 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); -290 list.add(kv); -291 return this; -292 } -293 -294 /** -295 * See {@link #addColumn(byte[], ByteBuffer, long, ByteBuffer)}. This version expects -296 * that the underlying arrays won't change. It's intended -297 * for usage internal HBase to and for advanced client applications. -298 */ -299 public Put addImmutable(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) { -300 if (ts < 0) { -301 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); -302 } -303 List<Cell> list = getCellList(family); -304 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); -305 list.add(kv); -306 return this; -307 } -308 -309 /** -310 * Add the specified KeyValue to this Put operation. Operation assumes that -311 * the passed KeyValue is immutable and its backing array will not be modified -312 * for the duration of this Put. -313 * @param kv individual KeyValue -314 * @return this -315 * @throws java.io.IOException e -316 */ -317 public Put add(Cell kv) throws IOException{ -318 byte [] family = CellUtil.cloneFamily(kv); -319 List<Cell> list = getCellList(family); -320 //Checking that the row of the kv is the same as the put -321 if (!CellUtil.matchingRows(kv, this.row)) { -322 throw new WrongRowIOException("The row in " + kv.toString() + -323 " doesn't match the original one " + Bytes.toStringBinary(this.row)); -324 } -325 list.add(kv); -326 return this; -327 } -328 -329 /** -330 * A convenience method to determine if this object's familyMap contains -331 * a value assigned to the given family &amp; qualifier. -332 * Both given arguments must match the KeyValue object to return true. -333 * -334 * @param family column family -335 * @param qualifier column qualifier -336 * @return returns true if the given family and qualifier already has an -337 * existing KeyValue object in the family map. -338 */ -339 public boolean has(byte [] family, byte [] qualifier) { -340 return has(family, qualifier, this.ts, HConstants.EMPTY_BYTE_ARRAY, true, true); -341 } -342 -343 /** -344 * A convenience method to determine if this object's familyMap contains -345 * a value assigned to the given family, qualifier and timestamp. -346 * All 3 given arguments must match the KeyValue object to return true. -347 * -348 * @param family column family -349 * @param qualifier column qualifier -350 * @param ts timestamp -351 * @return returns true if the given family, qualifier and timestamp already has an -352 * existing KeyValue object in the family map. -353 */ -354 public boolean has(byte [] family, byte [] qualifier, long ts) { -355 return has(family, qualifier, ts, HConstants.EMPTY_BYTE_ARRAY, false, true); -356 } -357 -358 /** -359 * A convenience method to determine if this object's familyMap contains -360 * a value assigned to the given family, qualifier and timestamp. -361 * All 3 given arguments must match the KeyValue object to return true. -362 * -363 * @param family column family -364 * @param qualifier column qualifier -365 * @param value value to check -366 * @return returns true if the given family, qualifier and value already has an -367 * existing KeyValue object in the family map. -368 */ -369 public boolean has(byte [] family, byte [] qualifier, byte [] value) { -370 return has(family, qualifier, this.ts, value, true, false); -371 } -372 -373 /** -374 * A convenience method to determine if this object's familyMap contains -375 * the given value assigned to the given family, qualifier and timestamp. -376 * All 4 given arguments must match the KeyValue object to return true. -377 * -378 * @param family column family -379 * @param qualifier column qualifier -380 * @param ts timestamp -381 * @param value value to check -382 * @return returns true if the given family, qualifier timestamp and value -383 * already has an existing KeyValue object in the family map. -384 */ -385 public boolean has(byte [] family, byte [] qualifier, long ts, byte [] value) { -386 return has(family, qualifier, ts, value, false, false); -387 } -388 -389 /* -390 * Private method to determine if this object's familyMap contains -391 * the given value assigned to the given family, qualifier and timestamp -392 * respecting the 2 boolean arguments -393 * -394 * @param family -395 * @param qualifier -396 * @param ts -397 * @param value -398 * @param ignoreTS -399 * @param ignoreValue -400 * @return returns true if the given family, qualifier timestamp and value -401 * already has an existing KeyValue object in the family map. -402 */ -403 private boolean has(byte[] family, byte[] qualifier, long ts, byte[] value, -404 boolean ignoreTS, boolean ignoreValue) { -405 List<Cell> list = getCellList(family); -406 if (list.isEmpty()) { -407 return false; -408 } -409 // Boolean analysis of ignoreTS/ignoreValue. -410 // T T => 2 -411 // T F => 3 (first is always true) -412 // F T => 2 -413 // F F => 1 -414 if (!ignoreTS && !ignoreValue) { -415 for (Cell cell : list) { -416 if (CellUtil.matchingFamily(cell, family) && -417 CellUtil.matchingQualifier(cell, qualifier) && -418 CellUtil.matchingValue(cell, value) && -419 cell.getTimestamp() == ts) { -420 return true; -421 } -422 } -423 } else if (ignoreValue && !ignoreTS) { -424 for (Cell cell : list) { -425 if (CellUtil.matchingFamily(cell, family) && CellUtil.matchingQualifier(cell, qualifier) -426 && cell.getTimestamp() == ts) { -427 return true; -428 } -429 } -430 } else if (!ignoreValue && ignoreTS) { -431 for (Cell cell : list) { -432 if (CellUtil.matchingFamily(cell, family) && CellUtil.matchingQualifier(cell, qualifier) -433 && CellUtil.matchingValue(cell, value)) { -434 return true; -435 } -436 } -437 } else { -438 for (Cell cell : list) { -439 if (CellUtil.matchingFamily(cell, family) && -440 CellUtil.matchingQualifier(cell, qualifier)) { -441 return true; -442 } -443 } -444 } -445 return false; -446 } -447 -448 /** -449 * Returns a list of all KeyValue objects with matching column family and qualifier. -450 * -451 * @param family column family -452 * @param qualifier column qualifier -453 * @return a list of KeyValue objects with the matching family and qualifier, -454 * returns an empty list if one doesn't exist for the given family. -455 */ -456 public List<Cell> get(byte[] family, byte[] qualifier) { -457 List<Cell> filteredList = new ArrayList<>(); -458 for (Cell cell: getCellList(family)) { -459 if (CellUtil.matchingQualifier(cell, qualifier)) { -460 filteredList.add(cell); -461 } -462 } -463 return filteredList; -464 } -465 -466 @Override -467 public Put setAttribute(String name, byte[] value) { -468 return (Put) super.setAttribute(name, value); -469 } -470 -471 @Override -472 public Put setId(String id) { -473 return (Put) super.setId(id); -474 } -475 -476 @Override -477 public Put setDurability(Durability d) { -478 return (Put) super.setDurability(d); -479 } -480 -481 @Override -482 public Put setFamilyCellMap(NavigableMap<byte[], List<Cell>> map) { -483 return (Put) super.setFamilyCellMap(map); -484 } -485 -486 @Override -487 public Put setClusterIds(List<UUID> clusterIds) { -488 return (Put) super.setClusterIds(clusterIds); -489 } -490 -491 @Override -492 public Put setCellVisibility(CellVisibility expression) { -493 return (Put) super.setCellVisibility(expression); -494 } -495 -496 @Override -497 public Put setACL(String user, Permission perms) { -498 return (Put) super.setACL(user, perms); -499 } -500 -501 @Override -502 public Put setACL(Map<String, Permission> perms) { -503 return (Put) super.setACL(perms); -504 } -505 -506 @Override -507 public Put setTTL(long ttl) { -508 return (Put) super.setTTL(ttl); -509 } -510} +274 /** +275 * Add the specified column and value, with the specified timestamp as +276 * its version to this Put operation. +277 * @param family family name +278 * @param qualifier column qualifier +279 * @param ts version timestamp +280 * @param value column value +281 * @return this +282 */ +283 public Put addColumn(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) { +284 if (ts < 0) { +285 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +286 } +287 List<Cell> list = getCellList(family); +288 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); +289 list.add(kv); +290 return this; +291 } +292 +293 /** +294 * See {@link #addColumn(byte[], ByteBuffer, long, ByteBuffer)}. This version expects +295 * that the underlying arrays won't change. It's intended +296 * for usage internal HBase to and for advanced client applications. +297 */ +298 public Put addImmutable(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) { +299 if (ts < 0) { +300 throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts); +301 } +302 List<Cell> list = getCellList(family); +303 KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null); +304 list.add(kv); +305 return this; +306 } +307 +308 /** +309 * Add the specified KeyValue to this Put operation. Operation assumes that +310 * the passed KeyValue is immutable and its backing array will not be modified +311 * for the duration of this Put. +312 * @param kv individual KeyValue +313 * @return this +314 * @throws java.io.IOException e +315 */ +316 public Put add(Cell kv) throws IOException{ +317 byte [] family = CellUtil.cloneFamily(kv); +318 List<Cell> list = getCellList(family); +319 //Checking that the row of the kv is the same as the put +320 if (!CellUtil.matchingRows(kv, this.row)) { +321 throw new WrongRowIOException("The row in " + kv.toString() + +322 " doesn't match the original one " + Bytes.toStringBinary(this.row)); +323 } +324 list.add(kv); +325 return this; +326 } +327 +328 @Override +329 public Put setTimestamp(long timestamp) { +330 super.setTimestamp(timestamp); +331 return this; +332 } +333 +334 @Override +335 public Put setAttribute(String name, byte[] value) { +336 return (Put) super.setAttribute(name, value); +337 } +338 +339 @Override +340 public Put setId(String id) { +341 return (Put) super.setId(id); +342 } +343 +344 @Override +345 public Put setDurability(Durability d) { +346 return (Put) super.setDurability(d); +347 } +348 +349 @Override +350 public Put setFamilyCellMap(NavigableMap<byte[], List<Cell>> map) { +351 return (Put) super.setFamilyCellMap(map); +352 } +353 +354 @Override +355 public Put setClusterIds(List<UUID> clusterIds) { +356 return (Put) super.setClusterIds(clusterIds); +357 } +358 +359 @Override +360 public Put setCellVisibility(CellVisibility expression) { +361 return (Put) super.setCellVisibility(expression); +362 } +363 +364 @Override +365 public Put setACL(String user, Permission perms) { +366 return (Put) super.setACL(user, perms); +367 } +368 +369 @Override +370 public Put setACL(Map<String, Permission> perms) { +371 return (Put) super.setACL(perms); +372 } +373 +374 @Override +375 public Put setTTL(long ttl) { +376 return (Put) super.setTTL(ttl); +377 } +378}