MCPcopy Create free account
hub / github.com/couchbase/forestdb / fdb_compact_file

Function fdb_compact_file

src/forestdb.cc:6018–6160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6016 bool clone_docs);
6017
6018fdb_status fdb_compact_file(fdb_file_handle *fhandle,
6019 const char *new_filename,
6020 bool in_place_compaction,
6021 bid_t marker_bid,
6022 bool clone_docs,
6023 const fdb_encryption_key *new_encryption_key)
6024{
6025 struct filemgr *new_file;
6026 struct filemgr_config fconfig;
6027 struct btreeblk_handle *new_bhandle;
6028 struct docio_handle *new_dhandle;
6029 struct hbtrie *new_trie = NULL;
6030 struct btree *new_seqtree = NULL, *old_seqtree;
6031 struct btree *new_staletree = NULL;
6032 struct hbtrie *new_seqtrie = NULL;
6033 fdb_kvs_handle *handle = fhandle->root;
6034 fdb_status status;
6035 LATENCY_STAT_START();
6036
6037 // prevent update to the target file
6038 filemgr_mutex_lock(handle->file);
6039
6040 status = _fdb_compact_file_checks(handle, new_filename);
6041 if (status != FDB_RESULT_SUCCESS) {
6042 filemgr_mutex_unlock(handle->file);
6043 return status;
6044 }
6045
6046 // sync handle
6047 fdb_sync_db_header(handle);
6048
6049 // set filemgr configuration
6050 _fdb_init_file_config(&handle->config, &fconfig);
6051 fconfig.blocksize = handle->config.blocksize;
6052 fconfig.ncacheblock = handle->config.buffercache_size / handle->config.blocksize;
6053 fconfig.chunksize = handle->config.chunksize;
6054 fconfig.options = FILEMGR_CREATE;
6055 fconfig.num_wal_shards = handle->config.num_wal_partitions;
6056 fconfig.num_bcache_shards = handle->config.num_bcache_partitions;
6057 fconfig.flag = 0x0;
6058
6059 if ((handle->config.durability_opt & FDB_DRB_ODIRECT) &&
6060 handle->config.buffercache_size) {
6061 fconfig.flag |= _ARCH_O_DIRECT;
6062 }
6063 if (!(handle->config.durability_opt & FDB_DRB_ASYNC)) {
6064 fconfig.options |= FILEMGR_SYNC;
6065 }
6066
6067 if (new_encryption_key) {
6068 fconfig.encryption_key = *new_encryption_key;
6069 }
6070
6071 // open new file
6072 filemgr_open_result result = filemgr_open((char *)new_filename,
6073 handle->fileops,
6074 &fconfig,
6075 &handle->log_callback);

Callers 2

compactor_threadFunction · 0.85
_fdb_compactFunction · 0.85

Calls 15

filemgr_mutex_lockFunction · 0.85
_fdb_compact_file_checksFunction · 0.85
filemgr_mutex_unlockFunction · 0.85
fdb_sync_db_headerFunction · 0.85
_fdb_init_file_configFunction · 0.85
filemgr_openFunction · 0.85
docio_initFunction · 0.85
btreeblk_initFunction · 0.85
hbtrie_initFunction · 0.85
hbtrie_set_leaf_cmpFunction · 0.85
btree_initFunction · 0.85

Tested by

no test coverage detected