fgb-vt - v1.0.4
    Preparing search index...

    Class LocalConnector

    Local filesystem connector using Node.js FileHandle with LRU pooling.

    Opens FGB files on demand and caches the resulting FileHandle in an LRU map. Subsequent reads against the same path reuse the cached handle, avoiding repeated open() syscalls. When the pool exceeds LocalConnectorOptions.maxOpenFiles, the least-recently-used handle is evicted and closed.

    import { LocalConnector } from 'fgb-vt';

    const connector = new LocalConnector({ maxOpenFiles: 128 });

    // Read 1024 bytes starting at offset 0
    const bytes = await connector.read('./data/buildings.fgb', 0, 1024);

    // Clean up when done
    await connector.close();

    Implements

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Close all pooled file handles and clear the LRU pool.

      After calling this method, the connector must not be used for further reads. Handles are closed concurrently via Promise.all.

      Returns Promise<void>

      Resolves when every open handle has been closed.

    • Read a contiguous byte range from a local file.

      The file handle is obtained from the LRU pool (or opened on first access). The returned Uint8Array may be shorter than length if the file is smaller than offset + length.

      Parameters

      • path: string

        Absolute or relative filesystem path to the FGB file.

      • offset: number

        Zero-based byte offset to begin reading from.

      • length: number

        Number of bytes to read.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The requested byte range.

      If the file cannot be opened or read (e.g. ENOENT, EACCES).

    • Read multiple byte ranges from the same local file in parallel.

      All ranges are dispatched concurrently via Promise.all, letting the OS I/O scheduler optimize disk access order.

      Parameters

      • path: string

        Absolute or relative filesystem path to the FGB file.

      • ranges: readonly { length: number; offset: number }[]

        Array of { offset, length } byte-range descriptors.

      Returns Promise<Uint8Array<ArrayBufferLike>[]>

      Array of Uint8Array chunks in the same order as the input ranges.

      If the file cannot be opened or any individual read fails.