/** ******************************************************************************** ** \brief ** validate that a k/v database exists in the ark *******************************************************************************/ uint32_t kv_query(ARK *ark, db_t *db) { uint32_t i = 0; uint32_t rc = 0; int64_t res = 0; char *gvalue = NULL; gvalue = malloc(db->vlen); assert(gvalue); for (i=0; i<db->len; i++) { while (EAGAIN == (rc=ark_get(ark, db->klen, db->kv[i].key, db->vlen, gvalue, 0, &res))) usleep(10000); if (rc) KV_ERR("get1", rc); if (db->vlen != res) KV_ERR("get2",0); while (EAGAIN == (rc=ark_exists(ark, db->klen, db->kv[i].key, &res))) usleep(10000); if (rc) KV_ERR("exists1",rc); if (db->vlen != res) KV_ERR("exists2",0); } free(gvalue); return 0; }
void fvt_kv_utils_query_off(ARK *ark, kv_t *db, uint32_t vbuflen, uint32_t LEN) { uint32_t i = 0; int64_t res = 0; uint32_t offset = 7; uint8_t *pval = NULL; uint8_t *gvalue = NULL; if (vbuflen==0) {gvalue=(uint8_t*)malloc(1);} else {gvalue=(uint8_t*)malloc(vbuflen);} ASSERT_TRUE(gvalue != NULL); ASSERT_TRUE(NULL != ark); ASSERT_TRUE(NULL != db); for (i=0; i<LEN; i++) { EXPECT_EQ(0, ark_exists(ark, db[i].klen, db[i].key, &res)); EXPECT_TRUE(db[i].vlen <= vbuflen); EXPECT_EQ(0, ark_get(ark, db[i].klen, db[i].key, db[i].vlen-offset, gvalue, offset, &res)); EXPECT_EQ(db[i].vlen, res); pval = (uint8_t*)db[i].value; EXPECT_EQ(0, memcmp(pval+offset, gvalue, db[i].vlen - offset)); } free(gvalue); }
void fvt_kv_utils_query_empty(ARK *ark, kv_t *db, uint32_t vbuflen,uint32_t LEN) { uint32_t i = 0; int64_t res = 0; uint8_t *gvalue = NULL; if (vbuflen==0) {gvalue=(uint8_t*)malloc(1);} else {gvalue=(uint8_t*)malloc(vbuflen);} ASSERT_TRUE(gvalue != NULL); ASSERT_TRUE(NULL != ark); ASSERT_TRUE(NULL != db); for (i=0; i<LEN; i++) { EXPECT_TRUE(db[i].vlen <= vbuflen); EXPECT_EQ(ENOENT, ark_get(ark, db[i].klen, db[i].key, db[i].vlen, gvalue, 0, &res)); EXPECT_EQ(ENOENT, ark_exists(ark, db[i].klen, db[i].key, &res)); } free(gvalue); }
uint32_t kv_query(ARK *ark, db_t *db) { uint32_t i = 0; uint32_t rc = 0; int64_t res = 0; uint8_t gvalue[db->vlen]; for (i=0; i<db->LEN; i++) { while (EAGAIN == (rc=ark_get(ark, db->klen, db->kv[i].key, db->vlen, gvalue, 0, &res))) usleep(10000); if (rc) KV_ERR("get1", rc); if (db->vlen != res) KV_ERR("get2",0); while (EAGAIN == (rc=ark_exists(ark, db->klen, db->kv[i].key, &res))) usleep(10000); if (rc) KV_ERR("exists1",rc); if (db->vlen != res) KV_ERR("exists2",0); } return 0; }
/** ******************************************************************************** ** \brief ** validate that a k/v database exists in the ark *******************************************************************************/ uint32_t kv_exists(ARK *ark, db_t *db) { uint32_t i = 0; uint32_t rc = 0; int64_t res = 0; for (i=0; i<db->len; i++) { while (EAGAIN == (rc=ark_exists(ark, db->klen, db->kv[i].key, &res))) usleep(10000); if (rc) KV_ERR("exists1",rc); if (db->vlen != res) KV_ERR("exists2",0); } return 0; }