Skip to content

Commit

Permalink
kinda working
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan1928 committed Feb 26, 2024
1 parent 31c5e02 commit 2e3968b
Showing 1 changed file with 31 additions and 12 deletions.
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;
}
}
}

0 comments on commit 2e3968b

Please sign in to comment.