qvdjs 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -5141,12 +5141,14 @@ var init_QvdFileReader = __esm({
5141
5141
  * viewer scrolls to - and the header is already in hand. `parseHeaderOnly` has to have run.
5142
5142
  *
5143
5143
  * @param {QvdRowWindow} window The rows the read would cover, normalised.
5144
- * @param {{chunkSize?: number|null, fields?: Array<string>|null, materialisesRows?: boolean}} [options]
5145
- * `chunkSize` for an `iterate()`; `fields` and `materialisesRows` to ask about a read other than the
5146
- * one this reader was built for, which is what a `QvdFile` does per call.
5144
+ * @param {{chunkSize?: number|null, fields?: Array<string>|null, materialisesRows?: boolean,
5145
+ * paging?: boolean}} [options] `chunkSize` for an `iterate()`; `fields` and `materialisesRows` to ask
5146
+ * about a read other than the one this reader was built for, which is what a `QvdFile` does per call;
5147
+ * `paging` to say whether the read being asked about is a paging read, which defaults to whether this
5148
+ * reader is one.
5147
5149
  * @return {any} The answer - see `checkMemory`.
5148
5150
  */
5149
- checkParsed(window, { chunkSize = null, fields = void 0, materialisesRows = void 0 } = {}) {
5151
+ checkParsed(window, { chunkSize = null, fields = void 0, materialisesRows = void 0, paging = this._symbolCache !== null } = {}) {
5150
5152
  assert4__default.default(this._header && this._allFields, "The QVD file header has not been parsed.");
5151
5153
  const header = this._header["QvdTableHeader"];
5152
5154
  const totalRows = headerInteger(header["NoOfRecords"]);
@@ -5157,15 +5159,13 @@ var init_QvdFileReader = __esm({
5157
5159
  const resolved = resolveWindow(window, totalRows);
5158
5160
  const windowRows = resolved.limit;
5159
5161
  const liveRows = chunkSize === null ? null : { rows: chunkSize * 2, perChunk: 2 };
5160
- const analysisAhead = this._analysisAhead(window, resolved, totalRows, symbolTableLength);
5162
+ const analysisAhead = paging ? false : this._analysisWouldRun(window, resolved, totalRows, symbolTableLength);
5161
5163
  const measured = getMemoryBudget();
5162
5164
  const ask = /* @__PURE__ */ __name((asked, rows) => {
5163
- const bytes = symbolBytesOf(this._fieldsHeldAfter(asked, this._allFields), symbolTableLength);
5164
- const read = symbolBytesOf(this._fieldsReadBy(asked), symbolTableLength);
5165
- const retained = symbolBytesOf(
5166
- this._fieldsHeldAfter(asked, this._allFields).slice(asked.length),
5167
- symbolTableLength
5168
- );
5165
+ const held = paging ? this._fieldsHeldAfter(asked, this._allFields) : asked;
5166
+ const bytes = symbolBytesOf(held, symbolTableLength);
5167
+ const read = symbolBytesOf(paging ? this._fieldsReadBy(asked) : asked, symbolTableLength);
5168
+ const retained = paging ? symbolBytesOf(held.slice(asked.length), symbolTableLength) : 0;
5169
5169
  return checkMemory({
5170
5170
  measured,
5171
5171
  symbolTableSize: bytes,
@@ -5176,7 +5176,7 @@ var init_QvdFileReader = __esm({
5176
5176
  materialisesRows: builds,
5177
5177
  live: liveRows,
5178
5178
  // A paging read keeps whole columns, so it is charged for whole columns - see `estimateMemoryUsage`.
5179
- wholeSymbols: this._symbolCache !== null,
5179
+ wholeSymbols: paging,
5180
5180
  retainedBytes: retained,
5181
5181
  bytesHeld: this._bytesHeld(read, rows, recordSize, liveRows, analysisAhead, bytes - retained),
5182
5182
  // What it reads from the file, which is not what it holds: the symbol areas it has still to read,
@@ -5511,12 +5511,16 @@ var init_QvdFile = __esm({
5511
5511
  /**
5512
5512
  * What a read of this file would cost, and whether it fits - with no I/O at all.
5513
5513
  *
5514
- * The same answer `QvdDataFrame.checkRead()` gives, from the header this file already holds, so a
5515
- * viewer can size a page before asking for it without touching the disk.
5514
+ * Without `chunkSize` it asks about a page, and answers for the page this file would read next: the
5515
+ * columns it names plus the ones earlier pages decoded and kept, since those are part of what the page
5516
+ * costs. With `chunkSize` it asks about an `iterate()` of the file instead - which this object cannot
5517
+ * make, but a caller holding it may want to weigh - and answers exactly as `QvdDataFrame.checkRead()`
5518
+ * would, from the header this file already holds rather than by reading it again.
5516
5519
  *
5517
5520
  * @param {{offset?: number, limit?: number|null, maxRows?: number|null, fields?: Array<string>|null,
5518
5521
  * as?: 'rows'|'columns', chunkSize?: number|null}} [options] The read being asked about - the same
5519
- * bag `rows()` takes, plus `as` and `chunkSize` to say which shape of read it is.
5522
+ * bag `rows()` takes, plus `as` to say which shape of page, and `chunkSize` to ask about an
5523
+ * `iterate()` of the file rather than a page.
5520
5524
  * @return {any} The answer - `fits`, `reason`, `estimate`, `budget`, `exact`, `suggestions`.
5521
5525
  * @throws {QvdValidationError} If the file is closed, or an option's value is not valid.
5522
5526
  */
@@ -5535,7 +5539,7 @@ var init_QvdFile = __esm({
5535
5539
  if (chunkSize !== null) {
5536
5540
  requireChunkSize(chunkSize, this._options.path);
5537
5541
  }
5538
- const reader = this._readers[as] ?? this._reader;
5542
+ const reader = chunkSize !== null ? this._reader : this._readers[as] ?? this._reader;
5539
5543
  return reader.checkParsed(normaliseWindow(windowFrom(options), this._options.path), {
5540
5544
  chunkSize,
5541
5545
  // Resolved here rather than left to the reader, exactly as `_page` resolves it. A warm reader is
@@ -5544,7 +5548,12 @@ var init_QvdFile = __esm({
5544
5548
  // file after a page naming one of them, it reported 27,490 bytes for a read that costs 108,160:
5545
5549
  // understating, which is the direction that approves a read the read then refuses.
5546
5550
  fields: options.fields === void 0 ? this._options.fields ?? null : options.fields,
5547
- materialisesRows: as === "rows"
5551
+ materialisesRows: as === "rows",
5552
+ // Said outright rather than read off the reader. The header reader has paging on, because a check
5553
+ // made before the first page has to be priced as that page will be - so it cannot tell an `iterate()`
5554
+ // question from a page one by its own mode, and routing to it alone still priced the iterate as a
5555
+ // page wherever a bounded window would have been filtered.
5556
+ ...chunkSize === null ? {} : { paging: false }
5548
5557
  });
5549
5558
  }
5550
5559
  /**