@gscdump/engine 0.33.4 → 0.33.6
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/rollups.mjs +27 -12
- package/package.json +3 -3
package/dist/rollups.mjs
CHANGED
|
@@ -785,12 +785,22 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
785
785
|
const sqlFor = dailyWindowSqlFor(useDim, canonExpr);
|
|
786
786
|
const cols = queryCanonicalDailyRollup.parquetColumns;
|
|
787
787
|
const sortKey = queryCanonicalDailyRollup.parquetSortKey;
|
|
788
|
-
const batchRows = [];
|
|
789
788
|
let i = windowOffset;
|
|
790
789
|
let page = startPageOffset;
|
|
791
790
|
let nextWindowOffset = windowsTotal;
|
|
792
791
|
let nextPageOffset = 0;
|
|
793
|
-
|
|
792
|
+
let rowsWritten = 0;
|
|
793
|
+
let pausedMidWindow = false;
|
|
794
|
+
const flushPage = async (windowIdx, pageOffset, rows) => {
|
|
795
|
+
if (rows.length === 0) return;
|
|
796
|
+
const key = rollupParquetKey(ctx, `${CANONICAL_DAILY_PART_STEM}__w${windowIdx}_p${pageOffset}`, builtAt, searchType);
|
|
797
|
+
await dataSource.write(key, encodeRowsToParquetFlex(rows, {
|
|
798
|
+
columns: cols,
|
|
799
|
+
sortKey
|
|
800
|
+
}));
|
|
801
|
+
rowsWritten += rows.length;
|
|
802
|
+
};
|
|
803
|
+
for (; i < windowsTotal; i++) {
|
|
794
804
|
const w = windows[i];
|
|
795
805
|
const coreSql = sqlFor(w);
|
|
796
806
|
for (;;) {
|
|
@@ -807,7 +817,7 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
807
817
|
},
|
|
808
818
|
sql: `${coreSql}\nORDER BY date, query_canonical\nLIMIT ${pageRows} OFFSET ${page}`
|
|
809
819
|
});
|
|
810
|
-
|
|
820
|
+
await flushPage(i, page, result.rows.map(mapDailyRow));
|
|
811
821
|
const windowDone = result.rows.length < pageRows;
|
|
812
822
|
page += pageRows;
|
|
813
823
|
if (windowDone) {
|
|
@@ -817,37 +827,42 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
817
827
|
if (Date.now() > deadlineMs) {
|
|
818
828
|
nextWindowOffset = i;
|
|
819
829
|
nextPageOffset = page;
|
|
820
|
-
|
|
830
|
+
pausedMidWindow = true;
|
|
831
|
+
break;
|
|
821
832
|
}
|
|
822
833
|
}
|
|
834
|
+
if (pausedMidWindow) break;
|
|
823
835
|
if (Date.now() > deadlineMs) {
|
|
824
836
|
nextWindowOffset = i + 1;
|
|
825
837
|
nextPageOffset = 0;
|
|
826
838
|
break;
|
|
827
839
|
}
|
|
828
840
|
}
|
|
829
|
-
const partKey = rollupParquetKey(ctx, `${CANONICAL_DAILY_PART_STEM}__w${windowOffset}_p${startPageOffset}`, builtAt, searchType);
|
|
830
|
-
await dataSource.write(partKey, encodeRowsToParquetFlex(batchRows, {
|
|
831
|
-
columns: cols,
|
|
832
|
-
sortKey
|
|
833
|
-
}));
|
|
834
841
|
if (nextWindowOffset < windowsTotal || nextPageOffset > 0) return {
|
|
835
842
|
done: false,
|
|
836
843
|
nextWindowOffset,
|
|
837
844
|
nextPageOffset,
|
|
838
845
|
windowsTotal,
|
|
839
846
|
windowsBuilt: nextWindowOffset - windowOffset,
|
|
840
|
-
rowsWritten
|
|
847
|
+
rowsWritten
|
|
841
848
|
};
|
|
842
849
|
const partPrefixDir = rollupParquetKey(ctx, CANONICAL_DAILY_PART_STEM, builtAt, searchType).replace(/[^/]*$/, "");
|
|
843
850
|
const partKeys = (await dataSource.list(partPrefixDir)).filter((k) => k.includes(`${CANONICAL_DAILY_PART_STEM}__w`) && k.endsWith(`__v${builtAt}.parquet`)).sort();
|
|
851
|
+
if (partKeys.length === 0) {
|
|
852
|
+
const emptyKey = rollupParquetKey(ctx, `${CANONICAL_DAILY_PART_STEM}__w0_p0`, builtAt, searchType);
|
|
853
|
+
await dataSource.write(emptyKey, encodeRowsToParquetFlex([], {
|
|
854
|
+
columns: cols,
|
|
855
|
+
sortKey
|
|
856
|
+
}));
|
|
857
|
+
partKeys.push(emptyKey);
|
|
858
|
+
}
|
|
844
859
|
const envelope = {
|
|
845
860
|
version: 1,
|
|
846
861
|
id: CANONICAL_DAILY_ROLLUP_FINAL_ID,
|
|
847
862
|
builtAt,
|
|
848
863
|
windowDays: queryCanonicalDailyRollup.windowDays,
|
|
849
864
|
payload: {
|
|
850
|
-
parquetKey: partKeys[0]
|
|
865
|
+
parquetKey: partKeys[0],
|
|
851
866
|
parquetKeys: partKeys,
|
|
852
867
|
rowCount: 0
|
|
853
868
|
}
|
|
@@ -859,7 +874,7 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
859
874
|
nextPageOffset,
|
|
860
875
|
windowsTotal,
|
|
861
876
|
windowsBuilt: nextWindowOffset - windowOffset,
|
|
862
|
-
rowsWritten
|
|
877
|
+
rowsWritten
|
|
863
878
|
};
|
|
864
879
|
}
|
|
865
880
|
const indexingMetadataRollup = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gscdump/engine",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.33.
|
|
4
|
+
"version": "0.33.6",
|
|
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/contracts": "0.33.
|
|
185
|
-
"gscdump": "0.33.
|
|
184
|
+
"@gscdump/contracts": "0.33.6",
|
|
185
|
+
"gscdump": "0.33.6"
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@duckdb/duckdb-wasm": "^1.32.0",
|