MCPcopy Create free account
hub / github.com/ElementsProject/elements / SanitizeOptions

Function SanitizeOptions

src/leveldb/db/db_impl.cc:95–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
94}
95Options SanitizeOptions(const std::string& dbname,
96 const InternalKeyComparator* icmp,
97 const InternalFilterPolicy* ipolicy,
98 const Options& src) {
99 Options result = src;
100 result.comparator = icmp;
101 result.filter_policy = (src.filter_policy != nullptr) ? ipolicy : nullptr;
102 ClipToRange(&result.max_open_files, 64 + kNumNonTableCacheFiles, 50000);
103 ClipToRange(&result.write_buffer_size, 64 << 10, 1 << 30);
104 ClipToRange(&result.max_file_size, 1 << 20, 1 << 30);
105 ClipToRange(&result.block_size, 1 << 10, 4 << 20);
106 if (result.info_log == nullptr) {
107 // Open a log file in the same directory as the db
108 src.env->CreateDir(dbname); // In case it does not exist
109 src.env->RenameFile(InfoLogFileName(dbname), OldInfoLogFileName(dbname));
110 Status s = src.env->NewLogger(InfoLogFileName(dbname), &result.info_log);
111 if (!s.ok()) {
112 // No place suitable for logging
113 result.info_log = nullptr;
114 }
115 }
116 if (result.block_cache == nullptr) {
117 result.block_cache = NewLRUCache(8 << 20);
118 }
119 return result;
120}
121
122static int TableCacheSize(const Options& sanitized_options) {
123 // Reserve ten files or so for other uses and give the rest to TableCache.

Callers 2

DBImplMethod · 0.85
RepairerMethod · 0.85

Calls 7

ClipToRangeFunction · 0.85
InfoLogFileNameFunction · 0.85
OldInfoLogFileNameFunction · 0.85
NewLRUCacheFunction · 0.85
CreateDirMethod · 0.45
RenameFileMethod · 0.45
NewLoggerMethod · 0.45

Tested by

no test coverage detected