Beispiel #1
0
      static bool init(unsigned char *vertex_state,
		       unsigned long vertex_index,
		       unsigned long bsp_phase,
		       per_processor_data *cpu_state)
      {
	struct hyperanf_vertex *vstate = (struct hyperanf_vertex *)vertex_state;
	if(bsp_phase == 0) {
	  hll_init(vstate->hll_ctr, &hll_param);
	  unsigned long hash = jenkins(vertex_index, 0xdeadbeef);
	  add_hll_counter(&hll_param, vstate->hll_ctr, hash);
	  vstate->changed = true;
	  return true;
	}
	else {
	  // rollup counters
	  hyperanf_pp_data * pp_data = 
	    static_cast<hyperanf_pp_data *>(cpu_state);
	  if(vstate->changed) {
	    vstate->count = count_hll_counter(&hll_param, vstate->hll_ctr);
	    vstate->changed = false;
	  }
	  pp_data->local_neighbour_cnt += vstate->count;
	  if(vstate->count > pp_data->local_seed_reach) {
	    pp_data->local_seed_reach = vstate->count;
	    pp_data->local_seed       = vertex_index;
	  }
	  return false;
	}
      }
Beispiel #2
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);
}
Beispiel #3
0
CAMLprim value
caml_hll_merge(value hll_a, value hll_b) {
    hll_t *_hll_a= (hll_t*)hll_a;
    hll_t *_hll_b= (hll_t*)hll_b;

    hll_t *merged_hll = malloc(sizeof(hll_t));
    int _init_res = hll_init(_hll_a->precision, merged_hll);
    int _merge_res = hll_merge(_hll_a, _hll_b, merged_hll);
    return (value)merged_hll;
}
Beispiel #4
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);
}
Beispiel #5
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;
}
Beispiel #6
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);
}
Beispiel #7
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);
}
Beispiel #8
0
/**
 * Converts a full exact set to an approximate HLL set.
 */
static void convert_exact_to_approx(set_t *s) {
    // Store the hashes, as HLL initialization
    // will step on the pointer
    uint64_t *hashes = s->store.s.hashes;

    // Initialize the HLL
    s->type = APPROX;
    hll_init(s->store.s.precision, &s->store.h);

    // Add each hash to the HLL
    for (int i=0; i < SET_MAX_EXACT; i++) {
        hll_add_hash(&s->store.h, hashes[i]);
    }

    // Free the array of hashes
    free(hashes);
}
Beispiel #9
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);
}
Beispiel #10
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);
}
Beispiel #11
0
Datei: rnd.c Projekt: 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;
}
Beispiel #12
0
CAMLprim value
caml_hll_init(value precision) {
    hll_t *hll = malloc(sizeof(hll_t));
    int res = hll_init(Int_val(precision), hll);
    return (value)hll;
}