Exemplo n.º 1
0
END_TEST


START_TEST(test_hll_init_and_destroy)
{
    hll_t h;
    fail_unless(hll_init(10, &h) == 0);
    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 2
0
/**
 * Destroys the set
 * @return 0 on sucess
 */
int set_destroy(set_t *s) {
    switch (s->type) {
        case EXACT:
            free(s->store.s.hashes);
            break;

        case APPROX:
            hll_destroy(&s->store.h);
            break;
    }
    return 0;
}
Exemplo n.º 3
0
END_TEST

START_TEST(test_hll_size)
{
    hll_t h;
    fail_unless(hll_init(10, &h) == 0);

    double s = hll_size(&h);
    fail_unless(s == 0);

    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 4
0
int main() {
    hll_t *hll = malloc(sizeof(hll_t));
    int res = hll_init(18, hll);
    char line[MAXLINELEN];
    double after;
    while (fgets(line, MAXLINELEN, stdin))  {
        hll_add(hll, line);
    }

    after = hll_size(hll);
    printf("%.1f\n", after);
    hll_destroy(hll);
    return 0;
}
Exemplo n.º 5
0
END_TEST

START_TEST(test_hll_add_hash)
{
    hll_t h;
    fail_unless(hll_init(10, &h) == 0);

    char buf[100];
    for (uint64_t i=0; i < 100; i++) {
        hll_add_hash(&h, i ^ rand());
    }

    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 6
0
END_TEST

START_TEST(test_hll_add)
{
    hll_t h;
    fail_unless(hll_init(10, &h) == 0);

    char buf[100];
    for (int i=0; i < 100; i++) {
        fail_unless(sprintf((char*)&buf, "test%d", i));
        hll_add(&h, (char*)&buf);
    }

    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 7
0
END_TEST

START_TEST(test_hll_add_size)
{
    hll_t h;
    fail_unless(hll_init(10, &h) == 0);

    char buf[100];
    for (int i=0; i < 100; i++) {
        fail_unless(sprintf((char*)&buf, "test%d", i));
        hll_add(&h, (char*)&buf);
    }

    double s = hll_size(&h);
    fail_unless(s > 95 && s < 105);

    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 8
0
END_TEST

START_TEST(test_hll_error_bound)
{
    // Precision 14 -> variance of 1%
    hll_t h;
    fail_unless(hll_init(14, &h) == 0);

    char buf[100];
    for (int i=0; i < 10000; i++) {
        fail_unless(sprintf((char*)&buf, "test%d", i));
        hll_add(&h, (char*)&buf);
    }

    // Should be within 1%
    double s = hll_size(&h);
    fail_unless(s > 9900 && s < 10100);

    fail_unless(hll_destroy(&h) == 0);
}
Exemplo n.º 9
0
Arquivo: rnd.c Projeto: avz/hll
int main(int argc, char *argv[]) {
	long i;
	struct HLL hll;

	if(hll_init(&hll, 16) == -1) {
		perror("hll_init");
		exit(1);
	}

	for(i = 0; i < 100000000; i++) {
		long r = random() % 1000000;

		hll_add(&hll, &r, sizeof(r));
	}

	printf("Estimate: %f\n", hll_count(&hll));

	hll_destroy(&hll);

	return 0;
}
Exemplo n.º 10
0
CAMLprim value
caml_hll_destroy(value hll) {
    hll_t *_hll = (hll_t*)hll;
    int res = hll_destroy(_hll);
    return (value)res;
}