[
https://issues.redhat.com/browse/JGRP-2503?page=com.atlassian.jira.plugin...
]
Bela Ban edited comment on JGRP-2503 at 10/12/20 9:21 AM:
----------------------------------------------------------
Hmm, not sure what you mean here... can you post an example that shows where you'd
avoid the byte array copy? If you need to read-ahead, can't you create a byte array of
a given size and always reuse it?
was (Author: belaban):
Hmm, not sure what you mean here... can you post an example that shows where you'd
avoid the byte array copy?
Extend DataInput & DataOutput to avoid copy of byte[]
-----------------------------------------------------
Key: JGRP-2503
URL:
https://issues.redhat.com/browse/JGRP-2503
Project: JGroups
Issue Type: Feature Request
Affects Versions: 5.0.4
Reporter: Jingqi Xu
Assignee: Bela Ban
Priority: Optional
Fix For: 5.1
"DataInput's void readFully(byte b[])" will cause an extra copy when
reading bytes from DataInput. Sometimes business logic needs to read bytes from DataInput
first, then process them conditionally(or will not process at all) , is it possible to
support ByteBuffer api like:
public interface XDataInput extends DataInput {
ByteBuffer readBuffer(int n);
}
public interface XDataOutput extends DataOutput {
void writeBuffer(ByteBuffer value);
}
ByteArrayDataInputStream.java
@Override
public ByteBuffer readBuffer(int n) {
ByteBuffer r = wrap(this.buf, this.pos, n); this.pos += n; return r;
}
public interface Streamable {
void writeTo(XDataOutput out) throws IOException;
void readFrom(XDataInput in) throws IOException, ClassNotFoundException;
}
--
This message was sent by Atlassian Jira
(v7.13.8#713008)