Function columnarBatchToResultPages

  • Experimental

    Walk a batch as a sequence of bounded ColumnarResult pages.

    This is how a caller converts more of a batch than one window without raising the ceiling: each page is a complete, independently valid Result bounded by maxFeatures, and only the page a consumer is holding is live. A consumer that streams a million-row batch to a file therefore retains one page, not a million features.

    Pages are emitted in ascending row order, contiguous and non-overlapping, so concatenating every page's features reproduces exactly the feature sequence a single window over the same range would have produced. An empty range yields no pages at all rather than one empty page.

    Cancellation is cooperative and real: options.signal is checked before each page and every 1,024 rows inside a page, and the traversal yields to the host task queue between pages so an abort raised by a task is actually delivered. An aborted traversal rejects with an AbortError DOMException and stops without materializing the remaining pages.

    Type Parameters

    • T extends Record<string, unknown> = Record<string, unknown>

    Returns AsyncGenerator<ColumnarResult<T>, void, undefined>

    HonuaGeoArrowError invalid-input when pageSize is not a positive safe integer, and row-limit-exceeded when pageSize exceeds maxFeatures. Both are checked before the batch is inspected.

    for await (const page of columnarBatchToResultPages(batch, { pageSize: 1_000, maxFeatures: 1_000, signal })) {
    await writeRows(page.features);
    }