| 8 | using namespace lbug::common; |
| 9 | |
| 10 | lbug_state lbug_database_init(const char* database_path, lbug_system_config config, |
| 11 | lbug_database* out_database) { |
| 12 | try { |
| 13 | clearLastCAPIErrorMessage(); |
| 14 | std::string database_path_str = database_path; |
| 15 | auto systemConfig = SystemConfig(config.buffer_pool_size, config.max_num_threads, |
| 16 | config.enable_compression, config.read_only, config.max_db_size, config.auto_checkpoint, |
| 17 | config.checkpoint_threshold, true, config.throw_on_wal_replay_failure, |
| 18 | config.enable_checksums, config.enable_multi_writes, config.enable_default_hash_index); |
| 19 | |
| 20 | #if defined(__APPLE__) |
| 21 | systemConfig.threadQos = config.thread_qos; |
| 22 | #endif |
| 23 | out_database->_database = new Database(database_path_str, systemConfig); |
| 24 | } catch (Exception& e) { |
| 25 | out_database->_database = nullptr; |
| 26 | setLastCAPIErrorMessage(e.what()); |
| 27 | return LbugError; |
| 28 | } |
| 29 | return LbugSuccess; |
| 30 | } |
| 31 | |
| 32 | void lbug_database_destroy(lbug_database* database) { |
| 33 | if (database == nullptr) { |