dlmarion commented on code in PR #4745:
URL: https://github.com/apache/accumulo/pull/4745#discussion_r1688332515
##########
core/src/main/java/org/apache/accumulo/core/file/rfile/RelativeKey.java:
##########
@@ -432,24 +432,24 @@ public static SkippR fastSkip(DataInput in, Key seekKey,
MutableByteSequence val
return new SkippR(result, count, newPrevKey);
}
- private static void read(DataInput in, MutableByteSequence mbseq) throws
IOException {
+ private static void read(DataInput in, ArrayByteSequence mbseq) throws
IOException {
int len = WritableUtils.readVInt(in);
read(in, mbseq, len);
}
- private static void readValue(DataInput in, MutableByteSequence mbseq)
throws IOException {
+ private static void readValue(DataInput in, ArrayByteSequence mbseq) throws
IOException {
int len = in.readInt();
read(in, mbseq, len);
}
- private static void read(DataInput in, MutableByteSequence mbseqDestination,
int len)
+ private static void read(DataInput in, ArrayByteSequence mbseqDestination,
int len)
throws IOException {
if (mbseqDestination.getBackingArray().length < len) {
- mbseqDestination.setArray(new
byte[UnsynchronizedBuffer.nextArraySize(len)], 0, 0);
+ mbseqDestination.reset(new
byte[UnsynchronizedBuffer.nextArraySize(len)], 0, 0);
}
in.readFully(mbseqDestination.getBackingArray(), 0, len);
- mbseqDestination.setLength(len);
+ mbseqDestination.reset(mbseqDestination.getBackingArray(),
mbseqDestination.offset(), len);
Review Comment:
> I think this could be redone as:
>
> ```
> if (mbseqDestination.getBackingArray().length < len) {
> byte[] buf = new byte[UnsynchronizedBuffer.nextArraySize(len);
> in.readFully(buf, 0, len);
> mbseqDestination.reset(buf, 0, len);
> } else {
> in.readFully(mbseqDestination.getBackingArray(), 0, len);
> mbseqDestination.reset(mbseqDestination.getBackingArray(),
mbseqDestination.offset(), len);
> }
> ```
Actually, it can be further simplified:
```
byte[] buf = dest.getBackingArray();
if (dest.getBackingArray().length < len) {
buf = new byte[UnsynchronizedBuffer.nextArraySize(len)];
}
in.readFully(buf, 0, len);
mbseqDestination.reset(buf, 0, len);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]