void set_p(my_int j,my_int k,int v)
{
// using encoding: 10 -> 2, 01 -> 1, 00 -> 2
	int Rc_int;
	JLI(pval,judy,j);
	if (v&1==1){
		J1S(Rc_int,*pval,2*k);}
	else	J1U(Rc_int,*pval,2*k);
	int v2=v>>1;
	if (v2&1==1){
		J1S(Rc_int,*pval,2*k+1);}
	else	J1U(Rc_int,*pval,2*k+1);

}
Пример #2
0
int jtableP_set(jtableP *table, void *key) {
	int ret;

	J1S(ret, table->t, (Word_t)key);
	if (!ret)
		logtxt(LOG_DEBUG, "Duplicate insert into jtableP");
	return ret;
}
Пример #3
0
/* Judy1 integer sparse set intersection */
static inline int j1_callback(void *key, void *data, void *arg)
{
  int r;
  Pvoid_t *arrayP = (Pvoid_t *) arg;
  J1S(r, *arrayP, (Word_t) data);
  if (r == JERR)
    return FALSE;
  return TRUE;
}
Пример #4
0
static bool
record_board(cube_t *cube)
{
    void **hbitsp = NULL;
    bool retval = 0;
    
    JLI(hbitsp, seen, cube->low);
    J1S(retval, *hbitsp, cube->pos);

    return retval;
}
Пример #5
0
static bool
csp_id_set_builder_add_one(struct csp_id_set_builder *builder, csp_id id)
{
    int rc;
    J1S(rc, builder->working_set, id);
    if (rc) {
        /* Only update the set's hash if we actually added a new element. */
        builder->hash ^= id;
    }
    return rc;
}
Пример #6
0
/**
 * adds the article bit array to the collection bit array / index,
 * zeroes the article index
 * 
 * article index - bit array index of an article
 * wikiIndex - bit / judy array of collection
 */
void addToIndex(bool articleIndex[lastNgram], Pvoid_t *wikiIndex, int articleNumber) {

	int returnCode;
	// adds the current document to the wikiIndex
	// adds document to one ngram per iteration
	// sets articleDictionary to default values
	for (Word_t currentNgram = 0; currentNgram < lastNgram; currentNgram++) {
		if (articleIndex[currentNgram] == 1) {
			J1S(returnCode, wikiIndex[currentNgram], articleNumber);
			articleIndex[currentNgram] = 0;
		}
	}
}
Пример #7
0
p4_pd_status_t
p4_pd_client_init(p4_pd_sess_hdl_t *sess_hdl, uint32_t max_txn_size) {
  pthread_mutex_lock(&lock);

  int Rc_int;
  Word_t index = 0;
  J1FE(Rc_int, used_session_handles, index);
  *sess_hdl = (p4_pd_sess_hdl_t)index;

  J1S(Rc_int, used_session_handles, index);
  assert(1 == Rc_int);

  pthread_mutex_unlock(&lock);

  return 0;
}
Пример #8
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;
}
Пример #9
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;
}
Пример #10
0
static Pvoid_t ixemes_freq_range(int p, int min_f, int max_f)
{
        Pvoid_t ix = NULL;
        Word_t xid;
        int i, tst;
        for (i = 0; i < dex_section[INVA].nof_entries; i++){

                xid = dex_section[INVA].toc[i].val;
                
                if (xid >= XID_META_FREQUENT_F &&
                    xid <= XID_META_FREQUENT_L)
                        continue;
                
                if (xid <= XID_TOKEN_FREQUENT_L &&
                    xid >= XID_TOKEN_FREQUENT_F)
                        continue;

                const inva_e *e = 
                        (const inva_e*)fetch_item(INVA, i);
                if (e->len > min_f && e->len <= max_f){
                        J1S(tst, ix, xid);
                }
        }

        xid = 0;
        J1F(tst, ix, xid);
        fw_layers[p].min_xid = xid;
        xid = -1;
        J1L(tst, ix, xid);
        fw_layers[p].max_xid = xid;
        
        J1C(tst, ix, 0, -1);
        dub_msg("Layer %u: number of xids %u min %u max %u", p, tst,
                fw_layers[p].min_xid, fw_layers[p].max_xid);

        return ix;
}
void set_rb(my_int k)
{
	J1S(Rc_intrb,judyrb,k);
}
Пример #12
0
int main(int argc, char **argv)
{
    static const char **fields;
    static uint64_t *lengths;
    dsfmt_t state;
    Pvoid_t uuids = NULL;
    tdb_cons* c = tdb_cons_init();
    test_cons_settings(c);
    uint64_t i, j;
    __uint128_t prev_uuid = 0;
    Word_t key;
    int tst;

    assert(tdb_cons_open(c, argv[1], fields, 0) == 0);
    dsfmt_init_gen_rand(&state, 2489);

    for (i = 0; i < NUM_TRAILS; i++){
        uint8_t uuid[16];
        gen_random_uuid(uuid, &state);
        memcpy(&key, uuid, 8);

        J1S(tst, uuids, key);
        if (!tst){
            printf("half-word collision! change random seed!\n");
            return -1;
        }

        for (j = 0; j < NUM_EVENTS; j++)
            tdb_cons_add(c, uuid, i * 100 + j, fields, lengths);
    }
    J1C(key, uuids, 0, -1);
    assert(key == NUM_TRAILS);
    assert(tdb_cons_finalize(c) == 0);
    tdb_cons_close(c);

    tdb* t = tdb_init();
    assert(tdb_open(t, argv[1]) == 0);

    assert(tdb_num_trails(t) == NUM_TRAILS);
    assert(tdb_num_events(t) == NUM_TRAILS * NUM_EVENTS);

    for (i = 0; i < NUM_TRAILS; i++){
        __uint128_t this_uuid;

        /* uuids must be monotonically increasing */
        memcpy(&this_uuid, tdb_get_uuid(t, i), 16);
        assert(this_uuid > prev_uuid);
        prev_uuid = this_uuid;

        /* remove this uuid from the uuid set and make sure it exists */
        memcpy(&key, &this_uuid, 8);
        J1U(tst, uuids, key);
        assert(tst == 1);
    }

    /* make sure we retrieved all uuids */
    J1C(key, uuids, 0, -1);
    assert(key == 0);

    return 0;
}
Пример #13
0
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;
}