MCPcopy Create free account
hub / github.com/apache/madlib / arr_to_sdata

Function arr_to_sdata

methods/svec/src/pg_gp/SparseData.c:1335–1369  ·  view source on GitHub ↗

* @param array The array of elements to be converted to a SparseData * @param width The size of the elements in array * @param type_of_data The object ID of the elements in array * @param count The size of array * @return A SparseData representation of an input array */

Source from the content-addressed store, hash-verified

1333 * @return A SparseData representation of an input array
1334 */
1335SparseData arr_to_sdata(char *array, size_t width, Oid type_of_data, int count){
1336 char *run_val=array;
1337 int64 run_len=1;
1338 SparseData sdata = makeSparseData();
1339
1340 sdata->type_of_data=type_of_data;
1341
1342 for (int i=1; i<count; i++) {
1343 char *curr_val=array+ (i*size_of_type(type_of_data));
1344
1345 /*
1346 * Note that special double values like denormalized numbers and exceptions
1347 * like NaN are treated like any other value - if there are duplicates, the
1348 * value of the special number is preserved and they are counted.
1349 */
1350 if (memcmp(curr_val,run_val,width))
1351 { /*run is interrupted, initiate new run */
1352 /* package up the finished run */
1353 add_run_to_sdata(run_val,run_len,width,sdata);
1354 /* mark beginning of new run */
1355 run_val=curr_val;
1356 run_len=1;
1357 } else
1358 { /* we're still in the same run */
1359 run_len++;
1360 }
1361 }
1362 add_run_to_sdata(run_val, run_len, width, sdata); /* package up the last run */
1363
1364 /* Add the final tallies */
1365 sdata->unique_value_count = sdata->vals->len/width;
1366 sdata->total_value_count = count;
1367
1368 return sdata;
1369}
1370
1371int compar(const void *i, const void *j){
1372 return (int)((int64*)array_pos_ref)[*(int*)i] - ((int64*)array_pos_ref)[*(int*)j];

Callers 1

float8arr_to_sdataFunction · 0.85

Calls 3

makeSparseDataFunction · 0.85
size_of_typeFunction · 0.85
add_run_to_sdataFunction · 0.85

Tested by

no test coverage detected