int return_p(my_int j,my_int k)
{
	int Rc_int;
	JLG(pval,judy,j);
	if (pval==NULL)
		return 0;
	J1T(Rc_int,*pval,2*k+1);
	if (Rc_int==1)
		return 2;
	J1T(Rc_int,*pval,2*k);
	if (Rc_int==1)
		return 1;
   	return 0;
}
int return_rb(my_int k)
{
	J1T(Rc_intrb,judyrb,k);
	if (Rc_intrb==1)
		return 1;
   	return 0;
}
예제 #3
0
void*
ofpat_action_get (Pvoid_t *aargs, enum ofp_action_type t) {
    if (!(J1T (rc, *aargs, t))) {
        P4_LOG ("No arg for ofp_action_type");
        return NULL;
    } else {
        JLG (pv, *aargs, t);
        return (void *) *pv;
    }
}
예제 #4
0
파일: a3b3.c 프로젝트: dancor/a3b3
int main(int argc, char *argv[]) {
  Word_t i, j, *i_cube, *j_cube;
  Word_t index;
  Word_t n = 1000;
  Word_t *p_value;
  Word_t *cubes;
  //Pvoid_t cubes = NULL;
  Pvoid_t j_array[HASH_SIZE] = {NULL};
  int ret;

  if (argc > 1) {
    n = strtoul(argv[1], NULL, 0);
  }

  cubes = (Word_t *)malloc(sizeof(Word_t) * (n + 1));
  for (i = 1; i <= n; i++) {
    // even at 10k array is better (17s vs 20s)
    cubes[i] = i * i * i;
    //JLI(p_value, cubes, i);
    //*p_value = i * i * i;
  }

  for (i = 0; i < HASH_SIZE; i++) {
    j_array[i] = NULL;
  }

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= i; j++) {
      index = cubes[i] + cubes[j];
      //JLG(i_cube, cubes, i);
      //JLG(j_cube, cubes, j);
      //index = *i_cube + *j_cube;
      J1T(ret, j_array[index % HASH_SIZE], index / HASH_SIZE);
      if (ret == 1) {
        printf("%d %d\n", i, j);
      } else {
        J1S(ret, j_array[index % HASH_SIZE], index / HASH_SIZE);
      }
    }
  }

  return 0;
}
예제 #5
0
static int encode_layer(const Pvoid_t ix)
{
        uint sid, no = 0;
        growing_glist *gg;
        GGLIST_INIT(gg, 100);

        for (sid = 0; sid < dex_section[FW].nof_entries; sid++){
                const void *d   = fetch_item(FW, sid);
                u32        offs = 0;
                u32        xid, tst;
                
                gg->lst.len = 0;
                DEX_FOREACH_VAL(d, &offs, xid)
                        J1T(tst, ix, xid);
                        if (tst){
                                GGLIST_APPEND(gg, xid);
                        }
                DEX_FOREACH_VAL_END
                
                if (gg->lst.len){
                        toc_e toc;
                        toc.val = sid; //dex_section[FW].toc[i].val;
                        toc.offs = ftello64(data_f);
                        fwrite(&toc, sizeof(toc_e), 1, toc_f);
                        
                        int i;
                        for (i = 0; i < gg->lst.len; i++){
                                if (!gg->lst.lst[i])
                                        dub_die("FOUND");
                        }

                        encode_segment(&gg->lst);
                        ++no;
                }
        }

        free(gg);
        dub_msg("%u / %u sids matched", no, dex_section[FW].nof_entries);
        return no;
}
예제 #6
0
int main()
{
    int Rc_int;

    int i;

    // Judy array to hold cached addresses
    Pvoid_t addrArray = (Pvoid_t) NULL;

    for(i = 0; i < 100000; i++)
    J1S(Rc_int, addrArray, (Word_t) i);

    for(i = 0; i < 100000; i++){
    J1T(Rc_int, addrArray, (Word_t) i);
    if(!Rc_int){
        printf("Something bad happened\n");
        return -1;
    }
    }

    return 0;
}
예제 #7
0
파일: jtable.c 프로젝트: thommey/plservices
int jtableP_check(jtableP *table, void *key) {
	int ret;

	J1T(ret, table->t, (Word_t)key);
	return ret;
}
예제 #8
0
파일: bloom_test.c 프로젝트: Zabrane/aino
int main(int argc, char **argv)
{
        uint  r          = ROUNDS;
        uint  only_crea  = 0;
        uint  do_judy    = 0;
        uint  seed       = 0;
        float scaler     = 0;
        uint  sum        = 0;
        uint  false_hits = 0;
        uint  nof_false  = 0;
        
        Pvoid_t judy     = NULL;
        
        dub_init();

        PPARM_INT(seed, SEED);
        PPARM_FLOAT(scaler, SCALER);
        
        /* allow at most one false hit in 10^7 queries */
        init_bloom(7, scaler);

        if (getenv("ONLY_CREATE")){
                dub_msg("Only encoding %u lists", r);
                only_crea = 1;
        }else
                dub_msg("Encoding %u lists and testing %u items per list",
                                r, TESTMAX);
        
        if (!only_crea && getenv("FALSE_HITS")){

                dub_msg("Checking for false hits");
                false_hits = 1;
                
        }else if (getenv("JUDY")){
                dub_msg("Using Judy");
                do_judy = 1;
        }
        
        srand(seed);

        while (r--){
                
                uint  sze  = MAXSZE * (rand() / (RAND_MAX + 1.0));
                u32   *p   = xmalloc(sze * 4);
                bloom_s *b = NULL;
                uint  j, k;
                
                for (j = 0; j < sze; j++)
                        p[j] = 1000 * (rand() / (RAND_MAX + 1.0));

                
                if (do_judy || false_hits){
                        uint tmp;
                        for (j = 0; j < sze; j++)
                                J1S(tmp, judy, p[j]);
                }

                if (!do_judy)
                        b = new_bloom(p, sze);

                sum += sze;
                
                if (only_crea)
                        goto next;
                
                for (j = 1; j < TESTMAX; j++){

                        if (false_hits){
                                
                                J1T(k, judy, j);
                                if (bloom_test(b, j)){
                                        if (!k) ++nof_false;
                                }else
                                        if (k){
                                                print(p, sze);
                                                dub_die("False negative! "
                                                  "Value %u not in bloom. "
                                                   "Bloom broken!", j);
                                        }
                                        
                        }else if (do_judy){
                                J1T(k, judy, j);
                        }else
                                bloom_test(b, j);
                }
                
next:
                if (do_judy || false_hits){
                        J1FA(k, judy);                
                }
                
                if (!do_judy){
                        free(b);
                        free(p);
                }
        }
        
        dub_msg("In total %u items in lists", sum);
        if (false_hits)
                dub_msg("In total %u false hits found", nof_false);
        
        return 0;
}