-
Notifications
You must be signed in to change notification settings - Fork 7
/
lsbf.c
47 lines (42 loc) · 935 Bytes
/
lsbf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include "bloom.h"
int main(int nargs, char **args) {
if(nargs < 5) {
printf("Usage: %s #nDatasetPoints #nQueryPoints R datasetFilename querysetFilename\n", args[0]);
return 0;
}
BLOOM **bloom;
int i, d;
int datasetNum, queryNum;
double R;
double *query;
datasetNum = atoi(args[1]);
queryNum = atoi(args[2]);
R = atof(args[3]);
getds(args[4], datasetNum);
if(!(bloom = bloom_create(K_hfun, 5000)))
{
printf("ERROR: Could not create bloom filter\n");
return -1;
}
bloom_set(bloom, dataset, datasetNum,R);
//query
FILE *fp;
fp = fopen(args[5], "r");
query = (double*)malloc(dimention * sizeof(double));
for(i = 0; i < queryNum; i++)
{
for(d = 0; d < dimention; d++)
{
fscanf(fp, "%lf", &query[d]);
}
printf("Query Point %d:", i);
if(bloom_check_similar(bloom, query,R))
printf("Yes\n");
else
printf("No\n");
}
bloom_destroy(bloom);
free(query);
fclose(fp);
return 0;
}