| 93 | if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue; |
| 94 | } |
| 95 | Options 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 | |
| 122 | static int TableCacheSize(const Options& sanitized_options) { |
| 123 | // Reserve ten files or so for other uses and give the rest to TableCache. |
no test coverage detected