@gscdump/engine 0.33.4 → 0.33.5
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 +22 -10
- package/package.json +3 -3
package/dist/rollups.mjs
CHANGED
|
@@ -785,11 +785,20 @@ 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;
|
|
792
|
+
let rowsWritten = 0;
|
|
793
|
+
const flushPage = async (windowIdx, pageOffset, rows) => {
|
|
794
|
+
if (rows.length === 0) return;
|
|
795
|
+
const key = rollupParquetKey(ctx, `${CANONICAL_DAILY_PART_STEM}__w${windowIdx}_p${pageOffset}`, builtAt, searchType);
|
|
796
|
+
await dataSource.write(key, encodeRowsToParquetFlex(rows, {
|
|
797
|
+
columns: cols,
|
|
798
|
+
sortKey
|
|
799
|
+
}));
|
|
800
|
+
rowsWritten += rows.length;
|
|
801
|
+
};
|
|
793
802
|
windowLoop: for (; i < windowsTotal; i++) {
|
|
794
803
|
const w = windows[i];
|
|
795
804
|
const coreSql = sqlFor(w);
|
|
@@ -807,7 +816,7 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
807
816
|
},
|
|
808
817
|
sql: `${coreSql}\nORDER BY date, query_canonical\nLIMIT ${pageRows} OFFSET ${page}`
|
|
809
818
|
});
|
|
810
|
-
|
|
819
|
+
await flushPage(i, page, result.rows.map(mapDailyRow));
|
|
811
820
|
const windowDone = result.rows.length < pageRows;
|
|
812
821
|
page += pageRows;
|
|
813
822
|
if (windowDone) {
|
|
@@ -826,28 +835,31 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
826
835
|
break;
|
|
827
836
|
}
|
|
828
837
|
}
|
|
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
838
|
if (nextWindowOffset < windowsTotal || nextPageOffset > 0) return {
|
|
835
839
|
done: false,
|
|
836
840
|
nextWindowOffset,
|
|
837
841
|
nextPageOffset,
|
|
838
842
|
windowsTotal,
|
|
839
843
|
windowsBuilt: nextWindowOffset - windowOffset,
|
|
840
|
-
rowsWritten
|
|
844
|
+
rowsWritten
|
|
841
845
|
};
|
|
842
846
|
const partPrefixDir = rollupParquetKey(ctx, CANONICAL_DAILY_PART_STEM, builtAt, searchType).replace(/[^/]*$/, "");
|
|
843
847
|
const partKeys = (await dataSource.list(partPrefixDir)).filter((k) => k.includes(`${CANONICAL_DAILY_PART_STEM}__w`) && k.endsWith(`__v${builtAt}.parquet`)).sort();
|
|
848
|
+
if (partKeys.length === 0) {
|
|
849
|
+
const emptyKey = rollupParquetKey(ctx, `${CANONICAL_DAILY_PART_STEM}__w0_p0`, builtAt, searchType);
|
|
850
|
+
await dataSource.write(emptyKey, encodeRowsToParquetFlex([], {
|
|
851
|
+
columns: cols,
|
|
852
|
+
sortKey
|
|
853
|
+
}));
|
|
854
|
+
partKeys.push(emptyKey);
|
|
855
|
+
}
|
|
844
856
|
const envelope = {
|
|
845
857
|
version: 1,
|
|
846
858
|
id: CANONICAL_DAILY_ROLLUP_FINAL_ID,
|
|
847
859
|
builtAt,
|
|
848
860
|
windowDays: queryCanonicalDailyRollup.windowDays,
|
|
849
861
|
payload: {
|
|
850
|
-
parquetKey: partKeys[0]
|
|
862
|
+
parquetKey: partKeys[0],
|
|
851
863
|
parquetKeys: partKeys,
|
|
852
864
|
rowCount: 0
|
|
853
865
|
}
|
|
@@ -859,7 +871,7 @@ async function rebuildCanonicalDailyResumable(opts) {
|
|
|
859
871
|
nextPageOffset,
|
|
860
872
|
windowsTotal,
|
|
861
873
|
windowsBuilt: nextWindowOffset - windowOffset,
|
|
862
|
-
rowsWritten
|
|
874
|
+
rowsWritten
|
|
863
875
|
};
|
|
864
876
|
}
|
|
865
877
|
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.5",
|
|
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
|
-
"
|
|
185
|
-
"gscdump": "0.33.
|
|
184
|
+
"gscdump": "0.33.5",
|
|
185
|
+
"@gscdump/contracts": "0.33.5"
|
|
186
186
|
},
|
|
187
187
|
"devDependencies": {
|
|
188
188
|
"@duckdb/duckdb-wasm": "^1.32.0",
|