Skip to content

Commit fd0c0f8

Browse files
authored
Merge pull request #3232 from perspective-dev/fix-exports
Add `zstd` support to `View::to_arrow`
2 parents fb02aa3 + 2086410 commit fd0c0f8

46 files changed

Lines changed: 1494 additions & 842 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build.yaml‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,12 @@ jobs:
847847
- ubuntu-22.04
848848
python-version:
849849
- 3.11
850-
node-version: [22.x]
850+
node-version: [22.x, 26.x]
851+
is-release:
852+
- ${{ startsWith(github.ref, 'refs/tags/v') || github.ref_name == 'master' || github.event.inputs.ci-full }}
853+
exclude:
854+
- node-version: 26.x
855+
is-release: false
851856

852857
steps:
853858
- name: Checkout
@@ -890,7 +895,7 @@ jobs:
890895
if: ${{ failure() && steps.run_tests.outcome == 'failure' }}
891896
uses: actions/upload-artifact@v4
892897
with:
893-
name: perspective-js-test-results
898+
name: perspective-js-test-results-node${{ matrix.node-version }}
894899
path: tools/test/dist/results
895900
if-no-files-found: ignore
896901
overwrite: true

‎docs/md/how_to/javascript/serializing.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,12 @@ console.log(await view.to_ndjson());
1919
// ArrayBuffer
2020
console.log(await view.to_arrow());
2121
```
22+
23+
`to_arrow()` writes an uncompressed Arrow IPC stream by default; pass
24+
`compression` to apply LZ4 or ZSTD body compression, which `Client::table` reads
25+
back transparently:
26+
27+
```javascript
28+
const compressed = await view.to_arrow({ compression: "zstd" });
29+
const table2 = await client.table(compressed);
30+
```

‎docs/md/how_to/javascript/viewer.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ never deletes the result.
153153
| `copy(options?)` | Copy a panel to the clipboard |
154154

155155
`export()`, `download()` and `copy()` all take a `method`, one of `"csv"`,
156-
`"json"`, `"ndjson"` or `"arrow"` — each with `-all` and `-selected` variants
157-
(e.g. `"csv-selected"`) — plus `"html"`, `"json-config"`, and `"plugin"`.
156+
`"json"`, `"ndjson"`, `"arrow"`, `"arrow-lz4"` or `"arrow-zstd"` — each with
157+
`-all` and `-selected` variants (e.g. `"csv-selected"`, `"arrow-zstd-all"`) —
158+
plus `"html"`, `"json-config"`, and `"plugin"`. The `"arrow-lz4"` and
159+
`"arrow-zstd"` methods write the Arrow IPC stream with LZ4 or ZSTD body
160+
compression.
158161
The `"plugin"` method asks the plugin to render itself, which produces a PNG
159162
for charts and text for the datagrid.
160163
| `getSelection(options?)` / `setSelection(...)` | Get or set the selected region |

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"llvm": "17.0.6",
1919
"pyodide": "0.29.4",
2020
"engines": {
21-
"node": ">=16 <24"
21+
"node": ">=16 <27"
2222
},
2323
"workspaces": [
2424
"tools/test",

‎pnpm-lock.yaml‎

Lines changed: 452 additions & 327 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ catalog:
4747
"@fontsource/roboto-mono": "4.5.10"
4848
"@iarna/toml": "3.0.0"
4949
"@jupyterlab/builder": "^4"
50-
"@playwright/experimental-ct-react": "=1.58.0"
51-
"@playwright/test": "=1.58.0"
50+
"@playwright/experimental-ct-react": "=1.62.0"
51+
"@playwright/test": "=1.62.0"
5252
"lightningcss": "^1.29.0"
5353
"@types/lodash": "^4.17.20"
5454
"@types/node": ">=22"

‎rust/perspective-client/src/rust/view.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ pub struct ViewWindow {
105105
#[serde(skip_serializing_if = "Option::is_none")]
106106
pub formatted: Option<bool>,
107107

108-
/// Only impacts [`View::to_arrow`]
108+
/// Arrow IPC body compression for [`View::to_arrow`], `"lz4"` or `"zstd"`
109+
/// (uncompressed when omitted).
109110
#[ts(optional)]
111+
#[ts(type = "\"lz4\" | \"zstd\"")]
110112
#[serde(skip_serializing_if = "Option::is_none")]
111113
pub compression: Option<String>,
112114

@@ -423,7 +425,8 @@ impl View {
423425
}
424426
}
425427

426-
/// Serializes a [`View`] to the Apache Arrow data format.
428+
/// Serializes a [`View`] to the Apache Arrow data format, with IPC body
429+
/// compression per [`ViewWindow::compression`].
427430
pub async fn to_arrow(&self, window: ViewWindow) -> ClientResult<Bytes> {
428431
let msg = self.client_message(ClientReq::ViewToArrowReq(ViewToArrowReq {
429432
viewport: Some(window.clone().into()),

‎rust/perspective-js/src/rust/view.rs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,17 @@ impl View {
195195
}
196196

197197
/// Serializes a [`View`] to the Apache Arrow data format.
198+
///
199+
/// # Arguments
200+
///
201+
/// - `window` - a [`ViewWindow`]; its `compression` key selects Arrow IPC
202+
/// body compression, `"lz4"` or `"zstd"` (uncompressed when omitted).
203+
///
204+
/// # JavaScript Examples
205+
///
206+
/// ```javascript
207+
/// const arrow = await view.to_arrow({ compression: "zstd" });
208+
/// ```
198209
#[wasm_bindgen]
199210
pub async fn to_arrow(&self, window: Option<JsViewWindow>) -> ApiResult<ArrayBuffer> {
200211
let window = window.into_serde_ext::<Option<ViewWindow>>()?;

‎rust/perspective-js/src/ts/perspective.node.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ async function compile_server_module(wasm_path: string) {
181181
const bytes = await load_wasm_stage_0(buffer.buffer as ArrayBuffer);
182182
return await compile_perspective(bytes.buffer as ArrayBuffer, {
183183
make_disk_bridge: make_node_disk_bridge,
184+
env: process.env,
184185
});
185186
}
186187

‎rust/perspective-js/src/ts/wasm/emscripten_api.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ export interface DiskBridgeHelpers {
2424
}
2525

2626
export interface CompileOptions {
27+
env?: Record<string, string | undefined>;
28+
2729
make_disk_bridge?: (helpers: DiskBridgeHelpers) => {
2830
store(
2931
namePtr: number | bigint,
@@ -49,6 +51,7 @@ export async function compile_perspective(
4951
return x;
5052
},
5153
make_disk_bridge: opts?.make_disk_bridge,
54+
env: opts?.env,
5255
instantiateWasm: async (
5356
imports: any,
5457
receive: (_: WebAssembly.Instance) => void,

0 commit comments

Comments
 (0)