io: Support 64 bits position/byte-count #20574
io: Support 64 bits position/byte-count #20574pcanal wants to merge 20 commits intoroot-project:Arlesiennefrom
Conversation
Test Results 1 files 1 suites 6h 57m 18s ⏱️ Results for commit 4248799. ♻️ This comment has been updated with latest results. |
Fixes root-project#14770 [io] add more checks in TBuffer functions as suggested by jblomer
00fe0ac to
41a877a
Compare
In order to support 64 bits byte count, which does not fit in the space reverse for them in the stream (4 bytes minus 3 control bits) and the position and some byte count do not fit in the variable used in existing code (arguments to WriteVersion, SetByteCount, ReadVersion and CheckByteCount), we need to pass them indirectly. Since the streaming is inherently serial, we can leverage the sequence of calls and cache the 64 bits values in a queue. The bytecount that can not be stored in place in the stream will be held in a collection (fByteCounts) that need to be stored externally to the buffer.
Note to store and restore the larger than 1GB byte count use:
// Copy the content of the const reference.
auto bytecounts{b.GetByteCounts()};
...
b.SetByteCounts(std::move(bytecounts));
jblomer
left a comment
There was a problem hiding this comment.
I have difficulties parsing the first sentence of the commit message of the first commit. Also, this sentence mentions three control bits. Isn't it just two (up to kByteCountMask, i.e. 0x40000000)?
We may want to swap the reading and writing commits so that the code always works correctly on small objects.
| //////////////////////////////////////////////////////////////////////////////// | ||
| /// Read class version from I/O buffer. | ||
|
|
||
| Version_t TBufferFile::ReadVersion(UInt_t *startpos, UInt_t *bcnt, const TClass *cl) |
There was a problem hiding this comment.
If both startpos and bcnt are provided, the code may add the position to fByteCountStack (it doesn't if the serialized object doesn't have a byte count). That means that the caller of ReadVersion needs to pop from the stack, correct? This looks a bit brittle and should at least be documented.
There was a problem hiding this comment.
If the user does not provide the address of their bytecount variable, they will not be given the value of the byte count and thus they can not and will not call CheckByteCount.
If the user has provided the address, we assume they are using it in a call to CheckByteCount.
I will add to the doc string that the CheckByteCount call is (now) required.
WIP: for byte count PR, revert unintended part
Currently the reading commit is first and should be able to read small buffers ... or am I missing something? |
New wording:
Correct. |
No description provided.