]
Bela Ban updated JGRP-2503:
---------------------------
Comment: was deleted
(was: Related to the byte[] copy in [1]
[1]
[
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
"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;
}