@gscdump/engine 0.31.6 → 0.31.8

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.
@@ -220,6 +220,8 @@ declare const WINDOW_BYTE_BUDGET: number;
220
220
  */
221
221
  declare const ROLLUP_PAGE_ROWS = 50000;
222
222
  declare const ROLLUP_PAGE_ROWS_WIDE = 20000;
223
+ declare const ROLLUP_PAGE_ROWS_DAILY = 90000;
224
+ declare const DAILY_MAX_WINDOW_DAYS = 7;
223
225
  /**
224
226
  * UTC day-aligned [startMs, endMs] span a partition covers. Returns null for
225
227
  * `hourly/` partitions and anything unrecognised — those are excluded from
@@ -240,7 +242,7 @@ declare function planRollupWindows(parts: Array<{
240
242
  }>, clampRange?: {
241
243
  start: string;
242
244
  end: string;
243
- }): Array<{
245
+ }, maxWindowDays?: number): Array<{
244
246
  start: string;
245
247
  end: string;
246
248
  partitions: string[];
@@ -280,7 +282,8 @@ declare function runWindowed(opts: {
280
282
  paginate?: {
281
283
  orderBy: string;
282
284
  pageRows: number;
283
- };
285
+ }; /** Cap each window's day span (output-cardinality bound). See `planRollupWindows`. */
286
+ maxWindowDays?: number;
284
287
  }): Promise<Row$1[]>;
285
288
  /**
286
289
  * Daily totals across the full history. One row per (date, table) with
@@ -446,4 +449,4 @@ declare const DEFAULT_ROLLUPS: readonly RollupDef[];
446
449
  * (CLI: `gscdump rollups --with-canonical`).
447
450
  */
448
451
  declare const CANONICAL_ROLLUPS: readonly RollupDef[];
449
- export { CANONICAL_ROLLUPS, DEFAULT_ROLLUPS, ParquetRollupPointer, ROLLUP_PAGE_ROWS, ROLLUP_PAGE_ROWS_WIDE, RebuildDailyFromHourlyOptions, RebuildRollupResult, RebuildRollupsOptions, RollupBucket, RollupCtx, RollupDef, RollupEngine, RollupEnvelope, WINDOW_BYTE_BUDGET, dailyTotalsRollup, indexPercentRollup, indexingHealthRollup, indexingMetadataRollup, partitionDaySpan, partitionsInRange, planRollupWindows, queryCanonicalDailyRollup, queryCanonicalVariantsRollup, readLatestRollup, rebuildDailyFromHourly, rebuildRollups, rollupKey, rollupParquetKey, runWindowed, sitemapChanges28dRollup, sitemapHealthRollup, topCountries28dRollup, topKeywords28dParquetRollup, topKeywords28dRollup, topPages28dRollup, weeklyTotalsRollup };
452
+ export { CANONICAL_ROLLUPS, DAILY_MAX_WINDOW_DAYS, DEFAULT_ROLLUPS, ParquetRollupPointer, ROLLUP_PAGE_ROWS, ROLLUP_PAGE_ROWS_DAILY, ROLLUP_PAGE_ROWS_WIDE, RebuildDailyFromHourlyOptions, RebuildRollupResult, RebuildRollupsOptions, RollupBucket, RollupCtx, RollupDef, RollupEngine, RollupEnvelope, WINDOW_BYTE_BUDGET, dailyTotalsRollup, indexPercentRollup, indexingHealthRollup, indexingMetadataRollup, partitionDaySpan, partitionsInRange, planRollupWindows, queryCanonicalDailyRollup, queryCanonicalVariantsRollup, readLatestRollup, rebuildDailyFromHourly, rebuildRollups, rollupKey, rollupParquetKey, runWindowed, sitemapChanges28dRollup, sitemapHealthRollup, topCountries28dRollup, topKeywords28dParquetRollup, topKeywords28dRollup, topPages28dRollup, weeklyTotalsRollup };
package/dist/rollups.mjs CHANGED
@@ -129,6 +129,8 @@ function utcDateMinusDays(at, days) {
129
129
  const WINDOW_BYTE_BUDGET = 10 * 1024 * 1024;
130
130
  const ROLLUP_PAGE_ROWS = 5e4;
131
131
  const ROLLUP_PAGE_ROWS_WIDE = 2e4;
132
+ const ROLLUP_PAGE_ROWS_DAILY = 9e4;
133
+ const DAILY_MAX_WINDOW_DAYS = 7;
132
134
  const DAY_RE = /^daily\/(\d{4})-(\d{2})-(\d{2})$/;
133
135
  const WEEK_RE = /^weekly\/(\d{4})-(\d{2})-(\d{2})$/;
134
136
  const MONTH_RE = /^monthly\/(\d{4})-(\d{2})$/;
@@ -177,7 +179,7 @@ function partitionDaySpan(partition) {
177
179
  function clamp(n, lo, hi) {
178
180
  return Math.max(lo, Math.min(hi, n));
179
181
  }
180
- function planRollupWindows(parts, clampRange) {
182
+ function planRollupWindows(parts, clampRange, maxWindowDays) {
181
183
  const clampStartMs = clampRange ? Date.parse(`${clampRange.start}T00:00:00Z`) : void 0;
182
184
  const clampEndMs = clampRange ? Date.parse(`${clampRange.end}T00:00:00Z`) : void 0;
183
185
  const spans = [];
@@ -202,7 +204,8 @@ function planRollupWindows(parts, clampRange) {
202
204
  const totalBytes = spans.reduce((a, s) => a + s.bytes, 0);
203
205
  const spanDays = Math.floor((rangeEndMs - rangeStartMs) / MS_PER_DAY) + 1;
204
206
  const bytesPerDay = Math.max(1, totalBytes / spanDays);
205
- const windowDays = clamp(Math.floor(WINDOW_BYTE_BUDGET / bytesPerDay), 7, 400);
207
+ const byteWindowDays = clamp(Math.floor(WINDOW_BYTE_BUDGET / bytesPerDay), 7, 400);
208
+ const windowDays = maxWindowDays != null ? Math.max(1, Math.min(byteWindowDays, maxWindowDays)) : byteWindowDays;
206
209
  const windows = [];
207
210
  let cursorMs = rangeStartMs;
208
211
  while (cursorMs <= rangeEndMs) {
@@ -248,7 +251,7 @@ async function runWindowed(opts) {
248
251
  ctx: opts.ctx,
249
252
  table: opts.table,
250
253
  ...opts.searchType !== void 0 ? { searchType: opts.searchType } : {}
251
- }));
254
+ }), void 0, opts.maxWindowDays);
252
255
  const rows = [];
253
256
  for (const w of windows) {
254
257
  const fileSets = {
@@ -707,8 +710,9 @@ const queryCanonicalDailyRollup = {
707
710
  } } } : {},
708
711
  paginate: {
709
712
  orderBy: "date, query_canonical",
710
- pageRows: ROLLUP_PAGE_ROWS
713
+ pageRows: ROLLUP_PAGE_ROWS_DAILY
711
714
  },
715
+ maxWindowDays: 7,
712
716
  sqlFor: useDim ? (w) => `
713
717
  SELECT
714
718
  ${canonExpr} AS query_canonical,
@@ -1052,4 +1056,4 @@ const DEFAULT_ROLLUPS = [
1052
1056
  sitemapChanges28dRollup
1053
1057
  ];
1054
1058
  const CANONICAL_ROLLUPS = [queryCanonicalVariantsRollup, queryCanonicalDailyRollup];
1055
- export { CANONICAL_ROLLUPS, DEFAULT_ROLLUPS, ROLLUP_PAGE_ROWS, ROLLUP_PAGE_ROWS_WIDE, WINDOW_BYTE_BUDGET, dailyTotalsRollup, indexPercentRollup, indexingHealthRollup, indexingMetadataRollup, partitionDaySpan, partitionsInRange, planRollupWindows, queryCanonicalDailyRollup, queryCanonicalVariantsRollup, readLatestRollup, rebuildDailyFromHourly, rebuildRollups, rollupKey, rollupParquetKey, runWindowed, sitemapChanges28dRollup, sitemapHealthRollup, topCountries28dRollup, topKeywords28dParquetRollup, topKeywords28dRollup, topPages28dRollup, weeklyTotalsRollup };
1059
+ export { CANONICAL_ROLLUPS, DAILY_MAX_WINDOW_DAYS, DEFAULT_ROLLUPS, ROLLUP_PAGE_ROWS, ROLLUP_PAGE_ROWS_DAILY, ROLLUP_PAGE_ROWS_WIDE, WINDOW_BYTE_BUDGET, dailyTotalsRollup, indexPercentRollup, indexingHealthRollup, indexingMetadataRollup, partitionDaySpan, partitionsInRange, planRollupWindows, queryCanonicalDailyRollup, queryCanonicalVariantsRollup, readLatestRollup, rebuildDailyFromHourly, rebuildRollups, rollupKey, rollupParquetKey, runWindowed, sitemapChanges28dRollup, sitemapHealthRollup, topCountries28dRollup, topKeywords28dParquetRollup, topKeywords28dRollup, topPages28dRollup, weeklyTotalsRollup };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gscdump/engine",
3
3
  "type": "module",
4
- "version": "0.31.6",
4
+ "version": "0.31.8",
5
5
  "description": "Append-only Parquet/DuckDB storage engine + planner + adapters for the gscdump pipeline. Node + edge runtimes; opt-in heavy peers.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -181,8 +181,8 @@
181
181
  "dependencies": {
182
182
  "drizzle-orm": "1.0.0-rc.3",
183
183
  "proper-lockfile": "^4.1.2",
184
- "gscdump": "0.31.6",
185
- "@gscdump/contracts": "0.31.6"
184
+ "@gscdump/contracts": "0.31.8",
185
+ "gscdump": "0.31.8"
186
186
  },
187
187
  "devDependencies": {
188
188
  "@duckdb/duckdb-wasm": "^1.32.0",