Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Jan 30, 2024
1 parent d4cd8fb commit 5684540
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions modules/flatgeobuf/src/lib/get-schema-from-fgb-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ enum fgbColumnType {
}

/** Convert FGB types to arrow like types */
// eslint-disable-next-line complexity
function getTypeFromFGBType(fgbType: fgbColumnType /* fgb.ColumnMeta['type'] */): DataType {
switch (fgbType) {
case fgbColumnType.Byte:
Expand Down
4 changes: 2 additions & 2 deletions modules/parquet/src/lib/wasm/encode-parquet-wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type {ParquetWriterOptions} from '../../parquet-wasm-writer';
*/
export async function encode(
table: ArrowTable,
options?: ParquetWriterOptions
options: ParquetWriterOptions
): Promise<ArrayBuffer> {
const wasmUrl = options?.parquet?.wasmUrl;
const wasmUrl = options.parquet?.wasmUrl!;
const wasm = await loadWasm(wasmUrl);

// Serialize the table to the IPC format.
Expand Down
24 changes: 14 additions & 10 deletions modules/parquet/src/lib/wasm/parse-parquet-wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ import * as arrow from 'apache-arrow';

export async function parseParquetWasm(
arrayBuffer: ArrayBuffer,
options?: ParquetWasmLoaderOptions
options: ParquetWasmLoaderOptions
): Promise<ArrowTable> {
const arr = new Uint8Array(arrayBuffer);

const wasmUrl = options?.parquet?.wasmUrl;
const wasm = await loadWasm(wasmUrl);

const arr = new Uint8Array(arrayBuffer);
const wasmTable = wasm.readParquet(arr);
const ipcStream = wasmTable.intoIPCStream();
const arrowTable = arrow.tableFromIPC(ipcStream);
try {
const ipcStream = wasmTable.intoIPCStream();
const arrowTable = arrow.tableFromIPC(ipcStream);

return {
shape: 'arrow-table',
schema: serializeArrowSchema(arrowTable.schema),
data: arrowTable
};
return {
shape: 'arrow-table',
schema: serializeArrowSchema(arrowTable.schema),
data: arrowTable
};
} finally {
wasmTable.free();
}
}

0 comments on commit 5684540

Please sign in to comment.