sliftutils 1.4.73 → 1.4.75

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.73",
3
+ "version": "1.4.75",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -396,7 +396,7 @@ async function executeBatch(
396
396
  }
397
397
  }
398
398
  }
399
- log(`${magenta("input")} ${sourceNames[si]}: ${fmtBytes(bytesRead)} read`);
399
+ log(`${magenta("input")} ${si + 1}/${sources.length} ${sourceNames[si]}: ${fmtBytes(bytesRead)} read`);
400
400
  }
401
401
 
402
402
  // Assemble + write each output file in this batch.
@@ -408,7 +408,7 @@ async function executeBatch(
408
408
  const { name, size } = await writeFile(fileBuf);
409
409
  const sourcesNamed = new Map<string, number>();
410
410
  for (const [si, n] of plan.sourceCounts) sourcesNamed.set(sourceNames[si], n);
411
- log(`${magenta("output")}: ${formatNumber(plan.keys.length)} rows from ${plan.sourceCounts.size} input(s), ${fmtBytes(size)}`);
411
+ log(`${magenta("output")} ${fi + 1}/${plans.length}: ${formatNumber(plan.keys.length)} rows from ${plan.sourceCounts.size} input(s), ${fmtBytes(size)}`);
412
412
  outputs.push({ name, minKey: plan.minKey, maxKey: plan.maxKey, rowCount: plan.keys.length, size, sources: sourcesNamed });
413
413
  }
414
414
  return outputs;
@@ -601,23 +601,32 @@ function getCompactor(baseDir: string, name: string): BulkDatabaseBase<{ key: st
601
601
  export async function autocompactBulkDatabases(root: string): Promise<void> {
602
602
  // Collections live under <baseDir>/bulkDatabases2/<name>/. The app may nest its data under a "data"
603
603
  // subfolder (see getFileStorageNested2's heuristic), so look in both <root> and <root>/data.
604
+ const collections: { baseDir: string; name: string }[] = [];
604
605
  for (const baseDir of [root, path.join(root, "data")]) {
605
- let names: string[];
606
606
  try {
607
- names = fs.readdirSync(path.join(baseDir, BULK_ROOT_FOLDER), { withFileTypes: true })
608
- .filter(d => d.isDirectory()).map(d => d.name);
609
- } catch { continue; } // no bulkDatabases2 here
610
- for (const name of names) {
611
- const start = Date.now();
612
- console.log(` [autocompact] ${name}: starting merge`);
613
- try {
614
- await getCompactor(baseDir, name).tryMergeNow();
615
- console.log(` [autocompact] ${name}: done (${Date.now() - start}ms)`);
616
- } catch (e) {
617
- console.warn(` [autocompact] ${name}: failed after ${Date.now() - start}ms - ${(e as Error).message}`);
607
+ for (const d of fs.readdirSync(path.join(baseDir, BULK_ROOT_FOLDER), { withFileTypes: true })) {
608
+ if (d.isDirectory()) collections.push({ baseDir, name: d.name });
618
609
  }
610
+ } catch { continue; } // no bulkDatabases2 here
611
+ }
612
+
613
+ const total = collections.length;
614
+ if (!total) return;
615
+ const passStart = Date.now();
616
+ console.log(` [autocompact] iterating over ${total} collection(s)`);
617
+ for (let i = 0; i < total; i++) {
618
+ const { baseDir, name } = collections[i];
619
+ const at = `${i + 1} / ${total}`;
620
+ const start = Date.now();
621
+ console.log(` [autocompact] ${at} ${name}: starting merge`);
622
+ try {
623
+ await getCompactor(baseDir, name).tryMergeNow();
624
+ console.log(` [autocompact] ${at} ${name}: done (${Date.now() - start}ms)`);
625
+ } catch (e) {
626
+ console.warn(` [autocompact] ${at} ${name}: failed after ${Date.now() - start}ms - ${(e as Error).message}`);
619
627
  }
620
628
  }
629
+ console.log(` [autocompact] done all ${total} collection(s) (${Date.now() - passStart}ms)`);
621
630
  }
622
631
 
623
632
  // CLI entry (invoked by bin/filehoster.js or `yarn filehoster <folder>`). Starts the server, logs the