void pc_hash_int(unsigned char * buffer, char salt, int element) { unsigned char item[5]; memcpy(item, &salt, 1); memcpy(item+1, &element, 4); pg_md5_binary(item, 5, buffer); }
void pc_hash_text(unsigned char * buffer, char salt, const char * element, int elen) { unsigned char item[elen + 1]; memcpy(item, &salt, 1); memcpy(item+1, element, elen); pg_md5_binary(item, elen + 1, buffer); }
void pcsa_add_element(PCSACounter pcsa, const char * element, int elen) { /* get the hash */ unsigned char hash[HASH_LENGTH]; /* compute the hash */ pg_md5_binary(element, elen, hash); /* add the hash to the counter */ pcsa_add_hash(pcsa, hash); }
void hyperloglog_add_element(HyperLogLogCounter hloglog, const char * element, int elen) { /* get the hash */ unsigned char hash[HASH_LENGTH]; /* compute the hash using the salt */ pg_md5_binary(element, elen, hash); /* add the hash to the estimator */ hyperloglog_add_hash(hloglog, hash); }
/* computes a hash of the int element (and stores it in the buffer) */ void ac_hash_int(unsigned char * buffer, int element) { pg_md5_binary(&element, sizeof(int), buffer); }
/* compute hash of the text element (and stores it in the buffer) */ void ac_hash_text(unsigned char * buffer, const char * element, int elen) { pg_md5_binary(element, elen, buffer); }