Exemple #1
0
static ENGINE_ERROR_CODE mock_item_delete(ENGINE_HANDLE* handle,
                                          const void* cookie,
                                          const void* key,
                                          const size_t nkey,
                                          uint64_t cas,
                                          uint16_t vbucket) {
    int r = genhash_delete_all(get_ht(handle), key, nkey);
    return r > 0 ? ENGINE_SUCCESS : ENGINE_KEY_ENOENT;
}
Exemple #2
0
static void
test_multiple_keys()
{
    genhash_t* h=genhash_init(1, get_string_hash_ops());
    int deleted = 0, i = 0;

    /* Pollute the space to allow some hash collisions */
    for(i=0; i<16000; i++) {
        char key[8];
        snprintf(key, sizeof(key), "k%d", i);
        genhash_store(h, key, key);
        assert_hash_val(key, h, key);
    }

    assert_hash_val(NULL, h, "x");
    genhash_store(h, "x", "a");
    genhash_store(h, "x", "b");

    assert_hash_val("b", h, "x");
    deleted=genhash_delete(h, "x");
    assert(deleted == 1);
    assert_hash_val("a", h, "x");
    deleted=genhash_delete(h, "x");
    assert(deleted == 1);
    assert_hash_val(NULL, h, "x");
    deleted=genhash_delete(h, "x");
    assert(deleted == 0);

    genhash_store(h, "x", "a");
    genhash_store(h, "x", "b");
    genhash_store(h, "y", "yz");

    assert(genhash_size(h) == 16003);
    assert(genhash_size_for_key(h, "x") == 2);

    deleted=genhash_delete_all(h, "x");
    assert(deleted == 2);

    genhash_free(h);
}
Exemple #3
0
static ENGINE_ERROR_CODE mock_item_delete(ENGINE_HANDLE* handle,
        const void* cookie,
        item* item) {
    int r = genhash_delete_all(get_ht(handle), item_get_key(item), item->nkey);
    return r > 0 ? ENGINE_SUCCESS : ENGINE_KEY_ENOENT;
}