StartRangeSourcePrefetch

Document management, Progressive loading, Performance

Description

Queues a background job that repeatedly discovers and fetches the missing byte ranges required by a page, form or indirect-object dependency graph

Syntax

Delphi

Function TPDFlib.StartRangeSourcePrefetch(DataKind, Index, Priority: Integer;
  MaxBytes: Int64= 0; ReadAheadBytes: LongInt= 0;
  MaxPasses: Integer= 0): Integer;

Parameters

DataKindPDF_RANGE_DATA_PAGE, PDF_RANGE_DATA_FORM or PDF_RANGE_DATA_OBJECT
IndexA one-based page number, zero for the form query, or an indirect object number
PriorityPDF_RANGE_PREFETCH_PRIORITY_LOW, PDF_RANGE_PREFETCH_PRIORITY_NORMAL, PDF_RANGE_PREFETCH_PRIORITY_HIGH or PDF_RANGE_PREFETCH_PRIORITY_CRITICAL
MaxBytesThe job read budget; zero selects 64 MiB and an explicit value must hold at least one source chunk
ReadAheadBytesExtra bytes scheduled after each discovered dependency range before chunk alignment
MaxPassesThe maximum dependency-discovery rounds; zero selects 128

Return value

A positive stream-local job handle on success, or zero with LastErrorCode set to 401 when the selected document is not range-backed or the arguments are invalid

Remarks

One worker services each range stream and selects the highest queued priority, preserving FIFO order within equal priorities

The worker uses an isolated parser over the shared byte-range cache, so dependency discovery does not share mutable reader state with foreground document operations

The byte budget includes uncached reads performed while initializing and advancing the isolated dependency parser

Prefetched bytes remain subject to the stream cache budget and least-recently-used eviction policy