|
|
|
@ -100,7 +100,6 @@ int db_usage_map(imdb_t *db, unsigned short int cols)
|
|
|
|
|
int rec_bitmap(imdb_t *db, uint64_t number) |
|
|
|
|
{ |
|
|
|
|
imdb_rec_t rec; |
|
|
|
|
unsigned char *map = NULL; |
|
|
|
|
|
|
|
|
|
assert(db != NULL); |
|
|
|
|
memset(&rec, 0x0, sizeof(imdb_rec_t)); |
|
|
|
@ -114,52 +113,44 @@ int rec_bitmap(imdb_t *db, uint64_t number)
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bitmap_unpack(&rec.data[REC_OFF_BM], &map); |
|
|
|
|
bitmap_print(map); |
|
|
|
|
bitmap_print(&rec.data[REC_OFF_BM]); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int rec_diff(imdb_t *db, uint64_t a, uint64_t b, unsigned short int showmap) |
|
|
|
|
{ |
|
|
|
|
imdb_rec_t src; |
|
|
|
|
imdb_rec_t dst; |
|
|
|
|
imdb_rec_t rec; |
|
|
|
|
float diff = 0.0; |
|
|
|
|
unsigned char one[BITMAP_SIZE]; |
|
|
|
|
unsigned char two[BITMAP_SIZE]; |
|
|
|
|
unsigned char map[BITMAP_SIZE]; |
|
|
|
|
|
|
|
|
|
assert(db != NULL); |
|
|
|
|
memset(&rec, 0x0, sizeof(imdb_rec_t)); |
|
|
|
|
|
|
|
|
|
memset(&src, 1, sizeof(imdb_rec_t)); |
|
|
|
|
memset(&dst, 2, sizeof(imdb_rec_t)); |
|
|
|
|
|
|
|
|
|
src.num = a; |
|
|
|
|
dst.num = b; |
|
|
|
|
|
|
|
|
|
if (imdb_read_rec(db, &src) < 1) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
if (!src.data[0]) { |
|
|
|
|
rec.num = a; |
|
|
|
|
if (imdb_read_rec(db, &rec) < 1) { |
|
|
|
|
puts("First sample not exists"); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
memcpy(one, &rec.data[REC_OFF_BM], BITMAP_SIZE); |
|
|
|
|
|
|
|
|
|
if (imdb_read_rec(db, &dst) < 1) |
|
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
if (!src.data[0]) { |
|
|
|
|
puts("First sample not exists"); |
|
|
|
|
rec.num = b; |
|
|
|
|
if (imdb_read_rec(db, &rec) < 1) { |
|
|
|
|
puts("Second sample not exists"); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
memcpy(two, &rec.data[REC_OFF_BM], BITMAP_SIZE); |
|
|
|
|
|
|
|
|
|
if (showmap == 0) { |
|
|
|
|
diff = (float) bitmap_compare(&src.data[REC_OFF_BM], &dst.data[REC_OFF_BM]); |
|
|
|
|
diff /= BITMAP_BITS; |
|
|
|
|
printf("%.2f%%\n", diff * 100); |
|
|
|
|
if (showmap) { |
|
|
|
|
bitmap_diffmap(map, one, two); |
|
|
|
|
bitmap_print(map); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bitmap_diffmap(&map[0], &src.data[REC_OFF_BM], &dst.data[REC_OFF_BM]); |
|
|
|
|
bitmap_print(map); |
|
|
|
|
diff = (float) bitmap_compare(one, two); |
|
|
|
|
printf("%.2f%%\n", (diff / BITMAP_BITS) * 100); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|