HBASE-9868 Remove some array copy, especially around protobuf
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1537988 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8fb1958b67
commit
336b5c52ef
|
@ -2736,7 +2736,7 @@ public class HConnectionManager {
|
|||
* - nested exceptions
|
||||
*
|
||||
* Looks for: RegionMovedException / RegionOpeningException / RegionTooBusyException
|
||||
* @returns null if we didn't find the exception, the exception otherwise.
|
||||
* @return null if we didn't find the exception, the exception otherwise.
|
||||
*/
|
||||
public static Throwable findException(Object exception) {
|
||||
if (exception == null || !(exception instanceof Throwable)) {
|
||||
|
|
|
@ -181,7 +181,8 @@ public class Increment extends Mutation implements Comparable<Row> {
|
|||
NavigableMap<byte [], Long> longs = new TreeMap<byte [], Long>(Bytes.BYTES_COMPARATOR);
|
||||
for (Cell cell: entry.getValue()) {
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
|
||||
longs.put(kv.getQualifier(), Bytes.toLong(kv.getValue()));
|
||||
longs.put(kv.getQualifier(),
|
||||
Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
|
||||
}
|
||||
results.put(entry.getKey(), longs);
|
||||
}
|
||||
|
@ -224,7 +225,8 @@ public class Increment extends Mutation implements Comparable<Row> {
|
|||
moreThanOneB = true;
|
||||
}
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
|
||||
sb.append(Bytes.toStringBinary(kv.getKey()) + "+=" + Bytes.toLong(kv.getValue()));
|
||||
sb.append(Bytes.toStringBinary(kv.getKey()) + "+=" +
|
||||
Bytes.toLong(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
|
||||
}
|
||||
sb.append("}");
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class Put extends Mutation implements HeapSize, Comparable<Row> {
|
|||
List<Cell> list = getCellList(family);
|
||||
KeyValue kv = createPutKeyValue(family, qualifier, ts, value);
|
||||
list.add(kv);
|
||||
familyMap.put(CellUtil.cloneFamily(kv), list);
|
||||
familyMap.put(family, list);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ public class BigDecimalColumnInterpreter extends ColumnInterpreter<BigDecimal, B
|
|||
if (kv == null || CellUtil.cloneValue(kv) == null) {
|
||||
return null;
|
||||
}
|
||||
return Bytes.toBigDecimal(CellUtil.cloneValue(kv)).setScale(2, RoundingMode.HALF_EVEN);
|
||||
return Bytes.toBigDecimal(kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()).
|
||||
setScale(2, RoundingMode.HALF_EVEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -969,8 +969,10 @@ public final class ProtobufUtil {
|
|||
if (values != null && values.size() > 0) {
|
||||
for (Cell cell: values) {
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
|
||||
valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(kv.getQualifier()));
|
||||
valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(kv.getValue()));
|
||||
valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(
|
||||
kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
|
||||
valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(
|
||||
kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
|
||||
columnBuilder.addQualifierValue(valueBuilder.build());
|
||||
}
|
||||
}
|
||||
|
@ -1006,8 +1008,10 @@ public final class ProtobufUtil {
|
|||
columnBuilder.clearQualifierValue();
|
||||
for (Cell cell: family.getValue()) {
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
|
||||
valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(kv.getQualifier()));
|
||||
valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(kv.getValue()));
|
||||
valueBuilder.setQualifier(ZeroCopyLiteralByteString.wrap(
|
||||
kv.getQualifierArray(), kv.getQualifierOffset(), kv.getQualifierLength()));
|
||||
valueBuilder.setValue(ZeroCopyLiteralByteString.wrap(
|
||||
kv.getValueArray(), kv.getValueOffset(), kv.getValueLength()));
|
||||
valueBuilder.setTimestamp(kv.getTimestamp());
|
||||
if(cell.getTagsLength() > 0) {
|
||||
valueBuilder.setTags(ByteString.copyFrom(CellUtil.getTagArray(kv)));
|
||||
|
|
|
@ -487,10 +487,12 @@ public final class RequestConverter {
|
|||
final List<Action<R>> actions)
|
||||
throws IOException {
|
||||
RegionAction.Builder builder = getRegionActionBuilderWithRegion(regionName);
|
||||
ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
|
||||
MutationProto.Builder mutationBuilder = ClientProtos.MutationProto.newBuilder();
|
||||
for (Action<R> action: actions) {
|
||||
Row row = action.getAction();
|
||||
ClientProtos.Action.Builder actionBuilder =
|
||||
ClientProtos.Action.newBuilder().setIndex(action.getOriginalIndex());
|
||||
actionBuilder.clear();
|
||||
actionBuilder.setIndex(action.getOriginalIndex());
|
||||
if (row instanceof Get) {
|
||||
Get g = (Get)row;
|
||||
builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
|
||||
|
@ -535,10 +537,11 @@ public final class RequestConverter {
|
|||
final List<Action<R>> actions, final List<CellScannable> cells)
|
||||
throws IOException {
|
||||
RegionAction.Builder builder = getRegionActionBuilderWithRegion(regionName);
|
||||
ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
|
||||
for (Action<R> action: actions) {
|
||||
Row row = action.getAction();
|
||||
ClientProtos.Action.Builder actionBuilder =
|
||||
ClientProtos.Action.newBuilder().setIndex(action.getOriginalIndex());
|
||||
actionBuilder.clear();
|
||||
actionBuilder.setIndex(action.getOriginalIndex());
|
||||
if (row instanceof Get) {
|
||||
Get g = (Get)row;
|
||||
builder.addAction(actionBuilder.setGet(ProtobufUtil.toGet(g)));
|
||||
|
|
|
@ -42,6 +42,13 @@ public final class ZeroCopyLiteralByteString extends LiteralByteString {
|
|||
return new LiteralByteString(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps a subset of a byte array in a {@link ByteString} without copying it.
|
||||
*/
|
||||
public static ByteString wrap(final byte[] array, int offset, int length) {
|
||||
return new BoundedByteString(array, offset, length);
|
||||
}
|
||||
|
||||
// TODO:
|
||||
// ZeroCopyLiteralByteString.wrap(this.buf, 0, this.count);
|
||||
|
||||
|
|
|
@ -294,7 +294,7 @@ public final class Constraints {
|
|||
* <tt>true</tt> if it should be run
|
||||
* @param priority
|
||||
* relative to other constraints
|
||||
* @returns a new configuration, storable in the {@link HTableDescriptor}
|
||||
* @return a new configuration, storable in the {@link HTableDescriptor}
|
||||
*/
|
||||
private static Configuration configure(Configuration conf, boolean enabled,
|
||||
long priority) {
|
||||
|
|
Loading…
Reference in New Issue