dlmarion commented on code in PR #4745:
URL: https://github.com/apache/accumulo/pull/4745#discussion_r1690355705
##########
core/src/main/java/org/apache/accumulo/core/file/rfile/RelativeKey.java:
##########
@@ -467,24 +467,24 @@ private static byte[] readPrefix(DataInput in,
ByteSequence prefixSource) throws
return data;
}
- private static void readPrefix(DataInput in, MutableByteSequence dest,
ByteSequence prefixSource)
+ private static void readPrefix(DataInput in, ArrayByteSequence dest,
ByteSequence prefixSource)
throws IOException {
int prefixLen = WritableUtils.readVInt(in);
int remainingLen = WritableUtils.readVInt(in);
int len = prefixLen + remainingLen;
+ byte[] buf = dest.getBackingArray();
if (dest.getBackingArray().length < len) {
- dest.setArray(new byte[UnsynchronizedBuffer.nextArraySize(len)], 0, 0);
+ buf = new byte[UnsynchronizedBuffer.nextArraySize(len)];
}
if (prefixSource.isBackedByArray()) {
- System.arraycopy(prefixSource.getBackingArray(), prefixSource.offset(),
- dest.getBackingArray(), 0, prefixLen);
+ System.arraycopy(prefixSource.getBackingArray(), prefixSource.offset(),
buf, 0, prefixLen);
} else {
byte[] prefixArray = prefixSource.toArray();
- System.arraycopy(prefixArray, 0, dest.getBackingArray(), 0, prefixLen);
+ System.arraycopy(prefixArray, 0, buf, 0, prefixLen);
}
// read remaining
- in.readFully(dest.getBackingArray(), prefixLen, remainingLen);
- dest.setLength(len);
+ in.readFully(buf, prefixLen, remainingLen);
+ dest.reset(buf, dest.offset(), len);
Review Comment:
is `dest.offset()` correct here? I'm curious why it's not zero.
##########
core/src/main/java/org/apache/accumulo/core/file/rfile/RelativeKey.java:
##########
@@ -467,24 +467,24 @@ private static byte[] readPrefix(DataInput in,
ByteSequence prefixSource) throws
return data;
}
- private static void readPrefix(DataInput in, MutableByteSequence dest,
ByteSequence prefixSource)
+ private static void readPrefix(DataInput in, ArrayByteSequence dest,
ByteSequence prefixSource)
throws IOException {
int prefixLen = WritableUtils.readVInt(in);
int remainingLen = WritableUtils.readVInt(in);
int len = prefixLen + remainingLen;
+ byte[] buf = dest.getBackingArray();
if (dest.getBackingArray().length < len) {
Review Comment:
Could change this to `buf.length` like the code above.
--
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]