Пример #1
0
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, &params[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;
}
Пример #2
0
  void createBadKeysizeTest() {
    ups_parameter_t p[] = {
      { UPS_PARAM_KEYSIZE, 7 },
      { 0, 0 }
    };

    REQUIRE(UPS_INV_KEYSIZE ==
        ups_env_create_db(env, &db, 2, UPS_RECORD_NUMBER32, &p[0]));
    REQUIRE(UPS_INV_KEYSIZE ==
        ups_env_create_db(env, &db, 2, UPS_RECORD_NUMBER64, &p[0]));

    p[0].value = 9;
    REQUIRE(UPS_INV_KEYSIZE ==
        ups_env_create_db(env, &db, 2, UPS_RECORD_NUMBER32, &p[0]));
    REQUIRE(UPS_INV_KEYSIZE ==
        ups_env_create_db(env, &db, 3, UPS_RECORD_NUMBER64, &p[0]));
  }
Пример #3
0
    /** Creates a new Database in the Environment. */
    db create_db(uint16_t name, uint32_t flags = 0,
                const ups_parameter_t *param = 0) {
      ups_db_t *dbh;

      ups_status_t st = ups_env_create_db(m_env, &dbh, name, flags, param);
      if (st)
        throw error(st);

      return (upscaledb::db(dbh));
    }