MCPcopy Create free account
hub / github.com/F-Stack/f-stack / hllDenseRegHisto

Function hllDenseRegHisto

app/redis-6.2.6/src/hyperloglog.c:519–574  ·  view source on GitHub ↗

Compute the register histogram in the dense representation. */

Source from the content-addressed store, hash-verified

517
518/* Compute the register histogram in the dense representation. */
519void hllDenseRegHisto(uint8_t *registers, int* reghisto) {
520 int j;
521
522 /* Redis default is to use 16384 registers 6 bits each. The code works
523 * with other values by modifying the defines, but for our target value
524 * we take a faster path with unrolled loops. */
525 if (HLL_REGISTERS == 16384 && HLL_BITS == 6) {
526 uint8_t *r = registers;
527 unsigned long r0, r1, r2, r3, r4, r5, r6, r7, r8, r9,
528 r10, r11, r12, r13, r14, r15;
529 for (j = 0; j < 1024; j++) {
530 /* Handle 16 registers per iteration. */
531 r0 = r[0] & 63;
532 r1 = (r[0] >> 6 | r[1] << 2) & 63;
533 r2 = (r[1] >> 4 | r[2] << 4) & 63;
534 r3 = (r[2] >> 2) & 63;
535 r4 = r[3] & 63;
536 r5 = (r[3] >> 6 | r[4] << 2) & 63;
537 r6 = (r[4] >> 4 | r[5] << 4) & 63;
538 r7 = (r[5] >> 2) & 63;
539 r8 = r[6] & 63;
540 r9 = (r[6] >> 6 | r[7] << 2) & 63;
541 r10 = (r[7] >> 4 | r[8] << 4) & 63;
542 r11 = (r[8] >> 2) & 63;
543 r12 = r[9] & 63;
544 r13 = (r[9] >> 6 | r[10] << 2) & 63;
545 r14 = (r[10] >> 4 | r[11] << 4) & 63;
546 r15 = (r[11] >> 2) & 63;
547
548 reghisto[r0]++;
549 reghisto[r1]++;
550 reghisto[r2]++;
551 reghisto[r3]++;
552 reghisto[r4]++;
553 reghisto[r5]++;
554 reghisto[r6]++;
555 reghisto[r7]++;
556 reghisto[r8]++;
557 reghisto[r9]++;
558 reghisto[r10]++;
559 reghisto[r11]++;
560 reghisto[r12]++;
561 reghisto[r13]++;
562 reghisto[r14]++;
563 reghisto[r15]++;
564
565 r += 12;
566 }
567 } else {
568 for(j = 0; j < HLL_REGISTERS; j++) {
569 unsigned long reg;
570 HLL_DENSE_GET_REGISTER(reg,registers,j);
571 reghisto[reg]++;
572 }
573 }
574}
575
576/* ================== Sparse representation implementation ================= */

Callers 1

hllCountFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected