Revert "HBASE-18026 ProtobufUtil seems to do extra array copying"
This reverts commit 5895631634
.
This commit is contained in:
parent
6b60ba8ade
commit
37650775a5
|
@ -17,8 +17,6 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hbase.protobuf;
|
package org.apache.hadoop.hbase.protobuf;
|
||||||
|
|
||||||
import static com.google.protobuf.HBaseZeroCopyByteString.zeroCopyGetBytes;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
@ -369,7 +367,7 @@ public final class ProtobufUtil {
|
||||||
*/
|
*/
|
||||||
public static Get toGet(final ClientProtos.Get proto) throws IOException {
|
public static Get toGet(final ClientProtos.Get proto) throws IOException {
|
||||||
if (proto == null) return null;
|
if (proto == null) return null;
|
||||||
byte[] row = zeroCopyGetBytes(proto.getRow());
|
byte[] row = proto.getRow().toByteArray();
|
||||||
Get get = new Get(row);
|
Get get = new Get(row);
|
||||||
if (proto.hasCacheBlocks()) {
|
if (proto.hasCacheBlocks()) {
|
||||||
get.setCacheBlocks(proto.getCacheBlocks());
|
get.setCacheBlocks(proto.getCacheBlocks());
|
||||||
|
@ -466,7 +464,7 @@ public final class ProtobufUtil {
|
||||||
MutationType type = proto.getMutateType();
|
MutationType type = proto.getMutateType();
|
||||||
assert type == MutationType.PUT: type.name();
|
assert type == MutationType.PUT: type.name();
|
||||||
long timestamp = proto.hasTimestamp()? proto.getTimestamp(): HConstants.LATEST_TIMESTAMP;
|
long timestamp = proto.hasTimestamp()? proto.getTimestamp(): HConstants.LATEST_TIMESTAMP;
|
||||||
Put put = proto.hasRow() ? new Put(zeroCopyGetBytes(proto.getRow()), timestamp) : null;
|
Put put = proto.hasRow() ? new Put(proto.getRow().toByteArray(), timestamp) : null;
|
||||||
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
||||||
if (cellCount > 0) {
|
if (cellCount > 0) {
|
||||||
// The proto has metadata only and the data is separate to be found in the cellScanner.
|
// The proto has metadata only and the data is separate to be found in the cellScanner.
|
||||||
|
@ -491,7 +489,7 @@ public final class ProtobufUtil {
|
||||||
}
|
}
|
||||||
// The proto has the metadata and the data itself
|
// The proto has the metadata and the data itself
|
||||||
for (ColumnValue column: proto.getColumnValueList()) {
|
for (ColumnValue column: proto.getColumnValueList()) {
|
||||||
byte[] family = zeroCopyGetBytes(column.getFamily());
|
byte[] family = column.getFamily().toByteArray();
|
||||||
for (QualifierValue qv: column.getQualifierValueList()) {
|
for (QualifierValue qv: column.getQualifierValueList()) {
|
||||||
if (!qv.hasValue()) {
|
if (!qv.hasValue()) {
|
||||||
throw new DoNotRetryIOException(
|
throw new DoNotRetryIOException(
|
||||||
|
@ -510,7 +508,7 @@ public final class ProtobufUtil {
|
||||||
allTagsBytes = qv.getTags().toByteArray();
|
allTagsBytes = qv.getTags().toByteArray();
|
||||||
if(qv.hasDeleteType()) {
|
if(qv.hasDeleteType()) {
|
||||||
byte[] qual = qv.hasQualifier() ? qv.getQualifier().toByteArray() : null;
|
byte[] qual = qv.hasQualifier() ? qv.getQualifier().toByteArray() : null;
|
||||||
put.add(new KeyValue(zeroCopyGetBytes(proto.getRow()), family, qual, ts,
|
put.add(new KeyValue(proto.getRow().toByteArray(), family, qual, ts,
|
||||||
fromDeleteType(qv.getDeleteType()), null, allTagsBytes));
|
fromDeleteType(qv.getDeleteType()), null, allTagsBytes));
|
||||||
} else {
|
} else {
|
||||||
List<Tag> tags = TagUtil.asList(allTagsBytes, 0, (short)allTagsBytes.length);
|
List<Tag> tags = TagUtil.asList(allTagsBytes, 0, (short)allTagsBytes.length);
|
||||||
|
@ -519,8 +517,8 @@ public final class ProtobufUtil {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(qv.hasDeleteType()) {
|
if(qv.hasDeleteType()) {
|
||||||
byte[] qual = qv.hasQualifier() ? zeroCopyGetBytes(qv.getQualifier()) : null;
|
byte[] qual = qv.hasQualifier() ? qv.getQualifier().toByteArray() : null;
|
||||||
put.add(new KeyValue(zeroCopyGetBytes(proto.getRow()), family, qual, ts,
|
put.add(new KeyValue(proto.getRow().toByteArray(), family, qual, ts,
|
||||||
fromDeleteType(qv.getDeleteType())));
|
fromDeleteType(qv.getDeleteType())));
|
||||||
} else{
|
} else{
|
||||||
put.addImmutable(family, qualifier, ts, value);
|
put.addImmutable(family, qualifier, ts, value);
|
||||||
|
@ -561,7 +559,7 @@ public final class ProtobufUtil {
|
||||||
MutationType type = proto.getMutateType();
|
MutationType type = proto.getMutateType();
|
||||||
assert type == MutationType.DELETE : type.name();
|
assert type == MutationType.DELETE : type.name();
|
||||||
long timestamp = proto.hasTimestamp() ? proto.getTimestamp() : HConstants.LATEST_TIMESTAMP;
|
long timestamp = proto.hasTimestamp() ? proto.getTimestamp() : HConstants.LATEST_TIMESTAMP;
|
||||||
Delete delete = proto.hasRow() ? new Delete(zeroCopyGetBytes(proto.getRow()), timestamp) : null;
|
Delete delete = proto.hasRow() ? new Delete(proto.getRow().toByteArray(), timestamp) : null;
|
||||||
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
||||||
if (cellCount > 0) {
|
if (cellCount > 0) {
|
||||||
// The proto has metadata only and the data is separate to be found in the cellScanner.
|
// The proto has metadata only and the data is separate to be found in the cellScanner.
|
||||||
|
@ -629,7 +627,7 @@ public final class ProtobufUtil {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
MutationType type = proto.getMutateType();
|
MutationType type = proto.getMutateType();
|
||||||
assert type == MutationType.APPEND : type.name();
|
assert type == MutationType.APPEND : type.name();
|
||||||
byte [] row = proto.hasRow()? zeroCopyGetBytes(proto.getRow()): null;
|
byte [] row = proto.hasRow()? proto.getRow().toByteArray(): null;
|
||||||
Append append = null;
|
Append append = null;
|
||||||
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
||||||
if (cellCount > 0) {
|
if (cellCount > 0) {
|
||||||
|
@ -652,17 +650,17 @@ public final class ProtobufUtil {
|
||||||
} else {
|
} else {
|
||||||
append = new Append(row);
|
append = new Append(row);
|
||||||
for (ColumnValue column: proto.getColumnValueList()) {
|
for (ColumnValue column: proto.getColumnValueList()) {
|
||||||
byte[] family = zeroCopyGetBytes(column.getFamily());
|
byte[] family = column.getFamily().toByteArray();
|
||||||
for (QualifierValue qv: column.getQualifierValueList()) {
|
for (QualifierValue qv: column.getQualifierValueList()) {
|
||||||
byte[] qualifier = zeroCopyGetBytes(qv.getQualifier());
|
byte[] qualifier = qv.getQualifier().toByteArray();
|
||||||
if (!qv.hasValue()) {
|
if (!qv.hasValue()) {
|
||||||
throw new DoNotRetryIOException(
|
throw new DoNotRetryIOException(
|
||||||
"Missing required field: qualifier value");
|
"Missing required field: qualifier value");
|
||||||
}
|
}
|
||||||
byte[] value = zeroCopyGetBytes(qv.getValue());
|
byte[] value = qv.getValue().toByteArray();
|
||||||
byte[] tags = null;
|
byte[] tags = null;
|
||||||
if (qv.hasTags()) {
|
if (qv.hasTags()) {
|
||||||
tags = zeroCopyGetBytes(qv.getTags());
|
tags = qv.getTags().toByteArray();
|
||||||
}
|
}
|
||||||
append.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
|
append.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
|
||||||
KeyValue.Type.Put, value, tags));
|
KeyValue.Type.Put, value, tags));
|
||||||
|
@ -708,7 +706,7 @@ public final class ProtobufUtil {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
MutationType type = proto.getMutateType();
|
MutationType type = proto.getMutateType();
|
||||||
assert type == MutationType.INCREMENT : type.name();
|
assert type == MutationType.INCREMENT : type.name();
|
||||||
byte [] row = proto.hasRow()? zeroCopyGetBytes(proto.getRow()): null;
|
byte [] row = proto.hasRow()? proto.getRow().toByteArray(): null;
|
||||||
Increment increment = null;
|
Increment increment = null;
|
||||||
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
int cellCount = proto.hasAssociatedCellCount()? proto.getAssociatedCellCount(): 0;
|
||||||
if (cellCount > 0) {
|
if (cellCount > 0) {
|
||||||
|
@ -731,16 +729,16 @@ public final class ProtobufUtil {
|
||||||
} else {
|
} else {
|
||||||
increment = new Increment(row);
|
increment = new Increment(row);
|
||||||
for (ColumnValue column: proto.getColumnValueList()) {
|
for (ColumnValue column: proto.getColumnValueList()) {
|
||||||
byte[] family = zeroCopyGetBytes(column.getFamily());
|
byte[] family = column.getFamily().toByteArray();
|
||||||
for (QualifierValue qv: column.getQualifierValueList()) {
|
for (QualifierValue qv: column.getQualifierValueList()) {
|
||||||
byte[] qualifier = zeroCopyGetBytes(qv.getQualifier());
|
byte[] qualifier = qv.getQualifier().toByteArray();
|
||||||
if (!qv.hasValue()) {
|
if (!qv.hasValue()) {
|
||||||
throw new DoNotRetryIOException("Missing required field: qualifier value");
|
throw new DoNotRetryIOException("Missing required field: qualifier value");
|
||||||
}
|
}
|
||||||
byte[] value = zeroCopyGetBytes(qv.getValue());
|
byte[] value = qv.getValue().toByteArray();
|
||||||
byte[] tags = null;
|
byte[] tags = null;
|
||||||
if (qv.hasTags()) {
|
if (qv.hasTags()) {
|
||||||
tags = zeroCopyGetBytes(qv.getTags());
|
tags = qv.getTags().toByteArray();
|
||||||
}
|
}
|
||||||
increment.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
|
increment.add(CellUtil.createCell(row, family, qualifier, qv.getTimestamp(),
|
||||||
KeyValue.Type.Put, value, tags));
|
KeyValue.Type.Put, value, tags));
|
||||||
|
@ -769,7 +767,7 @@ public final class ProtobufUtil {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
MutationType type = proto.getMutateType();
|
MutationType type = proto.getMutateType();
|
||||||
assert type == MutationType.INCREMENT || type == MutationType.APPEND : type.name();
|
assert type == MutationType.INCREMENT || type == MutationType.APPEND : type.name();
|
||||||
byte[] row = proto.hasRow() ? zeroCopyGetBytes(proto.getRow()) : null;
|
byte[] row = proto.hasRow() ? proto.getRow().toByteArray() : null;
|
||||||
Get get = null;
|
Get get = null;
|
||||||
int cellCount = proto.hasAssociatedCellCount() ? proto.getAssociatedCellCount() : 0;
|
int cellCount = proto.hasAssociatedCellCount() ? proto.getAssociatedCellCount() : 0;
|
||||||
if (cellCount > 0) {
|
if (cellCount > 0) {
|
||||||
|
@ -795,9 +793,9 @@ public final class ProtobufUtil {
|
||||||
} else {
|
} else {
|
||||||
get = new Get(row);
|
get = new Get(row);
|
||||||
for (ColumnValue column : proto.getColumnValueList()) {
|
for (ColumnValue column : proto.getColumnValueList()) {
|
||||||
byte[] family = zeroCopyGetBytes(column.getFamily());
|
byte[] family = column.getFamily().toByteArray();
|
||||||
for (QualifierValue qv : column.getQualifierValueList()) {
|
for (QualifierValue qv : column.getQualifierValueList()) {
|
||||||
byte[] qualifier = zeroCopyGetBytes(qv.getQualifier());
|
byte[] qualifier = qv.getQualifier().toByteArray();
|
||||||
if (!qv.hasValue()) {
|
if (!qv.hasValue()) {
|
||||||
throw new DoNotRetryIOException("Missing required field: qualifier value");
|
throw new DoNotRetryIOException("Missing required field: qualifier value");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue