ReadAt
Document management, Performance, Concurrency
Description
Reads bytes at an absolute source offset without changing the positional TStream cursor
Concurrent callers share an in-flight fetch for the same aligned chunk, while queued adjacent chunks are fetched together in one bounded source request
Syntax
Delphi
Function TByteRangeStream.ReadAt(Offset: Int64; Var Buffer; Count: Integer): Integer; Override;Parameters
| Offset | The absolute zero-based source offset |
|---|---|
| Buffer | The destination for the returned bytes |
| Count | The maximum number of bytes to read |
Return values
| 0 | The offset or count is invalid, the offset is at or beyond the source end, or the source request failed |
|---|---|
| >0 | The number of bytes copied to Buffer |
Remarks
The method implements the abstract ReadAt of TPDFReadAtStream, which lets parser code read at absolute offsets instead of sharing one cursor through Seek followed by Read
The coalesce window is applied only to the first uncached chunk of the call; later chunks are fetched without delay
One merged source fetch is capped at 16 MiB, and calls into the source are serialized, so a source implementation does not need its own transport lock
See also
TByteRangeStreamAvailability, ReadRange, GetTotalSize, LoadFromRangeSource