]
Bela Ban commented on JGRP-2503:
--------------------------------
Doesn't work, see my comments in the PR. Closing for now...
Extend DataInput & DataOutput to avoid copy of byte[]
-----------------------------------------------------
Key: JGRP-2503
URL:
https://issues.redhat.com/browse/JGRP-2503
Project: JGroups
Issue Type: Enhancement
Affects Versions: 5.0.4
Reporter: Jingqi Xu
Assignee: Bela Ban
Priority: Optional
Fix For: 5.1.3
"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;
}