コード例 #1
0
ファイル: hyper-anf.hpp プロジェクト: zhuoyw/x-stream-copy
      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;
	}
      }
コード例 #2
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #3
0
ファイル: stubs.c プロジェクト: pombredanne/ocaml-hll
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;
}
コード例 #4
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #5
0
ファイル: main.c プロジェクト: pombredanne/funzone
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;
}
コード例 #6
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #7
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #8
0
ファイル: set.c プロジェクト: Affirm/statsite
/**
 * 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);
}
コード例 #9
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #10
0
ファイル: test_hll.c プロジェクト: Affirm/statsite
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);
}
コード例 #11
0
ファイル: rnd.c プロジェクト: 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;
}
コード例 #12
0
ファイル: stubs.c プロジェクト: pombredanne/ocaml-hll
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;
}