From 2e3968b84011f90c4109b4d482701b70a6bf02cd Mon Sep 17 00:00:00 2001 From: Razvan Nazare Date: Mon, 26 Feb 2024 19:58:14 +0200 Subject: [PATCH] kinda working --- .../wafer-map/modules/wafer-map-convertor.ts | 43 +++++++++++++------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/packages/nimble-components/src/wafer-map/modules/wafer-map-convertor.ts b/packages/nimble-components/src/wafer-map/modules/wafer-map-convertor.ts index 347d408495..9255dd1f03 100644 --- a/packages/nimble-components/src/wafer-map/modules/wafer-map-convertor.ts +++ b/packages/nimble-components/src/wafer-map/modules/wafer-map-convertor.ts @@ -1,30 +1,49 @@ -import { Table, Int32, Float32, tableFromArrays } from 'apache-arrow'; +import { Table, tableFromArrays } from 'apache-arrow'; import type { WaferMapDie } from '../types'; /** - * This class is used to convert old wafer map data to new wafer map data + * This class is used to convert old wafer map data to new wafer map data */ export class WaferMapConvertor { - public convertWaferMapDiesToTable(waferMapDies: WaferMapDie[]): Table<{ - colIndex: Int32, - rowIndex: Int32, - value: Float32 - }>[] { + public convertWaferMapDiesToTable(waferMapDies: WaferMapDie[]): Table { const dieColIndexLayer: number[] = []; const dieRowIndexLayer: number[] = []; const dieValuesLayer: number[] = []; + const metadataColumns: { [key: string]: (number | string | boolean)[] } = {}; waferMapDies.forEach(die => { dieColIndexLayer.push(die.x); dieRowIndexLayer.push(die.y); dieValuesLayer.push(parseFloat(die.value)); + if (typeof die.metadata === 'object' && die.metadata !== null) { + Object.entries(die.metadata).forEach(([key, value]) => { + if (!metadataColumns[key]) { + metadataColumns[key] = []; + } + // Ensure value is of type number | string | boolean before pushing + if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean') { + metadataColumns[key]?.push(value); + } + }); + } }); - const table = tableFromArrays({ + + // eslint-disable-next-line no-console + console.log(waferMapDies); + + // eslint-disable-next-line no-console + console.log(metadataColumns); + + // Construct the arrays for table creation + const arrays = { colIndex: new Int32Array(dieColIndexLayer), rowIndex: new Int32Array(dieRowIndexLayer), - value: new Float32Array(dieValuesLayer) - }); + value: new Float32Array(dieValuesLayer), + ...metadataColumns + }; + + const table = tableFromArrays(arrays); - return [table]; + return table; } -} \ No newline at end of file +}