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

OffsetThe absolute zero-based source offset
BufferThe destination for the returned bytes
CountThe maximum number of bytes to read

Return values

0The offset or count is invalid, the offset is at or beyond the source end, or the source request failed
>0The 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