From dc20322a6a50cb464bb89dc4237fbb94cebb8999 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Tue, 19 Nov 2013 05:01:58 +0000 Subject: [PATCH] HBASE-9994 ZeroCopyLiteralByteString.wrap() should be used in place of ByteString.copyFrom() git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1543309 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/hadoop/hbase/codec/MessageCodec.java | 13 +++++++------ .../hbase/mapreduce/TableSnapshotInputFormat.java | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) 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 4457d3ad927..654df9af07a 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 @@ -27,6 +27,7 @@ import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.protobuf.generated.CellProtos; import com.google.protobuf.ByteString; +import com.google.protobuf.ZeroCopyLiteralByteString; /** * Codec that just writes out Cell as a protobuf Cell Message. Does not write the mvcc stamp. @@ -45,15 +46,15 @@ public class MessageCodec implements Codec { CellProtos.Cell.Builder builder = CellProtos.Cell.newBuilder(); // This copies bytes from Cell to ByteString. I don't see anyway around the copy. // ByteString is final. - builder.setRow(ByteString.copyFrom(cell.getRowArray(), cell.getRowOffset(), + builder.setRow(ZeroCopyLiteralByteString.wrap(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength())); - builder.setFamily(ByteString.copyFrom(cell.getFamilyArray(), cell.getFamilyOffset(), + builder.setFamily(ZeroCopyLiteralByteString.wrap(cell.getFamilyArray(), cell.getFamilyOffset(), cell.getFamilyLength())); - builder.setQualifier(ByteString.copyFrom(cell.getQualifierArray(), cell.getQualifierOffset(), - cell.getQualifierLength())); + builder.setQualifier(ZeroCopyLiteralByteString.wrap(cell.getQualifierArray(), + cell.getQualifierOffset(), cell.getQualifierLength())); builder.setTimestamp(cell.getTimestamp()); builder.setCellType(CellProtos.CellType.valueOf(cell.getTypeByte())); - builder.setValue(ByteString.copyFrom(cell.getValueArray(), cell.getValueOffset(), + builder.setValue(ZeroCopyLiteralByteString.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength())); CellProtos.Cell pbcell = builder.build(); pbcell.writeDelimitedTo(this.out); @@ -83,4 +84,4 @@ public class MessageCodec implements Codec { public Encoder getEncoder(OutputStream os) { return new MessageEncoder(os); } -} \ No newline at end of file +} diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java index 482d4669807..51eb3da2e3e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java @@ -69,7 +69,7 @@ import org.apache.hadoop.mapreduce.RecordReader; import org.apache.hadoop.mapreduce.TaskAttemptContext; import com.google.common.annotations.VisibleForTesting; -import com.google.protobuf.ByteString; +import com.google.protobuf.ZeroCopyLiteralByteString; /** * TableSnapshotInputFormat allows a MapReduce job to run over a table snapshot. The job @@ -157,7 +157,7 @@ public class TableSnapshotInputFormat extends InputFormat