2 #include "Util/types.h"
3 #include "Util/utils.h"
5 // deserialize a Work_t object from a bytes string
6 Work_t
* unpack_work(Byte
* packedWork
, uint32_t nbSeriesInChunk
)
8 Work_t
* work
= (Work_t
*) malloc(sizeof(Work_t
));
12 size_t inputFileNameSize
= 0;
13 while (packedWork
[inputFileNameSize
++] != 0) { }
14 work
->inputFileName
= (char*) malloc(inputFileNameSize
);
15 while (index
< inputFileNameSize
)
17 work
->inputFileName
[index
] = packedWork
[index
];
23 uint32_t nbSeries
= work
->nbSeries
= bInt_to_uint(packedWork
+ index
, 4);
26 work
->ranks
= (uint32_t*) malloc(nbSeries
* sizeof(uint32_t));
27 for (uint32_t i
= 0; i
< nbSeries
; i
++)
29 work
->ranks
[i
] = bInt_to_uint(packedWork
+ index
, 4);
32 // shift over the zeros
33 index
+= 4 * (nbSeriesInChunk
- nbSeries
);
35 work
->nbClusters
= bInt_to_uint(packedWork
+ index
, 4);
37 work
->clustOnMedoids
= bInt_to_uint(packedWork
+ index
, 4);
39 work
->p_for_dissims
= bInt_to_uint(packedWork
+ index
, 4);
44 // deserialize a Result_t object from a bytes string
45 Result_t
* unpack_result(Byte
* packedResult
)
47 Result_t
* result
= (Result_t
*) malloc(sizeof(Result_t
));
50 uint32_t nbClusters
= result
->nbClusters
= bInt_to_uint(packedResult
, 4);
53 result
->medoids_ID
= (uint32_t*) malloc(nbClusters
* sizeof(uint32_t));
54 for (uint32_t i
= 0; i
< nbClusters
; i
++)
56 result
->medoids_ID
[i
] = bInt_to_uint(packedResult
+ index
, 4);
60 result
->medoids_ranks
= (uint32_t*) malloc(nbClusters
* sizeof(uint32_t));
61 for (uint32_t i
= 0; i
< nbClusters
; i
++)
63 result
->medoids_ranks
[i
] = bInt_to_uint(packedResult
+ index
, 4);