Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump parquet and use arrow-js-ffi #341

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 49 additions & 49 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"@deck.gl/layers": "^8.9.33",
"@deck.gl/react": "^8.9.33",
"@geoarrow/deck.gl-layers": "^0.3.0-beta.8",
"apache-arrow": "^14.0.2",
"apache-arrow": "^15.0.0",
"arrow-js-ffi": "^0.4.1",
"maplibre-gl": "^3.5.2",
"parquet-wasm": "0.5.0",
"parquet-wasm": "^0.6.0-beta.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^7.1.7",
Expand Down
23 changes: 16 additions & 7 deletions src/parquet.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useEffect, useState } from "react";
import _initParquetWasm, { readParquet } from "parquet-wasm/esm/arrow2";
import _initParquetWasm, { readParquet, wasmMemory } from "parquet-wasm";

Check failure on line 2 in src/parquet.ts

View workflow job for this annotation

GitHub Actions / lint-and-test

Cannot find module 'parquet-wasm' or its corresponding type declarations.
import * as arrow from "apache-arrow";
import { parseTable } from "arrow-js-ffi";

// NOTE: this version must be synced exactly with the parquet-wasm version in
// use.
const PARQUET_WASM_VERSION = "0.5.0";
const PARQUET_WASM_CDN_URL = `https://cdn.jsdelivr.net/npm/parquet-wasm@${PARQUET_WASM_VERSION}/esm/arrow2_bg.wasm`;
const PARQUET_WASM_VERSION = "0.6.0-beta.2";
const PARQUET_WASM_CDN_URL = `https://cdn.jsdelivr.net/npm/parquet-wasm@${PARQUET_WASM_VERSION}/esm/parquet_wasm_bg.wasm`;
let WASM_READY: boolean = false;

export async function initParquetWasm() {
Expand All @@ -28,10 +29,18 @@
console.time("readParquet");

// TODO: use arrow-js-ffi for more memory-efficient wasm --> js transfer
const arrowIPCBuffer = readParquet(
new Uint8Array(dataView.buffer),
).intoIPCStream();
const arrowTable = arrow.tableFromIPC(arrowIPCBuffer);
const WASM_MEMORY = wasmMemory();
const wasmTable = readParquet(new Uint8Array(dataView.buffer));
const wasmFFITable = wasmTable.intoFFI();

console.time("arrow js ffi parseTable");
const arrowTable = parseTable(
WASM_MEMORY.buffer,
Array.from(wasmFFITable.arrayAddrs()),
wasmFFITable.schemaAddr(),
true,
);
console.timeEnd("arrow js ffi parseTable");

console.timeEnd("readParquet");

Expand Down
Loading