You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by te...@apache.org on 2013/11/19 06:01:58 UTC
svn commit: r1543309 - in
/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase:
codec/MessageCodec.java mapreduce/TableSnapshotInputFormat.java
Author: tedyu
Date: Tue Nov 19 05:01:58 2013
New Revision: 1543309
URL: http://svn.apache.org/r1543309
Log:
HBASE-9994 ZeroCopyLiteralByteString.wrap() should be used in place of ByteString.copyFrom()
Modified:
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java
hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java?rev=1543309&r1=1543308&r2=1543309&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/codec/MessageCodec.java Tue Nov 19 05:01:58 2013
@@ -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 Cod
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 Cod
public Encoder getEncoder(OutputStream os) {
return new MessageEncoder(os);
}
-}
\ No newline at end of file
+}
Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java?rev=1543309&r1=1543308&r2=1543309&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java (original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableSnapshotInputFormat.java Tue Nov 19 05:01:58 2013
@@ -69,7 +69,7 @@ import org.apache.hadoop.mapreduce.Recor
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 ex
MapReduceProtos.TableSnapshotRegionSplit.newBuilder()
.setRegion(RegionSpecifier.newBuilder()
.setType(RegionSpecifierType.ENCODED_REGION_NAME)
- .setValue(ByteString.copyFrom(Bytes.toBytes(regionName))).build());
+ .setValue(ZeroCopyLiteralByteString.wrap(Bytes.toBytes(regionName))).build());
for (String location : locations) {
builder.addLocations(location);