示例#1
0
文件: matrix.c 项目: wilx/mrg
inline
int 
trimatrix_get (const trimatrix_t * mx, unsigned x, unsigned y)
{
  if (x > mx->n || y > mx->n
      || x == 0 || y == 0)
    abort ();
  return bitmap_getbit (mx->bm, index_for_nxy (mx->n, x, y));
}
示例#2
0
END_TEST

START_TEST(getbit_bitmap_anonymous_one_onebyte)
{
    bloom_bitmap map;
    bitmap_from_file(-1, 4096, ANONYMOUS, &map);
    map.mmap[1] = 128;
    fail_unless(bitmap_getbit((&map), 8) == 1);
}
示例#3
0
END_TEST

START_TEST(getbit_bitmap_anonymous_one)
{
    bloom_bitmap map;
    bitmap_from_file(-1, 4096, ANONYMOUS, &map);
    memset(map.mmap, 255, 4096);
    for (int idx = 0; idx < 4096*8 ; idx++) {
        fail_unless(bitmap_getbit((&map), idx) == 1);
    }
}
示例#4
0
END_TEST

START_TEST(getbit_bitmap_file_persist_zero)
{
    bloom_bitmap map;
    int res = bitmap_from_filename("/tmp/persist_getbit_zero", 4096, 1, 1, PERSISTENT, &map);
    fail_unless(res == 0);
    for (int idx = 0; idx < 4096*8 ; idx++) {
        fail_unless(bitmap_getbit((&map), idx) == 0);
    }
    unlink("/tmp/persist_getbit_zero");
}
示例#5
0
END_TEST

START_TEST(getbit_bitmap_file_one)
{
    bloom_bitmap map;
    int res = bitmap_from_filename("/tmp/mmap_getbit_one", 4096, 1, 1, SHARED, &map);
    fail_unless(res == 0);
    memset(map.mmap, 255, 4096);
    for (int idx = 0; idx < 4096*8 ; idx++) {
        fail_unless(bitmap_getbit((&map), idx) == 1);
    }
    unlink("/tmp/mmap_getbit_one");
}
示例#6
0
END_TEST


/*
 *#define BITMAP_GETBIT(map, idx)
 */
START_TEST(getbit_bitmap_anonymous_zero)
{
    bloom_bitmap map;
    bitmap_from_file(-1, 4096, ANONYMOUS, &map);
    for (int idx = 0; idx < 4096*8 ; idx++) {
        fail_unless(bitmap_getbit((&map), idx) == 0);
    }
}
示例#7
0
文件: bloom.c 项目: BillWangCS/bloomd
/**
 * Internal bf_contains method.
 * @arg filter The filter
 * @arg key The key to check
 * @arg hashes Contains at least K num hashes
 * @return 0 if not contained, 1 if contained.
 */
static int bf_internal_contains(bloom_bloomfilter *filter, uint64_t *hashes) {
    uint64_t m = filter->offset;
    uint64_t offset;
    uint64_t h;
    uint32_t i;
    uint64_t bit;
    int res;

    for (i=0; i< filter->header->k_num; i++) {
        h = hashes[i];                                  // Get the hash value
        offset = 8*sizeof(bloom_filter_header) + i * m; // Get the partition offset
        bit = offset + (h % m);                         // Compute the bit offset
        res = bitmap_getbit(filter->map, bit);
        if (res == 0) {
            return 0;
        }
    }
    return 1;
}