Ejemplo n.º 1
0
void insert_bf(bf_t *block, char *s) {

//	(*bloom).block0[3] = 14;

	int hash = 0;
	int size = 2000000;
	int i = 0;

	blk_num = 0;
//	printf("block first starts %d\n",index);

	for (i = 0; i < 8; i++) {

		if (i == 0) {
			hash = universalhashfunction(s, size, b[i], v0);
		} else if (i == 1) {
			hash = universalhashfunction(s, size, b[i], v1);
		} else if (i == 2) {
			hash = universalhashfunction(s, size, b[i], v2);
		} else if (i == 3) {
			hash = universalhashfunction(s, size, b[i], v3);
		} else if (i == 4) {
			hash = universalhashfunction(s, size, b[i], v4);
		} else if (i == 5) {
			hash = universalhashfunction(s, size, b[i], v5);
		} else if (i == 6) {
			hash = universalhashfunction(s, size, b[i], v6);
		} else if (i == 7) {
			hash = universalhashfunction(s, size, b[i], v7);
		}

		hash = abs(hash);

		if (i == 0) {
			set_bit((*block).block0, hash);
		} else if (i == 1) {
			set_bit((*block).block1, hash);
		} else if (i == 2) {
			set_bit((*block).block2, hash);
		} else if (i == 3) {
			set_bit((*block).block3, hash);
		} else if (i == 4) {
			set_bit((*block).block4, hash);
		} else if (i == 5) {
			set_bit((*block).block5, hash);
		} else if (i == 6) {
			set_bit((*block).block6, hash);
		} else if (i == 7) {
			set_bit((*block).block7, hash);
		}

	}

}
Ejemplo n.º 2
0
/* insert the string s into the bloom filter b */
void insert_bf(bf_t *b, char *s){
    if( b == NULL ) return;

    for(int i=0; i < BF_TABLES; ++i){
        int bucketbit  = universalhashfunction(s, b->bf_param[i] );
        int index_byte = bucketbit / STRNGSIZE;
        int index_bit  = bucketbit % STRNGSIZE;
        (b->abits[i])[index_byte]  =
                (b->abits[i])[index_byte] | HEXREFTABLE[index_bit];
    }
}
Ejemplo n.º 3
0
/* return 1 if string q  accpted by Bloom filter else 0*/
int is_element(bf_t *b, char *q){
    if( b == NULL ){
        printf("ERROR: in is_element(), NULL bf_t object");
        exit(-1);
    }

    int result = 0;
    for(int i=0; i < BF_TABLES; ++i){
    /* flip bit in corresponding table for the string */
        int bucketbit  = universalhashfunction(q, b->bf_param[i] );
        int index_byte = bucketbit / STRNGSIZE;
        int index_bit  = bucketbit % STRNGSIZE;
        result += (((b->abits[i])[index_byte] & HEXREFTABLE[index_bit]) != 0x00);
    }

    return ( result != 10 ) ? 0 : 1;
}
Ejemplo n.º 4
0
int is_element(bf_t *block, char *s) {

	int result = 0;
	int hash = 0;
	int size = 2000000;

//printf("checking %s\n",s);

	int i = 0;
	int f = 0;

	blk_num = 0;

	for (i = 0; i < 8; i++) {

		if (i == 0) {
			hash = universalhashfunction(s, size, b[i], v0);
		} else if (i == 1) {
			hash = universalhashfunction(s, size, b[i], v1);
		} else if (i == 2) {
			hash = universalhashfunction(s, size, b[i], v2);
		} else if (i == 3) {
			hash = universalhashfunction(s, size, b[i], v3);
		} else if (i == 4) {
			hash = universalhashfunction(s, size, b[i], v4);
		} else if (i == 5) {
			hash = universalhashfunction(s, size, b[i], v5);
		} else if (i == 6) {
			hash = universalhashfunction(s, size, b[i], v6);
		} else if (i == 7) {
			hash = universalhashfunction(s, size, b[i], v7);
		}

		hash = abs(hash);

		if (i == 0) {
			result = get_bit((*block).block0, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 1) {
			result = get_bit((*block).block1, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 2) {
			result = get_bit((*block).block2, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 3) {
			result = get_bit((*block).block3, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 4) {
			result = get_bit((*block).block4, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 5) {
			result = get_bit((*block).block5, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 6) {
			result = get_bit((*block).block6, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		} else if (i == 7) {
			result = get_bit((*block).block7, hash);
			if (result == 0) {
				f++;
			} else if (result == 1) {
			}
		}

	}

	if (f > 0) {
		f = 0;
	} else if (f == 0) {
		f = 1;
	}

	return f;
}