Пример #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;
	}
      }
Пример #2
0
 size_t operator()(const std::string& v) const {
   const uint8_t* data = (const uint8_t*)v.c_str();
   size_t hv = jenkins(data, v.length());
   return hv;
 }
Пример #3
0
 size_t operator()(const int& v) const {
   const uint8_t* data = (const uint8_t*)&v;
   size_t hv = jenkins(data, sizeof(int));
   return hv;
 }
Пример #4
0
int main(int argc, char **argv)
{
    struct rbtree *t;
    struct rbtree_node **nodes;
    int c, i = 0;
    char buf[256];

    if (parse_args(argc, argv) == -1)
        exit(1);

    FILE *fp = NULL;
    if (!infile) {
        fp = stdin;
    } else {
        fp = fopen(infile, "r");
        if (!fp) {
            fprintf(stderr, "Can't open file: %s\n", infile);
            exit(1);
        }
    }

    t = rbtree_new();
    unsigned N = 100;
    unsigned next = 0;
    nodes = calloc(100, sizeof *nodes);

    while ((c = fgetc(fp)) != EOF) {
        if (c == '\n') {
            i = 0;
            if (next >= N) {
                nodes = realloc(nodes, N*2 * sizeof *nodes);
                N *= 2;
            }
            nodes[next] = calloc(1, sizeof *nodes[next]);
            nodes[next]->key = jenkins(buf);
            nodes[next]->ptr = strdup(buf);
            rbtree_insert(t, nodes[next]);
            next++;
            memset(buf, 0, sizeof buf);
        } else {
            buf[i++] = c;
        }
    }

    if (infile)
        fclose(fp);

    if (export) {
        fp = fopen(export, "w");
        dot_export(t, fp);
        fclose(fp);
    }

    free(nodes);
    rbtree_free(t);
    if (infile)
        free(infile);
    if (export)
        free(export);
    return 0;
}