/** Returns number of items in the Database. */ uint64_t count(ups_txn_t *txn = 0, uint32_t flags = 0) { uint64_t count = 0; ups_status_t st = ups_db_count(m_db, txn, flags, &count); if (st) throw error(st); return (count); }
int main(int argc, char **argv) { ups_env_t* env; ups_env_create(&env, "test.db", UPS_ENABLE_TRANSACTIONS, 0664, 0); ups_parameter_t params[] = { {UPS_PARAM_KEY_TYPE, UPS_TYPE_UINT32}, {0, } }; ups_txn_t* txn; ups_txn_begin(&txn, env, 0, 0, 0); ups_db_t* db; ups_env_create_db(env, &db, 1, 0, ¶ms[0]); for (int i = 0; i < 4; i++) { ups_key_t key = ups_make_key(&i, sizeof(i)); ups_record_t record = {0}; ups_db_insert(db, txn, &key, &record, 0); } uint64_t size; ups_db_count(db,0,0,&size); std::cout << size << std::endl; ups_txn_commit(txn, 0); return 0; }