sliftutils 1.4.43 → 1.4.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.43",
3
+ "version": "1.4.44",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -1249,12 +1249,16 @@ export class BulkDatabaseBase<T extends { key: string }> {
1249
1249
  if (recentBytes >= FIRST_MERGE_BYTES) break;
1250
1250
  }
1251
1251
  const span = recent.length ? recent[0].time - recent[recent.length - 1].time : 0;
1252
- // Fold when there's enough fragmentation to consolidate, OR when a foldable stream has grown too
1253
- // big to keep reading whole (even if it's the only recent file) see streamNeedsFold.
1254
- const heavyStreamRecent = this.streamNeedsFold() && recent.some(i => i.kind === "stream");
1252
+ // Fold when there's enough fragmentation to consolidate, OR when the foldable stream data here
1253
+ // has grown past the byte threshold (stream data can't be read per-cell, so a big stream is
1254
+ // costly to pull whole). The stream size is derived from THIS fresh listing — not a cached
1255
+ // counter — so it's correct even for an instance that never built a reader (e.g. the host's
1256
+ // autocompactor) and for streams that grew in place since the index was last loaded.
1257
+ const recentStreamBytes = recent.reduce((a, it) => a + (it.kind === "stream" ? it.bytes : 0), 0);
1258
+ const heavyStream = recentStreamBytes > bulkDatabase2Timing.streamFoldTriggerBytes;
1255
1259
  const triggered =
1256
1260
  recent.length >= 2 && (recent.length > bulkDatabase2Timing.firstMergeTriggerFiles || span > bulkDatabase2Timing.firstMergeTriggerRangeMs)
1257
- || heavyStreamRecent && recent.length >= 1;
1261
+ || heavyStream;
1258
1262
  if (triggered) {
1259
1263
  const rb = recent.filter(i => i.kind === "bulk").map(i => (i.file as BulkFileInfo));
1260
1264
  const rs = recent.filter(i => i.kind === "stream").map(i => (i.file as StreamFileInfo));