Cl binary nio channel#3919
Draft
clementleclercRTE wants to merge 16 commits into
Draft
Conversation
…wingByteBuffer` for efficient binary I/O, refactored `BinWriter` to adopt buffer-based writing, and updated tests to validate new implementations. Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
…ader` Refactored `BinWriter` to directly manage headers and buffers without intermediate wrapping. Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
# Conflicts: # commons/src/main/java/com/powsybl/commons/binary/BinReader.java # commons/src/test/java/com/powsybl/commons/binary/BinWriterReaderTest.java
Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
…f direct allocation for improved performance in small-element writes. Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
…ed `BinWriter` drain logic for improved memory management and performance. Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
Signed-off-by: Leclerc Clement <clement.leclerc@rte-france.com>
Signed-off-by: Damien Jeandemange <damien.jeandemange@artelys.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
Fixes #3881
What kind of change does this PR introduce?
Migrates the binary reader and writer from
DataInputStream/DataOutputStreamoverBufferedInputStream/BufferedOutputStreamto directByteBuffer+java.nio.channels.ReadableByteChannel/WritableByteChannel.What is the current behavior?
BinReaderwraps the caller'sInputStreaminto aBufferedInputStream+DataInputStream.BinWriterwraps the caller'sOutputStreaminto aBufferedOutputStream+DataOutputStream.NetworkSerDe.copy()usesPipedInputStream/PipedOutputStream.Files.newInputStream(path)/Files.newOutputStream(path)(themselves wrapping aFileChannel), the data path goesChannel → Stream → DataStream, withredundant adapters.
What is the new behavior (if this is a feature change)?
BinReadernow reads through aBufferedChannelReaderbacked by a directByteBufferand aReadableByteChannel.BinWriternow stages body bytes in a directByteBuffer(GrowingByteBuffer) and drains them straight to aWritableByteChannelon close.BinReader(ReadableByteChannel, byte[])/BinReader(Path, byte[])andBinWriter(WritableByteChannel, byte[], String)/BinWriter(Path, byte[], String)avoid theChannel → Stream → Channeldouble-wrapping when the caller already has a channel (or aPath).NetworkSerDe.read(Path, …)andNetworkSerDe.write(Network, ExportOptions, Path)now dispatch on format: for BIN, they open aFiles.newByteChannel(path)directly and feed the channelconstructors — no
OutputStream/InputStreamadapter.NetworkSerDe.copy()now usesPipe.SinkChannel/Pipe.SourceChannel. For BIN, the pipe channels are passed directly toBinWriter/BinReader— noChannels.newOutputStream/newInputStreamadapter.
Does this PR introduce a breaking change or deprecate an API?
If yes, please check if the following requirements are fulfilled
What changes might users need to make in their application due to this PR? (migration steps)
Other information: