-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31c5e02
commit 2e3968b
Showing
1 changed file
with
31 additions
and
12 deletions.
There are no files selected for viewing
43 changes: 31 additions & 12 deletions
43
packages/nimble-components/src/wafer-map/modules/wafer-map-convertor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |