You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2024/07/11 14:16:18 UTC
(hbase) branch branch-3 updated: HBASE-28684 Remove CellWrapper and use ExtendedCell internally in client side data structure (#6044)
This is an automated email from the ASF dual-hosted git repository.
zhangduo pushed a commit to branch branch-3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-3 by this push:
new c2ce859aeee HBASE-28684 Remove CellWrapper and use ExtendedCell internally in client side data structure (#6044)
c2ce859aeee is described below
commit c2ce859aeee46b37d32109a405a7c87c3d70450d
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu Jul 11 22:02:40 2024 +0800
HBASE-28684 Remove CellWrapper and use ExtendedCell internally in client side data structure (#6044)
Signed-off-by: Xin Sun <su...@apache.org>
(cherry picked from commit 2edd7e0f23de6490c63494635a11d0fd262bcc6e)
---
.../mapreduce/MapReduceHFileSplitterJob.java | 3 +-
.../hbase/client/AllowPartialScanResultCache.java | 6 +-
.../hbase/client/AsyncBatchRpcRetryingCaller.java | 10 +-
.../hadoop/hbase/client/BatchScanResultCache.java | 12 +-
.../hadoop/hbase/client/ConnectionUtils.java | 5 +-
.../org/apache/hadoop/hbase/client/Delete.java | 25 +-
.../org/apache/hadoop/hbase/client/Increment.java | 11 +-
.../org/apache/hadoop/hbase/client/Mutation.java | 222 ++---------
.../hbase/client/PackagePrivateFieldAccessor.java | 20 +
.../java/org/apache/hadoop/hbase/client/Put.java | 21 +-
.../org/apache/hadoop/hbase/client/Result.java | 65 +++-
.../java/org/apache/hadoop/hbase/ipc/Call.java | 13 +-
.../apache/hadoop/hbase/ipc/CellBlockBuilder.java | 18 +-
.../hbase/ipc/DelegatingHBaseRpcController.java | 8 +-
.../hadoop/hbase/ipc/HBaseRpcController.java | 12 +-
.../hadoop/hbase/ipc/HBaseRpcControllerImpl.java | 25 +-
.../org/apache/hadoop/hbase/ipc/RpcConnection.java | 4 +-
.../hadoop/hbase/ipc/RpcControllerFactory.java | 12 +-
.../hadoop/hbase/shaded/protobuf/ProtobufUtil.java | 5 +-
.../hbase/shaded/protobuf/RequestConverter.java | 38 +-
.../apache/hadoop/hbase/client/TestMutation.java | 12 +-
.../hadoop/hbase/ipc/TestCellBlockBuilder.java | 28 +-
.../hbase/ipc/TestHBaseRpcControllerImpl.java | 30 +-
.../hbase/shaded/protobuf/TestProtobufUtil.java | 11 +-
.../apache/hadoop/hbase/ByteBufferKeyValue.java | 4 +-
.../apache/hadoop/hbase/CellComparatorImpl.java | 2 +-
.../java/org/apache/hadoop/hbase/CellUtil.java | 25 +-
...CellScanner.java => ExtendedCellScannable.java} | 20 +-
...edCellScanner.java => ExtendedCellScanner.java} | 20 +-
.../java/org/apache/hadoop/hbase/KeyValue.java | 4 +-
.../org/apache/hadoop/hbase/KeyValueTestUtil.java | 8 +-
.../java/org/apache/hadoop/hbase/KeyValueUtil.java | 11 +-
.../org/apache/hadoop/hbase/PrivateCellUtil.java | 289 ++++++++++-----
.../main/java/org/apache/hadoop/hbase/TagUtil.java | 6 +-
.../org/apache/hadoop/hbase/codec/BaseDecoder.java | 10 +-
.../org/apache/hadoop/hbase/codec/BaseEncoder.java | 4 +-
.../org/apache/hadoop/hbase/codec/CellCodec.java | 6 +-
.../hadoop/hbase/codec/CellCodecWithTags.java | 6 +-
.../java/org/apache/hadoop/hbase/codec/Codec.java | 4 +-
.../apache/hadoop/hbase/codec/KeyValueCodec.java | 14 +-
.../hadoop/hbase/codec/KeyValueCodecWithTags.java | 10 +-
.../apache/hadoop/hbase/io/CellOutputStream.java | 4 +-
...lScanner.java => SizedExtendedCellScanner.java} | 6 +-
.../hadoop/hbase/io/encoding/EncodedDataBlock.java | 8 +-
.../hadoop/hbase/io/encoding/NoneEncoder.java | 4 +-
.../apache/hadoop/hbase/TestCellComparator.java | 2 +-
.../java/org/apache/hadoop/hbase/TestCellUtil.java | 165 +--------
.../apache/hadoop/hbase/codec/TestCellCodec.java | 12 +-
.../hadoop/hbase/codec/TestCellCodecWithTags.java | 16 +-
.../hbase/codec/TestKeyValueCodecWithTags.java | 4 +-
.../hbase/client/TestRpcControllerFactory.java | 9 +-
.../hadoop/hbase/mapreduce/CellSerialization.java | 8 +-
.../hadoop/hbase/mapreduce/CellSortReducer.java | 18 +-
.../hbase/mapreduce/ExtendedCellSerialization.java | 2 +-
.../hadoop/hbase/mapreduce/HFileOutputFormat2.java | 4 +-
.../org/apache/hadoop/hbase/mapreduce/Import.java | 30 +-
.../apache/hadoop/hbase/mapreduce/PutCombiner.java | 52 +--
.../hadoop/hbase/mapreduce/PutSortReducer.java | 11 +-
.../apache/hadoop/hbase/mapreduce/WALPlayer.java | 3 +-
.../hadoop/hbase/util/MapReduceExtendedCell.java | 21 +-
.../hbase/mapreduce/TestHFileOutputFormat2.java | 3 +-
.../hadoop/hbase/mapreduce/TestImportExport.java | 25 +-
.../AsyncRegionReplicationRetryingCaller.java | 4 +-
.../hbase/client/AsyncRegionServerAdmin.java | 11 +-
.../apache/hadoop/hbase/codec/MessageCodec.java | 6 +-
.../hadoop/hbase/io/hfile/HFilePrettyPrinter.java | 3 +-
.../org/apache/hadoop/hbase/ipc/CallRunner.java | 6 +-
.../apache/hadoop/hbase/ipc/NettyServerCall.java | 4 +-
.../hadoop/hbase/ipc/NettyServerRpcConnection.java | 4 +-
.../java/org/apache/hadoop/hbase/ipc/RpcCall.java | 7 +-
.../org/apache/hadoop/hbase/ipc/RpcServer.java | 3 +-
.../hadoop/hbase/ipc/RpcServerInterface.java | 5 +-
.../org/apache/hadoop/hbase/ipc/ServerCall.java | 12 +-
.../hadoop/hbase/ipc/ServerRpcConnection.java | 6 +-
.../apache/hadoop/hbase/ipc/SimpleServerCall.java | 4 +-
.../hbase/ipc/SimpleServerRpcConnection.java | 4 +-
.../java/org/apache/hadoop/hbase/mob/MobUtils.java | 8 +-
.../hbase/protobuf/ReplicationProtobufUtil.java | 35 +-
.../apache/hadoop/hbase/regionserver/HRegion.java | 22 +-
.../hbase/regionserver/MobReferenceOnlyFilter.java | 5 +-
.../hadoop/hbase/regionserver/RSRpcServices.java | 34 +-
.../regionserver/ReversedMobStoreScanner.java | 2 +-
.../regionserver/wal/AsyncProtobufLogWriter.java | 3 +-
.../hbase/regionserver/wal/ProtobufLogWriter.java | 3 +-
.../hbase/regionserver/wal/SecureWALCellCodec.java | 10 +-
.../hbase/regionserver/wal/WALCellCodec.java | 8 +-
.../ReplaySyncReplicationWALCallable.java | 7 +-
.../hbase/security/access/AccessController.java | 12 +-
.../hadoop/hbase/security/access/AuthManager.java | 5 +-
.../hbase/security/access/PermissionStorage.java | 3 +-
.../security/visibility/VisibilityController.java | 15 +-
.../TestCustomPriorityRpcControllerFactory.java | 4 +-
.../client/TestAllowPartialScanResultCache.java | 6 +-
.../hbase/client/TestBatchScanResultCache.java | 14 +-
.../hadoop/hbase/client/TestFromClientSide.java | 5 +-
.../hbase/client/TestIncrementsFromClientSide.java | 5 +-
.../hbase/client/TestMalformedCellFromClient.java | 7 +-
.../org/apache/hadoop/hbase/client/TestResult.java | 27 +-
.../hadoop/hbase/codec/CodecPerformance.java | 23 +-
.../hadoop/hbase/codec/TestCellMessageCodec.java | 12 +-
.../TestPassCustomCellViaRegionObserver.java | 406 ---------------------
.../TestPostIncrementAndAppendBeforeWAL.java | 13 +-
.../apache/hadoop/hbase/filter/TestFilterList.java | 7 +-
.../hadoop/hbase/io/compress/HFileTestBase.java | 4 +-
.../io/encoding/TestBufferedDataBlockEncoder.java | 8 +-
.../hbase/io/encoding/TestDataBlockEncoders.java | 10 +-
.../hadoop/hbase/io/hfile/TestHFileEncryption.java | 4 +-
.../hbase/io/hfile/TestScannerFromBucketCache.java | 26 +-
.../io/hfile/TestSeekBeforeWithInlineBlocks.java | 6 +-
.../apache/hadoop/hbase/io/hfile/TestSeekTo.java | 3 +-
.../apache/hadoop/hbase/ipc/AbstractTestIPC.java | 14 +-
.../hbase/ipc/TestNettyChannelWritability.java | 11 +-
.../hbase/ipc/TestProtobufRpcServiceImpl.java | 12 +-
.../hadoop/hbase/master/MockRegionServer.java | 9 +-
.../hadoop/hbase/mob/TestMobStoreCompaction.java | 13 +-
.../hbase/namequeues/TestNamedQueueRecorder.java | 6 +-
.../hadoop/hbase/namequeues/TestRpcLogDetails.java | 6 +-
.../store/region/TestRegionProcedureStore.java | 6 +-
.../hbase/protobuf/TestReplicationProtobuf.java | 10 +-
.../hbase/regionserver/DataBlockEncodingTool.java | 10 +-
.../regionserver/EncodedSeekPerformanceTest.java | 5 +-
.../hbase/regionserver/TestBlocksScanned.java | 6 +-
.../hadoop/hbase/regionserver/TestCellFlatSet.java | 12 +-
.../hadoop/hbase/regionserver/TestHMobStore.java | 12 +-
.../hadoop/hbase/regionserver/TestHRegion.java | 33 +-
.../regionserver/TestHRegionServerBulkLoad.java | 5 +-
.../hadoop/hbase/regionserver/TestHStore.java | 34 +-
.../hadoop/hbase/regionserver/TestHStoreFile.java | 5 +-
.../hadoop/hbase/regionserver/TestKeepDeletes.java | 11 +-
.../hbase/regionserver/TestMultiColumnScanner.java | 9 +-
.../hbase/regionserver/TestReplicateToReplica.java | 4 +-
.../TestStoreFileScannerWithTagCompression.java | 4 +-
.../apache/hadoop/hbase/regionserver/TestTags.java | 20 +-
.../regionserver/compactions/TestCompactor.java | 4 +-
.../hbase/replication/TestReplicationWithTags.java | 5 +-
.../ExpAsStringVisibilityLabelServiceImpl.java | 5 +-
.../TestVisibilityLabelsReplication.java | 12 +-
.../apache/hadoop/hbase/util/HFileTestUtil.java | 3 +-
.../hadoop/hbase/thrift2/ThriftUtilities.java | 18 +-
139 files changed, 1106 insertions(+), 1505 deletions(-)
diff --git a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceHFileSplitterJob.java b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceHFileSplitterJob.java
index 04180972885..2c073c56f7e 100644
--- a/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceHFileSplitterJob.java
+++ b/hbase-backup/src/main/java/org/apache/hadoop/hbase/backup/mapreduce/MapReduceHFileSplitterJob.java
@@ -24,6 +24,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
@@ -76,7 +77,7 @@ public class MapReduceHFileSplitterJob extends Configured implements Tool {
public void map(NullWritable key, Cell value, Context context)
throws IOException, InterruptedException {
context.write(new ImmutableBytesWritable(CellUtil.cloneRow(value)),
- new MapReduceExtendedCell(value));
+ new MapReduceExtendedCell(PrivateCellUtil.ensureExtendedCell(value)));
}
@Override
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AllowPartialScanResultCache.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AllowPartialScanResultCache.java
index 3ef28308f1c..c6796a5e63e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AllowPartialScanResultCache.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AllowPartialScanResultCache.java
@@ -21,8 +21,8 @@ import static org.apache.hadoop.hbase.client.ConnectionUtils.filterCells;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.yetus.audience.InterfaceAudience;
/**
@@ -36,14 +36,14 @@ class AllowPartialScanResultCache implements ScanResultCache {
// used to filter out the cells that already returned to user as we always start from the
// beginning of a row when retry.
- private Cell lastCell;
+ private ExtendedCell lastCell;
private boolean lastResultPartial;
private int numberOfCompleteRows;
private void recordLastResult(Result result) {
- lastCell = result.rawCells()[result.rawCells().length - 1];
+ lastCell = result.rawExtendedCells()[result.rawExtendedCells().length - 1];
lastResultPartial = result.mayHaveMoreCellsInRow();
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
index 4b28d4cd4e2..18d54fd300b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/AsyncBatchRpcRetryingCaller.java
@@ -17,7 +17,6 @@
*/
package org.apache.hadoop.hbase.client;
-import static org.apache.hadoop.hbase.CellUtil.createCellScanner;
import static org.apache.hadoop.hbase.client.ConnectionUtils.calcPriority;
import static org.apache.hadoop.hbase.client.ConnectionUtils.resetController;
import static org.apache.hadoop.hbase.client.ConnectionUtils.translateException;
@@ -44,11 +43,12 @@ import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.mutable.MutableBoolean;
-import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
import org.apache.hadoop.hbase.HBaseServerException;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.RetryImmediatelyException;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
@@ -274,7 +274,7 @@ class AsyncBatchRpcRetryingCaller<T> {
}
private ClientProtos.MultiRequest buildReq(Map<byte[], RegionRequest> actionsByRegion,
- List<CellScannable> cells, Map<Integer, Integer> indexMap) throws IOException {
+ List<ExtendedCellScannable> cells, Map<Integer, Integer> indexMap) throws IOException {
ClientProtos.MultiRequest.Builder multiRequestBuilder = ClientProtos.MultiRequest.newBuilder();
ClientProtos.RegionAction.Builder regionActionBuilder = ClientProtos.RegionAction.newBuilder();
ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
@@ -382,7 +382,7 @@ class AsyncBatchRpcRetryingCaller<T> {
return;
}
ClientProtos.MultiRequest req;
- List<CellScannable> cells = new ArrayList<>();
+ List<ExtendedCellScannable> cells = new ArrayList<>();
// Map from a created RegionAction to the original index for a RowMutations within
// the original list of actions. This will be used to process the results when there
// is RowMutations/CheckAndMutate in the action list.
@@ -398,7 +398,7 @@ class AsyncBatchRpcRetryingCaller<T> {
calcPriority(serverReq.getPriority(), tableName), tableName);
controller.setRequestAttributes(requestAttributes);
if (!cells.isEmpty()) {
- controller.setCellScanner(createCellScanner(cells));
+ controller.setCellScanner(PrivateCellUtil.createExtendedCellScanner(cells));
}
stub.multi(controller, req, resp -> {
if (controller.failed()) {
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/BatchScanResultCache.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/BatchScanResultCache.java
index b0423c6c5ce..9c2b658dc9a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/BatchScanResultCache.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/BatchScanResultCache.java
@@ -24,8 +24,8 @@ import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.yetus.audience.InterfaceAudience;
@@ -44,7 +44,7 @@ public class BatchScanResultCache implements ScanResultCache {
// used to filter out the cells that already returned to user as we always start from the
// beginning of a row when retry.
- private Cell lastCell;
+ private ExtendedCell lastCell;
private boolean lastResultPartial;
@@ -59,7 +59,7 @@ public class BatchScanResultCache implements ScanResultCache {
}
private void recordLastResult(Result result) {
- lastCell = result.rawCells()[result.rawCells().length - 1];
+ lastCell = result.rawExtendedCells()[result.rawExtendedCells().length - 1];
lastResultPartial = result.mayHaveMoreCellsInRow();
}
@@ -80,7 +80,7 @@ public class BatchScanResultCache implements ScanResultCache {
if (numCellsOfPartialResults < batch) {
return null;
}
- Cell[] cells = new Cell[batch];
+ ExtendedCell[] cells = new ExtendedCell[batch];
int cellCount = 0;
boolean stale = false;
for (;;) {
@@ -91,8 +91,8 @@ public class BatchScanResultCache implements ScanResultCache {
// We have more cells than expected, so split the current result
int len = batch - cellCount;
System.arraycopy(r.rawCells(), 0, cells, cellCount, len);
- Cell[] remainingCells = new Cell[r.size() - len];
- System.arraycopy(r.rawCells(), len, remainingCells, 0, r.size() - len);
+ ExtendedCell[] remainingCells = new ExtendedCell[r.size() - len];
+ System.arraycopy(r.rawExtendedCells(), len, remainingCells, 0, r.size() - len);
partialResults.addFirst(
Result.create(remainingCells, r.getExists(), r.isStale(), r.mayHaveMoreCellsInRow()));
break;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
index 84acc6e4d39..cdb85845f03 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ConnectionUtils.java
@@ -39,6 +39,7 @@ import java.util.function.Supplier;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -232,7 +233,7 @@ public final class ConnectionUtils {
return estimatedHeapSizeOfResult;
}
- static Result filterCells(Result result, Cell keepCellsAfter) {
+ static Result filterCells(Result result, ExtendedCell keepCellsAfter) {
if (keepCellsAfter == null) {
// do not need to filter
return result;
@@ -241,7 +242,7 @@ public final class ConnectionUtils {
if (!PrivateCellUtil.matchingRows(keepCellsAfter, result.getRow(), 0, result.getRow().length)) {
return result;
}
- Cell[] rawCells = result.rawCells();
+ ExtendedCell[] rawCells = result.rawExtendedCells();
int index = Arrays.binarySearch(rawCells, keepCellsAfter,
CellComparator.getInstance()::compareWithoutRow);
if (index < 0) {
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
index f97db8a116d..af1d06a6ac4 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Delete.java
@@ -25,6 +25,7 @@ import java.util.UUID;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.security.access.Permission;
@@ -171,10 +172,8 @@ public class Delete extends Mutation {
* @return this for invocation chaining
*/
public Delete addFamily(final byte[] family, final long timestamp) {
- if (timestamp < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(timestamp);
+ List<ExtendedCell> list = getCellList(family);
if (!list.isEmpty()) {
list.clear();
}
@@ -190,10 +189,8 @@ public class Delete extends Mutation {
* @return this for invocation chaining
*/
public Delete addFamilyVersion(final byte[] family, final long timestamp) {
- if (timestamp < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(ts);
+ List<ExtendedCell> list = getCellList(family);
list.add(new KeyValue(row, family, null, timestamp, KeyValue.Type.DeleteFamilyVersion));
return this;
}
@@ -218,10 +215,8 @@ public class Delete extends Mutation {
* @return this for invocation chaining
*/
public Delete addColumns(final byte[] family, final byte[] qualifier, final long timestamp) {
- if (timestamp < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(ts);
+ List<ExtendedCell> list = getCellList(family);
list.add(new KeyValue(this.row, family, qualifier, timestamp, KeyValue.Type.DeleteColumn));
return this;
}
@@ -247,10 +242,8 @@ public class Delete extends Mutation {
* @return this for invocation chaining
*/
public Delete addColumn(byte[] family, byte[] qualifier, long timestamp) {
- if (timestamp < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(ts);
+ List<ExtendedCell> list = getCellList(family);
KeyValue kv = new KeyValue(this.row, family, qualifier, timestamp, KeyValue.Type.Delete);
list.add(kv);
return this;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
index aad853f8c06..e1672cdff19 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Increment.java
@@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.security.access.Permission;
@@ -35,6 +36,8 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
+
/**
* Used to perform Increment operations on a single row.
* <p>
@@ -114,10 +117,8 @@ public class Increment extends Mutation {
* @return the Increment object
*/
public Increment addColumn(byte[] family, byte[] qualifier, long amount) {
- if (family == null) {
- throw new IllegalArgumentException("family cannot be null");
- }
- List<Cell> list = getCellList(family);
+ Preconditions.checkArgument(family != null, "family cannot be null");
+ List<ExtendedCell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, Bytes.toBytes(amount));
list.add(kv);
return this;
@@ -224,7 +225,7 @@ public class Increment extends Mutation {
}
sb.append(", families=");
boolean moreThanOne = false;
- for (Map.Entry<byte[], List<Cell>> entry : this.familyMap.entrySet()) {
+ for (Map.Entry<byte[], List<ExtendedCell>> entry : this.familyMap.entrySet()) {
if (moreThanOne) {
sb.append("), ");
} else {
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
index 0be0325d499..b638aa48dc8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Mutation.java
@@ -22,11 +22,9 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
-import java.util.Optional;
import java.util.TreeMap;
import java.util.UUID;
import java.util.stream.Collectors;
@@ -34,10 +32,10 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.IndividualBytesFieldCell;
import org.apache.hadoop.hbase.KeyValue;
@@ -66,7 +64,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
@InterfaceAudience.Public
public abstract class Mutation extends OperationWithAttributes
- implements Row, CellScannable, HeapSize {
+ implements Row, ExtendedCellScannable, HeapSize {
public static final long MUTATION_OVERHEAD = ClassSize.align(
// This
ClassSize.OBJECT +
@@ -96,13 +94,12 @@ public abstract class Mutation extends OperationWithAttributes
private static final String RETURN_RESULTS = "_rr_";
// TODO: row should be final
- protected byte[] row = null;
+ protected byte[] row;
protected long ts = HConstants.LATEST_TIMESTAMP;
protected Durability durability = Durability.USE_DEFAULT;
- // TODO: familyMap should be final
// A Map sorted by column family.
- protected NavigableMap<byte[], List<Cell>> familyMap;
+ protected final NavigableMap<byte[], List<ExtendedCell>> familyMap;
/**
* empty construction. We need this empty construction to keep binary compatibility.
@@ -115,7 +112,7 @@ public abstract class Mutation extends OperationWithAttributes
super(clone);
this.row = clone.getRow();
this.ts = clone.getTimestamp();
- this.familyMap = clone.getFamilyCellMap().entrySet().stream()
+ this.familyMap = clone.familyMap.entrySet().stream()
.collect(Collectors.toMap(e -> e.getKey(), e -> new ArrayList<>(e.getValue()), (k, v) -> {
throw new RuntimeException("collisions!!!");
}, () -> new TreeMap<>(Bytes.BYTES_COMPARATOR)));
@@ -127,18 +124,23 @@ public abstract class Mutation extends OperationWithAttributes
* @param ts timestamp
* @param familyMap the map to collect all cells internally. CAN'T be null
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
protected Mutation(byte[] row, long ts, NavigableMap<byte[], List<Cell>> familyMap) {
this.row = Preconditions.checkNotNull(row);
- if (row.length == 0) {
- throw new IllegalArgumentException("Row can't be empty");
- }
+ Preconditions.checkArgument(row.length > 0, "Row can't be empty");
this.ts = ts;
- this.familyMap = Preconditions.checkNotNull(familyMap);
+ // We do not allow other Cell types in HBase so here we just do a simple cast
+ this.familyMap = (NavigableMap) Preconditions.checkNotNull(familyMap);
}
+ /**
+ * For client users: You should only use the return value as a
+ * {@link org.apache.hadoop.hbase.CellScanner}, {@link ExtendedCellScanner} is marked as
+ * IA.Private which means there is no guarantee about its API stability.
+ */
@Override
- public CellScanner cellScanner() {
- return CellUtil.createCellScanner(getFamilyCellMap());
+ public ExtendedCellScanner cellScanner() {
+ return PrivateCellUtil.createExtendedCellScanner(familyMap);
}
/**
@@ -147,13 +149,8 @@ public abstract class Mutation extends OperationWithAttributes
* @param family column family
* @return a list of Cell objects, returns an empty list if one doesn't exist.
*/
- List<Cell> getCellList(byte[] family) {
- List<Cell> list = getFamilyCellMap().get(family);
- if (list == null) {
- list = new ArrayList<>();
- getFamilyCellMap().put(family, list);
- }
- return list;
+ List<ExtendedCell> getCellList(byte[] family) {
+ return familyMap.computeIfAbsent(family, k -> new ArrayList<>());
}
/**
@@ -218,7 +215,7 @@ public abstract class Mutation extends OperationWithAttributes
map.put("row", Bytes.toStringBinary(this.row));
int colCount = 0;
// iterate through all column families affected
- for (Map.Entry<byte[], List<Cell>> entry : getFamilyCellMap().entrySet()) {
+ for (Map.Entry<byte[], List<ExtendedCell>> entry : familyMap.entrySet()) {
// map from this family to details for each cell affected within the family
List<Map<String, Object>> qualifierDetails = new ArrayList<>();
columns.put(Bytes.toStringBinary(entry.getKey()), qualifierDetails);
@@ -227,7 +224,7 @@ public abstract class Mutation extends OperationWithAttributes
continue;
}
// add details for each cell
- for (Cell cell : entry.getValue()) {
+ for (ExtendedCell cell : entry.getValue()) {
if (--maxCols <= 0) {
continue;
}
@@ -250,7 +247,7 @@ public abstract class Mutation extends OperationWithAttributes
return map;
}
- private static Map<String, Object> cellToStringMap(Cell c) {
+ private static Map<String, Object> cellToStringMap(ExtendedCell c) {
Map<String, Object> stringMap = new HashMap<>();
stringMap.put("qualifier",
Bytes.toStringBinary(c.getQualifierArray(), c.getQualifierOffset(), c.getQualifierLength()));
@@ -283,8 +280,9 @@ public abstract class Mutation extends OperationWithAttributes
/**
* Method for retrieving the put's familyMap
*/
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public NavigableMap<byte[], List<Cell>> getFamilyCellMap() {
- return this.familyMap;
+ return (NavigableMap) this.familyMap;
}
/**
@@ -517,9 +515,7 @@ public abstract class Mutation extends OperationWithAttributes
* Set the timestamp of the delete.
*/
public Mutation setTimestamp(long timestamp) {
- if (timestamp < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + timestamp);
- }
+ checkTimestamp(timestamp);
this.ts = timestamp;
return this;
}
@@ -603,7 +599,7 @@ public abstract class Mutation extends OperationWithAttributes
*/
protected boolean has(byte[] family, byte[] qualifier, long ts, byte[] value, boolean ignoreTS,
boolean ignoreValue) {
- List<Cell> list = getCellList(family);
+ List<ExtendedCell> list = getCellList(family);
if (list.isEmpty()) {
return false;
}
@@ -613,7 +609,7 @@ public abstract class Mutation extends OperationWithAttributes
// F T => 2
// F F => 1
if (!ignoreTS && !ignoreValue) {
- for (Cell cell : list) {
+ for (ExtendedCell cell : list) {
if (
CellUtil.matchingFamily(cell, family) && CellUtil.matchingQualifier(cell, qualifier)
&& CellUtil.matchingValue(cell, value) && cell.getTimestamp() == ts
@@ -692,6 +688,10 @@ public abstract class Mutation extends OperationWithAttributes
}
}
+ protected final void checkTimestamp(long ts) {
+ Preconditions.checkArgument(ts >= 0, "Timestamp cannot be negative. ts=%s", ts);
+ }
+
Mutation add(Cell cell) throws IOException {
// Checking that the row of the kv is the same as the mutation
// TODO: It is fraught with risk if user pass the wrong row.
@@ -714,9 +714,9 @@ public abstract class Mutation extends OperationWithAttributes
}
if (cell instanceof ExtendedCell) {
- getCellList(family).add(cell);
+ getCellList(family).add((ExtendedCell) cell);
} else {
- getCellList(family).add(new CellWrapper(cell));
+ throw new IllegalArgumentException("Unsupported cell type: " + cell.getClass().getName());
}
return this;
}
@@ -743,7 +743,7 @@ public abstract class Mutation extends OperationWithAttributes
* @param cellType e.g Cell.Type.Put
* @return CellBuilder which already has relevant Type and Row set.
*/
- protected CellBuilder getCellBuilder(CellBuilderType cellBuilderType, Cell.Type cellType) {
+ protected final CellBuilder getCellBuilder(CellBuilderType cellBuilderType, Cell.Type cellType) {
CellBuilder builder = CellBuilderFactory.create(cellBuilderType).setRow(row).setType(cellType);
return new CellBuilder() {
@Override
@@ -818,158 +818,4 @@ public abstract class Mutation extends OperationWithAttributes
}
};
}
-
- private static final class CellWrapper implements ExtendedCell {
- private static final long FIXED_OVERHEAD = ClassSize.align(ClassSize.OBJECT // object header
- + KeyValue.TIMESTAMP_SIZE // timestamp
- + Bytes.SIZEOF_LONG // sequence id
- + 1 * ClassSize.REFERENCE); // references to cell
- private final Cell cell;
- private long sequenceId;
- private long timestamp;
-
- CellWrapper(Cell cell) {
- assert !(cell instanceof ExtendedCell);
- this.cell = cell;
- this.sequenceId = cell.getSequenceId();
- this.timestamp = cell.getTimestamp();
- }
-
- @Override
- public void setSequenceId(long seqId) {
- sequenceId = seqId;
- }
-
- @Override
- public void setTimestamp(long ts) {
- timestamp = ts;
- }
-
- @Override
- public void setTimestamp(byte[] ts) {
- timestamp = Bytes.toLong(ts);
- }
-
- @Override
- public long getSequenceId() {
- return sequenceId;
- }
-
- @Override
- public byte[] getValueArray() {
- return cell.getValueArray();
- }
-
- @Override
- public int getValueOffset() {
- return cell.getValueOffset();
- }
-
- @Override
- public int getValueLength() {
- return cell.getValueLength();
- }
-
- @Override
- public byte[] getTagsArray() {
- return cell.getTagsArray();
- }
-
- @Override
- public int getTagsOffset() {
- return cell.getTagsOffset();
- }
-
- @Override
- public int getTagsLength() {
- return cell.getTagsLength();
- }
-
- @Override
- public byte[] getRowArray() {
- return cell.getRowArray();
- }
-
- @Override
- public int getRowOffset() {
- return cell.getRowOffset();
- }
-
- @Override
- public short getRowLength() {
- return cell.getRowLength();
- }
-
- @Override
- public byte[] getFamilyArray() {
- return cell.getFamilyArray();
- }
-
- @Override
- public int getFamilyOffset() {
- return cell.getFamilyOffset();
- }
-
- @Override
- public byte getFamilyLength() {
- return cell.getFamilyLength();
- }
-
- @Override
- public byte[] getQualifierArray() {
- return cell.getQualifierArray();
- }
-
- @Override
- public int getQualifierOffset() {
- return cell.getQualifierOffset();
- }
-
- @Override
- public int getQualifierLength() {
- return cell.getQualifierLength();
- }
-
- @Override
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public byte getTypeByte() {
- return cell.getTypeByte();
- }
-
- @Override
- public Optional<Tag> getTag(byte type) {
- return PrivateCellUtil.getTag(cell, type);
- }
-
- @Override
- public Iterator<Tag> getTags() {
- return PrivateCellUtil.tagsIterator(cell);
- }
-
- @Override
- public byte[] cloneTags() {
- return PrivateCellUtil.cloneTags(cell);
- }
-
- private long heapOverhead() {
- return FIXED_OVERHEAD + ClassSize.ARRAY // row
- + getFamilyLength() == 0
- ? 0
- : ClassSize.ARRAY + getQualifierLength() == 0 ? 0
- : ClassSize.ARRAY + getValueLength() == 0 ? 0
- : ClassSize.ARRAY + getTagsLength() == 0 ? 0
- : ClassSize.ARRAY;
- }
-
- @Override
- public long heapSize() {
- return heapOverhead() + ClassSize.align(getRowLength()) + ClassSize.align(getFamilyLength())
- + ClassSize.align(getQualifierLength()) + ClassSize.align(getValueLength())
- + ClassSize.align(getTagsLength());
- }
- }
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/PackagePrivateFieldAccessor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/PackagePrivateFieldAccessor.java
index 56a8dd19fcc..08293ab83f8 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/PackagePrivateFieldAccessor.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/PackagePrivateFieldAccessor.java
@@ -17,6 +17,9 @@
*/
package org.apache.hadoop.hbase.client;
+import java.util.List;
+import java.util.NavigableMap;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.yetus.audience.InterfaceAudience;
/**
@@ -38,4 +41,21 @@ public class PackagePrivateFieldAccessor {
public static long getMvccReadPoint(Scan scan) {
return scan.getMvccReadPoint();
}
+
+ public static ExtendedCell[] getExtendedRawCells(Result result) {
+ return result.rawExtendedCells();
+ }
+
+ public static NavigableMap<byte[], List<ExtendedCell>> getExtendedFamilyCellMap(Mutation m) {
+ return m.familyMap;
+ }
+
+ public static Result createResult(ExtendedCell[] cells) {
+ return Result.create(cells);
+ }
+
+ public static Result createResult(ExtendedCell[] cells, Boolean exists, boolean stale,
+ boolean mayHaveMoreCellsInRow) {
+ return Result.create(cells, exists, stale, mayHaveMoreCellsInRow);
+ }
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
index dc470069f90..b97a023c389 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Put.java
@@ -26,6 +26,7 @@ import java.util.UUID;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.io.HeapSize;
@@ -93,11 +94,9 @@ public class Put extends Mutation implements HeapSize {
*/
public Put(byte[] rowArray, int rowOffset, int rowLength, long ts) {
checkRow(rowArray, rowOffset, rowLength);
+ checkTimestamp(ts);
this.row = Bytes.copy(rowArray, rowOffset, rowLength);
this.ts = ts;
- if (ts < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
- }
}
/**
@@ -119,9 +118,7 @@ public class Put extends Mutation implements HeapSize {
*/
public Put(byte[] row, long ts, boolean rowIsImmutable) {
// Check and set timestamp
- if (ts < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
- }
+ checkTimestamp(ts);
this.ts = ts;
// Deal with row according to rowIsImmutable
@@ -171,10 +168,8 @@ public class Put extends Mutation implements HeapSize {
* @param value column value
*/
public Put addColumn(byte[] family, byte[] qualifier, long ts, byte[] value) {
- if (ts < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(ts);
+ List<ExtendedCell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
list.add(kv);
return this;
@@ -189,10 +184,8 @@ public class Put extends Mutation implements HeapSize {
* @param value column value
*/
public Put addColumn(byte[] family, ByteBuffer qualifier, long ts, ByteBuffer value) {
- if (ts < 0) {
- throw new IllegalArgumentException("Timestamp cannot be negative. ts=" + ts);
- }
- List<Cell> list = getCellList(family);
+ checkTimestamp(ts);
+ List<ExtendedCell> list = getCellList(family);
KeyValue kv = createPutKeyValue(family, qualifier, ts, value, null);
list.add(kv);
return this;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
index ec1d3f2b1fa..f4ac525e5b9 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java
@@ -32,9 +32,11 @@ import java.util.NoSuchElementException;
import java.util.TreeMap;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
-import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -70,8 +72,8 @@ import org.apache.yetus.audience.InterfaceAudience;
* {@link #copyFrom(Result)}
*/
@InterfaceAudience.Public
-public class Result implements CellScannable, CellScanner {
- private Cell[] cells;
+public class Result implements ExtendedCellScannable, ExtendedCellScanner {
+ private ExtendedCell[] cells;
private Boolean exists; // if the query was just to check existence.
private boolean stale = false;
@@ -142,7 +144,8 @@ public class Result implements CellScannable, CellScanner {
if (exists != null) {
return new Result(null, exists, stale, mayHaveMoreCellsInRow);
}
- return new Result(cells.toArray(new Cell[cells.size()]), null, stale, mayHaveMoreCellsInRow);
+ return new Result(cells.toArray(new ExtendedCell[cells.size()]), null, stale,
+ mayHaveMoreCellsInRow);
}
/**
@@ -159,6 +162,26 @@ public class Result implements CellScannable, CellScanner {
}
public static Result create(Cell[] cells, Boolean exists, boolean stale,
+ boolean mayHaveMoreCellsInRow) {
+ if (exists != null) {
+ return new Result(null, exists, stale, mayHaveMoreCellsInRow);
+ }
+ ExtendedCell[] extendCells = cells instanceof ExtendedCell[]
+ ? (ExtendedCell[]) cells
+ : Arrays.copyOf(cells, cells.length, ExtendedCell[].class);
+ return new Result(extendCells, null, stale, mayHaveMoreCellsInRow);
+ }
+
+ // prefer these below methods inside hbase to avoid casting or copying
+ static Result create(ExtendedCell[] cells) {
+ return create(cells, null, false);
+ }
+
+ static Result create(ExtendedCell[] cells, Boolean exists, boolean stale) {
+ return create(cells, exists, stale, false);
+ }
+
+ static Result create(ExtendedCell[] cells, Boolean exists, boolean stale,
boolean mayHaveMoreCellsInRow) {
if (exists != null) {
return new Result(null, exists, stale, mayHaveMoreCellsInRow);
@@ -176,7 +199,8 @@ public class Result implements CellScannable, CellScanner {
}
/** Private ctor. Use {@link #create(Cell[])}. */
- private Result(Cell[] cells, Boolean exists, boolean stale, boolean mayHaveMoreCellsInRow) {
+ private Result(ExtendedCell[] cells, Boolean exists, boolean stale,
+ boolean mayHaveMoreCellsInRow) {
this.cells = cells;
this.exists = exists;
this.stale = stale;
@@ -212,6 +236,10 @@ public class Result implements CellScannable, CellScanner {
return cells;
}
+ ExtendedCell[] rawExtendedCells() {
+ return cells;
+ }
+
/**
* Create a sorted list of the Cell's in this result. Since HBase 0.20.5 this is equivalent to
* raw().
@@ -263,7 +291,7 @@ public class Result implements CellScannable, CellScanner {
}
}
- protected int binarySearch(final Cell[] kvs, final byte[] family, final byte[] qualifier) {
+ private int binarySearch(final Cell[] kvs, final byte[] family, final byte[] qualifier) {
byte[] familyNotNull = notNullBytes(family);
byte[] qualifierNotNull = notNullBytes(qualifier);
Cell searchTerm = PrivateCellUtil.createFirstOnRow(kvs[0].getRowArray(), kvs[0].getRowOffset(),
@@ -294,7 +322,7 @@ public class Result implements CellScannable, CellScanner {
* @param qlength qualifier length
* @return the index where the value was found, or -1 otherwise
*/
- protected int binarySearch(final Cell[] kvs, final byte[] family, final int foffset,
+ private int binarySearch(final Cell[] kvs, final byte[] family, final int foffset,
final int flength, final byte[] qualifier, final int qoffset, final int qlength) {
double keyValueSize =
@@ -734,12 +762,12 @@ public class Result implements CellScannable, CellScanner {
+ ", " + res1.size() + " cells are compared to " + res2.size() + " cells");
}
}
- Cell[] ourKVs = res1.rawCells();
- Cell[] replicatedKVs = res2.rawCells();
+ ExtendedCell[] ourKVs = res1.cells;
+ ExtendedCell[] replicatedKVs = res2.cells;
for (int i = 0; i < res1.size(); i++) {
if (
!ourKVs[i].equals(replicatedKVs[i]) || !CellUtil.matchingValue(ourKVs[i], replicatedKVs[i])
- || !CellUtil.matchingTags(ourKVs[i], replicatedKVs[i])
+ || !PrivateCellUtil.matchingTags(ourKVs[i], replicatedKVs[i])
) {
if (verbose) {
throw new Exception("This result was different: " + res1 + " compared to " + res2);
@@ -824,18 +852,29 @@ public class Result implements CellScannable, CellScanner {
this.cells = other.cells;
}
+ /**
+ * For client users: You should only use the return value as a
+ * {@link org.apache.hadoop.hbase.CellScanner}, {@link ExtendedCellScanner} is marked as
+ * IA.Private which means there is no guarantee about its API stability.
+ */
@Override
- public CellScanner cellScanner() {
+ public ExtendedCellScanner cellScanner() {
// Reset
this.cellScannerIndex = INITIAL_CELLSCANNER_INDEX;
return this;
}
+ /**
+ * For client users: You should only use the return value as a {@link Cell}, {@link ExtendedCell}
+ * is marked as IA.Private which means there is no guarantee about its API stability.
+ */
@Override
- public Cell current() {
+ public ExtendedCell current() {
if (
isEmpty() || cellScannerIndex == INITIAL_CELLSCANNER_INDEX || cellScannerIndex >= cells.length
- ) return null;
+ ) {
+ return null;
+ }
return this.cells[cellScannerIndex];
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/Call.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/Call.java
index 980e708d235..45a9b29daba 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/Call.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/Call.java
@@ -22,7 +22,7 @@ import java.io.IOException;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.client.MetricsConnection;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.yetus.audience.InterfaceAudience;
@@ -44,7 +44,7 @@ class Call {
* Optionally has cells when making call. Optionally has cells set on response. Used passing cells
* to the rpc and receiving the response.
*/
- CellScanner cells;
+ ExtendedCellScanner cells;
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "IS2_INCONSISTENT_SYNC",
justification = "Direct access is only allowed after done")
Message response; // value, null if error
@@ -63,9 +63,10 @@ class Call {
final Span span;
Timeout timeoutTask;
- Call(int id, final Descriptors.MethodDescriptor md, Message param, final CellScanner cells,
- final Message responseDefaultType, int timeout, int priority, Map<String, byte[]> attributes,
- RpcCallback<Call> callback, MetricsConnection.CallStats callStats) {
+ Call(int id, final Descriptors.MethodDescriptor md, Message param,
+ final ExtendedCellScanner cells, final Message responseDefaultType, int timeout, int priority,
+ Map<String, byte[]> attributes, RpcCallback<Call> callback,
+ MetricsConnection.CallStats callStats) {
this.param = param;
this.md = md;
this.cells = cells;
@@ -136,7 +137,7 @@ class Call {
* @param response return value of the call.
* @param cells Can be null
*/
- public void setResponse(Message response, final CellScanner cells) {
+ public void setResponse(Message response, final ExtendedCellScanner cells) {
synchronized (this) {
if (done) {
return;
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CellBlockBuilder.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CellBlockBuilder.java
index e7364ca3b42..a52aa8693f6 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CellBlockBuilder.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/CellBlockBuilder.java
@@ -26,8 +26,8 @@ import java.nio.ByteBuffer;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configurable;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.codec.Codec;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.io.ByteBuffInputStream;
@@ -110,7 +110,7 @@ class CellBlockBuilder {
* been flipped and is ready for reading. Use limit to find total size.
*/
public ByteBuffer buildCellBlock(final Codec codec, final CompressionCodec compressor,
- final CellScanner cellScanner) throws IOException {
+ final ExtendedCellScanner cellScanner) throws IOException {
ByteBufferOutputStreamSupplier supplier = new ByteBufferOutputStreamSupplier();
if (buildCellBlock(codec, compressor, cellScanner, supplier)) {
ByteBuffer bb = supplier.baos.getByteBuffer();
@@ -144,8 +144,8 @@ class CellBlockBuilder {
}
}
- public ByteBuf buildCellBlock(Codec codec, CompressionCodec compressor, CellScanner cellScanner,
- ByteBufAllocator alloc) throws IOException {
+ public ByteBuf buildCellBlock(Codec codec, CompressionCodec compressor,
+ ExtendedCellScanner cellScanner, ByteBufAllocator alloc) throws IOException {
ByteBufOutputStreamSupplier supplier = new ByteBufOutputStreamSupplier(alloc);
if (buildCellBlock(codec, compressor, cellScanner, supplier)) {
return supplier.buf;
@@ -155,7 +155,7 @@ class CellBlockBuilder {
}
private boolean buildCellBlock(final Codec codec, final CompressionCodec compressor,
- final CellScanner cellScanner, OutputStreamSupplier supplier) throws IOException {
+ final ExtendedCellScanner cellScanner, OutputStreamSupplier supplier) throws IOException {
if (cellScanner == null) {
return false;
}
@@ -171,7 +171,7 @@ class CellBlockBuilder {
return true;
}
- private void encodeCellsTo(OutputStream os, CellScanner cellScanner, Codec codec,
+ private void encodeCellsTo(OutputStream os, ExtendedCellScanner cellScanner, Codec codec,
CompressionCodec compressor) throws IOException {
Compressor poolCompressor = null;
try {
@@ -212,7 +212,7 @@ class CellBlockBuilder {
* @throws IOException if encoding the cells fail
*/
public ByteBufferListOutputStream buildCellBlockStream(Codec codec, CompressionCodec compressor,
- CellScanner cellScanner, ByteBuffAllocator allocator) throws IOException {
+ ExtendedCellScanner cellScanner, ByteBuffAllocator allocator) throws IOException {
if (cellScanner == null) {
return null;
}
@@ -235,7 +235,7 @@ class CellBlockBuilder {
* @return CellScanner to work against the content of <code>cellBlock</code>
* @throws IOException if encoding fails
*/
- public CellScanner createCellScanner(final Codec codec, final CompressionCodec compressor,
+ public ExtendedCellScanner createCellScanner(final Codec codec, final CompressionCodec compressor,
final byte[] cellBlock) throws IOException {
// Use this method from Client side to create the CellScanner
if (compressor != null) {
@@ -258,7 +258,7 @@ class CellBlockBuilder {
* out of the CellScanner will share the same ByteBuffer being passed.
* @throws IOException if cell encoding fails
*/
- public CellScanner createCellScannerReusingBuffers(final Codec codec,
+ public ExtendedCellScanner createCellScannerReusingBuffers(final Codec codec,
final CompressionCodec compressor, ByteBuff cellBlock) throws IOException {
// Use this method from HRS to create the CellScanner
// If compressed, decompress it first before passing it on else we will leak compression
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/DelegatingHBaseRpcController.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/DelegatingHBaseRpcController.java
index 2b8839bf846..5b220a24ec5 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/DelegatingHBaseRpcController.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/DelegatingHBaseRpcController.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.util.Map;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.TableName;
import org.apache.yetus.audience.InterfaceAudience;
@@ -74,12 +74,12 @@ public class DelegatingHBaseRpcController implements HBaseRpcController {
}
@Override
- public CellScanner cellScanner() {
+ public ExtendedCellScanner cellScanner() {
return delegate.cellScanner();
}
@Override
- public void setCellScanner(CellScanner cellScanner) {
+ public void setCellScanner(ExtendedCellScanner cellScanner) {
delegate.setCellScanner(cellScanner);
}
@@ -134,7 +134,7 @@ public class DelegatingHBaseRpcController implements HBaseRpcController {
}
@Override
- public void setDone(CellScanner cellScanner) {
+ public void setDone(ExtendedCellScanner cellScanner) {
delegate.setDone(cellScanner);
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcController.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcController.java
index 4d3e038bb5e..8fe44ca59cf 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcController.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcController.java
@@ -19,8 +19,8 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.util.Map;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
@@ -42,13 +42,13 @@ import org.apache.hbase.thirdparty.com.google.protobuf.RpcController;
@InterfaceAudience.LimitedPrivate({ HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.PHOENIX,
HBaseInterfaceAudience.REPLICATION })
@InterfaceStability.Evolving
-public interface HBaseRpcController extends RpcController, CellScannable {
+public interface HBaseRpcController extends RpcController, ExtendedCellScannable {
/**
* Only used to send cells to rpc server, the returned cells should be set by
- * {@link #setDone(CellScanner)}.
+ * {@link #setDone(ExtendedCellScanner)}.
*/
- void setCellScanner(CellScanner cellScanner);
+ void setCellScanner(ExtendedCellScanner cellScanner);
/**
* Set the priority for this operation.
@@ -97,7 +97,7 @@ public interface HBaseRpcController extends RpcController, CellScannable {
* <b>IMPORTANT:</b> always call this method if the call finished without any exception to tell
* the {@code HBaseRpcController} that we are done.
*/
- void setDone(CellScanner cellScanner);
+ void setDone(ExtendedCellScanner cellScanner);
/**
* A little different from the basic RpcController:
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcControllerImpl.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcControllerImpl.java
index 54e9310b5ae..0667ce2ee62 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcControllerImpl.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/HBaseRpcControllerImpl.java
@@ -22,10 +22,10 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.yetus.audience.InterfaceAudience;
@@ -72,28 +72,29 @@ public class HBaseRpcControllerImpl implements HBaseRpcController {
* sometimes the scanner is backed by a List of Cells and other times, it is backed by an encoded
* block that implements CellScanner.
*/
- private CellScanner cellScanner;
+ private ExtendedCellScanner cellScanner;
private Map<String, byte[]> requestAttributes = Collections.emptyMap();
public HBaseRpcControllerImpl() {
- this(null, (CellScanner) null);
+ this(null, (ExtendedCellScanner) null);
}
/**
* Used server-side. Clients should go via {@link RpcControllerFactory}
*/
- public HBaseRpcControllerImpl(final CellScanner cellScanner) {
+ public HBaseRpcControllerImpl(final ExtendedCellScanner cellScanner) {
this(null, cellScanner);
}
- HBaseRpcControllerImpl(RegionInfo regionInfo, final CellScanner cellScanner) {
+ HBaseRpcControllerImpl(RegionInfo regionInfo, final ExtendedCellScanner cellScanner) {
this.cellScanner = cellScanner;
this.regionInfo = regionInfo;
}
- HBaseRpcControllerImpl(RegionInfo regionInfo, final List<CellScannable> cellIterables) {
- this.cellScanner = cellIterables == null ? null : CellUtil.createCellScanner(cellIterables);
+ HBaseRpcControllerImpl(RegionInfo regionInfo, final List<ExtendedCellScannable> cellIterables) {
+ this.cellScanner =
+ cellIterables == null ? null : PrivateCellUtil.createExtendedCellScanner(cellIterables);
this.regionInfo = null;
}
@@ -109,14 +110,14 @@ public class HBaseRpcControllerImpl implements HBaseRpcController {
/** Returns One-shot cell scanner (you cannot back it up and restart) */
@Override
- public CellScanner cellScanner() {
+ public ExtendedCellScanner cellScanner() {
return cellScanner;
}
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "IS2_INCONSISTENT_SYNC",
justification = "The only possible race method is startCancel")
@Override
- public void setCellScanner(final CellScanner cellScanner) {
+ public void setCellScanner(final ExtendedCellScanner cellScanner) {
this.cellScanner = cellScanner;
}
@@ -240,7 +241,7 @@ public class HBaseRpcControllerImpl implements HBaseRpcController {
}
@Override
- public synchronized void setDone(CellScanner cellScanner) {
+ public synchronized void setDone(ExtendedCellScanner cellScanner) {
if (done) {
return;
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java
index 8017e99ec4f..dbdb0e2037f 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcConnection.java
@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import javax.security.sasl.SaslException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.client.MetricsConnection;
import org.apache.hadoop.hbase.codec.Codec;
@@ -382,7 +382,7 @@ abstract class RpcConnection {
} else {
value = null;
}
- CellScanner cellBlockScanner;
+ ExtendedCellScanner cellBlockScanner;
if (responseHeader.hasCellBlockMeta()) {
int size = responseHeader.getCellBlockMeta().getLength();
// Maybe we could read directly from the ByteBuf.
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcControllerFactory.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcControllerFactory.java
index a256769de70..1977f09abb1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcControllerFactory.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/ipc/RpcControllerFactory.java
@@ -19,8 +19,8 @@ package org.apache.hadoop.hbase.ipc;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.util.ReflectionUtils;
@@ -54,20 +54,20 @@ public class RpcControllerFactory {
return new HBaseRpcControllerImpl();
}
- public HBaseRpcController newController(CellScanner cellScanner) {
+ public HBaseRpcController newController(ExtendedCellScanner cellScanner) {
return new HBaseRpcControllerImpl(null, cellScanner);
}
- public HBaseRpcController newController(RegionInfo regionInfo, CellScanner cellScanner) {
+ public HBaseRpcController newController(RegionInfo regionInfo, ExtendedCellScanner cellScanner) {
return new HBaseRpcControllerImpl(regionInfo, cellScanner);
}
- public HBaseRpcController newController(final List<CellScannable> cellIterables) {
+ public HBaseRpcController newController(final List<ExtendedCellScannable> cellIterables) {
return new HBaseRpcControllerImpl(null, cellIterables);
}
public HBaseRpcController newController(RegionInfo regionInfo,
- final List<CellScannable> cellIterables) {
+ final List<ExtendedCellScannable> cellIterables) {
return new HBaseRpcControllerImpl(regionInfo, cellIterables);
}
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
index d48b8b73a31..d3672c5e841 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
@@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -245,7 +246,7 @@ public final class ProtobufUtil {
* Many results are simple: no cell, exists true or false. To save on object creations, we reuse
* them across calls.
*/
- private final static Cell[] EMPTY_CELL_ARRAY = new Cell[] {};
+ private final static ExtendedCell[] EMPTY_CELL_ARRAY = new ExtendedCell[0];
private final static Result EMPTY_RESULT = Result.create(EMPTY_CELL_ARRAY);
final static Result EMPTY_RESULT_EXISTS_TRUE = Result.create(null, true);
final static Result EMPTY_RESULT_EXISTS_FALSE = Result.create(null, false);
@@ -2024,7 +2025,7 @@ public final class ProtobufUtil {
return UnsafeByteOperations.unsafeWrap(dup);
}
- public static Cell toCell(ExtendedCellBuilder cellBuilder, final CellProtos.Cell cell,
+ public static ExtendedCell toCell(ExtendedCellBuilder cellBuilder, final CellProtos.Cell cell,
boolean decodeTags) {
ExtendedCellBuilder builder = cellBuilder.clear().setRow(cell.getRow().toByteArray())
.setFamily(cell.getFamily().toByteArray()).setQualifier(cell.getQualifier().toByteArray())
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
index 377b4649463..80def357f30 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/RequestConverter.java
@@ -27,11 +27,11 @@ import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
-import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.ClusterMetrics.Option;
import org.apache.hadoop.hbase.ClusterMetricsBuilder;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ServerName;
@@ -469,7 +469,7 @@ public final class RequestConverter {
* RowMutations/CheckAndMutate within the original list of actions
*/
public static void buildNoDataRegionActions(final byte[] regionName,
- final Iterable<Action> actions, final List<CellScannable> cells,
+ final Iterable<Action> actions, final List<ExtendedCellScannable> cells,
final MultiRequest.Builder multiRequestBuilder, final RegionAction.Builder regionActionBuilder,
final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder,
long nonceGroup, final Map<Integer, Integer> indexMap) throws IOException {
@@ -609,17 +609,19 @@ public final class RequestConverter {
}
}
- private static void buildNoDataRegionAction(final Put put, final List<CellScannable> cells,
- final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder,
- final MutationProto.Builder mutationBuilder) throws IOException {
+ private static void buildNoDataRegionAction(final Put put,
+ final List<ExtendedCellScannable> cells, final RegionAction.Builder regionActionBuilder,
+ final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
+ throws IOException {
cells.add(put);
regionActionBuilder.addAction(actionBuilder
.setMutation(ProtobufUtil.toMutationNoData(MutationType.PUT, put, mutationBuilder)));
}
- private static void buildNoDataRegionAction(final Delete delete, final List<CellScannable> cells,
- final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder,
- final MutationProto.Builder mutationBuilder) throws IOException {
+ private static void buildNoDataRegionAction(final Delete delete,
+ final List<ExtendedCellScannable> cells, final RegionAction.Builder regionActionBuilder,
+ final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
+ throws IOException {
int size = delete.size();
// Note that a legitimate Delete may have a size of zero; i.e. a Delete that has nothing
// in it but the row to delete. In this case, the current implementation does not make
@@ -637,18 +639,18 @@ public final class RequestConverter {
}
private static void buildNoDataRegionAction(final Increment increment,
- final List<CellScannable> cells, long nonce, final RegionAction.Builder regionActionBuilder,
- final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
- throws IOException {
+ final List<ExtendedCellScannable> cells, long nonce,
+ final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder,
+ final MutationProto.Builder mutationBuilder) throws IOException {
cells.add(increment);
regionActionBuilder.addAction(actionBuilder.setMutation(
ProtobufUtil.toMutationNoData(MutationType.INCREMENT, increment, mutationBuilder, nonce)));
}
- private static void buildNoDataRegionAction(final Append append, final List<CellScannable> cells,
- long nonce, final RegionAction.Builder regionActionBuilder,
- final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
- throws IOException {
+ private static void buildNoDataRegionAction(final Append append,
+ final List<ExtendedCellScannable> cells, long nonce,
+ final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder,
+ final MutationProto.Builder mutationBuilder) throws IOException {
cells.add(append);
regionActionBuilder.addAction(actionBuilder.setMutation(
ProtobufUtil.toMutationNoData(MutationType.APPEND, append, mutationBuilder, nonce)));
@@ -656,9 +658,9 @@ public final class RequestConverter {
/** Returns whether or not the rowMutations has a Increment or Append */
private static boolean buildNoDataRegionAction(final RowMutations rowMutations,
- final List<CellScannable> cells, long nonce, final RegionAction.Builder regionActionBuilder,
- final ClientProtos.Action.Builder actionBuilder, final MutationProto.Builder mutationBuilder)
- throws IOException {
+ final List<ExtendedCellScannable> cells, long nonce,
+ final RegionAction.Builder regionActionBuilder, final ClientProtos.Action.Builder actionBuilder,
+ final MutationProto.Builder mutationBuilder) throws IOException {
boolean ret = false;
for (Mutation mutation : rowMutations.getMutations()) {
mutationBuilder.clear();
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMutation.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMutation.java
index 718ca05b92f..5da59b144a5 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMutation.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestMutation.java
@@ -26,7 +26,9 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.io.TimeRange;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -124,13 +126,13 @@ public class TestMutation {
private void assertEquals(Mutation origin, Mutation clone) {
Assert.assertEquals(origin.getFamilyCellMap().size(), clone.getFamilyCellMap().size());
for (byte[] family : origin.getFamilyCellMap().keySet()) {
- List<Cell> originCells = origin.getCellList(family);
- List<Cell> cloneCells = clone.getCellList(family);
+ List<ExtendedCell> originCells = origin.getCellList(family);
+ List<ExtendedCell> cloneCells = clone.getCellList(family);
Assert.assertEquals(originCells.size(), cloneCells.size());
for (int i = 0; i != cloneCells.size(); ++i) {
- Cell originCell = originCells.get(i);
- Cell cloneCell = cloneCells.get(i);
- assertTrue(CellUtil.equals(originCell, cloneCell));
+ ExtendedCell originCell = originCells.get(i);
+ ExtendedCell cloneCell = cloneCells.get(i);
+ assertTrue(PrivateCellUtil.equals(originCell, cloneCell));
assertTrue(CellUtil.matchingValue(originCell, cloneCell));
}
}
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestCellBlockBuilder.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestCellBlockBuilder.java
index fccea923635..c3a145ea6f3 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestCellBlockBuilder.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestCellBlockBuilder.java
@@ -21,18 +21,17 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.nio.ByteBuffer;
-import java.util.Arrays;
import org.apache.commons.lang3.time.StopWatch;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.codec.Codec;
import org.apache.hadoop.hbase.codec.KeyValueCodec;
-import org.apache.hadoop.hbase.io.SizedCellScanner;
+import org.apache.hadoop.hbase.io.SizedExtendedCellScanner;
import org.apache.hadoop.hbase.nio.SingleByteBuff;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -78,10 +77,9 @@ public class TestCellBlockBuilder {
static void doBuildCellBlockUndoCellBlock(final CellBlockBuilder builder, final Codec codec,
final CompressionCodec compressor, final int count, final int size, final boolean sized)
throws IOException {
- Cell[] cells = getCells(count, size);
- CellScanner cellScanner = sized
- ? getSizedCellScanner(cells)
- : CellUtil.createCellScanner(Arrays.asList(cells).iterator());
+ ExtendedCell[] cells = getCells(count, size);
+ ExtendedCellScanner cellScanner =
+ sized ? getSizedCellScanner(cells) : PrivateCellUtil.createExtendedCellScanner(cells);
ByteBuffer bb = builder.buildCellBlock(codec, compressor, cellScanner);
cellScanner =
builder.createCellScannerReusingBuffers(codec, compressor, new SingleByteBuff(bb));
@@ -92,21 +90,21 @@ public class TestCellBlockBuilder {
assertEquals(count, i);
}
- static CellScanner getSizedCellScanner(final Cell[] cells) {
+ static ExtendedCellScanner getSizedCellScanner(final ExtendedCell[] cells) {
int size = -1;
for (Cell cell : cells) {
size += PrivateCellUtil.estimatedSerializedSizeOf(cell);
}
final int totalSize = ClassSize.align(size);
- final CellScanner cellScanner = CellUtil.createCellScanner(cells);
- return new SizedCellScanner() {
+ final ExtendedCellScanner cellScanner = PrivateCellUtil.createExtendedCellScanner(cells);
+ return new SizedExtendedCellScanner() {
@Override
public long heapSize() {
return totalSize;
}
@Override
- public Cell current() {
+ public ExtendedCell current() {
return cellScanner.current();
}
@@ -117,12 +115,12 @@ public class TestCellBlockBuilder {
};
}
- static Cell[] getCells(final int howMany) {
+ static ExtendedCell[] getCells(final int howMany) {
return getCells(howMany, 1024);
}
- static Cell[] getCells(final int howMany, final int valueSize) {
- Cell[] cells = new Cell[howMany];
+ static ExtendedCell[] getCells(final int howMany, final int valueSize) {
+ ExtendedCell[] cells = new ExtendedCell[howMany];
byte[] value = new byte[valueSize];
for (int i = 0; i < howMany; i++) {
byte[] index = Bytes.toBytes(i);
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseRpcControllerImpl.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseRpcControllerImpl.java
index a0b68646b14..a1ef458b3b4 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseRpcControllerImpl.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/ipc/TestHBaseRpcControllerImpl.java
@@ -24,8 +24,10 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -43,7 +45,7 @@ public class TestHBaseRpcControllerImpl {
@Test
public void testListOfCellScannerables() throws IOException {
final int count = 10;
- List<CellScannable> cells = new ArrayList<>(count);
+ List<ExtendedCellScannable> cells = new ArrayList<>(count);
for (int i = 0; i < count; i++) {
cells.add(createCell(i));
@@ -64,16 +66,16 @@ public class TestHBaseRpcControllerImpl {
* @param index the index of the cell to use as its value
* @return A faked out 'Cell' that does nothing but return index as its value
*/
- static CellScannable createCell(final int index) {
- return new CellScannable() {
+ static ExtendedCellScannable createCell(final int index) {
+ return new ExtendedCellScannable() {
@Override
- public CellScanner cellScanner() {
- return new CellScanner() {
+ public ExtendedCellScanner cellScanner() {
+ return new ExtendedCellScanner() {
@Override
- public Cell current() {
+ public ExtendedCell current() {
// Fake out a Cell. All this Cell has is a value that is an int in size and equal
// to the above 'index' param serialized as an int.
- return new Cell() {
+ return new ExtendedCell() {
@Override
public long heapSize() {
return 0;
@@ -180,6 +182,18 @@ public class TestHBaseRpcControllerImpl {
public Type getType() {
return null;
}
+
+ @Override
+ public void setSequenceId(long seqId) throws IOException {
+ }
+
+ @Override
+ public void setTimestamp(long ts) throws IOException {
+ }
+
+ @Override
+ public void setTimestamp(byte[] ts) throws IOException {
+ }
};
}
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
index 2b4380dfbb6..acc56181285 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
@@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellComparatorImpl;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
@@ -505,7 +506,7 @@ public class TestProtobufUtil {
CellProtos.Cell protoCell = ProtobufUtil.toCell(cell, true);
assertNotNull(protoCell);
- Cell decodedCell = getCellFromProtoResult(protoCell, true);
+ ExtendedCell decodedCell = getCellFromProtoResult(protoCell, true);
List<Tag> decodedTags = PrivateCellUtil.getTags(decodedCell);
assertEquals(1, decodedTags.size());
Tag decodedTag = decodedTags.get(0);
@@ -525,7 +526,7 @@ public class TestProtobufUtil {
return cellBuilder.build();
}
- private Cell getCellFromProtoResult(CellProtos.Cell protoCell, boolean decodeTags) {
+ private ExtendedCell getCellFromProtoResult(CellProtos.Cell protoCell, boolean decodeTags) {
ExtendedCellBuilder decodedBuilder =
ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY);
return ProtobufUtil.toCell(decodedBuilder, protoCell, decodeTags);
@@ -542,7 +543,7 @@ public class TestProtobufUtil {
CellProtos.Cell protoCell = ProtobufUtil.toCell(cell, false);
assertNotNull(protoCell);
- Cell decodedCell = getCellFromProtoResult(protoCell, false);
+ ExtendedCell decodedCell = getCellFromProtoResult(protoCell, false);
List<Tag> decodedTags = PrivateCellUtil.getTags(decodedCell);
assertEquals(0, decodedTags.size());
}
@@ -558,7 +559,7 @@ public class TestProtobufUtil {
CellProtos.Cell protoCell = ProtobufUtil.toCell(cell, false);
assertNotNull(protoCell);
- Cell decodedCell = getCellFromProtoResult(protoCell, true);
+ ExtendedCell decodedCell = getCellFromProtoResult(protoCell, true);
List<Tag> decodedTags = PrivateCellUtil.getTags(decodedCell);
assertEquals(0, decodedTags.size());
}
@@ -574,7 +575,7 @@ public class TestProtobufUtil {
CellProtos.Cell protoCell = ProtobufUtil.toCell(cell, true);
assertNotNull(protoCell);
- Cell decodedCell = getCellFromProtoResult(protoCell, false);
+ ExtendedCell decodedCell = getCellFromProtoResult(protoCell, false);
List<Tag> decodedTags = PrivateCellUtil.getTags(decodedCell);
assertEquals(0, decodedTags.size());
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
index 749f6b46782..45e6f2d11d4 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ByteBufferKeyValue.java
@@ -328,10 +328,10 @@ public class ByteBufferKeyValue extends ByteBufferExtendedCell {
*/
@Override
public boolean equals(Object other) {
- if (!(other instanceof Cell)) {
+ if (!(other instanceof ExtendedCell)) {
return false;
}
- return CellUtil.equals(this, (Cell) other);
+ return PrivateCellUtil.equals(this, (ExtendedCell) other);
}
/**
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
index a94c3679f47..0cd0905cc3a 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellComparatorImpl.java
@@ -761,7 +761,7 @@ public class CellComparatorImpl implements CellComparator {
}
@Override
- public Comparator getSimpleComparator() {
+ public Comparator<Cell> getSimpleComparator() {
return this;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
index 85f23550efc..10213b14363 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/CellUtil.java
@@ -309,10 +309,14 @@ public final class CellUtil {
public boolean advance() throws IOException {
while (true) {
if (this.cellScanner == null) {
- if (!this.iterator.hasNext()) return false;
+ if (!this.iterator.hasNext()) {
+ return false;
+ }
this.cellScanner = this.iterator.next().cellScanner();
}
- if (this.cellScanner.advance()) return true;
+ if (this.cellScanner.advance()) {
+ return true;
+ }
this.cellScanner = null;
}
}
@@ -357,13 +361,17 @@ public final class CellUtil {
@Override
public Cell current() {
- if (cells == null) return null;
+ if (cells == null) {
+ return null;
+ }
return (index < 0) ? null : this.cells[index];
}
@Override
public boolean advance() {
- if (cells == null) return false;
+ if (cells == null) {
+ return false;
+ }
return ++index < this.cells.length;
}
};
@@ -549,8 +557,13 @@ public final class CellUtil {
buf.length);
}
+ /**
+ * @deprecated Since 3.0.0, will be removed in 4.0.0. Tags are now internal only, you should not
+ * try to check it through the {@link Cell} interface.
+ */
+ @Deprecated
public static boolean matchingTags(final Cell left, final Cell right) {
- return PrivateCellUtil.matchingTags(left, right, left.getTagsLength(), right.getTagsLength());
+ return PrivateCellUtil.matchingTags((ExtendedCell) left, (ExtendedCell) right);
}
/**
@@ -662,7 +675,7 @@ public final class CellUtil {
public static boolean equals(Cell a, Cell b) {
return matchingRows(a, b) && matchingFamily(a, b) && matchingQualifier(a, b)
- && matchingTimestamp(a, b) && PrivateCellUtil.matchingType(a, b);
+ && matchingTimestamp(a, b) && a.getTypeByte() == b.getTypeByte();
}
public static boolean matchingTimestamp(Cell a, Cell b) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScannable.java
similarity index 65%
copy from hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
copy to hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScannable.java
index 379dfca051a..c3772f16622 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScannable.java
@@ -15,17 +15,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hadoop.hbase.io;
+package org.apache.hadoop.hbase;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.yetus.audience.InterfaceStability;
/**
- * A CellScanner that knows its size in memory in bytes. Used playing the CellScanner into an
- * in-memory buffer; knowing the size ahead of time saves on background buffer resizings.
+ * We use this class in HBase internally for getting {@link ExtendedCell} directly without casting.
+ * <p>
+ * In general, all {@link Cell}s in HBase should and must be {@link ExtendedCell}.
+ * <p>
+ * See HBASE-28684 and related issues for more details.
+ * @see CellScannable
+ * @see ExtendedCellScanner
+ * @see ExtendedCell
*/
@InterfaceAudience.Private
-@InterfaceStability.Unstable
-public interface SizedCellScanner extends CellScanner, HeapSize {
+public interface ExtendedCellScannable extends CellScannable {
+
+ @Override
+ ExtendedCellScanner cellScanner();
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScanner.java
similarity index 66%
copy from hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
copy to hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScanner.java
index 379dfca051a..f7011291d9c 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/ExtendedCellScanner.java
@@ -15,17 +15,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hadoop.hbase.io;
+package org.apache.hadoop.hbase;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.yetus.audience.InterfaceStability;
/**
- * A CellScanner that knows its size in memory in bytes. Used playing the CellScanner into an
- * in-memory buffer; knowing the size ahead of time saves on background buffer resizings.
+ * We use this class in HBase internally for getting {@link ExtendedCell} directly without casting.
+ * <p>
+ * In general, all {@link Cell}s in HBase should and must be {@link ExtendedCell}.
+ * <p>
+ * See HBASE-28684 and related issues for more details.
+ * @see CellScanner
+ * @see ExtendedCellScannable
+ * @see ExtendedCell
*/
@InterfaceAudience.Private
-@InterfaceStability.Unstable
-public interface SizedCellScanner extends CellScanner, HeapSize {
+public interface ExtendedCellScanner extends CellScanner {
+
+ @Override
+ ExtendedCell current();
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
index 89e91ca8036..a87a5214fad 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
@@ -978,10 +978,10 @@ public class KeyValue implements ExtendedCell, Cloneable {
*/
@Override
public boolean equals(Object other) {
- if (!(other instanceof Cell)) {
+ if (!(other instanceof ExtendedCell)) {
return false;
}
- return CellUtil.equals(this, (Cell) other);
+ return PrivateCellUtil.equals(this, (ExtendedCell) other);
}
/**
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueTestUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueTestUtil.java
index ed3687e9ed4..eacd819a23e 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueTestUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueTestUtil.java
@@ -63,9 +63,13 @@ public class KeyValueTestUtil {
for (Cell kv1 : kvCollection1) {
boolean found = false;
for (Cell kv2 : kvCollection2) {
- if (PrivateCellUtil.equalsIgnoreMvccVersion(kv1, kv2)) found = true;
+ if (PrivateCellUtil.equalsIgnoreMvccVersion((ExtendedCell) kv1, (ExtendedCell) kv2)) {
+ found = true;
+ }
+ }
+ if (!found) {
+ return false;
}
- if (!found) return false;
}
return true;
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
index 4b61688abc2..6c8f2e6e4ed 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValueUtil.java
@@ -88,7 +88,7 @@ public class KeyValueUtil {
/**************** copy the cell to create a new keyvalue *********************/
- public static KeyValue copyToNewKeyValue(final Cell cell) {
+ public static KeyValue copyToNewKeyValue(final ExtendedCell cell) {
byte[] bytes = copyToNewByteArray(cell);
KeyValue kvCell = new KeyValue(bytes, 0, bytes.length);
kvCell.setSequenceId(cell.getSequenceId());
@@ -120,7 +120,7 @@ public class KeyValueUtil {
return kv;
}
- public static byte[] copyToNewByteArray(final Cell cell) {
+ public static byte[] copyToNewByteArray(final ExtendedCell cell) {
// Cell#getSerializedSize returns the serialized size of the Source cell, which may
// not serialize all fields. We are constructing a KeyValue backing array here,
// which does include all fields, and must allocate accordingly.
@@ -133,7 +133,7 @@ public class KeyValueUtil {
return backingBytes;
}
- public static int appendKeyTo(final Cell cell, final byte[] output, final int offset) {
+ public static int appendKeyTo(final ExtendedCell cell, final byte[] output, final int offset) {
int nextOffset = offset;
nextOffset = Bytes.putShort(output, nextOffset, cell.getRowLength());
nextOffset = CellUtil.copyRowTo(cell, output, nextOffset);
@@ -147,7 +147,8 @@ public class KeyValueUtil {
/**************** copy key and value *********************/
- public static int appendToByteArray(Cell cell, byte[] output, int offset, boolean withTags) {
+ public static int appendToByteArray(ExtendedCell cell, byte[] output, int offset,
+ boolean withTags) {
int pos = offset;
pos = Bytes.putInt(output, pos, keyLength(cell));
pos = Bytes.putInt(output, pos, cell.getValueLength());
@@ -416,7 +417,7 @@ public class KeyValueUtil {
* @deprecated without any replacement.
*/
@Deprecated
- public static KeyValue ensureKeyValue(final Cell cell) {
+ public static KeyValue ensureKeyValue(final ExtendedCell cell) {
if (cell == null) return null;
if (cell instanceof KeyValue) {
if (cell.getClass().getName().equals(KeyValue.class.getName())) {
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
index 9013f9a9f26..bf514d81c5a 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/PrivateCellUtil.java
@@ -29,6 +29,8 @@ import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map.Entry;
+import java.util.NavigableMap;
import java.util.Optional;
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.io.TagCompressionContext;
@@ -40,6 +42,8 @@ import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.ClassSize;
import org.apache.yetus.audience.InterfaceAudience;
+import org.apache.hbase.thirdparty.com.google.common.base.Preconditions;
+
/**
* Utility methods helpful slinging {@link Cell} instances. It has more powerful and rich set of
* APIs than those in {@link CellUtil} for internal usage.
@@ -72,7 +76,7 @@ public final class PrivateCellUtil {
return range.set(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
}
- public static ByteRange fillTagRange(Cell cell, ByteRange range) {
+ public static ByteRange fillTagRange(ExtendedCell cell, ByteRange range) {
return range.set(cell.getTagsArray(), cell.getTagsOffset(), cell.getTagsLength());
}
@@ -582,8 +586,8 @@ public final class PrivateCellUtil {
* Made into a static method so as to reuse the logic within
* ValueAndTagRewriteByteBufferExtendedCell
*/
- static int write(OutputStream out, boolean withTags, Cell cell, byte[] value, byte[] tags)
- throws IOException {
+ static int write(OutputStream out, boolean withTags, ExtendedCell cell, byte[] value,
+ byte[] tags) throws IOException {
int valLen = value == null ? 0 : value.length;
ByteBufferUtils.putInt(out, KeyValueUtil.keyLength(cell));// Key length
ByteBufferUtils.putInt(out, valLen);// Value length
@@ -802,11 +806,16 @@ public final class PrivateCellUtil {
right.getValueArray(), right.getValueOffset(), rvlength);
}
- public static boolean matchingType(Cell a, Cell b) {
+ public static boolean matchingType(ExtendedCell a, ExtendedCell b) {
return a.getTypeByte() == b.getTypeByte();
}
- public static boolean matchingTags(final Cell left, final Cell right, int llength, int rlength) {
+ public static boolean matchingTags(final ExtendedCell left, final ExtendedCell right) {
+ return matchingTags(left, right, left.getTagsLength(), right.getTagsLength());
+ }
+
+ public static boolean matchingTags(final ExtendedCell left, final ExtendedCell right, int llength,
+ int rlength) {
if (left instanceof ByteBufferExtendedCell && right instanceof ByteBufferExtendedCell) {
ByteBufferExtendedCell leftBBCell = (ByteBufferExtendedCell) left;
ByteBufferExtendedCell rightBBCell = (ByteBufferExtendedCell) right;
@@ -840,7 +849,7 @@ public final class PrivateCellUtil {
return cell.getTypeByte() == KeyValue.Type.Delete.getCode();
}
- public static boolean isDeleteFamily(final Cell cell) {
+ public static boolean isDeleteFamily(final ExtendedCell cell) {
return cell.getTypeByte() == KeyValue.Type.DeleteFamily.getCode();
}
@@ -862,14 +871,14 @@ public final class PrivateCellUtil {
return t == KeyValue.Type.DeleteColumn.getCode() || t == KeyValue.Type.DeleteFamily.getCode();
}
- public static byte[] cloneTags(Cell cell) {
+ public static byte[] cloneTags(ExtendedCell cell) {
byte[] output = new byte[cell.getTagsLength()];
copyTagsTo(cell, output, 0);
return output;
}
/** Copies the tags info into the tag portion of the cell */
- public static int copyTagsTo(Cell cell, byte[] destination, int destinationOffset) {
+ public static int copyTagsTo(ExtendedCell cell, byte[] destination, int destinationOffset) {
int tlen = cell.getTagsLength();
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyFromBufferToArray(destination,
@@ -883,7 +892,7 @@ public final class PrivateCellUtil {
}
/** Copies the tags info into the tag portion of the cell */
- public static int copyTagsTo(Cell cell, ByteBuffer destination, int destinationOffset) {
+ public static int copyTagsTo(ExtendedCell cell, ByteBuffer destination, int destinationOffset) {
int tlen = cell.getTagsLength();
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyFromBufferToBuffer(((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
@@ -900,7 +909,7 @@ public final class PrivateCellUtil {
* @param cell The Cell
* @return Tags in the given Cell as a List
*/
- public static List<Tag> getTags(Cell cell) {
+ public static List<Tag> getTags(ExtendedCell cell) {
List<Tag> tags = new ArrayList<>();
Iterator<Tag> tagsItr = tagsIterator(cell);
while (tagsItr.hasNext()) {
@@ -915,7 +924,7 @@ public final class PrivateCellUtil {
* @param type Type of the Tag to retrieve
* @return Optional, empty if there is no tag of the passed in tag type
*/
- public static Optional<Tag> getTag(Cell cell, byte type) {
+ public static Optional<Tag> getTag(ExtendedCell cell, byte type) {
boolean bufferBacked = cell instanceof ByteBufferExtendedCell;
int length = cell.getTagsLength();
int offset =
@@ -946,7 +955,7 @@ public final class PrivateCellUtil {
* @param cell The Cell over which tags iterator is needed.
* @return iterator for the tags
*/
- public static Iterator<Tag> tagsIterator(final Cell cell) {
+ public static Iterator<Tag> tagsIterator(final ExtendedCell cell) {
final int tagsLength = cell.getTagsLength();
// Save an object allocation where we can
if (tagsLength == 0) {
@@ -1069,8 +1078,8 @@ public final class PrivateCellUtil {
* @param withTsType when true check timestamp and type bytes also.
* @return length of common prefix
*/
- public static int findCommonPrefixInFlatKey(Cell c1, Cell c2, boolean bypassFamilyCheck,
- boolean withTsType) {
+ public static int findCommonPrefixInFlatKey(ExtendedCell c1, ExtendedCell c2,
+ boolean bypassFamilyCheck, boolean withTsType) {
// Compare the 2 bytes in RK length part
short rLen1 = c1.getRowLength();
short rLen2 = c2.getRowLength();
@@ -2196,7 +2205,7 @@ public final class PrivateCellUtil {
* rk len><rk><1 byte cf len><cf><qualifier><8 bytes
* timestamp><1 byte type>
*/
- public static void writeFlatKey(Cell cell, DataOutput out) throws IOException {
+ public static void writeFlatKey(ExtendedCell cell, DataOutput out) throws IOException {
short rowLen = cell.getRowLength();
byte fLen = cell.getFamilyLength();
int qLen = cell.getQualifierLength();
@@ -2223,68 +2232,7 @@ public final class PrivateCellUtil {
out.writeByte(cell.getTypeByte());
}
- /**
- * Deep clones the given cell if the cell supports deep cloning
- * @param cell the cell to be cloned
- * @return the cloned cell
- */
- public static Cell deepClone(Cell cell) throws CloneNotSupportedException {
- if (cell instanceof ExtendedCell) {
- return ((ExtendedCell) cell).deepClone();
- }
- throw new CloneNotSupportedException();
- }
-
- /**
- * Writes the cell to the given OutputStream
- * @param cell the cell to be written
- * @param out the outputstream
- * @param withTags if tags are to be written or not
- * @return the total bytes written
- */
- public static int writeCell(Cell cell, OutputStream out, boolean withTags) throws IOException {
- if (cell instanceof ExtendedCell) {
- return ((ExtendedCell) cell).write(out, withTags);
- } else {
- ByteBufferUtils.putInt(out, estimatedSerializedSizeOfKey(cell));
- ByteBufferUtils.putInt(out, cell.getValueLength());
- writeFlatKey(cell, out);
- writeValue(out, cell, cell.getValueLength());
- int tagsLength = cell.getTagsLength();
- if (withTags) {
- byte[] len = new byte[Bytes.SIZEOF_SHORT];
- Bytes.putAsShort(len, 0, tagsLength);
- out.write(len);
- if (tagsLength > 0) {
- writeTags(out, cell, tagsLength);
- }
- }
- int lenWritten =
- (2 * Bytes.SIZEOF_INT) + estimatedSerializedSizeOfKey(cell) + cell.getValueLength();
- if (withTags) {
- lenWritten += Bytes.SIZEOF_SHORT + tagsLength;
- }
- return lenWritten;
- }
- }
-
- /**
- * Writes a cell to the buffer at the given offset
- * @param cell the cell to be written
- * @param buf the buffer to which the cell has to be wrriten
- * @param offset the offset at which the cell should be written
- */
- public static void writeCellToBuffer(Cell cell, ByteBuffer buf, int offset) {
- if (cell instanceof ExtendedCell) {
- ((ExtendedCell) cell).write(buf, offset);
- } else {
- // Using the KVUtil
- byte[] bytes = KeyValueUtil.copyToNewByteArray(cell);
- ByteBufferUtils.copyFromArrayToBuffer(buf, offset, bytes, 0, bytes.length);
- }
- }
-
- public static int writeFlatKey(Cell cell, OutputStream out) throws IOException {
+ public static int writeFlatKey(ExtendedCell cell, OutputStream out) throws IOException {
short rowLen = cell.getRowLength();
byte fLen = cell.getFamilyLength();
int qLen = cell.getQualifierLength();
@@ -2359,9 +2307,9 @@ public final class PrivateCellUtil {
* @return True if cell timestamp is modified.
* @throws IOException when the passed cell is not of type {@link ExtendedCell}
*/
- public static boolean updateLatestStamp(Cell cell, long ts) throws IOException {
+ public static boolean updateLatestStamp(ExtendedCell cell, long ts) throws IOException {
if (cell.getTimestamp() == HConstants.LATEST_TIMESTAMP) {
- setTimestamp(cell, ts);
+ cell.setTimestamp(ts);
return true;
}
return false;
@@ -2452,7 +2400,8 @@ public final class PrivateCellUtil {
* @param cell The cell whose contents has to be written
* @param vlength the value length
*/
- public static void writeValue(OutputStream out, Cell cell, int vlength) throws IOException {
+ public static void writeValue(OutputStream out, ExtendedCell cell, int vlength)
+ throws IOException {
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getValueByteBuffer(),
((ByteBufferExtendedCell) cell).getValuePosition(), vlength);
@@ -2467,7 +2416,8 @@ public final class PrivateCellUtil {
* @param cell The cell whose contents has to be written
* @param tagsLength the tag length
*/
- public static void writeTags(OutputStream out, Cell cell, int tagsLength) throws IOException {
+ public static void writeTags(OutputStream out, ExtendedCell cell, int tagsLength)
+ throws IOException {
if (cell instanceof ByteBufferExtendedCell) {
ByteBufferUtils.copyBufferToStream(out, ((ByteBufferExtendedCell) cell).getTagsByteBuffer(),
((ByteBufferExtendedCell) cell).getTagsPosition(), tagsLength);
@@ -2479,22 +2429,31 @@ public final class PrivateCellUtil {
/**
* special case for Cell.equals
*/
- public static boolean equalsIgnoreMvccVersion(Cell a, Cell b) {
+ public static boolean equalsIgnoreMvccVersion(ExtendedCell a, ExtendedCell b) {
// row
boolean res = CellUtil.matchingRows(a, b);
- if (!res) return res;
+ if (!res) {
+ return res;
+ }
// family
res = CellUtil.matchingColumn(a, b);
- if (!res) return res;
+ if (!res) {
+ return res;
+ }
// timestamp: later sorts first
- if (!CellUtil.matchingTimestamp(a, b)) return false;
+ if (!CellUtil.matchingTimestamp(a, b)) {
+ return false;
+ }
// type
int c = (0xff & b.getTypeByte()) - (0xff & a.getTypeByte());
- if (c != 0) return false;
- else return true;
+ if (c != 0) {
+ return false;
+ } else {
+ return true;
+ }
}
/**
@@ -2619,8 +2578,8 @@ public final class PrivateCellUtil {
* @return an int greater than 0 if left is greater than right lesser than 0 if left is lesser
* than right equal to 0 if left is equal to right
*/
- public static final int compare(CellComparator comparator, Cell left, byte[] key, int offset,
- int length) {
+ public static final int compare(CellComparator comparator, ExtendedCell left, byte[] key,
+ int offset, int length) {
// row
short rrowlength = Bytes.toShort(key, offset);
int c = comparator.compareRows(left, key, offset + Bytes.SIZEOF_SHORT, rrowlength);
@@ -2646,7 +2605,7 @@ public final class PrivateCellUtil {
* @return greater than 0 if left cell is bigger, less than 0 if right cell is bigger, 0 if both
* cells are equal
*/
- static final int compareWithoutRow(CellComparator comparator, Cell left, byte[] right,
+ static final int compareWithoutRow(CellComparator comparator, ExtendedCell left, byte[] right,
int roffset, int rlength, short rowlength) {
/***
* KeyValue Format and commonLength:
@@ -2954,4 +2913,154 @@ public final class PrivateCellUtil {
public static ExtendedCell createFirstDeleteFamilyCellOnRow(final byte[] row, final byte[] fam) {
return new FirstOnRowDeleteFamilyCell(row, fam);
}
+
+ /**
+ * In fact, in HBase, all {@link Cell}s are {@link ExtendedCell}s. We do not expect users to
+ * implement their own {@link Cell} types, except some special projects like Phoenix, where they
+ * just use {@link org.apache.hadoop.hbase.KeyValue} and {@link ExtendedCell} directly.
+ * @return the original {@code cell} which has already been cast to an {@link ExtendedCell}.
+ * @throws IllegalArgumentException if the given {@code cell} is not an {@link ExtendedCell}.
+ */
+ public static ExtendedCell ensureExtendedCell(Cell cell) {
+ if (cell == null) {
+ return null;
+ }
+ Preconditions.checkArgument(cell instanceof ExtendedCell, "Unsupported cell type: %s",
+ cell.getClass().getName());
+ return (ExtendedCell) cell;
+ }
+
+ public static boolean equals(ExtendedCell a, ExtendedCell b) {
+ return CellUtil.matchingRows(a, b) && CellUtil.matchingFamily(a, b)
+ && CellUtil.matchingQualifier(a, b) && CellUtil.matchingTimestamp(a, b)
+ && PrivateCellUtil.matchingType(a, b);
+ }
+
+ /** Returns ExtendedCellScanner interface over <code>cellIterables</code> */
+ public static ExtendedCellScanner
+ createExtendedCellScanner(final List<? extends ExtendedCellScannable> cellScannerables) {
+ return new ExtendedCellScanner() {
+ private final Iterator<? extends ExtendedCellScannable> iterator =
+ cellScannerables.iterator();
+ private ExtendedCellScanner cellScanner = null;
+
+ @Override
+ public ExtendedCell current() {
+ return this.cellScanner != null ? this.cellScanner.current() : null;
+ }
+
+ @Override
+ public boolean advance() throws IOException {
+ while (true) {
+ if (this.cellScanner == null) {
+ if (!this.iterator.hasNext()) {
+ return false;
+ }
+ this.cellScanner = this.iterator.next().cellScanner();
+ }
+ if (this.cellScanner.advance()) {
+ return true;
+ }
+ this.cellScanner = null;
+ }
+ }
+ };
+ }
+
+ /**
+ * Flatten the map of cells out under the ExtendedCellScanner
+ * @param map Map of Cell Lists; for example, the map of families to ExtendedCells that is used
+ * inside Put, etc., keeping Cells organized by family.
+ * @return ExtendedCellScanner interface over <code>cellIterable</code>
+ */
+ public static ExtendedCellScanner
+ createExtendedCellScanner(final NavigableMap<byte[], List<ExtendedCell>> map) {
+ return new ExtendedCellScanner() {
+ private final Iterator<Entry<byte[], List<ExtendedCell>>> entries = map.entrySet().iterator();
+ private Iterator<ExtendedCell> currentIterator = null;
+ private ExtendedCell currentCell;
+
+ @Override
+ public ExtendedCell current() {
+ return this.currentCell;
+ }
+
+ @Override
+ public boolean advance() {
+ while (true) {
+ if (this.currentIterator == null) {
+ if (!this.entries.hasNext()) {
+ return false;
+ }
+ this.currentIterator = this.entries.next().getValue().iterator();
+ }
+ if (this.currentIterator.hasNext()) {
+ this.currentCell = this.currentIterator.next();
+ return true;
+ }
+ this.currentCell = null;
+ this.currentIterator = null;
+ }
+ }
+ };
+ }
+
+ /** Returns CellScanner interface over <code>cellArray</code> */
+ public static ExtendedCellScanner createExtendedCellScanner(final ExtendedCell[] cellArray) {
+ return new ExtendedCellScanner() {
+ private final ExtendedCell[] cells = cellArray;
+ private int index = -1;
+
+ @Override
+ public ExtendedCell current() {
+ if (cells == null) {
+ return null;
+ }
+ return (index < 0) ? null : this.cells[index];
+ }
+
+ @Override
+ public boolean advance() {
+ if (cells == null) {
+ return false;
+ }
+ return ++index < this.cells.length;
+ }
+ };
+ }
+
+ /** Returns ExtendedCellScanner interface over <code>cellIterable</code> */
+ public static ExtendedCellScanner
+ createExtendedCellScanner(final Iterable<ExtendedCell> cellIterable) {
+ if (cellIterable == null) {
+ return null;
+ }
+ return createExtendedCellScanner(cellIterable.iterator());
+ }
+
+ /**
+ * Returns ExtendedCellScanner interface over <code>cellIterable</code> or null if
+ * <code>cells</code> is null
+ */
+ public static ExtendedCellScanner createExtendedCellScanner(final Iterator<ExtendedCell> cells) {
+ if (cells == null) {
+ return null;
+ }
+ return new ExtendedCellScanner() {
+ private final Iterator<ExtendedCell> iterator = cells;
+ private ExtendedCell current = null;
+
+ @Override
+ public ExtendedCell current() {
+ return this.current;
+ }
+
+ @Override
+ public boolean advance() {
+ boolean hasNext = this.iterator.hasNext();
+ this.current = hasNext ? this.iterator.next() : null;
+ return hasNext;
+ }
+ };
+ }
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
index 6d911bccd58..cc15fa7ba75 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/TagUtil.java
@@ -66,12 +66,12 @@ public final class TagUtil {
}
/** Returns A List<Tag> of any Tags found in <code>cell</code> else null. */
- public static List<Tag> carryForwardTags(final Cell cell) {
+ public static List<Tag> carryForwardTags(final ExtendedCell cell) {
return carryForwardTags(null, cell);
}
/** Add to <code>tagsOrNull</code> any Tags <code>cell</code> is carrying or null if none. */
- public static List<Tag> carryForwardTags(final List<Tag> tagsOrNull, final Cell cell) {
+ public static List<Tag> carryForwardTags(final List<Tag> tagsOrNull, final ExtendedCell cell) {
Iterator<Tag> itr = PrivateCellUtil.tagsIterator(cell);
if (itr == EMPTY_TAGS_ITR) {
// If no Tags, return early.
@@ -87,7 +87,7 @@ public final class TagUtil {
return tags;
}
- public static byte[] concatTags(byte[] tags, Cell cell) {
+ public static byte[] concatTags(byte[] tags, ExtendedCell cell) {
int cellTagsLen = cell.getTagsLength();
if (cellTagsLen == 0) {
// If no Tags, return early.
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseDecoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseDecoder.java
index 9a2a29356b1..8f4692ee778 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseDecoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseDecoder.java
@@ -22,21 +22,21 @@ import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * TODO javadoc
+ * Base implementation for {@link Codec.Decoder}.
*/
@InterfaceAudience.LimitedPrivate({ HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.PHOENIX })
public abstract class BaseDecoder implements Codec.Decoder {
protected static final Logger LOG = LoggerFactory.getLogger(BaseDecoder.class);
protected final InputStream in;
- private Cell current = null;
+ private ExtendedCell current = null;
protected static class PBIS extends PushbackInputStream {
public PBIS(InputStream in, int size) {
@@ -98,10 +98,10 @@ public abstract class BaseDecoder implements Codec.Decoder {
* thrown if EOF is reached prematurely. Does not return null.
*/
@NonNull
- protected abstract Cell parseCell() throws IOException;
+ protected abstract ExtendedCell parseCell() throws IOException;
@Override
- public Cell current() {
+ public ExtendedCell current() {
return this.current;
}
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseEncoder.java
index 3ca5d2462de..4875fcd227c 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/BaseEncoder.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.codec;
import java.io.IOException;
import java.io.OutputStream;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.yetus.audience.InterfaceAudience;
@@ -42,7 +42,7 @@ public abstract class BaseEncoder implements Codec.Encoder {
}
@Override
- public abstract void write(Cell cell) throws IOException;
+ public abstract void write(ExtendedCell cell) throws IOException;
protected void checkFlushed() throws CodecException {
if (this.flushed) throw new CodecException("Flushed; done");
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java
index f4552c03826..356513be7f7 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodec.java
@@ -21,8 +21,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
@@ -43,7 +43,7 @@ public class CellCodec implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
// Row
write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
@@ -80,7 +80,7 @@ public class CellCodec implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
byte[] row = readByteArray(this.in);
byte[] family = readByteArray(in);
byte[] qualifier = readByteArray(in);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java
index 07bfb53d5df..6a8e7e94443 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/CellCodecWithTags.java
@@ -21,8 +21,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
@@ -44,7 +44,7 @@ public class CellCodecWithTags implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
// Row
write(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength());
@@ -82,7 +82,7 @@ public class CellCodecWithTags implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
byte[] row = readByteArray(this.in);
byte[] family = readByteArray(in);
byte[] qualifier = readByteArray(in);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/Codec.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/Codec.java
index df8a94f5614..18c8b8ea0ab 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/Codec.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/Codec.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.codec;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.io.CellOutputStream;
import org.apache.hadoop.hbase.nio.ByteBuff;
@@ -46,7 +46,7 @@ public interface Codec {
* Implementations should implicitly clean up any resources allocated when the Decoder/CellScanner
* runs off the end of the cell block. Do this rather than require the user call close explicitly.
*/
- interface Decoder extends CellScanner {
+ interface Decoder extends ExtendedCellScanner {
}
Decoder getDecoder(InputStream is);
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodec.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodec.java
index 9913eac3615..ef40b395b7b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodec.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodec.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.NoTagsByteBufferKeyValue;
@@ -55,7 +55,7 @@ public class KeyValueCodec implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
// Do not write tags over RPC
ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, false));
@@ -69,7 +69,7 @@ public class KeyValueCodec implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
// No tags here
return KeyValueUtil.createKeyValueFromInputStream(in, false);
}
@@ -78,7 +78,7 @@ public class KeyValueCodec implements Codec {
public static class ByteBuffKeyValueDecoder implements Codec.Decoder {
protected final ByteBuff buf;
- protected Cell current = null;
+ protected ExtendedCell current = null;
public ByteBuffKeyValueDecoder(ByteBuff buf) {
this.buf = buf;
@@ -101,15 +101,15 @@ public class KeyValueCodec implements Codec {
}
@Override
- public Cell current() {
+ public ExtendedCell current() {
return this.current;
}
- protected Cell createCell(byte[] buf, int offset, int len) {
+ protected ExtendedCell createCell(byte[] buf, int offset, int len) {
return new NoTagsKeyValue(buf, offset, len);
}
- protected Cell createCell(ByteBuffer bb, int pos, int len) {
+ protected ExtendedCell createCell(ByteBuffer bb, int pos, int len) {
// We know there is not going to be any tags.
return new NoTagsByteBufferKeyValue(bb, pos, len);
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodecWithTags.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodecWithTags.java
index 8c2c20625df..655bc4c5f26 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodecWithTags.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/codec/KeyValueCodecWithTags.java
@@ -22,7 +22,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -58,7 +58,7 @@ public class KeyValueCodecWithTags implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
// Write tags
ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, true));
@@ -72,7 +72,7 @@ public class KeyValueCodecWithTags implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
// create KeyValue with tags
return KeyValueUtil.createKeyValueFromInputStream(in, true);
}
@@ -85,12 +85,12 @@ public class KeyValueCodecWithTags implements Codec {
}
@Override
- protected Cell createCell(byte[] buf, int offset, int len) {
+ protected ExtendedCell createCell(byte[] buf, int offset, int len) {
return new KeyValue(buf, offset, len);
}
@Override
- protected Cell createCell(ByteBuffer bb, int pos, int len) {
+ protected ExtendedCell createCell(ByteBuffer bb, int pos, int len) {
return new ByteBufferKeyValue(bb, pos, len);
}
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/CellOutputStream.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/CellOutputStream.java
index d1310137e8c..8236dceca91 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/CellOutputStream.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/CellOutputStream.java
@@ -18,7 +18,7 @@
package org.apache.hadoop.hbase.io;
import java.io.IOException;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
@@ -40,7 +40,7 @@ public interface CellOutputStream {
* the copy of the Cell that was added in the write.
* @param cell Cell to write out
*/
- void write(Cell cell) throws IOException;
+ void write(ExtendedCell cell) throws IOException;
/**
* Let the implementation decide what to do. Usually means writing accumulated data into a byte[]
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedExtendedCellScanner.java
similarity index 85%
rename from hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
rename to hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedExtendedCellScanner.java
index 379dfca051a..8f31ba8fc83 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedCellScanner.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/SizedExtendedCellScanner.java
@@ -17,15 +17,13 @@
*/
package org.apache.hadoop.hbase.io;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.yetus.audience.InterfaceAudience;
-import org.apache.yetus.audience.InterfaceStability;
/**
* A CellScanner that knows its size in memory in bytes. Used playing the CellScanner into an
* in-memory buffer; knowing the size ahead of time saves on background buffer resizings.
*/
@InterfaceAudience.Private
-@InterfaceStability.Unstable
-public interface SizedCellScanner extends CellScanner, HeapSize {
+public interface SizedExtendedCellScanner extends ExtendedCellScanner, HeapSize {
}
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
index 68b300ae60f..31724723bcd 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/EncodedDataBlock.java
@@ -29,7 +29,7 @@ import java.util.Iterator;
import java.util.List;
import org.apache.commons.lang3.NotImplementedException;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
@@ -93,7 +93,7 @@ public class EncodedDataBlock {
* @param headerSize header size of the block.
* @return Forwards sequential iterator.
*/
- public Iterator<Cell> getIterator(int headerSize) {
+ public Iterator<ExtendedCell> getIterator(int headerSize) {
final int rawSize = rawKVs.length;
byte[] encodedDataWithHeader = getEncodedData();
int bytesToSkip = headerSize + Bytes.SIZEOF_SHORT;
@@ -101,7 +101,7 @@ public class EncodedDataBlock {
encodedDataWithHeader.length - bytesToSkip);
final DataInputStream dis = new DataInputStream(bais);
- return new Iterator<Cell>() {
+ return new Iterator<ExtendedCell>() {
private ByteBuffer decompressedData = null;
private Iterator<Boolean> it = isTagsLenZero.iterator();
@@ -114,7 +114,7 @@ public class EncodedDataBlock {
}
@Override
- public Cell next() {
+ public ExtendedCell next() {
if (decompressedData == null) {
try {
decompressedData = dataBlockEncoder.decodeKeyValues(dis,
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java
index 2c48e5b7d7b..7fb4fd9685e 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/NoneEncoder.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.io.encoding;
import java.io.DataOutputStream;
import java.io.IOException;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -37,7 +37,7 @@ public class NoneEncoder {
this.encodingCtx = encodingCtx;
}
- public int write(Cell cell) throws IOException {
+ public int write(ExtendedCell cell) throws IOException {
// We write tags seperately because though there is no tag in KV
// if the hfilecontext says include tags we need the tags length to be
// written
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
index c4b24728b42..553b3931136 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellComparator.java
@@ -76,7 +76,7 @@ public class TestCellComparator {
kv1 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
kv2 = new KeyValue(row1, fam1, qual1, 1L, KeyValue.Type.Put);
- assertTrue(CellUtil.equals(kv1, kv2));
+ assertTrue(PrivateCellUtil.equals(kv1, kv2));
}
@Test
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
index dcd796fa3d4..3ff63ef6ff6 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/TestCellUtil.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -92,7 +91,7 @@ public class TestCellUtil {
/**
* Cell used in test. Has row only.
*/
- private static class TestCell implements Cell {
+ private static class TestCell implements ExtendedCell {
private final byte[] row;
TestCell(final int i) {
@@ -116,67 +115,56 @@ public class TestCellUtil {
@Override
public byte[] getFamilyArray() {
- // TODO Auto-generated method stub
return null;
}
@Override
public int getFamilyOffset() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public byte getFamilyLength() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public byte[] getQualifierArray() {
- // TODO Auto-generated method stub
return null;
}
@Override
public int getQualifierOffset() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public int getQualifierLength() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public long getTimestamp() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public byte getTypeByte() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public byte[] getValueArray() {
- // TODO Auto-generated method stub
return null;
}
@Override
public int getValueOffset() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public int getValueLength() {
- // TODO Auto-generated method stub
return 0;
}
@@ -187,25 +175,21 @@ public class TestCellUtil {
@Override
public byte[] getTagsArray() {
- // TODO Auto-generated method stub
return null;
}
@Override
public int getTagsOffset() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public long getSequenceId() {
- // TODO Auto-generated method stub
return 0;
}
@Override
public int getTagsLength() {
- // TODO Auto-generated method stub
return 0;
}
@@ -213,6 +197,20 @@ public class TestCellUtil {
public long heapSize() {
return 0;
}
+
+ @Override
+ public void setSequenceId(long seqId) throws IOException {
+
+ }
+
+ @Override
+ public void setTimestamp(long ts) throws IOException {
+
+ }
+
+ @Override
+ public void setTimestamp(byte[] ts) throws IOException {
+ }
}
/**
@@ -444,7 +442,7 @@ public class TestCellUtil {
KeyValue kv =
new KeyValue(r, f, q, 0, q.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags);
ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer());
- Cell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
+ ExtendedCell bbCell = new ByteBufferKeyValue(buffer, 0, buffer.remaining());
byte[] rDest = CellUtil.cloneRow(bbCell);
assertTrue(Bytes.equals(r, rDest));
byte[] fDest = CellUtil.cloneFamily(bbCell);
@@ -519,30 +517,9 @@ public class TestCellUtil {
assertEquals(bd, PrivateCellUtil.getValueAsBigDecimal(bbCell));
}
- @Test
- public void testWriteCell() throws IOException {
- byte[] r = Bytes.toBytes("row1");
- byte[] f = Bytes.toBytes("cf1");
- byte[] q1 = Bytes.toBytes("qual1");
- byte[] v = Bytes.toBytes("val1");
- byte[] tags = Bytes.toBytes("tag1");
- KeyValue kv =
- new KeyValue(r, f, q1, 0, q1.length, 1234L, KeyValue.Type.Put, v, 0, v.length, tags);
- NonExtendedCell nonExtCell = new NonExtendedCell(kv);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- PrivateCellUtil.writeCell(nonExtCell, os, true);
- byte[] byteArray = os.toByteArray();
- KeyValue res = new KeyValue(byteArray);
- assertTrue(CellUtil.equals(kv, res));
- }
-
- // Workaround for jdk 11 - reflective access to interface default methods for testGetType
- private static abstract class CellForMockito implements Cell {
- }
-
@Test
public void testGetType() {
- CellForMockito c = Mockito.mock(CellForMockito.class);
+ ExtendedCell c = Mockito.mock(ExtendedCell.class);
Mockito.when(c.getType()).thenCallRealMethod();
for (Cell.Type type : Cell.Type.values()) {
Mockito.when(c.getTypeByte()).thenReturn(type.getCode());
@@ -563,112 +540,4 @@ public class TestCellUtil {
} catch (UnsupportedOperationException e) {
}
}
-
- private static class NonExtendedCell implements Cell {
- private KeyValue kv;
-
- public NonExtendedCell(KeyValue kv) {
- this.kv = kv;
- }
-
- @Override
- public byte[] getRowArray() {
- return this.kv.getRowArray();
- }
-
- @Override
- public int getRowOffset() {
- return this.kv.getRowOffset();
- }
-
- @Override
- public short getRowLength() {
- return this.kv.getRowLength();
- }
-
- @Override
- public byte[] getFamilyArray() {
- return this.kv.getFamilyArray();
- }
-
- @Override
- public int getFamilyOffset() {
- return this.kv.getFamilyOffset();
- }
-
- @Override
- public byte getFamilyLength() {
- return this.kv.getFamilyLength();
- }
-
- @Override
- public byte[] getQualifierArray() {
- return this.kv.getQualifierArray();
- }
-
- @Override
- public int getQualifierOffset() {
- return this.kv.getQualifierOffset();
- }
-
- @Override
- public int getQualifierLength() {
- return this.kv.getQualifierLength();
- }
-
- @Override
- public long getTimestamp() {
- return this.kv.getTimestamp();
- }
-
- @Override
- public byte getTypeByte() {
- return this.kv.getTypeByte();
- }
-
- @Override
- public long getSequenceId() {
- return this.kv.getSequenceId();
- }
-
- @Override
- public byte[] getValueArray() {
- return this.kv.getValueArray();
- }
-
- @Override
- public int getValueOffset() {
- return this.kv.getValueOffset();
- }
-
- @Override
- public int getValueLength() {
- return this.kv.getValueLength();
- }
-
- @Override
- public int getSerializedSize() {
- return this.kv.getSerializedSize();
- }
-
- @Override
- public byte[] getTagsArray() {
- return this.kv.getTagsArray();
- }
-
- @Override
- public int getTagsOffset() {
- return this.kv.getTagsOffset();
- }
-
- @Override
- public int getTagsLength() {
- return this.kv.getTagsLength();
- }
-
- @Override
- public long heapSize() {
- return this.kv.heapSize();
- }
- }
}
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
index 9963e37c17f..3508419cea7 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodec.java
@@ -26,10 +26,10 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
@@ -113,14 +113,14 @@ public class TestCellCodec {
DataInputStream dis = new DataInputStream(cis);
Codec.Decoder decoder = codec.getDecoder(dis);
assertTrue(decoder.advance());
- Cell c = decoder.current();
- assertTrue(CellUtil.equals(c, kv1));
+ ExtendedCell c = decoder.current();
+ assertTrue(PrivateCellUtil.equals(c, kv1));
assertTrue(decoder.advance());
c = decoder.current();
- assertTrue(CellUtil.equals(c, kv2));
+ assertTrue(PrivateCellUtil.equals(c, kv2));
assertTrue(decoder.advance());
c = decoder.current();
- assertTrue(CellUtil.equals(c, kv3));
+ assertTrue(PrivateCellUtil.equals(c, kv3));
assertFalse(decoder.advance());
dis.close();
assertEquals(offset, cis.getCount());
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
index b44473ee49e..17c95eb2c72 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestCellCodecWithTags.java
@@ -28,8 +28,8 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.hbase.ArrayBackedTag;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -58,15 +58,15 @@ public class TestCellCodecWithTags {
DataOutputStream dos = new DataOutputStream(cos);
Codec codec = new CellCodecWithTags();
Codec.Encoder encoder = codec.getEncoder(dos);
- final Cell cell1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("1"),
- HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"),
+ final ExtendedCell cell1 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"),
+ Bytes.toBytes("1"), HConstants.LATEST_TIMESTAMP, Bytes.toBytes("1"),
new Tag[] { new ArrayBackedTag((byte) 1, Bytes.toBytes("teststring1")),
new ArrayBackedTag((byte) 2, Bytes.toBytes("teststring2")) });
- final Cell cell2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("2"),
- HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"),
+ final ExtendedCell cell2 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"),
+ Bytes.toBytes("2"), HConstants.LATEST_TIMESTAMP, Bytes.toBytes("2"),
new Tag[] { new ArrayBackedTag((byte) 1, Bytes.toBytes("teststring3")), });
- final Cell cell3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("3"),
- HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"),
+ final ExtendedCell cell3 = new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"),
+ Bytes.toBytes("3"), HConstants.LATEST_TIMESTAMP, Bytes.toBytes("3"),
new Tag[] { new ArrayBackedTag((byte) 2, Bytes.toBytes("teststring4")),
new ArrayBackedTag((byte) 2, Bytes.toBytes("teststring5")),
new ArrayBackedTag((byte) 1, Bytes.toBytes("teststring6")) });
@@ -81,7 +81,7 @@ public class TestCellCodecWithTags {
DataInputStream dis = new DataInputStream(cis);
Codec.Decoder decoder = codec.getDecoder(dis);
assertTrue(decoder.advance());
- Cell c = decoder.current();
+ ExtendedCell c = decoder.current();
assertTrue(CellUtil.equals(c, cell1));
List<Tag> tags = PrivateCellUtil.getTags(c);
assertEquals(2, tags.size());
diff --git a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
index 66a874e5c5e..e2bdecbf7c6 100644
--- a/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
+++ b/hbase-common/src/test/java/org/apache/hadoop/hbase/codec/TestKeyValueCodecWithTags.java
@@ -28,8 +28,8 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.hbase.ArrayBackedTag;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -81,7 +81,7 @@ public class TestKeyValueCodecWithTags {
DataInputStream dis = new DataInputStream(cis);
Codec.Decoder decoder = codec.getDecoder(dis);
assertTrue(decoder.advance());
- Cell c = decoder.current();
+ ExtendedCell c = decoder.current();
assertTrue(CellUtil.equals(c, kv1));
List<Tag> tags = PrivateCellUtil.getTags(c);
assertEquals(2, tags.size());
diff --git a/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java b/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java
index 9d122fb0b81..cb6e14d1b27 100644
--- a/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java
+++ b/hbase-endpoint/src/test/java/org/apache/hadoop/hbase/client/TestRpcControllerFactory.java
@@ -26,8 +26,8 @@ import java.io.IOException;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -72,13 +72,14 @@ public class TestRpcControllerFactory {
}
@Override
- public HBaseRpcController newController(RegionInfo regionInfo, CellScanner cellScanner) {
+ public HBaseRpcController newController(RegionInfo regionInfo,
+ ExtendedCellScanner cellScanner) {
return new CountingRpcController(super.newController(regionInfo, cellScanner));
}
@Override
public HBaseRpcController newController(RegionInfo regionInfo,
- List<CellScannable> cellIterables) {
+ List<ExtendedCellScannable> cellIterables) {
return new CountingRpcController(super.newController(regionInfo, cellIterables));
}
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSerialization.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSerialization.java
index 9d567f95a0e..456f99629e3 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSerialization.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSerialization.java
@@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -85,7 +86,12 @@ public class CellSerialization implements Serialization<Cell> {
@Override
public void serialize(Cell kv) throws IOException {
dos.writeInt(PrivateCellUtil.estimatedSerializedSizeOf(kv) - Bytes.SIZEOF_INT);
- PrivateCellUtil.writeCell(kv, dos, true);
+ if (kv instanceof ExtendedCell) {
+ ((ExtendedCell) kv).write(dos, true);
+ } else {
+ throw new UnsupportedOperationException(
+ "Unsupported cell type: " + kv.getClass().getName());
+ }
}
}
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSortReducer.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSortReducer.java
index 9380b0e7133..dd6ff00497f 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSortReducer.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/CellSortReducer.java
@@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hbase.mapreduce;
-import java.io.IOException;
import java.util.TreeSet;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.util.MapReduceExtendedCell;
@@ -38,19 +38,17 @@ public class CellSortReducer
protected void reduce(ImmutableBytesWritable row, Iterable<Cell> kvs,
Reducer<ImmutableBytesWritable, Cell, ImmutableBytesWritable, Cell>.Context context)
throws java.io.IOException, InterruptedException {
- TreeSet<Cell> map = new TreeSet<>(CellComparator.getInstance());
+ TreeSet<ExtendedCell> set = new TreeSet<>(CellComparator.getInstance());
for (Cell kv : kvs) {
- try {
- map.add(PrivateCellUtil.deepClone(kv));
- } catch (CloneNotSupportedException e) {
- throw new IOException(e);
- }
+ set.add(PrivateCellUtil.ensureExtendedCell(kv));
}
- context.setStatus("Read " + map.getClass());
+ context.setStatus("Read " + set.getClass());
int index = 0;
- for (Cell kv : map) {
+ for (ExtendedCell kv : set) {
context.write(row, new MapReduceExtendedCell(kv));
- if (++index % 100 == 0) context.setStatus("Wrote " + index);
+ if (++index % 100 == 0) {
+ context.setStatus("Wrote " + index);
+ }
}
}
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/ExtendedCellSerialization.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/ExtendedCellSerialization.java
index c784b256188..9e89c789626 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/ExtendedCellSerialization.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/ExtendedCellSerialization.java
@@ -94,7 +94,7 @@ public class ExtendedCellSerialization implements Serialization<ExtendedCell> {
@Override
public void serialize(ExtendedCell kv) throws IOException {
dos.writeInt(PrivateCellUtil.estimatedSerializedSizeOf(kv) - Bytes.SIZEOF_INT);
- PrivateCellUtil.writeCell(kv, dos, true);
+ kv.write(dos, true);
dos.writeLong(kv.getSequenceId());
}
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java
index 225a2dc6fe2..51e23abc8ca 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/HFileOutputFormat2.java
@@ -240,13 +240,13 @@ public class HFileOutputFormat2 extends FileOutputFormat<ImmutableBytesWritable,
@Override
public void write(ImmutableBytesWritable row, V cell) throws IOException {
- Cell kv = cell;
// null input == user explicitly wants to flush
- if (row == null && kv == null) {
+ if (row == null && cell == null) {
rollWriters(null);
return;
}
+ ExtendedCell kv = PrivateCellUtil.ensureExtendedCell(cell);
byte[] rowKey = CellUtil.cloneRow(kv);
int length = (PrivateCellUtil.estimatedSerializedSizeOf(kv)) - Bytes.SIZEOF_INT;
byte[] family = CellUtil.cloneFamily(kv);
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java
index 6605c6783ba..8a8b846959b 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/Import.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -51,6 +52,7 @@ import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Result;
@@ -114,7 +116,7 @@ public class Import extends Configured implements Tool {
public static class CellWritableComparable implements WritableComparable<CellWritableComparable> {
- private Cell kv = null;
+ private ExtendedCell kv = null;
static {
// register this comparator
@@ -125,7 +127,7 @@ public class Import extends Configured implements Tool {
}
public CellWritableComparable(Cell kv) {
- this.kv = kv;
+ this.kv = (ExtendedCell) kv;
}
@Override
@@ -174,7 +176,7 @@ public class Import extends Configured implements Tool {
int index = 0;
for (Cell kv : kvs) {
context.write(new ImmutableBytesWritable(CellUtil.cloneRow(kv)),
- new MapReduceExtendedCell(kv));
+ new MapReduceExtendedCell(PrivateCellUtil.ensureExtendedCell(kv)));
if (++index % 100 == 0) context.setStatus("Wrote " + index + " KeyValues, "
+ "and the rowkey whose is being wrote is " + Bytes.toString(kv.getRowArray()));
}
@@ -203,10 +205,12 @@ public class Import extends Configured implements Tool {
filter == null || !filter.filterRowKey(
PrivateCellUtil.createFirstOnRow(row.get(), row.getOffset(), (short) row.getLength()))
) {
- for (Cell kv : value.rawCells()) {
+ for (ExtendedCell kv : PackagePrivateFieldAccessor.getExtendedRawCells(value)) {
kv = filterKv(filter, kv);
// skip if we filtered it out
- if (kv == null) continue;
+ if (kv == null) {
+ continue;
+ }
Cell ret = convertKv(kv, cfRenameMap);
context.write(new CellWritableComparable(ret), ret);
}
@@ -267,10 +271,12 @@ public class Import extends Configured implements Tool {
filter == null || !filter.filterRowKey(
PrivateCellUtil.createFirstOnRow(row.get(), row.getOffset(), (short) row.getLength()))
) {
- for (Cell kv : value.rawCells()) {
+ for (ExtendedCell kv : PackagePrivateFieldAccessor.getExtendedRawCells(value)) {
kv = filterKv(filter, kv);
// skip if we filtered it out
- if (kv == null) continue;
+ if (kv == null) {
+ continue;
+ }
context.write(row, new MapReduceExtendedCell(convertKv(kv, cfRenameMap)));
}
}
@@ -330,10 +336,12 @@ public class Import extends Configured implements Tool {
protected void processKV(ImmutableBytesWritable key, Result result, Context context, Put put,
Delete delete) throws IOException, InterruptedException {
- for (Cell kv : result.rawCells()) {
+ for (ExtendedCell kv : PackagePrivateFieldAccessor.getExtendedRawCells(result)) {
kv = filterKv(filter, kv);
// skip if we filter it out
- if (kv == null) continue;
+ if (kv == null) {
+ continue;
+ }
kv = convertKv(kv, cfRenameMap);
// Deletes and Puts are gathered and written when finished
@@ -476,7 +484,7 @@ public class Import extends Configured implements Tool {
* @return <tt>null</tt> if the key should not be written, otherwise returns the original
* {@link Cell}
*/
- public static Cell filterKv(Filter filter, Cell c) throws IOException {
+ public static ExtendedCell filterKv(Filter filter, ExtendedCell c) throws IOException {
// apply the filter and skip this kv if the filter doesn't apply
if (filter != null) {
Filter.ReturnCode code = filter.filterCell(c);
@@ -495,7 +503,7 @@ public class Import extends Configured implements Tool {
}
// helper: create a new KeyValue based on CF rename map
- private static Cell convertKv(Cell kv, Map<byte[], byte[]> cfRenameMap) {
+ private static ExtendedCell convertKv(ExtendedCell kv, Map<byte[], byte[]> cfRenameMap) {
if (cfRenameMap != null) {
// If there's a rename mapping for this CF, create a new KeyValue
byte[] newCfName = cfRenameMap.get(CellUtil.cloneFamily(kv));
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutCombiner.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutCombiner.java
index 90dc5c1d555..cd25736bd6e 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutCombiner.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutCombiner.java
@@ -21,10 +21,8 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.ExtendedCell;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.yetus.audience.InterfaceAudience;
@@ -51,45 +49,51 @@ public class PutCombiner<K> extends Reducer<K, Put, K, Put> {
context.getConfiguration().getLong("putcombiner.row.threshold", 1L * (1 << 30));
int cnt = 0;
long curSize = 0;
- Put put = null;
- Map<byte[], List<Cell>> familyMap = null;
+ Put combinedPut = null;
+ Map<byte[], List<ExtendedCell>> combinedFamilyMap = null;
for (Put p : vals) {
cnt++;
- if (put == null) {
- put = p;
- familyMap = put.getFamilyCellMap();
+ if (combinedPut == null) {
+ combinedPut = p;
+ combinedFamilyMap = PackagePrivateFieldAccessor.getExtendedFamilyCellMap(combinedPut);
} else {
- for (Entry<byte[], List<Cell>> entry : p.getFamilyCellMap().entrySet()) {
- List<Cell> cells = familyMap.get(entry.getKey());
- List<Cell> kvs = (cells != null) ? (List<Cell>) cells : null;
- for (Cell cell : entry.getValue()) {
- KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) cell);
- curSize += kv.heapSize();
- if (kvs != null) {
- kvs.add(kv);
+ for (Entry<byte[], List<ExtendedCell>> entry : PackagePrivateFieldAccessor
+ .getExtendedFamilyCellMap(p).entrySet()) {
+ List<ExtendedCell> existCells = combinedFamilyMap.get(entry.getKey());
+ if (existCells == null) {
+ // no cells for this family yet, just put it
+ combinedFamilyMap.put(entry.getKey(), entry.getValue());
+ // do not forget to calculate the size
+ for (ExtendedCell cell : entry.getValue()) {
+ curSize += cell.heapSize();
+ }
+ } else {
+ // otherwise just add the cells to the existent list for this family
+ for (ExtendedCell cell : entry.getValue()) {
+ existCells.add(cell);
+ curSize += cell.heapSize();
}
}
- if (cells == null) {
- familyMap.put(entry.getKey(), entry.getValue());
- }
}
- if (cnt % 10 == 0) context.setStatus("Combine " + cnt);
+ if (cnt % 10 == 0) {
+ context.setStatus("Combine " + cnt);
+ }
if (curSize > threshold) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Combined %d Put(s) into %d.", cnt, 1));
}
- context.write(row, put);
- put = null;
+ context.write(row, combinedPut);
+ combinedPut = null;
curSize = 0;
cnt = 0;
}
}
}
- if (put != null) {
+ if (combinedPut != null) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("Combined %d Put(s) into %d.", cnt, 1));
}
- context.write(row, put);
+ context.write(row, combinedPut);
}
}
}
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutSortReducer.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutSortReducer.java
index b4061d6be6a..c8f32c205fb 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutSortReducer.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/PutSortReducer.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.TreeSet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ArrayBackedTag;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.KeyValue;
@@ -32,6 +31,7 @@ import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagType;
import org.apache.hadoop.hbase.TagUtil;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
@@ -62,9 +62,9 @@ public class PutSortReducer
}
@Override
- protected void reduce(ImmutableBytesWritable row, java.lang.Iterable<Put> puts,
+ protected void reduce(ImmutableBytesWritable row, Iterable<Put> puts,
Reducer<ImmutableBytesWritable, Put, ImmutableBytesWritable, KeyValue>.Context context)
- throws java.io.IOException, InterruptedException {
+ throws IOException, InterruptedException {
// although reduce() is called per-row, handle pathological case
long threshold =
context.getConfiguration().getLong("putsortreducer.row.threshold", 1L * (1 << 30));
@@ -100,8 +100,9 @@ public class PutSortReducer
// just ignoring the bad one?
throw new IOException("Invalid visibility expression found in mutation " + p, e);
}
- for (List<Cell> cells : p.getFamilyCellMap().values()) {
- for (ExtendedCell cell : (List<ExtendedCell>) (List) cells) {
+ for (List<ExtendedCell> cells : PackagePrivateFieldAccessor.getExtendedFamilyCellMap(p)
+ .values()) {
+ for (ExtendedCell cell : cells) {
// Creating the KV which needs to be directly written to HFiles. Using the Facade
// KVCreator for creation of kvs.
KeyValue kv = null;
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
index 37e99c096e5..888e285f340 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/mapreduce/WALPlayer.java
@@ -117,7 +117,8 @@ public class WALPlayer extends Configured implements Tool {
byte[] outKey = multiTableSupport
? Bytes.add(table.getName(), Bytes.toBytes(tableSeparator), CellUtil.cloneRow(cell))
: CellUtil.cloneRow(cell);
- context.write(new ImmutableBytesWritable(outKey), new MapReduceExtendedCell(cell));
+ context.write(new ImmutableBytesWritable(outKey),
+ new MapReduceExtendedCell(PrivateCellUtil.ensureExtendedCell(cell)));
}
}
} catch (InterruptedException e) {
diff --git a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceExtendedCell.java b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceExtendedCell.java
index ca0d5f63a07..4233e96f2c7 100644
--- a/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceExtendedCell.java
+++ b/hbase-mapreduce/src/main/java/org/apache/hadoop/hbase/util/MapReduceExtendedCell.java
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import org.apache.hadoop.hbase.ByteBufferExtendedCell;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.PrivateCellUtil;
@@ -33,9 +32,9 @@ import org.apache.yetus.audience.InterfaceAudience;
@InterfaceAudience.Private
public class MapReduceExtendedCell extends ByteBufferExtendedCell {
- private final Cell cell;
+ private final ExtendedCell cell;
- public MapReduceExtendedCell(Cell cell) {
+ public MapReduceExtendedCell(ExtendedCell cell) {
this.cell = cell;
}
@@ -226,17 +225,17 @@ public class MapReduceExtendedCell extends ByteBufferExtendedCell {
@Override
public void setSequenceId(long seqId) throws IOException {
- PrivateCellUtil.setSequenceId(cell, seqId);
+ cell.setSequenceId(seqId);
}
@Override
public void setTimestamp(long ts) throws IOException {
- PrivateCellUtil.setTimestamp(cell, ts);
+ cell.setTimestamp(ts);
}
@Override
public void setTimestamp(byte[] ts) throws IOException {
- PrivateCellUtil.setTimestamp(cell, ts);
+ cell.setTimestamp(ts);
}
@Override
@@ -246,7 +245,7 @@ public class MapReduceExtendedCell extends ByteBufferExtendedCell {
@Override
public int write(OutputStream out, boolean withTags) throws IOException {
- return PrivateCellUtil.writeCell(cell, out, withTags);
+ return cell.write(out, withTags);
}
@Override
@@ -256,15 +255,11 @@ public class MapReduceExtendedCell extends ByteBufferExtendedCell {
@Override
public void write(ByteBuffer buf, int offset) {
- PrivateCellUtil.writeCellToBuffer(cell, buf, offset);
+ cell.write(buf, offset);
}
@Override
public ExtendedCell deepClone() {
- try {
- return (ExtendedCell) PrivateCellUtil.deepClone(cell);
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e);
- }
+ return cell.deepClone();
}
}
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
index e67ee3dbb73..0714f27e64d 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestHFileOutputFormat2.java
@@ -56,6 +56,7 @@ import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -518,7 +519,7 @@ public class TestHFileOutputFormat2 {
HFile.createReader(fs, keyFileStatus.getPath(), new CacheConfig(conf), true, conf);
HFileScanner scanner = reader.getScanner(conf, false, false, false);
scanner.seekTo();
- Cell cell = scanner.getCell();
+ ExtendedCell cell = scanner.getCell();
List<Tag> tagsFromCell = PrivateCellUtil.getTags(cell);
assertTrue(tagsFromCell.size() > 0);
for (Tag tag : tagsFromCell) {
diff --git a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
index 5e3e52de6ad..140f871e438 100644
--- a/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
+++ b/hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportExport.java
@@ -42,9 +42,9 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -60,6 +60,7 @@ import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.Result;
@@ -365,7 +366,7 @@ public class TestImportExport {
s.setRaw(true);
ResultScanner scanner = t.getScanner(s);
Result r = scanner.next();
- Cell[] res = r.rawCells();
+ ExtendedCell[] res = PackagePrivateFieldAccessor.getExtendedRawCells(r);
assertTrue(PrivateCellUtil.isDeleteFamily(res[0]));
assertEquals(now + 4, res[1].getTimestamp());
assertEquals(now + 3, res[2].getTimestamp());
@@ -646,13 +647,12 @@ public class TestImportExport {
}).when(ctx).write(any(), any());
importer.setup(ctx);
- Result value = mock(Result.class);
KeyValue[] keys = {
new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("family"), Bytes.toBytes("qualifier"),
Bytes.toBytes("value")),
new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("family"), Bytes.toBytes("qualifier"),
Bytes.toBytes("value1")) };
- when(value.rawCells()).thenReturn(keys);
+ Result value = Result.create(keys);
importer.map(new ImmutableBytesWritable(Bytes.toBytes("Key")), value, ctx);
}
@@ -820,7 +820,7 @@ public class TestImportExport {
}
private void checkWhetherTagExists(TableName table, boolean tagExists) throws IOException {
- List<Cell> values = new ArrayList<>();
+ List<ExtendedCell> values = new ArrayList<>();
for (HRegion region : UTIL.getHBaseCluster().getRegions(table)) {
Scan scan = new Scan();
// Make sure to set rawScan to true so that we will get Delete Markers.
@@ -830,13 +830,13 @@ public class TestImportExport {
// Need to use RegionScanner instead of table#getScanner since the latter will
// not return tags since it will go through rpc layer and remove tags intentionally.
RegionScanner scanner = region.getScanner(scan);
- scanner.next(values);
+ scanner.next((List) values);
if (!values.isEmpty()) {
break;
}
}
boolean deleteFound = false;
- for (Cell cell : values) {
+ for (ExtendedCell cell : values) {
if (PrivateCellUtil.isDelete(cell.getType().getCode())) {
deleteFound = true;
List<Tag> tags = PrivateCellUtil.getTags(cell);
@@ -881,11 +881,11 @@ public class TestImportExport {
}
Tag sourceOpTag = new ArrayBackedTag(TEST_TAG_TYPE, sourceOpAttr);
List<Cell> updatedCells = new ArrayList<>();
- for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
- Cell cell = cellScanner.current();
+ for (ExtendedCellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
+ ExtendedCell cell = cellScanner.current();
List<Tag> tags = PrivateCellUtil.getTags(cell);
tags.add(sourceOpTag);
- Cell updatedCell = PrivateCellUtil.createCell((ExtendedCell) cell, tags);
+ Cell updatedCell = PrivateCellUtil.createCell(cell, tags);
updatedCells.add(updatedCell);
}
m.getFamilyCellMap().clear();
@@ -934,9 +934,10 @@ public class TestImportExport {
int count = 0;
Result result;
while ((result = scanner.next()) != null) {
- List<Cell> cells = result.listCells();
+ List<ExtendedCell> cells =
+ Arrays.asList(PackagePrivateFieldAccessor.getExtendedRawCells(result));
assertEquals(2, cells.size());
- Cell cell = cells.get(0);
+ ExtendedCell cell = cells.get(0);
assertTrue(CellUtil.isDelete(cell));
List<Tag> tags = PrivateCellUtil.getTags(cell);
assertEquals(0, tags.size());
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionReplicationRetryingCaller.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionReplicationRetryingCaller.java
index e2b45fe30c3..a0ca5b990dd 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionReplicationRetryingCaller.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionReplicationRetryingCaller.java
@@ -22,8 +22,8 @@ import static org.apache.hadoop.hbase.util.FutureUtils.addListener;
import java.io.IOException;
import java.util.Collections;
import java.util.List;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.protobuf.ReplicationProtobufUtil;
import org.apache.hadoop.hbase.util.Pair;
@@ -94,7 +94,7 @@ public class AsyncRegionReplicationRetryingCaller extends AsyncRpcRetryingCaller
err -> conn.getLocator().updateCachedLocationOnError(loc, err));
return;
}
- Pair<ReplicateWALEntryRequest, CellScanner> pair = ReplicationProtobufUtil
+ Pair<ReplicateWALEntryRequest, ExtendedCellScanner> pair = ReplicationProtobufUtil
.buildReplicateWALEntryRequest(entries, replica.getEncodedNameAsBytes(), null, null, null);
resetCallTimeout();
controller.setCellScanner(pair.getSecond());
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionServerAdmin.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionServerAdmin.java
index f5fcc02e918..81707fe1f16 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionServerAdmin.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/client/AsyncRegionServerAdmin.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.client;
import java.io.IOException;
import java.util.concurrent.CompletableFuture;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.ipc.HBaseRpcController;
import org.apache.yetus.audience.InterfaceAudience;
@@ -95,7 +95,8 @@ public class AsyncRegionServerAdmin {
void call(AdminService.Interface stub, HBaseRpcController controller, RpcCallback<RESP> done);
}
- private <RESP> CompletableFuture<RESP> call(RpcCall<RESP> rpcCall, CellScanner cellScanner) {
+ private <RESP> CompletableFuture<RESP> call(RpcCall<RESP> rpcCall,
+ ExtendedCellScanner cellScanner) {
CompletableFuture<RESP> future = new CompletableFuture<>();
HBaseRpcController controller = conn.rpcControllerFactory.newController(null, cellScanner);
try {
@@ -158,8 +159,8 @@ public class AsyncRegionServerAdmin {
return call((stub, controller, done) -> stub.compactRegion(controller, request, done));
}
- public CompletableFuture<ReplicateWALEntryResponse>
- replicateWALEntry(ReplicateWALEntryRequest request, CellScanner cellScanner, int timeout) {
+ public CompletableFuture<ReplicateWALEntryResponse> replicateWALEntry(
+ ReplicateWALEntryRequest request, ExtendedCellScanner cellScanner, int timeout) {
return call((stub, controller, done) -> {
controller.setCallTimeout(timeout);
stub.replicateWALEntry(controller, request, done);
@@ -167,7 +168,7 @@ public class AsyncRegionServerAdmin {
}
public CompletableFuture<ReplicateWALEntryResponse> replay(ReplicateWALEntryRequest request,
- CellScanner cellScanner) {
+ ExtendedCellScanner cellScanner) {
return call((stub, controller, done) -> stub.replay(controller, request, done), cellScanner);
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java
index a6d6940e1e4..8482a819c0d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java
@@ -20,8 +20,8 @@ package org.apache.hadoop.hbase.codec;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
@@ -46,7 +46,7 @@ public class MessageCodec implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder();
// This copies bytes from Cell to ByteString. I don't see anyway around the copy.
@@ -75,7 +75,7 @@ public class MessageCodec implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
return ProtobufUtil.toCell(cellBuilder, CellProtos.Cell.parseDelimitedFrom(this.in), false);
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java
index 0c32303746c..9900aa63cab 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFilePrettyPrinter.java
@@ -48,6 +48,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
@@ -369,7 +370,7 @@ public class HFilePrettyPrinter extends Configured implements Tool {
Set<String> foundMobFiles = new LinkedHashSet<>(FOUND_MOB_FILES_CACHE_CAPACITY);
Set<String> missingMobFiles = new LinkedHashSet<>(MISSING_MOB_FILES_CACHE_CAPACITY);
do {
- Cell cell = scanner.getCell();
+ ExtendedCell cell = scanner.getCell();
if (row != null && row.length != 0) {
int result = CellComparator.getInstance().compareRows(cell, row, 0, row.length);
if (result > 0) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
index 0134e11d891..ce3ea3fd941 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/CallRunner.java
@@ -23,7 +23,7 @@ import io.opentelemetry.context.Scope;
import java.net.InetSocketAddress;
import java.nio.channels.ClosedChannelException;
import org.apache.hadoop.hbase.CallDroppedException;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
@@ -111,7 +111,7 @@ public class CallRunner {
}
Throwable errorThrowable = null;
String error = null;
- Pair<Message, CellScanner> resultPair = null;
+ Pair<Message, ExtendedCellScanner> resultPair = null;
RpcServer.CurCall.set(call);
final Span ipcServerSpan = new IpcServerSpanBuilder(call).build();
try (Scope ignored1 = ipcServerSpan.makeCurrent()) {
@@ -156,7 +156,7 @@ public class CallRunner {
call.cleanup();
// Set the response
Message param = resultPair != null ? resultPair.getFirst() : null;
- CellScanner cells = resultPair != null ? resultPair.getSecond() : null;
+ ExtendedCellScanner cells = resultPair != null ? resultPair.getSecond() : null;
call.setResponse(param, cells, errorThrowable, error);
call.sendResponseIfReady();
// don't touch `span` here because its status and `end()` are managed in `call#setResponse()`
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerCall.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerCall.java
index 4f0540da80a..62cac989d8a 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerCall.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerCall.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.net.InetAddress;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
import org.apache.yetus.audience.InterfaceAudience;
@@ -39,7 +39,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader
class NettyServerCall extends ServerCall<NettyServerRpcConnection> {
NettyServerCall(int id, BlockingService service, MethodDescriptor md, RequestHeader header,
- Message param, CellScanner cellScanner, NettyServerRpcConnection connection, long size,
+ Message param, ExtendedCellScanner cellScanner, NettyServerRpcConnection connection, long size,
InetAddress remoteAddress, long receiveTime, int timeout, ByteBuffAllocator bbAllocator,
CellBlockBuilder cellBlockBuilder, CallCleanup reqCleanup) {
super(id, service, md, header, param, cellScanner, connection, size, remoteAddress, receiveTime,
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
index f52357539de..f63b8d2730f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyServerRpcConnection.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
import org.apache.hadoop.hbase.nio.ByteBuff;
import org.apache.hadoop.hbase.nio.SingleByteBuff;
@@ -107,7 +107,7 @@ class NettyServerRpcConnection extends ServerRpcConnection {
@Override
public NettyServerCall createCall(int id, final BlockingService service,
- final MethodDescriptor md, RequestHeader header, Message param, CellScanner cellScanner,
+ final MethodDescriptor md, RequestHeader header, Message param, ExtendedCellScanner cellScanner,
long size, final InetAddress remoteAddress, int timeout, CallCleanup reqCleanup) {
return new NettyServerCall(id, service, md, header, param, cellScanner, this, size,
remoteAddress, EnvironmentEdgeManager.currentTime(), timeout, this.rpcServer.bbAllocator,
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCall.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCall.java
index 2d06aa7c47a..804d7b32bb4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCall.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcCall.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.yetus.audience.InterfaceAudience;
import org.apache.yetus.audience.InterfaceStability;
@@ -48,7 +48,7 @@ public interface RpcCall extends RpcCallContext {
Message getParam();
/** Returns The CellScanner that can carry input and result payload. */
- CellScanner getCellScanner();
+ ExtendedCellScanner getCellScanner();
/** Returns The timestamp when the call is constructed. */
long getReceiveTime();
@@ -117,7 +117,8 @@ public interface RpcCall extends RpcCallContext {
* @param errorThrowable The error Throwable resulting from the call.
* @param error Extra error message.
*/
- void setResponse(Message param, CellScanner cells, Throwable errorThrowable, String error);
+ void setResponse(Message param, ExtendedCellScanner cells, Throwable errorThrowable,
+ String error);
/**
* Send the response of this RPC call. Implementation provides the underlying facility
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
index a84d132a013..4ff1a0b5482 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServer.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.CallQueueTooBigException;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.conf.ConfigurationObserver;
@@ -428,7 +429,7 @@ public abstract class RpcServer implements RpcServerInterface, ConfigurationObse
* the protobuf response.
*/
@Override
- public Pair<Message, CellScanner> call(RpcCall call, MonitoredRPCHandler status)
+ public Pair<Message, ExtendedCellScanner> call(RpcCall call, MonitoredRPCHandler status)
throws IOException {
try {
MethodDescriptor md = call.getMethod();
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
index 2c0dd1cc2b0..9bf5fc3817d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/RpcServerInterface.java
@@ -20,7 +20,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.net.InetSocketAddress;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
import org.apache.hadoop.hbase.namequeues.NamedQueueRecorder;
@@ -45,7 +45,8 @@ public interface RpcServerInterface {
InetSocketAddress getListenerAddress();
- Pair<Message, CellScanner> call(RpcCall call, MonitoredRPCHandler status) throws IOException;
+ Pair<Message, ExtendedCellScanner> call(RpcCall call, MonitoredRPCHandler status)
+ throws IOException;
void setErrorHandler(HBaseRPCErrorHandler handler);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
index 25d153c068a..c2c6b4d063c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerCall.java
@@ -30,8 +30,8 @@ import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseServerException;
import org.apache.hadoop.hbase.exceptions.RegionMovedException;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
@@ -72,7 +72,7 @@ public abstract class ServerCall<T extends ServerRpcConnection> implements RpcCa
protected final RequestHeader header;
protected Message param; // the parameter passed
// Optional cell data passed outside of protobufs.
- protected final CellScanner cellScanner;
+ protected final ExtendedCellScanner cellScanner;
protected final T connection; // connection to client
protected final long receiveTime; // the time received when response is null
// the time served when response is not null
@@ -120,8 +120,8 @@ public abstract class ServerCall<T extends ServerRpcConnection> implements RpcCa
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH",
justification = "Can't figure why this complaint is happening... see below")
ServerCall(int id, BlockingService service, MethodDescriptor md, RequestHeader header,
- Message param, CellScanner cellScanner, T connection, long size, InetAddress remoteAddress,
- long receiveTime, int timeout, ByteBuffAllocator byteBuffAllocator,
+ Message param, ExtendedCellScanner cellScanner, T connection, long size,
+ InetAddress remoteAddress, long receiveTime, int timeout, ByteBuffAllocator byteBuffAllocator,
CellBlockBuilder cellBlockBuilder, CallCleanup reqCleanup) {
this.id = id;
this.service = service;
@@ -273,7 +273,7 @@ public abstract class ServerCall<T extends ServerRpcConnection> implements RpcCa
}
@Override
- public synchronized void setResponse(Message m, final CellScanner cells, Throwable t,
+ public synchronized void setResponse(Message m, final ExtendedCellScanner cells, Throwable t,
String errorMsg) {
if (this.isError) {
return;
@@ -544,7 +544,7 @@ public abstract class ServerCall<T extends ServerRpcConnection> implements RpcCa
}
@Override
- public CellScanner getCellScanner() {
+ public ExtendedCellScanner getCellScanner() {
return cellScanner;
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java
index 31f46f30c38..c17a8da9041 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/ServerRpcConnection.java
@@ -39,8 +39,8 @@ import java.util.Properties;
import org.apache.commons.crypto.cipher.CryptoCipherFactory;
import org.apache.commons.crypto.random.CryptoRandom;
import org.apache.commons.crypto.random.CryptoRandomFactory;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.client.ConnectionRegistryEndpoint;
import org.apache.hadoop.hbase.client.VersionInfoUtil;
import org.apache.hadoop.hbase.codec.Codec;
@@ -588,7 +588,7 @@ abstract class ServerRpcConnection implements Closeable {
}
MethodDescriptor md = null;
Message param = null;
- CellScanner cellScanner = null;
+ ExtendedCellScanner cellScanner = null;
try {
if (header.hasRequestParam() && header.getRequestParam()) {
md = this.service.getDescriptorForType().findMethodByName(header.getMethodName());
@@ -816,7 +816,7 @@ abstract class ServerRpcConnection implements Closeable {
public abstract boolean isConnectionOpen();
public abstract ServerCall<?> createCall(int id, BlockingService service, MethodDescriptor md,
- RequestHeader header, Message param, CellScanner cellScanner, long size,
+ RequestHeader header, Message param, ExtendedCellScanner cellScanner, long size,
InetAddress remoteAddress, int timeout, CallCleanup reqCleanup);
private static class ByteBuffByteInput extends ByteInput {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerCall.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerCall.java
index 5c5e9102115..aa6e2b7b4ac 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerCall.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerCall.java
@@ -19,7 +19,7 @@ package org.apache.hadoop.hbase.ipc;
import java.io.IOException;
import java.net.InetAddress;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.io.ByteBuffAllocator;
import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
import org.apache.yetus.audience.InterfaceAudience;
@@ -43,7 +43,7 @@ class SimpleServerCall extends ServerCall<SimpleServerRpcConnection> {
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH",
justification = "Can't figure why this complaint is happening... see below")
SimpleServerCall(int id, final BlockingService service, final MethodDescriptor md,
- RequestHeader header, Message param, CellScanner cellScanner,
+ RequestHeader header, Message param, ExtendedCellScanner cellScanner,
SimpleServerRpcConnection connection, long size, final InetAddress remoteAddress,
long receiveTime, int timeout, ByteBuffAllocator bbAllocator, CellBlockBuilder cellBlockBuilder,
CallCleanup reqCleanup, SimpleRpcServerResponder responder) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
index 1b28c19b430..e8619b2eb7f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleServerRpcConnection.java
@@ -30,8 +30,8 @@ import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.atomic.LongAdder;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.client.VersionInfoUtil;
import org.apache.hadoop.hbase.exceptions.RequestTooBigException;
import org.apache.hadoop.hbase.ipc.RpcServer.CallCleanup;
@@ -456,7 +456,7 @@ class SimpleServerRpcConnection extends ServerRpcConnection {
@Override
public SimpleServerCall createCall(int id, BlockingService service, MethodDescriptor md,
- RequestHeader header, Message param, CellScanner cellScanner, long size,
+ RequestHeader header, Message param, ExtendedCellScanner cellScanner, long size,
InetAddress remoteAddress, int timeout, CallCleanup reqCleanup) {
return new SimpleServerCall(id, service, md, header, param, cellScanner, this, size,
remoteAddress, EnvironmentEdgeManager.currentTime(), timeout, this.rpcServer.bbAllocator,
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java
index 2fadc83340e..66160dd4aa6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mob/MobUtils.java
@@ -120,7 +120,7 @@ public final class MobUtils {
* @param cell The current cell.
* @return True if the cell has a mob reference tag, false if it doesn't.
*/
- public static boolean isMobReferenceCell(Cell cell) {
+ public static boolean isMobReferenceCell(ExtendedCell cell) {
if (cell.getTagsLength() > 0) {
Optional<Tag> tag = PrivateCellUtil.getTag(cell, TagType.MOB_REFERENCE_TAG_TYPE);
if (tag.isPresent()) {
@@ -135,7 +135,7 @@ public final class MobUtils {
* @param cell The current cell.
* @return The table name tag.
*/
- private static Optional<Tag> getTableNameTag(Cell cell) {
+ private static Optional<Tag> getTableNameTag(ExtendedCell cell) {
Optional<Tag> tag = Optional.empty();
if (cell.getTagsLength() > 0) {
tag = PrivateCellUtil.getTag(cell, TagType.MOB_TABLE_NAME_TAG_TYPE);
@@ -148,7 +148,7 @@ public final class MobUtils {
* @param cell to extract tag from
* @return table name as a string. empty if the tag is not found.
*/
- public static Optional<String> getTableNameString(Cell cell) {
+ public static Optional<String> getTableNameString(ExtendedCell cell) {
Optional<Tag> tag = getTableNameTag(cell);
Optional<String> name = Optional.empty();
if (tag.isPresent()) {
@@ -162,7 +162,7 @@ public final class MobUtils {
* @param cell to extract tag from
* @return name of table as a TableName. empty if the tag is not found.
*/
- public static Optional<TableName> getTableName(Cell cell) {
+ public static Optional<TableName> getTableName(ExtendedCell cell) {
Optional<Tag> maybe = getTableNameTag(cell);
Optional<TableName> name = Optional.empty();
if (maybe.isPresent()) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ReplicationProtobufUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ReplicationProtobufUtil.java
index 6754fdef08a..0b1736e21a4 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ReplicationProtobufUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/protobuf/ReplicationProtobufUtil.java
@@ -24,10 +24,11 @@ import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.client.AsyncRegionServerAdmin;
-import org.apache.hadoop.hbase.io.SizedCellScanner;
+import org.apache.hadoop.hbase.io.SizedExtendedCellScanner;
import org.apache.hadoop.hbase.regionserver.wal.WALCellCodec;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.wal.WAL.Entry;
@@ -56,8 +57,8 @@ public class ReplicationProtobufUtil {
public static CompletableFuture<ReplicateWALEntryResponse> replicateWALEntry(
AsyncRegionServerAdmin admin, Entry[] entries, String replicationClusterId,
Path sourceBaseNamespaceDir, Path sourceHFileArchiveDir, int timeout) {
- Pair<ReplicateWALEntryRequest, CellScanner> p = buildReplicateWALEntryRequest(entries, null,
- replicationClusterId, sourceBaseNamespaceDir, sourceHFileArchiveDir);
+ Pair<ReplicateWALEntryRequest, ExtendedCellScanner> p = buildReplicateWALEntryRequest(entries,
+ null, replicationClusterId, sourceBaseNamespaceDir, sourceHFileArchiveDir);
return admin.replicateWALEntry(p.getFirst(), p.getSecond(), timeout);
}
@@ -66,7 +67,7 @@ public class ReplicationProtobufUtil {
* @param entries the WAL entries to be replicated
* @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values found.
*/
- public static Pair<ReplicateWALEntryRequest, CellScanner>
+ public static Pair<ReplicateWALEntryRequest, ExtendedCellScanner>
buildReplicateWALEntryRequest(final Entry[] entries) {
return buildReplicateWALEntryRequest(entries, null, null, null, null);
}
@@ -81,11 +82,11 @@ public class ReplicationProtobufUtil {
* @param sourceHFileArchiveDir Path to the source cluster hfile archive directory
* @return a pair of ReplicateWALEntryRequest and a CellScanner over all the WALEdit values found.
*/
- public static Pair<ReplicateWALEntryRequest, CellScanner> buildReplicateWALEntryRequest(
+ public static Pair<ReplicateWALEntryRequest, ExtendedCellScanner> buildReplicateWALEntryRequest(
final Entry[] entries, byte[] encodedRegionName, String replicationClusterId,
Path sourceBaseNamespaceDir, Path sourceHFileArchiveDir) {
// Accumulate all the Cells seen in here.
- List<List<? extends Cell>> allCells = new ArrayList<>(entries.length);
+ List<List<? extends ExtendedCell>> allCells = new ArrayList<>(entries.length);
int size = 0;
WALEntry.Builder entryBuilder = WALEntry.newBuilder();
ReplicateWALEntryRequest.Builder builder = ReplicateWALEntryRequest.newBuilder();
@@ -104,7 +105,8 @@ public class ReplicationProtobufUtil {
}
entryBuilder.setKey(keyBuilder.build());
WALEdit edit = entry.getEdit();
- List<Cell> cells = edit.getCells();
+ // TODO: avoid this cast
+ List<ExtendedCell> cells = (List) edit.getCells();
// Add up the size. It is used later serializing out the kvs.
for (Cell cell : cells) {
size += PrivateCellUtil.estimatedSerializedSizeOf(cell);
@@ -130,21 +132,24 @@ public class ReplicationProtobufUtil {
}
/** Returns <code>cells</code> packaged as a CellScanner */
- static CellScanner getCellScanner(final List<List<? extends Cell>> cells, final int size) {
- return new SizedCellScanner() {
- private final Iterator<List<? extends Cell>> entries = cells.iterator();
- private Iterator<? extends Cell> currentIterator = null;
- private Cell currentCell;
+ static ExtendedCellScanner getCellScanner(final List<List<? extends ExtendedCell>> cells,
+ final int size) {
+ return new SizedExtendedCellScanner() {
+ private final Iterator<List<? extends ExtendedCell>> entries = cells.iterator();
+ private Iterator<? extends ExtendedCell> currentIterator = null;
+ private ExtendedCell currentCell;
@Override
- public Cell current() {
+ public ExtendedCell current() {
return this.currentCell;
}
@Override
public boolean advance() {
if (this.currentIterator == null) {
- if (!this.entries.hasNext()) return false;
+ if (!this.entries.hasNext()) {
+ return false;
+ }
this.currentIterator = this.entries.next().iterator();
}
if (this.currentIterator.hasNext()) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
index 2792ab2754c..68f5356f554 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
@@ -112,6 +112,7 @@ import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.IsolationLevel;
import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
@@ -3512,7 +3513,7 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// store the family map reference to allow for mutations
// we know that in mutation, only ExtendedCells are allow so here we do a fake cast, to
// simplify later logic
- familyCellMaps[index] = (Map) mutation.getFamilyCellMap();
+ familyCellMaps[index] = PackagePrivateFieldAccessor.getExtendedFamilyCellMap(mutation);
}
// store durability for the batch (highest durability of all operations in the batch)
@@ -4063,7 +4064,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
assert mutation instanceof Increment || mutation instanceof Append;
Map<byte[], List<ExtendedCell>> ret = new TreeMap<>(Bytes.BYTES_COMPARATOR);
// Process a Store/family at a time.
- for (Map.Entry<byte[], List<Cell>> entry : mutation.getFamilyCellMap().entrySet()) {
+ for (Map.Entry<byte[], List<ExtendedCell>> entry : PackagePrivateFieldAccessor
+ .getExtendedFamilyCellMap(mutation).entrySet()) {
final byte[] columnFamilyName = entry.getKey();
List<ExtendedCell> deltas = (List) entry.getValue();
// Reckon for the Store what to apply to WAL and MemStore.
@@ -4184,9 +4186,9 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
return cellPairs.stream().map(Pair::getSecond).collect(Collectors.toList());
}
- private static ExtendedCell reckonDelta(final Cell delta, final Cell currentCell,
- final byte[] columnFamily, final long now, Mutation mutation, Function<Cell, byte[]> supplier)
- throws IOException {
+ private static ExtendedCell reckonDelta(final ExtendedCell delta,
+ final ExtendedCell currentCell, final byte[] columnFamily, final long now, Mutation mutation,
+ Function<ExtendedCell, byte[]> supplier) throws IOException {
// Forward any tags found on the delta.
List<Tag> tags = TagUtil.carryForwardTags(delta);
if (currentCell != null) {
@@ -4204,7 +4206,6 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
} else {
tags = TagUtil.carryForwardTTLTag(tags, mutation.getTTL());
PrivateCellUtil.updateLatestStamp(delta, now);
- assert delta instanceof ExtendedCell;
ExtendedCell deltaCell = (ExtendedCell) delta;
return CollectionUtils.isEmpty(tags)
? deltaCell
@@ -4522,7 +4523,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
// Returned mutations from coprocessor correspond to the Mutation at index i. We can
// directly add the cells from those mutations to the familyMaps of this mutation.
- Map<byte[], List<ExtendedCell>> cpFamilyMap = (Map) cpMutation.getFamilyCellMap();
+ Map<byte[], List<ExtendedCell>> cpFamilyMap =
+ PackagePrivateFieldAccessor.getExtendedFamilyCellMap(cpMutation);
region.rewriteCellTags(cpFamilyMap, mutation);
// will get added to the memStore later
mergeFamilyMaps(familyCellMaps[i], cpFamilyMap);
@@ -5094,14 +5096,16 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
byte[] byteTs = Bytes.toBytes(ts);
if (mutation != null) {
if (mutation instanceof Put) {
- updateCellTimestamps((Iterable) mutation.getFamilyCellMap().values(), byteTs);
+ updateCellTimestamps(
+ PackagePrivateFieldAccessor.getExtendedFamilyCellMap(mutation).values(), byteTs);
}
// And else 'delete' is not needed since it already does a second get, and sets the
// timestamp from get (see prepareDeleteTimestamps).
} else {
for (Mutation m : rowMutations.getMutations()) {
if (m instanceof Put) {
- updateCellTimestamps((Iterable) m.getFamilyCellMap().values(), byteTs);
+ updateCellTimestamps(
+ PackagePrivateFieldAccessor.getExtendedFamilyCellMap(m).values(), byteTs);
}
}
// And else 'delete' is not needed since it already does a second get, and sets the
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MobReferenceOnlyFilter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MobReferenceOnlyFilter.java
index 4efc29dea10..f3191c6374d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MobReferenceOnlyFilter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MobReferenceOnlyFilter.java
@@ -18,6 +18,7 @@
package org.apache.hadoop.hbase.regionserver;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.filter.FilterBase;
import org.apache.hadoop.hbase.mob.MobUtils;
import org.apache.yetus.audience.InterfaceAudience;
@@ -30,9 +31,9 @@ class MobReferenceOnlyFilter extends FilterBase {
@Override
public ReturnCode filterCell(final Cell cell) {
- if (null != cell) {
+ if (null != cell && cell instanceof ExtendedCell) {
// If a cell with a mob reference tag, it's included.
- if (MobUtils.isMobReferenceCell(cell)) {
+ if (MobUtils.isMobReferenceCell((ExtendedCell) cell)) {
return ReturnCode.INCLUDE;
}
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 66c97fb9401..5e16b08369b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -47,11 +47,12 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.CacheEvictionStats;
import org.apache.hadoop.hbase.CacheEvictionStatsBuilder;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScannable;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.DroppedSnapshotException;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseIOException;
import org.apache.hadoop.hbase.HBaseRpcServicesBase;
import org.apache.hadoop.hbase.HConstants;
@@ -72,6 +73,7 @@ import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.OperationWithAttributes;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.RegionReplicaUtil;
@@ -581,7 +583,7 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
builder.addCellsPerResult(res.size());
builder.addPartialFlagPerResult(res.mayHaveMoreCellsInRow());
}
- controller.setCellScanner(CellUtil.createCellScanner(results));
+ controller.setCellScanner(PrivateCellUtil.createExtendedCellScanner(results));
} else {
for (Result res : results) {
ClientProtos.Result pbr = ProtobufUtil.toResult(res);
@@ -725,10 +727,10 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
* @param context the current RpcCallContext
* @return Return the <code>cellScanner</code> passed
*/
- private List<CellScannable> doNonAtomicRegionMutation(final HRegion region,
+ private List<ExtendedCellScannable> doNonAtomicRegionMutation(final HRegion region,
final OperationQuota quota, final RegionAction actions, final CellScanner cellScanner,
- final RegionActionResult.Builder builder, List<CellScannable> cellsToReturn, long nonceGroup,
- final RegionScannersCloseCallBack closeCallBack, RpcCallContext context,
+ final RegionActionResult.Builder builder, List<ExtendedCellScannable> cellsToReturn,
+ long nonceGroup, final RegionScannersCloseCallBack closeCallBack, RpcCallContext context,
ActivePolicyEnforcement spaceQuotaEnforcement) {
// Gather up CONTIGUOUS Puts and Deletes in this mutations List. Idea is that rather than do
// one at a time, we instead pass them in batch. Be aware that the corresponding
@@ -2053,9 +2055,9 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
return response;
}
- private CellScanner getAndReset(RpcController controller) {
+ private ExtendedCellScanner getAndReset(RpcController controller) {
HBaseRpcController hrc = (HBaseRpcController) controller;
- CellScanner cells = hrc.cellScanner();
+ ExtendedCellScanner cells = hrc.cellScanner();
hrc.setCellScanner(null);
return cells;
}
@@ -2498,8 +2500,8 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
&& VersionInfoUtil.hasMinimumVersion(context.getClientVersionInfo(), 1, 3)
) {
pbr = ProtobufUtil.toResultNoData(r);
- ((HBaseRpcController) controller)
- .setCellScanner(CellUtil.createCellScanner(r.rawCells()));
+ ((HBaseRpcController) controller).setCellScanner(PrivateCellUtil
+ .createExtendedCellScanner(PackagePrivateFieldAccessor.getExtendedRawCells(r)));
addSize(context, r);
} else {
pbr = ProtobufUtil.toResult(r);
@@ -2648,10 +2650,7 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
// rpc controller is how we bring in data via the back door; it is unprotobuf'ed data.
// It is also the conduit via which we pass back data.
HBaseRpcController controller = (HBaseRpcController) rpcc;
- CellScanner cellScanner = controller != null ? controller.cellScanner() : null;
- if (controller != null) {
- controller.setCellScanner(null);
- }
+ CellScanner cellScanner = controller != null ? getAndReset(controller) : null;
long nonceGroup = request.hasNonceGroup() ? request.getNonceGroup() : HConstants.NO_NONCE;
@@ -2732,7 +2731,7 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
}
// this will contain all the cells that we need to return. It's created later, if needed.
- List<CellScannable> cellsToReturn = null;
+ List<ExtendedCellScannable> cellsToReturn = null;
RegionScannersCloseCallBack closeCallBack = null;
RpcCallContext context = RpcServer.getCurrentCall().orElse(null);
Map<RegionSpecifier, ClientProtos.RegionLoadStats> regionStats =
@@ -2858,7 +2857,7 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
}
// Load the controller with the Cells to return.
if (cellsToReturn != null && !cellsToReturn.isEmpty() && controller != null) {
- controller.setCellScanner(CellUtil.createCellScanner(cellsToReturn));
+ controller.setCellScanner(PrivateCellUtil.createExtendedCellScanner(cellsToReturn));
}
MultiRegionLoadStats.Builder builder = MultiRegionLoadStats.newBuilder();
@@ -3427,7 +3426,10 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
int lastIdx = results.size() - 1;
Result r = results.get(lastIdx);
if (r.mayHaveMoreCellsInRow()) {
- results.set(lastIdx, Result.create(r.rawCells(), r.getExists(), r.isStale(), false));
+ results.set(lastIdx,
+ PackagePrivateFieldAccessor.createResult(
+ PackagePrivateFieldAccessor.getExtendedRawCells(r), r.getExists(), r.isStale(),
+ false));
}
}
boolean sizeLimitReached = scannerContext.checkSizeLimit(LimitScope.BETWEEN_ROWS);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedMobStoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedMobStoreScanner.java
index 505cd5dedce..81a4cc467f9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedMobStoreScanner.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ReversedMobStoreScanner.java
@@ -75,7 +75,7 @@ public class ReversedMobStoreScanner extends ReversedStoreScanner {
for (int i = 0; i < outResult.size(); i++) {
Cell cell = outResult.get(i);
assert cell instanceof ExtendedCell;
- if (MobUtils.isMobReferenceCell(cell)) {
+ if (MobUtils.isMobReferenceCell((ExtendedCell) cell)) {
MobCell mobCell = mobStore.resolve((ExtendedCell) cell, cacheMobBlocks, readPt,
readEmptyValueOnMobCellMiss);
mobKVCount++;
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncProtobufLogWriter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncProtobufLogWriter.java
index bb874a001d2..dff2052efe7 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncProtobufLogWriter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncProtobufLogWriter.java
@@ -31,6 +31,7 @@ import java.util.function.Consumer;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.exceptions.TimeoutIOException;
import org.apache.hadoop.hbase.io.ByteBufferWriter;
@@ -139,7 +140,7 @@ public class AsyncProtobufLogWriter extends AbstractProtobufLogWriter
}
try {
for (Cell cell : entry.getEdit().getCells()) {
- cellEncoder.write(cell);
+ cellEncoder.write((ExtendedCell) cell);
}
} catch (IOException e) {
throw new AssertionError("should not happen", e);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
index 52317949cc8..6e6727db085 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
@@ -26,6 +26,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.StreamCapabilities;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.io.asyncfs.monitor.StreamSlowMonitor;
import org.apache.hadoop.hbase.util.AtomicUtils;
import org.apache.hadoop.hbase.util.CommonFSUtils;
@@ -58,7 +59,7 @@ public class ProtobufLogWriter extends AbstractProtobufLogWriter implements FSHL
.writeDelimitedTo(output);
for (Cell cell : entry.getEdit().getCells()) {
// cellEncoder must assume little about the stream, since we write PB and cells in turn.
- cellEncoder.write(cell);
+ cellEncoder.write((ExtendedCell) cell);
}
length.set(output.getPos());
}
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java
index 754368f73f3..9adeb958bd0 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/SecureWALCellCodec.java
@@ -24,7 +24,6 @@ import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -79,7 +78,7 @@ public class SecureWALCellCodec extends WALCellCodec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
if (this.decryptor == null) {
return super.parseCell();
}
@@ -174,15 +173,12 @@ public class SecureWALCellCodec extends WALCellCodec {
}
@Override
- public void write(Cell c) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
if (encryptor == null) {
- super.write(c);
+ super.write(cell);
return;
}
- assert c instanceof ExtendedCell;
- ExtendedCell cell = (ExtendedCell) c;
-
byte[] iv = nextIv();
encryptor.setIv(iv);
encryptor.reset();
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
index e6a20b0d020..87154a62066 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java
@@ -233,9 +233,7 @@ public class WALCellCodec implements Codec {
}
@Override
- public void write(Cell c) throws IOException {
- assert c instanceof ExtendedCell;
- ExtendedCell cell = (ExtendedCell) c;
+ public void write(ExtendedCell cell) throws IOException {
// We first write the KeyValue infrastructure as VInts.
StreamUtils.writeRawVInt32(out, KeyValueUtil.keyLength(cell));
StreamUtils.writeRawVInt32(out, cell.getValueLength());
@@ -290,7 +288,7 @@ public class WALCellCodec implements Codec {
}
@Override
- protected Cell parseCell() throws IOException {
+ protected ExtendedCell parseCell() throws IOException {
int keylength = StreamUtils.readRawVarint32(in);
int vlength = StreamUtils.readRawVarint32(in);
int tagsLength = StreamUtils.readRawVarint32(in);
@@ -396,7 +394,7 @@ public class WALCellCodec implements Codec {
}
@Override
- public void write(Cell cell) throws IOException {
+ public void write(ExtendedCell cell) throws IOException {
checkFlushed();
// Make sure to write tags into WAL
ByteBufferUtils.putInt(this.out, KeyValueUtil.getSerializedSize(cell, true));
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplaySyncReplicationWALCallable.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplaySyncReplicationWALCallable.java
index a60186c13dc..427fe80b0c3 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplaySyncReplicationWALCallable.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplaySyncReplicationWALCallable.java
@@ -23,8 +23,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.executor.EventType;
import org.apache.hadoop.hbase.procedure2.BaseRSProcedureCallable;
import org.apache.hadoop.hbase.protobuf.ReplicationProtobufUtil;
@@ -106,8 +106,9 @@ public class ReplaySyncReplicationWALCallable extends BaseRSProcedureCallable {
try {
List<Entry> entries = readWALEntries(reader, wal);
while (!entries.isEmpty()) {
- Pair<AdminProtos.ReplicateWALEntryRequest, CellScanner> pair = ReplicationProtobufUtil
- .buildReplicateWALEntryRequest(entries.toArray(new Entry[entries.size()]));
+ Pair<AdminProtos.ReplicateWALEntryRequest, ExtendedCellScanner> pair =
+ ReplicationProtobufUtil
+ .buildReplicateWALEntryRequest(entries.toArray(new Entry[entries.size()]));
ReplicateWALEntryRequest request = pair.getFirst();
rs.getReplicationSinkService().replicateLogEntries(request.getEntryList(), pair.getSecond(),
request.getReplicationClusterId(), request.getSourceBaseNamespaceDirPath(),
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
index d0c19d7cfcd..f0158f299f2 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessController.java
@@ -35,13 +35,13 @@ import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.CompoundConfiguration;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -644,7 +644,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
if (m.getAttribute(TAG_CHECK_PASSED) != null) {
return;
}
- for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
+ for (ExtendedCellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
Iterator<Tag> tagsItr = PrivateCellUtil.tagsIterator(cellScanner.current());
while (tagsItr.hasNext()) {
if (tagsItr.next().getType() == PermissionStorage.ACL_TAG_TYPE) {
@@ -1732,8 +1732,9 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
// there is no need to rewrite them again. Just extract non-acl tags of newCell if we need to
// add a new acl tag for the cell. Actually, oldCell is useless here.
List<Tag> tags = Lists.newArrayList();
- if (newCell != null) {
- Iterator<Tag> tagIterator = PrivateCellUtil.tagsIterator(newCell);
+ ExtendedCell newExtendedCell = (ExtendedCell) newCell;
+ if (newExtendedCell != null) {
+ Iterator<Tag> tagIterator = PrivateCellUtil.tagsIterator(newExtendedCell);
while (tagIterator.hasNext()) {
Tag tag = tagIterator.next();
if (tag.getType() != PermissionStorage.ACL_TAG_TYPE) {
@@ -1750,8 +1751,7 @@ public class AccessController implements MasterCoprocessor, RegionCoprocessor,
// We have checked the ACL tag of mutation is not null.
// So that the tags could not be empty.
tags.add(new ArrayBackedTag(PermissionStorage.ACL_TAG_TYPE, mutation.getACL()));
- assert newCell instanceof ExtendedCell;
- return PrivateCellUtil.createCell((ExtendedCell) newCell, tags);
+ return PrivateCellUtil.createCell(newExtendedCell, tags);
}
@Override
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AuthManager.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AuthManager.java
index 023eccbd27d..c27063752c5 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AuthManager.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AuthManager.java
@@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.AuthUtil;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.security.Superusers;
@@ -452,7 +453,9 @@ public final class AuthManager {
*/
public boolean authorizeCell(User user, TableName table, Cell cell, Permission.Action action) {
try {
- List<Permission> perms = PermissionStorage.getCellPermissionsForUser(user, cell);
+ assert cell instanceof ExtendedCell;
+ List<Permission> perms =
+ PermissionStorage.getCellPermissionsForUser(user, (ExtendedCell) cell);
if (LOG.isTraceEnabled()) {
LOG.trace("Perms for user {} in table {} in cell {}: {}", user.getShortName(), table, cell,
(perms != null ? perms : ""));
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/PermissionStorage.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/PermissionStorage.java
index 7a444429101..b66c0ed0b09 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/PermissionStorage.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/PermissionStorage.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
@@ -866,7 +867,7 @@ public final class PermissionStorage {
return Arrays.copyOfRange(namespace, 1, namespace.length);
}
- public static List<Permission> getCellPermissionsForUser(User user, Cell cell)
+ public static List<Permission> getCellPermissionsForUser(User user, ExtendedCell cell)
throws IOException {
// Save an object allocation where we can
if (cell.getTagsLength() == 0) {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
index 0e98fd456ae..7433b73ff3d 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
@@ -35,10 +35,10 @@ import java.util.Optional;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.AuthUtil;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseInterfaceAudience;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
@@ -300,10 +300,9 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
boolean sanityFailure = false;
boolean modifiedTagFound = false;
Pair<Boolean, Tag> pair = new Pair<>(false, null);
- for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
- Cell cell = cellScanner.current();
- assert cell instanceof ExtendedCell;
- pair = checkForReservedVisibilityTagPresence((ExtendedCell) cell, pair);
+ for (ExtendedCellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
+ ExtendedCell cell = cellScanner.current();
+ pair = checkForReservedVisibilityTagPresence(cell, pair);
if (!pair.getFirst()) {
// Don't disallow reserved tags if authorization is disabled
if (authorizationEnabled) {
@@ -342,10 +341,8 @@ public class VisibilityController implements MasterCoprocessor, RegionCoprocesso
}
if (visibilityTags != null) {
List<ExtendedCell> updatedCells = new ArrayList<>();
- for (CellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
- Cell ce = cellScanner.current();
- assert ce instanceof ExtendedCell;
- ExtendedCell cell = (ExtendedCell) ce;
+ for (ExtendedCellScanner cellScanner = m.cellScanner(); cellScanner.advance();) {
+ ExtendedCell cell = cellScanner.current();
List<Tag> tags = PrivateCellUtil.getTags(cell);
if (modifiedTagFound) {
// Rewrite the tags by removing the modified tags.
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestCustomPriorityRpcControllerFactory.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestCustomPriorityRpcControllerFactory.java
index fde491983ce..435037ab17d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/TestCustomPriorityRpcControllerFactory.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/TestCustomPriorityRpcControllerFactory.java
@@ -281,12 +281,12 @@ public class TestCustomPriorityRpcControllerFactory {
}
@Override
- public HBaseRpcController newController(CellScanner cellScanner) {
+ public HBaseRpcController newController(ExtendedCellScanner cellScanner) {
return new PriorityController(EXPECTED_PRIORITY.get(), super.newController(cellScanner));
}
@Override
- public HBaseRpcController newController(List<CellScannable> cellIterables) {
+ public HBaseRpcController newController(List<ExtendedCellScannable> cellIterables) {
return new PriorityController(EXPECTED_PRIORITY.get(), super.newController(cellIterables));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAllowPartialScanResultCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAllowPartialScanResultCache.java
index 0baf0443800..21831a67b0f 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAllowPartialScanResultCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestAllowPartialScanResultCache.java
@@ -23,7 +23,7 @@ import static org.junit.Assert.assertSame;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
@@ -63,8 +63,8 @@ public class TestAllowPartialScanResultCache {
assertSame(ScanResultCache.EMPTY_RESULT_ARRAY,
resultCache.addAndGet(ScanResultCache.EMPTY_RESULT_ARRAY, true));
- Cell[] cells1 = createCells(CF, 1, 10);
- Cell[] cells2 = createCells(CF, 2, 10);
+ ExtendedCell[] cells1 = createCells(CF, 1, 10);
+ ExtendedCell[] cells2 = createCells(CF, 2, 10);
Result[] results1 = resultCache.addAndGet(
new Result[] { Result.create(Arrays.copyOf(cells1, 5), null, false, true) }, false);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBatchScanResultCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBatchScanResultCache.java
index b8c57fb5f6b..dd0074ae691 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBatchScanResultCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestBatchScanResultCache.java
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertSame;
import java.io.IOException;
import java.util.Arrays;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.testclassification.ClientTests;
@@ -56,12 +56,12 @@ public class TestBatchScanResultCache {
resultCache = null;
}
- static Cell createCell(byte[] cf, int key, int cq) {
+ static ExtendedCell createCell(byte[] cf, int key, int cq) {
return new KeyValue(Bytes.toBytes(key), cf, Bytes.toBytes("cq" + cq), Bytes.toBytes(key));
}
- static Cell[] createCells(byte[] cf, int key, int numCqs) {
- Cell[] cells = new Cell[numCqs];
+ static ExtendedCell[] createCells(byte[] cf, int key, int numCqs) {
+ ExtendedCell[] cells = new ExtendedCell[numCqs];
for (int i = 0; i < numCqs; i++) {
cells[i] = createCell(cf, key, i);
}
@@ -83,9 +83,9 @@ public class TestBatchScanResultCache {
assertSame(ScanResultCache.EMPTY_RESULT_ARRAY,
resultCache.addAndGet(ScanResultCache.EMPTY_RESULT_ARRAY, true));
- Cell[] cells1 = createCells(CF, 1, 10);
- Cell[] cells2 = createCells(CF, 2, 10);
- Cell[] cells3 = createCells(CF, 3, 10);
+ ExtendedCell[] cells1 = createCells(CF, 1, 10);
+ ExtendedCell[] cells2 = createCells(CF, 2, 10);
+ ExtendedCell[] cells3 = createCells(CF, 3, 10);
assertEquals(0, resultCache.addAndGet(
new Result[] { Result.create(Arrays.copyOf(cells1, 3), null, false, true) }, false).length);
Result[] results = resultCache
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
index 8e5895c6914..2e4a13fc8ce 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide.java
@@ -37,6 +37,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -232,7 +233,7 @@ public class TestFromClientSide extends FromClientSideBase {
s.setTimeRange(0, ts + 3);
s.readAllVersions();
ResultScanner scanner = h.getScanner(s);
- Cell[] kvs = scanner.next().rawCells();
+ ExtendedCell[] kvs = scanner.next().rawExtendedCells();
assertArrayEquals(T2, CellUtil.cloneValue(kvs[0]));
assertArrayEquals(T1, CellUtil.cloneValue(kvs[1]));
scanner.close();
@@ -241,7 +242,7 @@ public class TestFromClientSide extends FromClientSideBase {
s.setRaw(true);
s.readAllVersions();
scanner = h.getScanner(s);
- kvs = scanner.next().rawCells();
+ kvs = scanner.next().rawExtendedCells();
assertTrue(PrivateCellUtil.isDeleteFamily(kvs[0]));
assertArrayEquals(T3, CellUtil.cloneValue(kvs[1]));
assertTrue(CellUtil.isDelete(kvs[2]));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIncrementsFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIncrementsFromClientSide.java
index f2b0f75724d..be70c4c5cd6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIncrementsFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestIncrementsFromClientSide.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -566,8 +567,8 @@ public class TestIncrementsFromClientSide {
int count = 0;
Result result;
while ((result = scanner.next()) != null) {
- Cell[] cells = result.rawCells();
- for (Cell cell : cells) {
+ ExtendedCell[] cells = result.rawExtendedCells();
+ for (ExtendedCell cell : cells) {
List<Tag> tags = PrivateCellUtil.getTags(cell);
// Make sure there is only 1 tag.
assertEquals(1, tags.size());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMalformedCellFromClient.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMalformedCellFromClient.java
index 64f4c89a34f..37422c1f1a0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMalformedCellFromClient.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestMalformedCellFromClient.java
@@ -32,9 +32,11 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.ipc.HBaseRpcController;
import org.apache.hadoop.hbase.regionserver.HRegion;
@@ -199,14 +201,15 @@ public class TestMalformedCellFromClient {
ProtobufUtil.toMutationNoData(ClientProtos.MutationProto.MutationType.PUT, put))))
.build();
- List<Cell> cells = new ArrayList<>();
+ List<ExtendedCell> cells = new ArrayList<>();
for (Mutation m : rm.getMutations()) {
cells.addAll(m.getCellList(FAMILY));
}
cells.addAll(put.getCellList(FAMILY));
assertEquals(3, cells.size());
HBaseRpcController controller = Mockito.mock(HBaseRpcController.class);
- Mockito.when(controller.cellScanner()).thenReturn(CellUtil.createCellScanner(cells));
+ Mockito.when(controller.cellScanner())
+ .thenReturn(PrivateCellUtil.createExtendedCellScanner(cells));
HRegionServer rs = TEST_UTIL.getMiniHBaseCluster().getRegionServer(TEST_UTIL
.getMiniHBaseCluster().getServerHoldingRegion(TABLE_NAME, r.getRegionInfo().getRegionName()));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
index c5842629e60..1de686b253b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestResult.java
@@ -23,7 +23,9 @@ import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -45,6 +47,7 @@ import org.apache.hadoop.hbase.testclassification.ClientTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.ByteBufferUtils;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -83,15 +86,16 @@ public class TestResult {
Cell[] cells = genKVs(row, family, value, 1, 10);
Arrays.sort(cells, CellComparator.getInstance());
Result r = Result.create(cells);
- assertSame(r, cells);
+ assertCellsSame(r, cells);
// Assert I run over same result multiple times.
- assertSame(r.cellScanner(), cells);
- assertSame(r.cellScanner(), cells);
+ assertCellsSame(r.cellScanner(), cells);
+ assertCellsSame(r.cellScanner(), cells);
// Assert we are not creating new object when doing cellscanner
assertTrue(r == r.cellScanner());
}
- private void assertSame(final CellScanner cellScanner, final Cell[] cells) throws IOException {
+ private void assertCellsSame(final CellScanner cellScanner, final Cell[] cells)
+ throws IOException {
int count = 0;
while (cellScanner.advance()) {
assertTrue(cells[count].equals(cellScanner.current()));
@@ -458,7 +462,6 @@ public class TestResult {
* Microbenchmark that compares {@link Result#getValue} and {@link Result#loadValue} performance.
*/
public void doReadBenchmark() throws Exception {
-
final int n = 5;
final int m = 100000000;
@@ -516,6 +519,20 @@ public class TestResult {
System.out.println("getValue(): " + (stop - start));
}
+ @Test
+ public void testCreateResultWithCellArray() {
+ Cell[] cells = genKVs(row, family, value, EnvironmentEdgeManager.currentTime(), 5);
+ Result r = Result.create(cells);
+ // the cells is actually a KeyValue[], which can be cast to ExtendedCell[] directly, so we
+ // should get the same one without copying
+ assertSame(cells, r.rawCells());
+
+ Cell[] emptyCells = new Cell[0];
+ Result emptyResult = Result.create(emptyCells);
+ // emptyCells is a Cell[] instead of ExtendedCell[], so we need to copy it to a new array
+ assertNotSame(emptyCells, emptyResult.rawCells());
+ }
+
/**
* Calls non-functional test methods.
*/
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/CodecPerformance.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/CodecPerformance.java
index 272bf1c4609..2481cb200d8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/CodecPerformance.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/CodecPerformance.java
@@ -24,7 +24,8 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.io.CellOutputStream;
import org.apache.hadoop.hbase.util.Bytes;
@@ -42,8 +43,8 @@ public class CodecPerformance {
@Deprecated
public static final Logger LOG = LoggerFactory.getLogger(CodecPerformance.class);
- static Cell[] getCells(final int howMany) {
- Cell[] cells = new Cell[howMany];
+ static ExtendedCell[] getCells(final int howMany) {
+ ExtendedCell[] cells = new ExtendedCell[howMany];
for (int i = 0; i < howMany; i++) {
byte[] index = Bytes.toBytes(i);
KeyValue kv = new KeyValue(index, Bytes.toBytes("f"), index, index);
@@ -62,7 +63,7 @@ public class CodecPerformance {
}
static byte[] runEncoderTest(final int index, final int initialBufferSize,
- final ByteArrayOutputStream baos, final CellOutputStream encoder, final Cell[] cells)
+ final ByteArrayOutputStream baos, final CellOutputStream encoder, final ExtendedCell[] cells)
throws IOException {
long startTime = EnvironmentEdgeManager.currentTime();
for (int i = 0; i < cells.length; i++) {
@@ -76,9 +77,9 @@ public class CodecPerformance {
return baos.toByteArray();
}
- static Cell[] runDecoderTest(final int index, final int count, final CellScanner decoder)
- throws IOException {
- Cell[] cells = new Cell[count];
+ static ExtendedCell[] runDecoderTest(final int index, final int count,
+ final ExtendedCellScanner decoder) throws IOException {
+ ExtendedCell[] cells = new ExtendedCell[count];
long startTime = EnvironmentEdgeManager.currentTime();
for (int i = 0; decoder.advance(); i++) {
cells[i] = decoder.current();
@@ -94,10 +95,10 @@ public class CodecPerformance {
assertArrayEquals(input, output);
}
- static void doCodec(final Codec codec, final Cell[] cells, final int cycles, final int count,
- final int initialBufferSize) throws IOException {
+ static void doCodec(final Codec codec, final ExtendedCell[] cells, final int cycles,
+ final int count, final int initialBufferSize) throws IOException {
byte[] bytes = null;
- Cell[] cellsDecoded = null;
+ ExtendedCell[] cellsDecoded = null;
for (int i = 0; i < cycles; i++) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(initialBufferSize);
Codec.Encoder encoder = codec.getEncoder(baos);
@@ -117,7 +118,7 @@ public class CodecPerformance {
// How many times to do an operation; repeat gives hotspot chance to warm up.
final int cycles = 30;
- Cell[] cells = getCells(count);
+ ExtendedCell[] cells = getCells(count);
int size = getRoughSize(cells);
int initialBufferSize = 2 * size; // Multiply by 2 to ensure we don't have to grow buffer
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/TestCellMessageCodec.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/TestCellMessageCodec.java
index d580c3d7ff1..657f770dd32 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/TestCellMessageCodec.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/codec/TestCellMessageCodec.java
@@ -26,10 +26,10 @@ import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes;
@@ -116,14 +116,14 @@ public class TestCellMessageCodec {
DataInputStream dis = new DataInputStream(cis);
Codec.Decoder decoder = cmc.getDecoder(dis);
assertTrue(decoder.advance());
- Cell c = decoder.current();
- assertTrue(CellUtil.equals(c, kv1));
+ ExtendedCell c = decoder.current();
+ assertTrue(PrivateCellUtil.equals(c, kv1));
assertTrue(decoder.advance());
c = decoder.current();
- assertTrue(CellUtil.equals(c, kv2));
+ assertTrue(PrivateCellUtil.equals(c, kv2));
assertTrue(decoder.advance());
c = decoder.current();
- assertTrue(CellUtil.equals(c, kv3));
+ assertTrue(PrivateCellUtil.equals(c, kv3));
assertFalse(decoder.advance());
dis.close();
assertEquals(offset, cis.getCount());
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPassCustomCellViaRegionObserver.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPassCustomCellViaRegionObserver.java
deleted file mode 100644
index b00296f213f..00000000000
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPassCustomCellViaRegionObserver.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.hbase.coprocessor;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Optional;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellUtil;
-import org.apache.hadoop.hbase.CompareOperator;
-import org.apache.hadoop.hbase.HBaseClassTestRule;
-import org.apache.hadoop.hbase.HBaseTestingUtil;
-import org.apache.hadoop.hbase.HConstants;
-import org.apache.hadoop.hbase.KeyValueUtil;
-import org.apache.hadoop.hbase.TableName;
-import org.apache.hadoop.hbase.client.Admin;
-import org.apache.hadoop.hbase.client.Append;
-import org.apache.hadoop.hbase.client.ColumnFamilyDescriptorBuilder;
-import org.apache.hadoop.hbase.client.Delete;
-import org.apache.hadoop.hbase.client.Durability;
-import org.apache.hadoop.hbase.client.Get;
-import org.apache.hadoop.hbase.client.Increment;
-import org.apache.hadoop.hbase.client.Put;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.Table;
-import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
-import org.apache.hadoop.hbase.filter.ByteArrayComparable;
-import org.apache.hadoop.hbase.testclassification.CoprocessorTests;
-import org.apache.hadoop.hbase.testclassification.MediumTests;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.hadoop.hbase.wal.WALEdit;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TestName;
-
-@Category({ CoprocessorTests.class, MediumTests.class })
-public class TestPassCustomCellViaRegionObserver {
-
- @ClassRule
- public static final HBaseClassTestRule CLASS_RULE =
- HBaseClassTestRule.forClass(TestPassCustomCellViaRegionObserver.class);
-
- @Rule
- public TestName testName = new TestName();
-
- private TableName tableName;
- private Table table = null;
-
- private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
-
- private static final byte[] ROW = Bytes.toBytes("ROW");
- private static final byte[] FAMILY = Bytes.toBytes("FAMILY");
- private static final byte[] QUALIFIER = Bytes.toBytes("QUALIFIER");
- private static final byte[] VALUE = Bytes.toBytes(10L);
- private static final byte[] APPEND_VALUE = Bytes.toBytes("MB");
-
- private static final byte[] QUALIFIER_FROM_CP = Bytes.toBytes("QUALIFIER_FROM_CP");
-
- @BeforeClass
- public static void setupBeforeClass() throws Exception {
- // small retry number can speed up the failed tests.
- UTIL.getConfiguration().setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 2);
- UTIL.startMiniCluster();
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception {
- UTIL.shutdownMiniCluster();
- }
-
- @Before
- public void clearTable() throws IOException {
- RegionObserverImpl.COUNT.set(0);
- tableName = TableName.valueOf(testName.getMethodName());
- if (table != null) {
- table.close();
- }
- try (Admin admin = UTIL.getAdmin()) {
- for (TableName name : admin.listTableNames()) {
- try {
- admin.disableTable(name);
- } catch (IOException e) {
- }
- admin.deleteTable(name);
- }
- table = UTIL.createTable(TableDescriptorBuilder.newBuilder(tableName)
- .setColumnFamily(ColumnFamilyDescriptorBuilder.of(FAMILY))
- .setCoprocessor(RegionObserverImpl.class.getName()).build(), null);
- }
- }
-
- @Test
- public void testMutation() throws Exception {
-
- Put put = new Put(ROW);
- put.addColumn(FAMILY, QUALIFIER, VALUE);
- table.put(put);
- byte[] value = VALUE;
- assertResult(table.get(new Get(ROW)), value, value);
- assertObserverHasExecuted();
-
- Increment inc = new Increment(ROW);
- inc.addColumn(FAMILY, QUALIFIER, 10L);
- table.increment(inc);
- // QUALIFIER -> 10 (put) + 10 (increment)
- // QUALIFIER_FROM_CP -> 10 (from cp's put) + 10 (from cp's increment)
- value = Bytes.toBytes(20L);
- assertResult(table.get(new Get(ROW)), value, value);
- assertObserverHasExecuted();
-
- Append append = new Append(ROW);
- append.addColumn(FAMILY, QUALIFIER, APPEND_VALUE);
- table.append(append);
- // 10L + "MB"
- value = ByteBuffer.wrap(new byte[value.length + APPEND_VALUE.length]).put(value)
- .put(APPEND_VALUE).array();
- assertResult(table.get(new Get(ROW)), value, value);
- assertObserverHasExecuted();
-
- Delete delete = new Delete(ROW);
- delete.addColumns(FAMILY, QUALIFIER);
- table.delete(delete);
- assertTrue(Arrays.asList(table.get(new Get(ROW)).rawCells()).toString(),
- table.get(new Get(ROW)).isEmpty());
- assertObserverHasExecuted();
-
- assertTrue(table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifNotExists().thenPut(put));
- assertObserverHasExecuted();
-
- assertTrue(
- table.checkAndMutate(ROW, FAMILY).qualifier(QUALIFIER).ifEquals(VALUE).thenDelete(delete));
- assertObserverHasExecuted();
-
- assertTrue(table.get(new Get(ROW)).isEmpty());
- }
-
- @Test
- public void testMultiPut() throws Exception {
- List<Put> puts =
- IntStream.range(0, 10).mapToObj(i -> new Put(ROW).addColumn(FAMILY, Bytes.toBytes(i), VALUE))
- .collect(Collectors.toList());
- table.put(puts);
- assertResult(table.get(new Get(ROW)), VALUE);
- assertObserverHasExecuted();
-
- List<Delete> deletes =
- IntStream.range(0, 10).mapToObj(i -> new Delete(ROW).addColumn(FAMILY, Bytes.toBytes(i)))
- .collect(Collectors.toList());
- table.delete(deletes);
- assertTrue(table.get(new Get(ROW)).isEmpty());
- assertObserverHasExecuted();
- }
-
- private static void assertObserverHasExecuted() {
- assertTrue(RegionObserverImpl.COUNT.getAndSet(0) > 0);
- }
-
- private static void assertResult(Result result, byte[] expectedValue) {
- assertFalse(result.isEmpty());
- for (Cell c : result.rawCells()) {
- assertTrue(c.toString(), Bytes.equals(ROW, CellUtil.cloneRow(c)));
- assertTrue(c.toString(), Bytes.equals(FAMILY, CellUtil.cloneFamily(c)));
- assertTrue(c.toString(), Bytes.equals(expectedValue, CellUtil.cloneValue(c)));
- }
- }
-
- private static void assertResult(Result result, byte[] expectedValue, byte[] expectedFromCp) {
- assertFalse(result.isEmpty());
- for (Cell c : result.rawCells()) {
- assertTrue(c.toString(), Bytes.equals(ROW, CellUtil.cloneRow(c)));
- assertTrue(c.toString(), Bytes.equals(FAMILY, CellUtil.cloneFamily(c)));
- if (Bytes.equals(QUALIFIER, CellUtil.cloneQualifier(c))) {
- assertTrue(c.toString(), Bytes.equals(expectedValue, CellUtil.cloneValue(c)));
- } else if (Bytes.equals(QUALIFIER_FROM_CP, CellUtil.cloneQualifier(c))) {
- assertTrue(c.toString(), Bytes.equals(expectedFromCp, CellUtil.cloneValue(c)));
- } else {
- fail("No valid qualifier");
- }
- }
- }
-
- private static Cell createCustomCell(byte[] row, byte[] family, byte[] qualifier, Cell.Type type,
- byte[] value) {
- return new Cell() {
-
- @Override
- public long heapSize() {
- return 0;
- }
-
- private byte[] getArray(byte[] array) {
- return array == null ? HConstants.EMPTY_BYTE_ARRAY : array;
- }
-
- private int length(byte[] array) {
- return array == null ? 0 : array.length;
- }
-
- @Override
- public byte[] getRowArray() {
- return getArray(row);
- }
-
- @Override
- public int getRowOffset() {
- return 0;
- }
-
- @Override
- public short getRowLength() {
- return (short) length(row);
- }
-
- @Override
- public byte[] getFamilyArray() {
- return getArray(family);
- }
-
- @Override
- public int getFamilyOffset() {
- return 0;
- }
-
- @Override
- public byte getFamilyLength() {
- return (byte) length(family);
- }
-
- @Override
- public byte[] getQualifierArray() {
- return getArray(qualifier);
- }
-
- @Override
- public int getQualifierOffset() {
- return 0;
- }
-
- @Override
- public int getQualifierLength() {
- return length(qualifier);
- }
-
- @Override
- public long getTimestamp() {
- return HConstants.LATEST_TIMESTAMP;
- }
-
- @Override
- public byte getTypeByte() {
- return type.getCode();
- }
-
- @Override
- public long getSequenceId() {
- return 0;
- }
-
- @Override
- public byte[] getValueArray() {
- return getArray(value);
- }
-
- @Override
- public int getValueOffset() {
- return 0;
- }
-
- @Override
- public int getValueLength() {
- return length(value);
- }
-
- @Override
- public int getSerializedSize() {
- return KeyValueUtil.getSerializedSize(this, true);
- }
-
- @Override
- public byte[] getTagsArray() {
- return getArray(null);
- }
-
- @Override
- public int getTagsOffset() {
- return 0;
- }
-
- @Override
- public int getTagsLength() {
- return length(null);
- }
-
- @Override
- public Type getType() {
- return type;
- }
- };
- }
-
- private static Cell createCustomCell(Put put) {
- return createCustomCell(put.getRow(), FAMILY, QUALIFIER_FROM_CP, Cell.Type.Put, VALUE);
- }
-
- private static Cell createCustomCell(Append append) {
- return createCustomCell(append.getRow(), FAMILY, QUALIFIER_FROM_CP, Cell.Type.Put,
- APPEND_VALUE);
- }
-
- private static Cell createCustomCell(Increment inc) {
- return createCustomCell(inc.getRow(), FAMILY, QUALIFIER_FROM_CP, Cell.Type.Put, VALUE);
- }
-
- private static Cell createCustomCell(Delete delete) {
- return createCustomCell(delete.getRow(), FAMILY, QUALIFIER_FROM_CP, Cell.Type.DeleteColumn,
- null);
- }
-
- public static class RegionObserverImpl implements RegionCoprocessor, RegionObserver {
- static final AtomicInteger COUNT = new AtomicInteger(0);
-
- @Override
- public Optional<RegionObserver> getRegionObserver() {
- return Optional.of(this);
- }
-
- @Override
- public void prePut(ObserverContext<RegionCoprocessorEnvironment> c, Put put, WALEdit edit,
- Durability durability) throws IOException {
- put.add(createCustomCell(put));
- COUNT.incrementAndGet();
- }
-
- @Override
- public void preDelete(ObserverContext<RegionCoprocessorEnvironment> c, Delete delete,
- WALEdit edit, Durability durability) throws IOException {
- delete.add(createCustomCell(delete));
- COUNT.incrementAndGet();
- }
-
- @Override
- public boolean preCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row,
- byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator, Put put,
- boolean result) throws IOException {
- put.add(createCustomCell(put));
- COUNT.incrementAndGet();
- return result;
- }
-
- @Override
- public boolean preCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row,
- byte[] family, byte[] qualifier, CompareOperator op, ByteArrayComparable comparator,
- Delete delete, boolean result) throws IOException {
- delete.add(createCustomCell(delete));
- COUNT.incrementAndGet();
- return result;
- }
-
- @Override
- public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> c, Append append)
- throws IOException {
- append.add(createCustomCell(append));
- COUNT.incrementAndGet();
- return null;
- }
-
- @Override
- public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment)
- throws IOException {
- increment.add(createCustomCell(increment));
- COUNT.incrementAndGet();
- return null;
- }
-
- }
-
-}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPostIncrementAndAppendBeforeWAL.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPostIncrementAndAppendBeforeWAL.java
index 406618295ca..64f47e1d1ba 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPostIncrementAndAppendBeforeWAL.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/coprocessor/TestPostIncrementAndAppendBeforeWAL.java
@@ -30,6 +30,7 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -247,7 +248,7 @@ public class TestPostIncrementAndAppendBeforeWAL {
}
}
- private static boolean checkAclTag(byte[] acl, Cell cell) {
+ private static boolean checkAclTag(byte[] acl, ExtendedCell cell) {
Iterator<Tag> iter = PrivateCellUtil.tagsIterator(cell);
while (iter.hasNext()) {
Tag tag = iter.next();
@@ -342,7 +343,10 @@ public class TestPostIncrementAndAppendBeforeWAL {
List<Pair<Cell, Cell>> cellPairs) throws IOException {
List<Pair<Cell, Cell>> result = super.postIncrementBeforeWAL(ctx, mutation, cellPairs);
for (Pair<Cell, Cell> pair : result) {
- if (mutation.getACL() != null && !checkAclTag(mutation.getACL(), pair.getSecond())) {
+ if (
+ mutation.getACL() != null
+ && !checkAclTag(mutation.getACL(), (ExtendedCell) pair.getSecond())
+ ) {
throw new DoNotRetryIOException("Unmatched ACL tag.");
}
}
@@ -355,7 +359,10 @@ public class TestPostIncrementAndAppendBeforeWAL {
List<Pair<Cell, Cell>> cellPairs) throws IOException {
List<Pair<Cell, Cell>> result = super.postAppendBeforeWAL(ctx, mutation, cellPairs);
for (Pair<Cell, Cell> pair : result) {
- if (mutation.getACL() != null && !checkAclTag(mutation.getACL(), pair.getSecond())) {
+ if (
+ mutation.getACL() != null
+ && !checkAclTag(mutation.getACL(), (ExtendedCell) pair.getSecond())
+ ) {
throw new DoNotRetryIOException("Unmatched ACL tag.");
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
index f64381a8a22..26144d4adea 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
@@ -31,6 +31,7 @@ import java.util.Objects;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CompareOperator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -554,12 +555,14 @@ public class TestFilterList {
// Value for fam:qual1 should be stripped:
assertEquals(Filter.ReturnCode.INCLUDE, flist.filterCell(kvQual1));
- final KeyValue transformedQual1 = KeyValueUtil.ensureKeyValue(flist.transformCell(kvQual1));
+ final KeyValue transformedQual1 =
+ KeyValueUtil.ensureKeyValue((ExtendedCell) flist.transformCell(kvQual1));
assertEquals(0, transformedQual1.getValueLength());
// Value for fam:qual2 should not be stripped:
assertEquals(Filter.ReturnCode.INCLUDE, flist.filterCell(kvQual2));
- final KeyValue transformedQual2 = KeyValueUtil.ensureKeyValue(flist.transformCell(kvQual2));
+ final KeyValue transformedQual2 =
+ KeyValueUtil.ensureKeyValue((ExtendedCell) flist.transformCell(kvQual2));
assertEquals("value", Bytes.toString(transformedQual2.getValueArray(),
transformedQual2.getValueOffset(), transformedQual2.getValueLength()));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/compress/HFileTestBase.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/compress/HFileTestBase.java
index 024fb04c687..afbaceebeea 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/compress/HFileTestBase.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/compress/HFileTestBase.java
@@ -27,7 +27,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
@@ -88,7 +88,7 @@ public class HFileTestBase {
scanner = reader.getScanner(conf, false, false);
assertTrue("Initial seekTo failed", scanner.seekTo());
do {
- Cell kv = scanner.getCell();
+ ExtendedCell kv = scanner.getCell();
assertTrue("Read back an unexpected or invalid KV",
testKvs.contains(KeyValueUtil.ensureKeyValue(kv)));
i++;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestBufferedDataBlockEncoder.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestBufferedDataBlockEncoder.java
index 68ce5e359f5..24d69d88c10 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestBufferedDataBlockEncoder.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestBufferedDataBlockEncoder.java
@@ -24,11 +24,11 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.nio.ByteBuffer;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValue.Type;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.codec.Codec.Decoder;
import org.apache.hadoop.hbase.codec.Codec.Encoder;
import org.apache.hadoop.hbase.codec.KeyValueCodecWithTags;
@@ -127,11 +127,11 @@ public class TestBufferedDataBlockEncoder {
ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
Decoder decoder = codec.getDecoder(is);
assertTrue(decoder.advance());
- assertTrue(CellUtil.equals(c1, decoder.current()));
+ assertTrue(PrivateCellUtil.equals(c1, decoder.current()));
assertTrue(decoder.advance());
- assertTrue(CellUtil.equals(c2, decoder.current()));
+ assertTrue(PrivateCellUtil.equals(c2, decoder.current()));
assertTrue(decoder.advance());
- assertTrue(CellUtil.equals(c3, decoder.current()));
+ assertTrue(PrivateCellUtil.equals(c3, decoder.current()));
assertFalse(decoder.advance());
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
index 6ae5a74ebe8..a37c5a5a5f9 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
@@ -327,7 +327,7 @@ public class TestDataBlockEncoders {
int i = 0;
do {
KeyValue expectedKeyValue = sampleKv.get(i);
- Cell cell = seeker.getCell();
+ ExtendedCell cell = seeker.getCell();
if (
PrivateCellUtil.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, expectedKeyValue,
cell) != 0
@@ -360,7 +360,7 @@ public class TestDataBlockEncoders {
DataBlockEncoder encoder = encoding.getEncoder();
ByteBuffer encodedBuffer = encodeKeyValues(encoding, sampleKv,
getEncodingContext(conf, Compression.Algorithm.NONE, encoding), this.useOffheapData);
- Cell key = encoder.getFirstKeyCellInBlock(new SingleByteBuff(encodedBuffer));
+ ExtendedCell key = encoder.getFirstKeyCellInBlock(new SingleByteBuff(encodedBuffer));
KeyValue firstKv = sampleKv.get(0);
if (0 != PrivateCellUtil.compareKeyIgnoresMvcc(CellComparatorImpl.COMPARATOR, key, firstKv)) {
int commonPrefix = PrivateCellUtil.findCommonPrefixInFlatKey(key, firstKv, false, true);
@@ -394,20 +394,20 @@ public class TestDataBlockEncoders {
private void checkSeekingConsistency(List<DataBlockEncoder.EncodedSeeker> encodedSeekers,
boolean seekBefore, ExtendedCell keyValue) {
- Cell expectedKeyValue = null;
+ ExtendedCell expectedKeyValue = null;
ByteBuffer expectedKey = null;
ByteBuffer expectedValue = null;
for (DataBlockEncoder.EncodedSeeker seeker : encodedSeekers) {
seeker.seekToKeyInBlock(keyValue, seekBefore);
seeker.rewind();
- Cell actualKeyValue = seeker.getCell();
+ ExtendedCell actualKeyValue = seeker.getCell();
ByteBuffer actualKey = null;
actualKey = ByteBuffer.wrap(((KeyValue) seeker.getKey()).getKey());
ByteBuffer actualValue = seeker.getValueShallowCopy();
if (expectedKeyValue != null) {
- assertTrue(CellUtil.equals(expectedKeyValue, actualKeyValue));
+ assertTrue(PrivateCellUtil.equals(expectedKeyValue, actualKeyValue));
} else {
expectedKeyValue = actualKeyValue;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileEncryption.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileEncryption.java
index f3711428ce5..663c0d54049 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileEncryption.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFileEncryption.java
@@ -34,7 +34,7 @@ import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -244,7 +244,7 @@ public class TestHFileEncryption {
scanner = reader.getScanner(conf, false, false);
assertTrue("Initial seekTo failed", scanner.seekTo());
do {
- Cell kv = scanner.getCell();
+ ExtendedCell kv = scanner.getCell();
assertTrue("Read back an unexpected or invalid KV",
testKvs.contains(KeyValueUtil.ensureKeyValue(kv)));
i++;
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
index 837ee17110e..ec1ebfd9d63 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestScannerFromBucketCache.java
@@ -26,7 +26,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -116,9 +116,9 @@ public class TestScannerFromBucketCache {
String method = this.getName();
this.region = initHRegion(tableName, method, conf, test_util, fam1);
try {
- List<Cell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, false);
+ List<ExtendedCell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, false);
- List<Cell> actual = performScan(row1, fam1);
+ List<ExtendedCell> actual = performScan(row1, fam1);
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof ByteBufferKeyValue);
@@ -154,9 +154,9 @@ public class TestScannerFromBucketCache {
String method = this.getName();
this.region = initHRegion(tableName, method, conf, test_util, fam1);
try {
- List<Cell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, false);
+ List<ExtendedCell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, false);
- List<Cell> actual = performScan(row1, fam1);
+ List<ExtendedCell> actual = performScan(row1, fam1);
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof ByteBufferKeyValue);
@@ -195,9 +195,9 @@ public class TestScannerFromBucketCache {
String method = this.getName();
this.region = initHRegion(tableName, method, conf, test_util, fam1);
try {
- List<Cell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, true);
+ List<ExtendedCell> expected = insertData(row1, qf1, qf2, fam1, ts1, ts2, ts3, true);
- List<Cell> actual = performScan(row1, fam1);
+ List<ExtendedCell> actual = performScan(row1, fam1);
// Verify result
for (int i = 0; i < expected.size(); i++) {
assertFalse(actual.get(i) instanceof ByteBufferKeyValue);
@@ -211,7 +211,7 @@ public class TestScannerFromBucketCache {
actual = new ArrayList<>();
InternalScanner scanner = region.getScanner(scan);
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
// Verify result
for (int i = 0; i < expected.size(); i++) {
@@ -229,7 +229,7 @@ public class TestScannerFromBucketCache {
}
}
- private List<Cell> insertData(byte[] row1, byte[] qf1, byte[] qf2, byte[] fam1, long ts1,
+ private List<ExtendedCell> insertData(byte[] row1, byte[] qf1, byte[] qf2, byte[] fam1, long ts1,
long ts2, long ts3, boolean withVal) throws IOException {
// Putting data in Region
Put put = null;
@@ -276,7 +276,7 @@ public class TestScannerFromBucketCache {
}
// Expected
- List<Cell> expected = new ArrayList<>();
+ List<ExtendedCell> expected = new ArrayList<>();
expected.add(kv13);
expected.add(kv12);
expected.add(kv23);
@@ -284,12 +284,12 @@ public class TestScannerFromBucketCache {
return expected;
}
- private List<Cell> performScan(byte[] row1, byte[] fam1) throws IOException {
+ private List<ExtendedCell> performScan(byte[] row1, byte[] fam1) throws IOException {
Scan scan = new Scan().withStartRow(row1).addFamily(fam1).readVersions(MAX_VERSIONS);
- List<Cell> actual = new ArrayList<>();
+ List<ExtendedCell> actual = new ArrayList<>();
InternalScanner scanner = region.getScanner(scan);
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
return actual;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekBeforeWithInlineBlocks.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekBeforeWithInlineBlocks.java
index 04c38127d51..f07238e134d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekBeforeWithInlineBlocks.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekBeforeWithInlineBlocks.java
@@ -25,13 +25,13 @@ import java.util.Random;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.fs.HFileSystem;
import org.apache.hadoop.hbase.regionserver.BloomType;
import org.apache.hadoop.hbase.regionserver.StoreFileWriter;
@@ -178,8 +178,8 @@ public class TestSeekBeforeWithInlineBlocks {
}
/** Check a key/value pair after it was read by the reader */
- private void checkCell(Cell expected, Cell actual) {
+ private void checkCell(ExtendedCell expected, ExtendedCell actual) {
assertTrue(String.format("Expected key %s, but was %s", CellUtil.getCellKeyAsString(expected),
- CellUtil.getCellKeyAsString(actual)), CellUtil.equals(expected, actual));
+ CellUtil.getCellKeyAsString(actual)), PrivateCellUtil.equals(expected, actual));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
index bf26b019e2a..4c55c85f903 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestSeekTo.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.ByteBufferKeyValue;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -171,7 +172,7 @@ public class TestSeekTo {
assertEquals("g", toRowStr(scanner.getCell()));
assertTrue(scanner.seekBefore(toKV("j", tagUsage)));
assertEquals("i", toRowStr(scanner.getCell()));
- Cell cell = scanner.getCell();
+ ExtendedCell cell = scanner.getCell();
if (tagUsage != TagUsage.NO_TAG && cell.getTagsLength() > 0) {
Iterator<Tag> tagsIterator = PrivateCellUtil.tagsIterator(cell);
while (tagsIterator.hasNext()) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java
index 0f0c22baf9f..248e8f9d8ce 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/AbstractTestIPC.java
@@ -62,14 +62,14 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseServerBase;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.MatcherPredicate;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.Server;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.Waiter;
@@ -176,7 +176,7 @@ public abstract class AbstractTestIPC {
public void testCompressCellBlock() throws IOException, ServiceException {
Configuration clientConf = new Configuration(CONF);
clientConf.set("hbase.client.rpc.compressor", GzipCodec.class.getCanonicalName());
- List<Cell> cells = new ArrayList<>();
+ List<ExtendedCell> cells = new ArrayList<>();
int count = 3;
for (int i = 0; i < count; i++) {
cells.add(CELL);
@@ -188,7 +188,8 @@ public abstract class AbstractTestIPC {
try (AbstractRpcClient<?> client = createRpcClient(clientConf)) {
rpcServer.start();
BlockingInterface stub = newBlockingStub(client, rpcServer.getListenerAddress());
- HBaseRpcController pcrc = new HBaseRpcControllerImpl(CellUtil.createCellScanner(cells));
+ HBaseRpcController pcrc =
+ new HBaseRpcControllerImpl(PrivateCellUtil.createExtendedCellScanner(cells));
String message = "hello";
assertEquals(message,
stub.echo(pcrc, EchoRequestProto.newBuilder().setMessage(message).build()).getMessage());
@@ -270,9 +271,8 @@ public abstract class AbstractTestIPC {
}
// set total RPC size bigger than 100 bytes
EchoRequestProto param = EchoRequestProto.newBuilder().setMessage(message.toString()).build();
- stub.echo(
- new HBaseRpcControllerImpl(CellUtil.createCellScanner(ImmutableList.<Cell> of(CELL))),
- param);
+ stub.echo(new HBaseRpcControllerImpl(
+ PrivateCellUtil.createExtendedCellScanner(ImmutableList.<ExtendedCell> of(CELL))), param);
fail("RPC should have failed because it exceeds max request size");
} catch (ServiceException e) {
LOG.info("Caught expected exception: " + e);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
index 001f6dbd22c..64fc47ca194 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
@@ -32,13 +32,13 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompatibilityFactory;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
@@ -112,7 +112,7 @@ public class TestNettyChannelWritability {
private void sendAndReceive(Configuration conf, NettyRpcServer rpcServer, int requestCount)
throws Exception {
- List<Cell> cells = new ArrayList<>();
+ List<ExtendedCell> cells = new ArrayList<>();
int count = 3;
for (int i = 0; i < count; i++) {
cells.add(CELL);
@@ -136,9 +136,10 @@ public class TestNettyChannelWritability {
}
}
- private void sendMessage(List<Cell> cells,
+ private void sendMessage(List<ExtendedCell> cells,
TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface stub) throws Exception {
- HBaseRpcController pcrc = new HBaseRpcControllerImpl(CellUtil.createCellScanner(cells));
+ HBaseRpcController pcrc =
+ new HBaseRpcControllerImpl(PrivateCellUtil.createExtendedCellScanner(cells));
String message = "hello";
assertEquals(message,
stub.echo(pcrc, TestProtos.EchoRequestProto.newBuilder().setMessage(message).build())
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtobufRpcServiceImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtobufRpcServiceImpl.java
index b2ac0a3deb9..edb9a64a7a8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtobufRpcServiceImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestProtobufRpcServiceImpl.java
@@ -21,10 +21,10 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
-import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.CellScanner;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.DoNotRetryIOException;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
@@ -82,8 +82,8 @@ public class TestProtobufRpcServiceImpl implements BlockingInterface {
HBaseRpcController pcrc = (HBaseRpcController) controller;
// If cells, scan them to check we are able to iterate what we were given and since this is an
// echo, just put them back on the controller creating a new block. Tests our block building.
- CellScanner cellScanner = pcrc.cellScanner();
- List<Cell> list = null;
+ ExtendedCellScanner cellScanner = pcrc.cellScanner();
+ List<ExtendedCell> list = null;
if (cellScanner != null) {
list = new ArrayList<>();
try {
@@ -94,7 +94,7 @@ public class TestProtobufRpcServiceImpl implements BlockingInterface {
throw new ServiceException(e);
}
}
- cellScanner = CellUtil.createCellScanner(list);
+ cellScanner = PrivateCellUtil.createExtendedCellScanner(list);
pcrc.setCellScanner(cellScanner);
}
return EchoResponseProto.newBuilder().setMessage(request.getMessage()).build();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
index a7164a6fab6..a25bae6ec7b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/MockRegionServer.java
@@ -33,10 +33,10 @@ import java.util.concurrent.ThreadLocalRandom;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.hbase.Abortable;
-import org.apache.hadoop.hbase.CellScannable;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ChoreService;
import org.apache.hadoop.hbase.CoordinatedStateManager;
+import org.apache.hadoop.hbase.ExtendedCellScannable;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableDescriptors;
import org.apache.hadoop.hbase.TableName;
@@ -388,9 +388,10 @@ class MockRegionServer implements AdminProtos.AdminService.BlockingInterface,
Result result = next(scannerId);
if (result != null) {
builder.addCellsPerResult(result.size());
- List<CellScannable> results = new ArrayList<>(1);
+ List<ExtendedCellScannable> results = new ArrayList<>(1);
results.add(result);
- ((HBaseRpcController) controller).setCellScanner(CellUtil.createCellScanner(results));
+ ((HBaseRpcController) controller)
+ .setCellScanner(PrivateCellUtil.createExtendedCellScanner(results));
builder.setMoreResults(true);
} else {
builder.setMoreResults(false);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
index c2f2b3fd426..835d8b83d69 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/mob/TestMobStoreCompaction.java
@@ -39,6 +39,7 @@ import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -373,11 +374,11 @@ public class TestMobStoreCompaction {
InternalScanner scanner = region.getScanner(scan);
int scannedCount = 0;
- List<Cell> results = new ArrayList<>();
+ List<ExtendedCell> results = new ArrayList<>();
boolean hasMore = true;
while (hasMore) {
- hasMore = scanner.next(results);
- for (Cell c : results) {
+ hasMore = scanner.next((List) results);
+ for (ExtendedCell c : results) {
if (MobUtils.isMobReferenceCell(c)) {
scannedCount++;
}
@@ -401,15 +402,15 @@ public class TestMobStoreCompaction {
scan.setAttribute(MobConstants.MOB_SCAN_RAW, Bytes.toBytes(Boolean.TRUE));
InternalScanner scanner = region.getScanner(scan);
- List<Cell> kvs = new ArrayList<>();
+ List<ExtendedCell> kvs = new ArrayList<>();
boolean hasMore = true;
String fileName;
Set<String> files = new HashSet<>();
do {
kvs.clear();
- hasMore = scanner.next(kvs);
+ hasMore = scanner.next((List) kvs);
for (Cell kv : kvs) {
- if (!MobUtils.isMobReferenceCell(kv)) {
+ if (!MobUtils.isMobReferenceCell((ExtendedCell) kv)) {
continue;
}
if (!MobUtils.hasValidMobRefCellValue(kv)) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestNamedQueueRecorder.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestNamedQueueRecorder.java
index 124214e46af..05243bd93a6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestNamedQueueRecorder.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestNamedQueueRecorder.java
@@ -31,7 +31,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -717,7 +717,7 @@ public class TestNamedQueueRecorder {
}
@Override
- public CellScanner getCellScanner() {
+ public ExtendedCellScanner getCellScanner() {
return null;
}
@@ -783,7 +783,7 @@ public class TestNamedQueueRecorder {
}
@Override
- public void setResponse(Message param, CellScanner cells, Throwable errorThrowable,
+ public void setResponse(Message param, ExtendedCellScanner cells, Throwable errorThrowable,
String error) {
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestRpcLogDetails.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestRpcLogDetails.java
index 1de0a0d31a3..4ec3e90aad8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestRpcLogDetails.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/namequeues/TestRpcLogDetails.java
@@ -29,7 +29,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.ipc.RpcCall;
import org.apache.hadoop.hbase.ipc.RpcCallback;
@@ -118,7 +118,7 @@ public class TestRpcLogDetails {
}
@Override
- public CellScanner getCellScanner() {
+ public ExtendedCellScanner getCellScanner() {
return null;
}
@@ -182,7 +182,7 @@ public class TestRpcLogDetails {
}
@Override
- public void setResponse(Message param, CellScanner cells, Throwable errorThrowable,
+ public void setResponse(Message param, ExtendedCellScanner cells, Throwable errorThrowable,
String error) {
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestRegionProcedureStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestRegionProcedureStore.java
index fdd5c7d5cf9..b440431f1fb 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestRegionProcedureStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/procedure2/store/region/TestRegionProcedureStore.java
@@ -28,7 +28,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.ipc.RpcCall;
@@ -184,7 +184,7 @@ public class TestRegionProcedureStore extends RegionProcedureStoreTestBase {
}
@Override
- public CellScanner getCellScanner() {
+ public ExtendedCellScanner getCellScanner() {
return null;
}
@@ -244,7 +244,7 @@ public class TestRegionProcedureStore extends RegionProcedureStoreTestBase {
}
@Override
- public void setResponse(Message param, CellScanner cells, Throwable errorThrowable,
+ public void setResponse(Message param, ExtendedCellScanner cells, Throwable errorThrowable,
String error) {
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestReplicationProtobuf.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestReplicationProtobuf.java
index 5dd0ce8dafb..bfbeed76855 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestReplicationProtobuf.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestReplicationProtobuf.java
@@ -23,8 +23,8 @@ import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.testclassification.MiscTests;
@@ -46,19 +46,19 @@ public class TestReplicationProtobuf {
*/
@Test
public void testGetCellScanner() throws IOException {
- List<Cell> a = new ArrayList<>();
+ List<ExtendedCell> a = new ArrayList<>();
KeyValue akv = new KeyValue(Bytes.toBytes("a"), -1L);
a.add(akv);
// Add a few just to make it less regular.
a.add(new KeyValue(Bytes.toBytes("aa"), -1L));
a.add(new KeyValue(Bytes.toBytes("aaa"), -1L));
- List<Cell> b = new ArrayList<>();
+ List<ExtendedCell> b = new ArrayList<>();
KeyValue bkv = new KeyValue(Bytes.toBytes("b"), -1L);
a.add(bkv);
- List<Cell> c = new ArrayList<>();
+ List<ExtendedCell> c = new ArrayList<>();
KeyValue ckv = new KeyValue(Bytes.toBytes("c"), -1L);
c.add(ckv);
- List<List<? extends Cell>> all = new ArrayList<>();
+ List<List<? extends ExtendedCell>> all = new ArrayList<>();
all.add(a);
all.add(b);
all.add(c);
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java
index ec9de92e9f2..edabfc51f2b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/DataBlockEncodingTool.java
@@ -30,7 +30,7 @@ import java.util.Locale;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -251,7 +251,7 @@ public class DataBlockEncodingTool {
KeyValue currentKv;
scanner.seek(KeyValue.LOWESTKEY);
- List<Iterator<Cell>> codecIterators = new ArrayList<>();
+ List<Iterator<ExtendedCell>> codecIterators = new ArrayList<>();
for (EncodedDataBlock codec : codecs) {
codecIterators.add(codec.getIterator(HFileBlock.headerSize(useHBaseChecksum)));
}
@@ -260,8 +260,8 @@ public class DataBlockEncodingTool {
while ((currentKv = KeyValueUtil.ensureKeyValue(scanner.next())) != null && j < kvLimit) {
// Iterates through key/value pairs
++j;
- for (Iterator<Cell> it : codecIterators) {
- Cell c = it.next();
+ for (Iterator<ExtendedCell> it : codecIterators) {
+ ExtendedCell c = it.next();
KeyValue codecKv = KeyValueUtil.ensureKeyValue(c);
if (
codecKv == null
@@ -337,7 +337,7 @@ public class DataBlockEncodingTool {
for (int itTime = 0; itTime < benchmarkNTimes; ++itTime) {
totalSize = 0;
- Iterator<Cell> it;
+ Iterator<ExtendedCell> it;
it = codec.getIterator(HFileBlock.headerSize(useHBaseChecksum));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java
index 60137035774..f33faf8c8e0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/EncodedSeekPerformanceTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Random;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -97,7 +96,7 @@ public class EncodedSeekPerformanceTest {
StoreFileScanner scanner = reader.getStoreFileScanner(true, false, false, 0, 0, false);
long startReadingTime = System.nanoTime();
- Cell current;
+ ExtendedCell current;
scanner.seek(KeyValue.LOWESTKEY);
while (null != (current = scanner.next())) { // just iterate it!
if (KeyValueUtil.ensureKeyValue(current).getLength() < 0) {
@@ -111,7 +110,7 @@ public class EncodedSeekPerformanceTest {
long startSeeksTime = System.nanoTime();
for (ExtendedCell keyValue : seeks) {
scanner.seek(keyValue);
- Cell toVerify = scanner.next();
+ ExtendedCell toVerify = scanner.next();
if (!keyValue.equals(toVerify)) {
System.out
.println(String.format("KeyValue doesn't match:\n" + "Orig key: %s\n" + "Ret key: %s",
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
index 066eaf53cc1..0d0b2d08783 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBlocksScanned.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValueUtil;
@@ -114,8 +114,8 @@ public class TestBlocksScanned {
scan.readVersions(1);
InternalScanner s = r.getScanner(scan);
- List<Cell> results = new ArrayList<>();
- while (s.next(results))
+ List<ExtendedCell> results = new ArrayList<>();
+ while (s.next((List) results))
;
s.close();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCellFlatSet.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCellFlatSet.java
index e2f9ac2f34a..52826e2e8e2 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCellFlatSet.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestCellFlatSet.java
@@ -31,11 +31,11 @@ import java.util.SortedSet;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparator;
-import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
+import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.io.util.MemorySizeUtil;
import org.apache.hadoop.hbase.regionserver.ChunkCreator.ChunkType;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
@@ -187,10 +187,10 @@ public class TestCellFlatSet {
Iterator<ExtendedCell> excludeIter = excludeTail.iterator();
Iterator<ExtendedCell> includeIter = includeTail.iterator();
for (int j = 1 + i; j != ascCells.length; ++j) {
- assertEquals(true, CellUtil.equals(excludeIter.next(), ascCells[j]));
+ assertEquals(true, PrivateCellUtil.equals(excludeIter.next(), ascCells[j]));
}
for (int j = i; j != ascCells.length; ++j) {
- assertEquals(true, CellUtil.equals(includeIter.next(), ascCells[j]));
+ assertEquals(true, PrivateCellUtil.equals(includeIter.next(), ascCells[j]));
}
}
assertEquals(NUM_OF_CELLS, cs.tailSet(lowerOuterCell, false).size());
@@ -203,10 +203,10 @@ public class TestCellFlatSet {
Iterator<ExtendedCell> excludeIter = excludeHead.iterator();
Iterator<ExtendedCell> includeIter = includeHead.iterator();
for (int j = 0; j != i; ++j) {
- assertEquals(true, CellUtil.equals(excludeIter.next(), ascCells[j]));
+ assertEquals(true, PrivateCellUtil.equals(excludeIter.next(), ascCells[j]));
}
for (int j = 0; j != i + 1; ++j) {
- assertEquals(true, CellUtil.equals(includeIter.next(), ascCells[j]));
+ assertEquals(true, PrivateCellUtil.equals(includeIter.next(), ascCells[j]));
}
}
assertEquals(0, cs.headSet(lowerOuterCell, false).size());
@@ -217,7 +217,7 @@ public class TestCellFlatSet {
assertEquals(NUM_OF_CELLS, sub.size());
Iterator<ExtendedCell> iter = sub.values().iterator();
for (int i = 0; i != ascCells.length; ++i) {
- assertEquals(true, CellUtil.equals(iter.next(), ascCells[i]));
+ assertEquals(true, PrivateCellUtil.equals(iter.next(), ascCells[i]));
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java
index 53e183f8259..c9e6cd83ec6 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHMobStore.java
@@ -311,15 +311,15 @@ public class TestHMobStore {
InternalScanner scanner = (InternalScanner) store.getScanner(scan,
scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
- List<Cell> results = new ArrayList<>();
- scanner.next(results);
+ List<ExtendedCell> results = new ArrayList<>();
+ scanner.next((List) results);
Collections.sort(results, CellComparatorImpl.COMPARATOR);
scanner.close();
// Compare
Assert.assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
- Cell cell = results.get(i);
+ ExtendedCell cell = results.get(i);
Assert.assertTrue(MobUtils.isMobReferenceCell(cell));
}
}
@@ -399,15 +399,15 @@ public class TestHMobStore {
InternalScanner scanner = (InternalScanner) store.getScanner(scan,
scan.getFamilyMap().get(store.getColumnFamilyDescriptor().getName()), 0);
- List<Cell> results = new ArrayList<>();
- scanner.next(results);
+ List<ExtendedCell> results = new ArrayList<>();
+ scanner.next((List) results);
Collections.sort(results, CellComparatorImpl.COMPARATOR);
scanner.close();
// Compare
Assert.assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
- Cell cell = results.get(i);
+ ExtendedCell cell = results.get(i);
// this is not mob reference cell.
Assert.assertFalse(MobUtils.isMobReferenceCell(cell));
Assert.assertEquals(expected.get(i), results.get(i));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
index a271920c015..d9856b40a83 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java
@@ -82,6 +82,7 @@ import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.CompatibilitySingletonFactory;
import org.apache.hadoop.hbase.DoNotRetryIOException;
import org.apache.hadoop.hbase.DroppedSnapshotException;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
@@ -3780,26 +3781,26 @@ public class TestHRegion {
scan.addFamily(fam2);
scan.addFamily(fam4);
try (InternalScanner is = region.getScanner(scan)) {
- List<Cell> res = null;
+ List<ExtendedCell> res = null;
// Result 1
- List<Cell> expected1 = new ArrayList<>();
+ List<ExtendedCell> expected1 = new ArrayList<>();
expected1.add(new KeyValue(row1, fam2, null, ts, KeyValue.Type.Put, null));
expected1.add(new KeyValue(row1, fam4, null, ts, KeyValue.Type.Put, null));
res = new ArrayList<>();
- is.next(res);
+ is.next((List) res);
for (int i = 0; i < res.size(); i++) {
assertTrue(PrivateCellUtil.equalsIgnoreMvccVersion(expected1.get(i), res.get(i)));
}
// Result 2
- List<Cell> expected2 = new ArrayList<>();
+ List<ExtendedCell> expected2 = new ArrayList<>();
expected2.add(new KeyValue(row2, fam2, null, ts, KeyValue.Type.Put, null));
expected2.add(new KeyValue(row2, fam4, null, ts, KeyValue.Type.Put, null));
res = new ArrayList<>();
- is.next(res);
+ is.next((List) res);
for (int i = 0; i < res.size(); i++) {
assertTrue(PrivateCellUtil.equalsIgnoreMvccVersion(expected2.get(i), res.get(i)));
}
@@ -3894,7 +3895,7 @@ public class TestHRegion {
region.flush(true);
// Expected
- List<Cell> expected = new ArrayList<>();
+ List<ExtendedCell> expected = new ArrayList<>();
expected.add(kv13);
expected.add(kv12);
expected.add(kv23);
@@ -3904,9 +3905,9 @@ public class TestHRegion {
scan.addColumn(fam1, qf1);
scan.addColumn(fam1, qf2);
scan.readVersions(MAX_VERSIONS);
- List<Cell> actual = new ArrayList<>();
+ List<ExtendedCell> actual = new ArrayList<>();
try (InternalScanner scanner = region.getScanner(scan)) {
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
// Verify result
@@ -3968,7 +3969,7 @@ public class TestHRegion {
region.put(put);
// Expected
- List<Cell> expected = new ArrayList<>();
+ List<ExtendedCell> expected = new ArrayList<>();
expected.add(kv14);
expected.add(kv13);
expected.add(kv12);
@@ -3981,9 +3982,9 @@ public class TestHRegion {
scan.addColumn(fam1, qf2);
int versions = 3;
scan.readVersions(versions);
- List<Cell> actual = new ArrayList<>();
+ List<ExtendedCell> actual = new ArrayList<>();
try (InternalScanner scanner = region.getScanner(scan)) {
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
// Verify result
@@ -4082,7 +4083,7 @@ public class TestHRegion {
region.flush(true);
// Expected
- List<Cell> expected = new ArrayList<>();
+ List<ExtendedCell> expected = new ArrayList<>();
expected.add(kv13);
expected.add(kv12);
expected.add(kv23);
@@ -4091,9 +4092,9 @@ public class TestHRegion {
Scan scan = new Scan().withStartRow(row1);
scan.addFamily(fam1);
scan.readVersions(MAX_VERSIONS);
- List<Cell> actual = new ArrayList<>();
+ List<ExtendedCell> actual = new ArrayList<>();
try (InternalScanner scanner = region.getScanner(scan)) {
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
// Verify result
@@ -4207,9 +4208,9 @@ public class TestHRegion {
Scan scan = new Scan().withStartRow(row1);
int versions = 3;
scan.readVersions(versions);
- List<Cell> actual = new ArrayList<>();
+ List<ExtendedCell> actual = new ArrayList<>();
try (InternalScanner scanner = region.getScanner(scan)) {
- boolean hasNext = scanner.next(actual);
+ boolean hasNext = scanner.next((List) actual);
assertEquals(false, hasNext);
// Verify result
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
index 7b8fcf4e334..6a410f953fe 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegionServerBulkLoad.java
@@ -35,6 +35,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -397,8 +398,8 @@ public class TestHRegionServerBulkLoad {
@Override
public void visitLogEntryBeforeWrite(RegionInfo info, WALKey logKey, WALEdit logEdit) {
for (Cell cell : logEdit.getCells()) {
- KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
- for (Map.Entry entry : kv.toStringMap().entrySet()) {
+ KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) cell);
+ for (Map.Entry<String, Object> entry : kv.toStringMap().entrySet()) {
if (entry.getValue().equals(Bytes.toString(WALEdit.BULK_LOAD))) {
found = true;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
index a3fa1bb65db..13f2101c004 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java
@@ -2113,7 +2113,7 @@ public class TestHStore {
(StoreScanner) store.getScanner(new Scan(new Get(rowKey1)), quals, seqId + 1);
SegmentScanner segmentScanner = getTypeKeyValueScanner(storeScanner, SegmentScanner.class);
ExtendedCell resultCell1 = segmentScanner.next();
- assertTrue(CellUtil.equals(resultCell1, originalCell1));
+ assertTrue(PrivateCellUtil.equals(resultCell1, originalCell1));
int cell1ChunkId = resultCell1.getChunkId();
assertTrue(cell1ChunkId != ExtendedCell.CELL_NOT_BASED_ON_CHUNK);
assertNull(segmentScanner.next());
@@ -2140,12 +2140,12 @@ public class TestHStore {
// {@link CellChunkMap#getCell} we could not get the data chunk by chunkId.
storeScanner = (StoreScanner) store.getScanner(new Scan(new Get(rowKey1)), quals, seqId + 1);
segmentScanner = getTypeKeyValueScanner(storeScanner, SegmentScanner.class);
- Cell newResultCell1 = segmentScanner.next();
+ ExtendedCell newResultCell1 = segmentScanner.next();
assertTrue(newResultCell1 != resultCell1);
- assertTrue(CellUtil.equals(newResultCell1, originalCell1));
+ assertTrue(PrivateCellUtil.equals(newResultCell1, originalCell1));
- Cell resultCell2 = segmentScanner.next();
- assertTrue(CellUtil.equals(resultCell2, originalCell2));
+ ExtendedCell resultCell2 = segmentScanner.next();
+ assertTrue(PrivateCellUtil.equals(resultCell2, originalCell2));
assertNull(segmentScanner.next());
segmentScanner.close();
storeScanner.close();
@@ -2569,17 +2569,17 @@ public class TestHStore {
assertTrue(!memStoreLAB.chunks.isEmpty());
assertTrue(!memStoreLAB.isReclaimed());
- Cell cell1 = segmentScanner.next();
- CellUtil.equals(smallCell, cell1);
- Cell cell2 = segmentScanner.next();
- CellUtil.equals(largeCell, cell2);
+ ExtendedCell cell1 = segmentScanner.next();
+ PrivateCellUtil.equals(smallCell, cell1);
+ ExtendedCell cell2 = segmentScanner.next();
+ PrivateCellUtil.equals(largeCell, cell2);
assertNull(segmentScanner.next());
} else {
- List<Cell> results = new ArrayList<>();
- storeScanner.next(results);
+ List<ExtendedCell> results = new ArrayList<>();
+ storeScanner.next((List) results);
assertEquals(2, results.size());
- CellUtil.equals(smallCell, results.get(0));
- CellUtil.equals(largeCell, results.get(1));
+ PrivateCellUtil.equals(smallCell, results.get(0));
+ PrivateCellUtil.equals(largeCell, results.get(1));
}
assertTrue(exceptionRef.get() == null);
} finally {
@@ -2712,11 +2712,11 @@ public class TestHStore {
assertTrue(storeScanner.currentScanners.size() == 1);
assertTrue(storeScanner.currentScanners.get(0) instanceof StoreFileScanner);
- List<Cell> results = new ArrayList<>();
- storeScanner.next(results);
+ List<ExtendedCell> results = new ArrayList<>();
+ storeScanner.next((List) results);
assertEquals(2, results.size());
- CellUtil.equals(smallCell, results.get(0));
- CellUtil.equals(largeCell, results.get(1));
+ PrivateCellUtil.equals(smallCell, results.get(0));
+ PrivateCellUtil.equals(largeCell, results.get(1));
} finally {
if (storeScanner != null) {
storeScanner.close();
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
index 824c195fd0f..3db0b3d3f64 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStoreFile.java
@@ -45,6 +45,7 @@ import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -1058,8 +1059,8 @@ public class TestHStoreFile {
readerTwo.loadFileInfo();
StoreFileScanner scannerTwo = getStoreFileScanner(readerTwo, true, true);
scannerTwo.seek(KeyValue.LOWESTKEY);
- Cell kv1 = null;
- Cell kv2 = null;
+ ExtendedCell kv1 = null;
+ ExtendedCell kv2 = null;
while ((kv1 = scannerOne.next()) != null) {
kv2 = scannerTwo.next();
assertTrue(kv1.equals(kv2));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java
index f9c332564d9..fdaa19dc3e5 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestKeepDeletes.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -349,8 +350,8 @@ public class TestKeepDeletes {
s.setRaw(true);
s.readAllVersions();
InternalScanner scan = region.getScanner(s);
- List<Cell> kvs = new ArrayList<>();
- scan.next(kvs);
+ List<ExtendedCell> kvs = new ArrayList<>();
+ scan.next((List) kvs);
assertEquals(8, kvs.size());
assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(0)));
assertArrayEquals(CellUtil.cloneValue(kvs.get(1)), T3);
@@ -369,7 +370,7 @@ public class TestKeepDeletes {
s.setTimeRange(0, 1);
scan = region.getScanner(s);
kvs = new ArrayList<>();
- scan.next(kvs);
+ scan.next((List) kvs);
// nothing in this interval, not even delete markers
assertTrue(kvs.isEmpty());
@@ -380,7 +381,7 @@ public class TestKeepDeletes {
s.setTimeRange(0, ts + 2);
scan = region.getScanner(s);
kvs = new ArrayList<>();
- scan.next(kvs);
+ scan.next((List) kvs);
assertEquals(4, kvs.size());
assertTrue(PrivateCellUtil.isDeleteFamily(kvs.get(0)));
assertArrayEquals(CellUtil.cloneValue(kvs.get(1)), T1);
@@ -395,7 +396,7 @@ public class TestKeepDeletes {
s.setTimeRange(ts + 3, ts + 5);
scan = region.getScanner(s);
kvs = new ArrayList<>();
- scan.next(kvs);
+ scan.next((List) kvs);
assertEquals(2, kvs.size());
assertArrayEquals(CellUtil.cloneValue(kvs.get(0)), T3);
assertTrue(CellUtil.isDelete(kvs.get(1)));
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java
index 0f55805f6fd..0db4175916d 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMultiColumnScanner.java
@@ -36,6 +36,7 @@ import java.util.concurrent.ThreadLocalRandom;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueTestUtil;
@@ -210,15 +211,15 @@ public abstract class TestMultiColumnScanner {
}
InternalScanner scanner = region.getScanner(scan);
- List<Cell> results = new ArrayList<>();
+ List<ExtendedCell> results = new ArrayList<>();
int kvPos = 0;
int numResults = 0;
String queryInfo = "columns queried: " + qualSet + " (columnBitMask=" + columnBitMask
+ "), maxVersions=" + maxVersions;
- while (scanner.next(results) || results.size() > 0) {
- for (Cell kv : results) {
+ while (scanner.next((List) results) || results.size() > 0) {
+ for (ExtendedCell kv : results) {
while (
kvPos < kvs.size()
&& !matchesQuery(kvs.get(kvPos), qualSet, maxVersions, lastDelTimeMap)
@@ -236,7 +237,7 @@ public abstract class TestMultiColumnScanner {
"Scanner returned additional key/value: " + kv + ", " + queryInfo + deleteInfo + ";",
kvPos < kvs.size());
assertTrue("Scanner returned wrong key/value; " + queryInfo + deleteInfo + ";",
- PrivateCellUtil.equalsIgnoreMvccVersion(kvs.get(kvPos), (kv)));
+ PrivateCellUtil.equalsIgnoreMvccVersion(kvs.get(kvPos), kv));
++kvPos;
++numResults;
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReplicateToReplica.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReplicateToReplica.java
index a3b4c9e0347..253ca876bd3 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReplicateToReplica.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestReplicateToReplica.java
@@ -40,7 +40,7 @@ import java.util.concurrent.CompletableFuture;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.hbase.CellScanner;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -251,7 +251,7 @@ public class TestReplicateToReplica {
private void replicate(Pair<List<WAL.Entry>, CompletableFuture<Void>> pair) throws IOException {
Pair<ReplicateWALEntryRequest,
- CellScanner> params = ReplicationProtobufUtil.buildReplicateWALEntryRequest(
+ ExtendedCellScanner> params = ReplicationProtobufUtil.buildReplicateWALEntryRequest(
pair.getFirst().toArray(new WAL.Entry[0]),
secondary.getRegionInfo().getEncodedNameAsBytes(), null, null, null);
for (WALEntry entry : params.getFirst().getEntryList()) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFileScannerWithTagCompression.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFileScannerWithTagCompression.java
index 67671fe12fe..e3ba4d85a3a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFileScannerWithTagCompression.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestStoreFileScannerWithTagCompression.java
@@ -26,7 +26,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.ArrayBackedTag;
-import org.apache.hadoop.hbase.Cell;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
@@ -93,7 +93,7 @@ public class TestStoreFileScannerWithTagCompression {
// Now do reseek with empty KV to position to the beginning of the file
KeyValue k = KeyValueUtil.createFirstOnRow(Bytes.toBytes("k2"));
s.reseek(k);
- Cell kv = s.next();
+ ExtendedCell kv = s.next();
kv = s.next();
kv = s.next();
byte[] key5 = Bytes.toBytes("k5");
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java
index 45b927c07af..b04a0054276 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestTags.java
@@ -29,6 +29,8 @@ import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
+import org.apache.hadoop.hbase.ExtendedCellScanner;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
@@ -489,7 +491,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
ResultScanner scanner = table.getScanner(new Scan());
Result result = scanner.next();
- KeyValue kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
List<Tag> tags = TestCoprocessorForTags.tags;
assertEquals(3L, Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
assertEquals(1, tags.size());
@@ -504,7 +506,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
scanner = table.getScanner(new Scan());
result = scanner.next();
- kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
tags = TestCoprocessorForTags.tags;
assertEquals(5L, Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
assertEquals(2, tags.size());
@@ -529,7 +531,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
scanner = table.getScanner(new Scan().withStartRow(row2));
result = scanner.next();
- kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
tags = TestCoprocessorForTags.tags;
assertEquals(4L, Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
assertEquals(1, tags.size());
@@ -549,7 +551,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
scanner = table.getScanner(new Scan().withStartRow(row3));
result = scanner.next();
- kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
tags = TestCoprocessorForTags.tags;
assertEquals(1, tags.size());
assertEquals("tag1", Bytes.toString(Tag.cloneValue(tags.get(0))));
@@ -563,7 +565,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
scanner = table.getScanner(new Scan().withStartRow(row3));
result = scanner.next();
- kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
tags = TestCoprocessorForTags.tags;
assertEquals(2, tags.size());
// We cannot assume the ordering of tags
@@ -587,7 +589,7 @@ public class TestTags {
TestCoprocessorForTags.checkTagPresence = true;
scanner = table.getScanner(new Scan().withStartRow(row4));
result = scanner.next();
- kv = KeyValueUtil.ensureKeyValue(result.getColumnLatestCell(f, q));
+ kv = KeyValueUtil.ensureKeyValue((ExtendedCell) result.getColumnLatestCell(f, q));
tags = TestCoprocessorForTags.tags;
assertEquals(1, tags.size());
assertEquals("tag2", Bytes.toString(Tag.cloneValue(tags.get(0))));
@@ -653,7 +655,7 @@ public class TestTags {
if (attribute != null) {
for (List<? extends Cell> edits : m.getFamilyCellMap().values()) {
for (Cell cell : edits) {
- KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+ KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) cell);
if (cf == null) {
cf = CellUtil.cloneFamily(kv);
}
@@ -696,9 +698,9 @@ public class TestTags {
if (results.size() > 0) {
// Check tag presence in the 1st cell in 1st Result
Result result = results.get(0);
- CellScanner cellScanner = result.cellScanner();
+ ExtendedCellScanner cellScanner = result.cellScanner();
if (cellScanner.advance()) {
- Cell cell = cellScanner.current();
+ ExtendedCell cell = cellScanner.current();
tags = PrivateCellUtil.getTags(cell);
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java
index 5359dec2e64..028de5066c8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/compactions/TestCompactor.java
@@ -203,7 +203,9 @@ public class TestCompactor {
@Override
public boolean next(List<Cell> result, ScannerContext scannerContext) throws IOException {
- if (kvs.isEmpty()) return false;
+ if (kvs.isEmpty()) {
+ return false;
+ }
result.add(kvs.remove(0));
return !kvs.isEmpty();
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java
index 484206ad838..33efd51368b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/replication/TestReplicationWithTags.java
@@ -29,6 +29,7 @@ import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -219,7 +220,7 @@ public class TestReplicationWithTags {
if (attribute != null) {
for (List<? extends Cell> edits : put.getFamilyCellMap().values()) {
for (Cell cell : edits) {
- KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+ KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) cell);
if (cf == null) {
cf = CellUtil.cloneFamily(kv);
}
@@ -257,7 +258,7 @@ public class TestReplicationWithTags {
// Check tag presence in the 1st cell in 1st Result
if (!results.isEmpty()) {
Cell cell = results.get(0);
- TAGS = PrivateCellUtil.getTags(cell);
+ TAGS = PrivateCellUtil.getTags((ExtendedCell) cell);
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/ExpAsStringVisibilityLabelServiceImpl.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/ExpAsStringVisibilityLabelServiceImpl.java
index 0b9a9d663e5..f3fd0878f9a 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/ExpAsStringVisibilityLabelServiceImpl.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/ExpAsStringVisibilityLabelServiceImpl.java
@@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilder;
import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HConstants.OperationStatusCode;
import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.Tag;
@@ -273,7 +274,9 @@ public class ExpAsStringVisibilityLabelServiceImpl implements VisibilityLabelSer
final List<String> authLabelsFinal = authLabels;
return new VisibilityExpEvaluator() {
@Override
- public boolean evaluate(Cell cell) throws IOException {
+ public boolean evaluate(Cell c) throws IOException {
+ assert c instanceof ExtendedCell;
+ ExtendedCell cell = (ExtendedCell) c;
boolean visibilityTagPresent = false;
// Save an object allocation where we can
if (cell.getTagsLength() > 0) {
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
index dc313d414ae..10ca33e3872 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/visibility/TestVisibilityLabelsReplication.java
@@ -33,6 +33,7 @@ import org.apache.hadoop.hbase.ArrayBackedTag;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellScanner;
import org.apache.hadoop.hbase.CellUtil;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
@@ -292,7 +293,7 @@ public class TestVisibilityLabelsReplication {
(Bytes.equals(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength(), row, 0,
row.length))
) {
- List<Tag> tags = PrivateCellUtil.getTags(cell);
+ List<Tag> tags = PrivateCellUtil.getTags((ExtendedCell) cell);
for (Tag tag : tags) {
if (tag.getType() == TagType.STRING_VIS_TAG_TYPE) {
assertEquals(visTag, Tag.getValueAsString(tag));
@@ -418,14 +419,15 @@ public class TestVisibilityLabelsReplication {
if (attribute != null) {
for (List<? extends Cell> edits : m.getFamilyCellMap().values()) {
for (Cell cell : edits) {
- KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
+ KeyValue kv = KeyValueUtil.ensureKeyValue((ExtendedCell) cell);
if (cf == null) {
cf = CellUtil.cloneFamily(kv);
}
Tag tag = new ArrayBackedTag((byte) NON_VIS_TAG_TYPE, attribute);
- List<Tag> tagList = new ArrayList<>(PrivateCellUtil.getTags(cell).size() + 1);
+ List<Tag> tagList =
+ new ArrayList<>(PrivateCellUtil.getTags((ExtendedCell) cell).size() + 1);
tagList.add(tag);
- tagList.addAll(PrivateCellUtil.getTags(cell));
+ tagList.addAll(PrivateCellUtil.getTags((ExtendedCell) cell));
Cell newcell = PrivateCellUtil.createCell(kv, tagList);
((List<Cell>) updatedCells).add(newcell);
}
@@ -452,7 +454,7 @@ public class TestVisibilityLabelsReplication {
// Check tag presence in the 1st cell in 1st Result
if (!results.isEmpty()) {
Cell cell = results.get(0);
- tags = PrivateCellUtil.getTags(cell);
+ tags = PrivateCellUtil.getTags((ExtendedCell) cell);
}
}
}
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileTestUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileTestUtil.java
index 20f621fba61..d017db6eb9b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileTestUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/util/HFileTestUtil.java
@@ -144,7 +144,8 @@ public class HFileTestUtil {
ResultScanner s = table.getScanner(new Scan());
for (Result r : s) {
for (Cell c : r.listCells()) {
- Optional<Tag> tag = PrivateCellUtil.getTag(c, TagType.MOB_TABLE_NAME_TAG_TYPE);
+ Optional<Tag> tag =
+ PrivateCellUtil.getTag((ExtendedCell) c, TagType.MOB_TABLE_NAME_TAG_TYPE);
if (!tag.isPresent()) {
fail(c.toString() + " has null tag");
continue;
diff --git a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
index a02f944e12a..ee060bd5387 100644
--- a/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
+++ b/hbase-thrift/src/main/java/org/apache/hadoop/hbase/thrift2/ThriftUtilities.java
@@ -34,6 +34,7 @@ import org.apache.hadoop.hbase.CellBuilderFactory;
import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
+import org.apache.hadoop.hbase.ExtendedCell;
import org.apache.hadoop.hbase.ExtendedCellBuilder;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HConstants;
@@ -55,6 +56,7 @@ import org.apache.hadoop.hbase.client.LogQueryFilter;
import org.apache.hadoop.hbase.client.Mutation;
import org.apache.hadoop.hbase.client.OnlineLogRecord;
import org.apache.hadoop.hbase.client.OperationWithAttributes;
+import org.apache.hadoop.hbase.client.PackagePrivateFieldAccessor;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.client.Result;
@@ -120,7 +122,7 @@ import org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos;
@InterfaceAudience.Private
public final class ThriftUtilities {
- private final static Cell[] EMPTY_CELL_ARRAY = new Cell[] {};
+ private final static ExtendedCell[] EMPTY_CELL_ARRAY = new ExtendedCell[0];
private final static Result EMPTY_RESULT = Result.create(EMPTY_CELL_ARRAY);
private final static Result EMPTY_RESULT_STALE = Result.create(EMPTY_CELL_ARRAY, null, true);
@@ -220,14 +222,14 @@ public final class ThriftUtilities {
* @return converted result, returns an empty result if the input is <code>null</code>
*/
public static TResult resultFromHBase(Result in) {
- Cell[] raw = in.rawCells();
+ ExtendedCell[] raw = PackagePrivateFieldAccessor.getExtendedRawCells(in);
TResult out = new TResult();
byte[] row = in.getRow();
if (row != null) {
out.setRow(in.getRow());
}
List<TColumnValue> columnValues = new ArrayList<>(raw.length);
- for (Cell kv : raw) {
+ for (ExtendedCell kv : raw) {
TColumnValue col = new TColumnValue();
col.setFamily(CellUtil.cloneFamily(kv));
col.setQualifier(CellUtil.cloneQualifier(kv));
@@ -1309,9 +1311,10 @@ public final class ThriftUtilities {
if (in.getDurability() != Durability.USE_DEFAULT) {
out.setDurability(durabilityFromHBase(in.getDurability()));
}
- for (Map.Entry<byte[], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
+ for (Map.Entry<byte[], List<ExtendedCell>> entry : PackagePrivateFieldAccessor
+ .getExtendedFamilyCellMap(in).entrySet()) {
byte[] family = entry.getKey();
- for (Cell cell : entry.getValue()) {
+ for (ExtendedCell cell : entry.getValue()) {
TColumnValue columnValue = new TColumnValue();
columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell))
.setType(cell.getType().getCode()).setTimestamp(cell.getTimestamp())
@@ -1372,9 +1375,10 @@ public final class ThriftUtilities {
if (in.getDurability() != Durability.USE_DEFAULT) {
out.setDurability(durabilityFromHBase(in.getDurability()));
}
- for (Map.Entry<byte[], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
+ for (Map.Entry<byte[], List<ExtendedCell>> entry : PackagePrivateFieldAccessor
+ .getExtendedFamilyCellMap(in).entrySet()) {
byte[] family = entry.getKey();
- for (Cell cell : entry.getValue()) {
+ for (ExtendedCell cell : entry.getValue()) {
TColumnValue columnValue = new TColumnValue();
columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell))
.setType(cell.getType().getCode()).setTimestamp(cell.getTimestamp())