erp5_wendelin: add data mapping
data mapping is used to map complex data into a single value the idea is if an object has complet data to process, like (object, value1, value2, value3,value4....), we can mapping (object, value1, value2, value3,value4....) into a single value X, then we process only X to make it faster here is an use case: we have two 2D data arrays with 5 columns, the first column is the name of object, the other fours are the differents value of this object Data ArrayA: | object | value1 | value2 | value3 | value4 | | ------ | ------ | ------ | ------ | ------ | | X | 1 | 2 | 3 | 4 | | Y | 5 | 6 | 7 | 8 | | Z | 9 | 10 | 11 | 12 | Data ArrayB: | object | value1 | value2 | value3 | value4 | | ------ | ------ | ------ | ------ | ------ | | X | 1 | 2 | 3 | 4 | | Y | 5 | 8 | 7 | 8 | | Z | 9 | 10 | 192 | 12 | now we need to compare data array A to data array B to find which object inside A has different value. without data mapping, we need to compare each object's 4 values, the complexity is O(2^n) with data mapping: we map those values: (X, 1, 2, 3, 4) ==> 1 (Y, 5, 6, 7, 8) ==> 2 (Z, 9, 10, 11,12) ==>3 (Y, 5, 8, 7, 8) ==> 4 (Z, 9, 10, 192, 12) ==> 5 Data ArrayA: | object | | ------ | | 1 | | 2 | | 3 | Data ArrayB: | object | | ------ | | 1 | | 4 | | 5 | then compare 1D array is fast, the complexity is O(n)
Showing
Please register or sign in to comment