db_impl.h 20.6 KB
Newer Older
1 2 3 4 5
//  Copyright (c) 2013, Facebook, Inc.  All rights reserved.
//  This source code is licensed under the BSD-style license found in the
//  LICENSE file in the root directory of this source tree. An additional grant
//  of patent rights can be found in the PATENTS file in the same directory.
//
J
jorlow@chromium.org 已提交
6 7 8
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. See the AUTHORS file for names of contributors.
9
#pragma once
K
Kai Liu 已提交
10

H
Haobo Xu 已提交
11
#include <atomic>
12
#include <deque>
J
jorlow@chromium.org 已提交
13
#include <set>
T
Tomislav Novak 已提交
14
#include <utility>
15
#include <vector>
I
Igor Canadi 已提交
16
#include <string>
K
kailiu 已提交
17

J
jorlow@chromium.org 已提交
18 19 20
#include "db/dbformat.h"
#include "db/log_writer.h"
#include "db/snapshot.h"
21
#include "db/column_family.h"
22
#include "db/version_edit.h"
K
Kai Liu 已提交
23 24
#include "memtable_list.h"
#include "port/port.h"
25 26 27 28
#include "rocksdb/db.h"
#include "rocksdb/env.h"
#include "rocksdb/memtablerep.h"
#include "rocksdb/transaction_log.h"
29
#include "util/autovector.h"
30
#include "util/stats_logger.h"
31
#include "util/thread_local.h"
I
Igor Canadi 已提交
32
#include "db/internal_stats.h"
33

34
namespace rocksdb {
J
jorlow@chromium.org 已提交
35 36 37 38 39 40 41 42 43

class MemTable;
class TableCache;
class Version;
class VersionEdit;
class VersionSet;

class DBImpl : public DB {
 public:
I
Igor Canadi 已提交
44
  DBImpl(const DBOptions& options, const std::string& dbname);
J
jorlow@chromium.org 已提交
45 46 47
  virtual ~DBImpl();

  // Implementations of the DB interface
48 49
  using DB::Put;
  virtual Status Put(const WriteOptions& options,
50
                     ColumnFamilyHandle* column_family, const Slice& key,
51 52 53
                     const Slice& value);
  using DB::Merge;
  virtual Status Merge(const WriteOptions& options,
54 55
                       ColumnFamilyHandle* column_family, const Slice& key,
                       const Slice& value);
56 57
  using DB::Delete;
  virtual Status Delete(const WriteOptions& options,
58
                        ColumnFamilyHandle* column_family, const Slice& key);
59
  using DB::Write;
J
jorlow@chromium.org 已提交
60
  virtual Status Write(const WriteOptions& options, WriteBatch* updates);
61
  using DB::Get;
J
jorlow@chromium.org 已提交
62
  virtual Status Get(const ReadOptions& options,
63
                     ColumnFamilyHandle* column_family, const Slice& key,
J
jorlow@chromium.org 已提交
64
                     std::string* value);
65 66 67
  using DB::MultiGet;
  virtual std::vector<Status> MultiGet(
      const ReadOptions& options,
68
      const std::vector<ColumnFamilyHandle*>& column_family,
69
      const std::vector<Slice>& keys, std::vector<std::string>* values);
70

71
  virtual Status CreateColumnFamily(const ColumnFamilyOptions& options,
72
                                    const std::string& column_family,
73 74
                                    ColumnFamilyHandle** handle);
  virtual Status DropColumnFamily(ColumnFamilyHandle* column_family);
75

76 77 78 79
  // Returns false if key doesn't exist in the database and true if it may.
  // If value_found is not passed in as null, then return the value if found in
  // memory. On return, if value was found, then value_found will be set to true
  // , otherwise false.
80
  using DB::KeyMayExist;
81
  virtual bool KeyMayExist(const ReadOptions& options,
82 83
                           ColumnFamilyHandle* column_family, const Slice& key,
                           std::string* value, bool* value_found = nullptr);
84 85
  using DB::NewIterator;
  virtual Iterator* NewIterator(const ReadOptions& options,
86
                                ColumnFamilyHandle* column_family);
87 88
  virtual Status NewIterators(
      const ReadOptions& options,
89
      const std::vector<ColumnFamilyHandle*>& column_family,
90
      std::vector<Iterator*>* iterators);
J
jorlow@chromium.org 已提交
91 92
  virtual const Snapshot* GetSnapshot();
  virtual void ReleaseSnapshot(const Snapshot* snapshot);
93
  using DB::GetProperty;
94
  virtual bool GetProperty(ColumnFamilyHandle* column_family,
95 96
                           const Slice& property, std::string* value);
  using DB::GetApproximateSizes;
97
  virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
98 99
                                   const Range* range, int n, uint64_t* sizes);
  using DB::CompactRange;
100
  virtual Status CompactRange(ColumnFamilyHandle* column_family,
101
                              const Slice* begin, const Slice* end,
L
Lei Jin 已提交
102
                              bool reduce_level = false, int target_level = -1);
103 104

  using DB::NumberLevels;
105
  virtual int NumberLevels(ColumnFamilyHandle* column_family);
106
  using DB::MaxMemCompactionLevel;
107
  virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family);
108
  using DB::Level0StopWriteTrigger;
109
  virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family);
I
Igor Canadi 已提交
110
  virtual const std::string& GetName() const;
111
  virtual Env* GetEnv() const;
112
  using DB::GetOptions;
113
  virtual const Options& GetOptions(ColumnFamilyHandle* column_family) const;
114 115
  using DB::Flush;
  virtual Status Flush(const FlushOptions& options,
116
                       ColumnFamilyHandle* column_family);
117
  virtual Status DisableFileDeletions();
118
  virtual Status EnableFileDeletions(bool force);
I
Igor Canadi 已提交
119
  // All the returned filenames start with "/"
120
  virtual Status GetLiveFiles(std::vector<std::string>&,
121 122
                              uint64_t* manifest_file_size,
                              bool flush_memtable = true);
123
  virtual Status GetSortedWalFiles(VectorLogPtr& files);
124
  virtual SequenceNumber GetLatestSequenceNumber() const;
125 126 127 128
  virtual Status GetUpdatesSince(
      SequenceNumber seq_number, unique_ptr<TransactionLogIterator>* iter,
      const TransactionLogIterator::ReadOptions&
          read_options = TransactionLogIterator::ReadOptions());
129 130
  virtual Status DeleteFile(std::string name);

131
  virtual void GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata);
132

133 134
  virtual Status GetDbIdentity(std::string& identity);

I
Igor Canadi 已提交
135 136
  Status RunManualCompaction(ColumnFamilyData* cfd, int input_level,
                             int output_level, const Slice* begin,
L
Lei Jin 已提交
137
                             const Slice* end);
138

J
jorlow@chromium.org 已提交
139 140
  // Extra methods (for testing) that are not in the public DB interface

141
  // Compact any files in the named level that overlap [*begin, *end]
142 143
  Status TEST_CompactRange(int level, const Slice* begin, const Slice* end,
                           ColumnFamilyHandle* column_family = nullptr);
J
jorlow@chromium.org 已提交
144

145 146
  // Force current memtable contents to be flushed.
  Status TEST_FlushMemTable();
J
jorlow@chromium.org 已提交
147

148
  // Wait for memtable compaction
149
  Status TEST_WaitForFlushMemTable(ColumnFamilyHandle* column_family = nullptr);
150 151 152 153

  // Wait for any compaction
  Status TEST_WaitForCompact();

J
jorlow@chromium.org 已提交
154 155 156
  // Return an internal iterator over the current state of the database.
  // The keys of this iterator are internal keys (see format.h).
  // The returned iterator should be deleted when no longer needed.
157 158
  Iterator* TEST_NewInternalIterator(ColumnFamilyHandle* column_family =
                                         nullptr);
J
jorlow@chromium.org 已提交
159

160 161
  // Return the maximum overlapping data (in bytes) at next level for any
  // file at a level >= 1.
162 163
  int64_t TEST_MaxNextLevelOverlappingBytes(ColumnFamilyHandle* column_family =
                                                nullptr);
164

165 166 167
  // Simulate a db crash, no elegant closing of database.
  void TEST_Destroy_DBImpl();

A
Abhishek Kona 已提交
168 169
  // Return the current manifest file no.
  uint64_t TEST_Current_Manifest_FileNo();
170 171 172 173

  // Trigger's a background call for testing.
  void TEST_PurgeObsoleteteWAL();

174
  // get total level0 file size. Only for testing.
175
  uint64_t TEST_GetLevel0TotalSize();
176

177 178 179 180 181
  void TEST_SetDefaultTimeToCheck(uint64_t default_interval_to_delete_obsolete_WAL)
  {
    default_interval_to_delete_obsolete_WAL_ = default_interval_to_delete_obsolete_WAL;
  }

182 183
  void TEST_GetFilesMetaData(ColumnFamilyHandle* column_family,
                             std::vector<std::vector<FileMetaData>>* metadata);
184

I
Igor Canadi 已提交
185
  // needed for CleanupIteratorState
I
Igor Canadi 已提交
186 187
  struct DeletionState {
    inline bool HaveSomethingToDelete() const {
K
kailiu 已提交
188
      return  candidate_files.size() ||
I
Igor Canadi 已提交
189 190 191
        sst_delete_files.size() ||
        log_delete_files.size();
    }
192

I
Igor Canadi 已提交
193 194 195
    // a list of all files that we'll consider deleting
    // (every once in a while this is filled up with all files
    // in the DB directory)
K
kailiu 已提交
196
    std::vector<std::string> candidate_files;
I
Igor Canadi 已提交
197 198 199 200 201 202 203 204 205 206

    // the list of all live sst files that cannot be deleted
    std::vector<uint64_t> sst_live;

    // a list of sst files that we need to delete
    std::vector<FileMetaData*> sst_delete_files;

    // a list of log files that we need to delete
    std::vector<uint64_t> log_delete_files;

207
    // a list of memtables to be free
K
Kai Liu 已提交
208
    autovector<MemTable*> memtables_to_free;
209

210
    autovector<SuperVersion*> superversions_to_free;
I
Igor Canadi 已提交
211

212
    SuperVersion* new_superversion;  // if nullptr no new superversion
I
Igor Canadi 已提交
213

I
Igor Canadi 已提交
214 215 216 217
    // the current manifest_file_number, log_number and prev_log_number
    // that corresponds to the set of files in 'live'.
    uint64_t manifest_file_number, log_number, prev_log_number;

K
Kai Liu 已提交
218
    explicit DeletionState(bool create_superversion = false) {
I
Igor Canadi 已提交
219 220 221
      manifest_file_number = 0;
      log_number = 0;
      prev_log_number = 0;
222
      new_superversion = create_superversion ? new SuperVersion() : nullptr;
I
Igor Canadi 已提交
223 224 225 226 227 228 229
    }

    ~DeletionState() {
      // free pending memtables
      for (auto m : memtables_to_free) {
        delete m;
      }
230 231 232 233
      // free superversions
      for (auto s : superversions_to_free) {
        delete s;
      }
I
Igor Canadi 已提交
234 235 236
      // if new_superversion was not used, it will be non-nullptr and needs
      // to be freed here
      delete new_superversion;
I
Igor Canadi 已提交
237 238 239 240
    }
  };

  // Returns the list of live files in 'live' and the list
K
kailiu 已提交
241
  // of all files in the filesystem in 'candidate_files'.
I
Igor Canadi 已提交
242 243 244 245 246 247 248 249 250 251 252 253 254
  // If force == false and the last call was less than
  // options_.delete_obsolete_files_period_micros microseconds ago,
  // it will not fill up the deletion_state
  void FindObsoleteFiles(DeletionState& deletion_state,
                         bool force,
                         bool no_full_scan = false);

  // Diffs the files listed in filenames and those that do not
  // belong to live files are posibly removed. Also, removes all the
  // files in sst_delete_files and log_delete_files.
  // It is not necessary to hold the mutex when invoking this method.
  void PurgeObsoleteFiles(DeletionState& deletion_state);

255 256
  ColumnFamilyHandle* DefaultColumnFamily() const;

257
 protected:
H
heyongqiang 已提交
258 259
  Env* const env_;
  const std::string dbname_;
260
  unique_ptr<VersionSet> versions_;
I
Igor Canadi 已提交
261
  const DBOptions options_;
H
heyongqiang 已提交
262

263 264
  Iterator* NewInternalIterator(const ReadOptions&, ColumnFamilyData* cfd,
                                SuperVersion* super_version);
265

J
jorlow@chromium.org 已提交
266 267
 private:
  friend class DB;
T
Tomislav Novak 已提交
268
  friend class TailingIterator;
269 270
  struct CompactionState;
  struct Writer;
J
jorlow@chromium.org 已提交
271 272 273 274 275 276

  Status NewDB();

  // Recover the descriptor from persistent storage.  May do a significant
  // amount of work to recover recently logged updates.  Any changes to
  // be made to the descriptor are added to *edit.
277 278
  Status Recover(const std::vector<ColumnFamilyDescriptor>& column_families,
                 bool read_only = false, bool error_if_log_file_exist = false);
J
jorlow@chromium.org 已提交
279 280 281

  void MaybeIgnoreError(Status* s) const;

282 283
  const Status CreateArchivalDirectory();

J
jorlow@chromium.org 已提交
284 285 286
  // Delete any unneeded files and stale in-memory entries.
  void DeleteObsoleteFiles();

287
  // Flush the in-memory write buffer to storage.  Switches to a new
J
jorlow@chromium.org 已提交
288
  // log-file/memtable and writes a new descriptor iff successful.
289
  Status FlushMemTableToOutputFile(ColumnFamilyData* cfd, bool* madeProgress,
I
Igor Canadi 已提交
290
                                   DeletionState& deletion_state);
J
jorlow@chromium.org 已提交
291

I
Igor Canadi 已提交
292 293
  Status RecoverLogFile(uint64_t log_number, SequenceNumber* max_sequence,
                        bool read_only);
J
jorlow@chromium.org 已提交
294

295 296 297 298 299
  // The following two methods are used to flush a memtable to
  // storage. The first one is used atdatabase RecoveryTime (when the
  // database is opened) and is heavyweight because it holds the mutex
  // for the entire period. The second method WriteLevel0Table supports
  // concurrent flush memtables to storage.
300 301
  Status WriteLevel0TableForRecovery(ColumnFamilyData* cfd, MemTable* mem,
                                     VersionEdit* edit);
302
  Status WriteLevel0Table(ColumnFamilyData* cfd, autovector<MemTable*>& mems,
303
                          VersionEdit* edit, uint64_t* filenumber);
J
jorlow@chromium.org 已提交
304

M
Mark Callaghan 已提交
305
  uint64_t SlowdownAmount(int n, double bottom, double top);
306 307
  Status MakeRoomForWrite(ColumnFamilyData* cfd,
                          bool force /* flush even if there is room? */);
308 309
  void BuildBatchGroup(Writer** last_writer,
                       autovector<WriteBatch*>* write_batch_group);
J
jorlow@chromium.org 已提交
310

H
heyongqiang 已提交
311
  // Force current memtable contents to be flushed.
312
  Status FlushMemTable(ColumnFamilyData* cfd, const FlushOptions& options);
H
heyongqiang 已提交
313

314
  // Wait for memtable flushed
315
  Status WaitForFlushMemTable(ColumnFamilyData* cfd);
H
heyongqiang 已提交
316

317
  void MaybeScheduleLogDBDeployStats();
318 319
  static void BGLogDBDeployStats(void* db);
  void LogDBDeployStats();
320

321
  void MaybeScheduleFlushOrCompaction();
322 323 324 325
  static void BGWorkCompaction(void* db);
  static void BGWorkFlush(void* db);
  void BackgroundCallCompaction();
  void BackgroundCallFlush();
326 327
  Status BackgroundCompaction(bool* madeProgress, DeletionState& deletion_state,
                              LogBuffer* log_buffer);
I
Igor Canadi 已提交
328
  Status BackgroundFlush(bool* madeProgress, DeletionState& deletion_state);
329
  void CleanupCompaction(CompactionState* compact, Status status);
I
Igor Canadi 已提交
330 331
  Status DoCompactionWork(CompactionState* compact,
                          DeletionState& deletion_state);
J
jorlow@chromium.org 已提交
332 333 334 335

  Status OpenCompactionOutputFile(CompactionState* compact);
  Status FinishCompactionOutputFile(CompactionState* compact, Iterator* input);
  Status InstallCompactionResults(CompactionState* compact);
336 337
  void AllocateCompactionOutputFileNumbers(CompactionState* compact);
  void ReleaseCompactionUnusedFileNumbers(CompactionState* compact);
A
Abhishek Kona 已提交
338

339
  void PurgeObsoleteWALFiles();
340

341 342 343
  Status AppendSortedWalsOfType(const std::string& path,
                                VectorLogPtr& log_files,
                                WalFileType type);
344

345 346 347 348 349
  // Requires: all_logs should be sorted with earliest log file first
  // Retains all log files in all_logs which contain updates with seq no.
  // Greater Than or Equal to the requested SequenceNumber.
  Status RetainProbableWalFiles(VectorLogPtr& all_logs,
                                const SequenceNumber target);
350
  //  return true if
351 352
  bool CheckWalFileExistsAndEmpty(const WalFileType type,
                                  const uint64_t number);
353

354 355
  Status ReadFirstRecord(const WalFileType type, const uint64_t number,
                         WriteBatch* const result);
356 357

  Status ReadFirstLine(const std::string& fname, WriteBatch* const batch);
358

359 360
  void PrintStatistics();

361
  // dump rocksdb.stats to LOG
362 363
  void MaybeDumpStats();

364 365
  // Return the minimum empty level that could hold the total data in the
  // input level. Return the input level, if such level could not be found.
I
Igor Canadi 已提交
366
  int FindMinimumEmptyLevelFitting(ColumnFamilyData* cfd, int level);
367

368 369 370
  // Move the files in the input level to the target level.
  // If target_level < 0, automatically calculate the minimum level that could
  // hold the data set.
I
Igor Canadi 已提交
371
  Status ReFitLevel(ColumnFamilyData* cfd, int level, int target_level = -1);
372

T
Tomislav Novak 已提交
373
  // Returns a pair of iterators (mutable-only and immutable-only) used
374
  // internally by TailingIterator and stores cfd->GetSuperVersionNumber() in
T
Tomislav Novak 已提交
375 376 377
  // *superversion_number. These iterators are always up-to-date, i.e. can
  // be used to read new data.
  std::pair<Iterator*, Iterator*> GetTailingIteratorPair(
378 379
      const ReadOptions& options, ColumnFamilyData* cfd,
      uint64_t* superversion_number);
380

J
jorlow@chromium.org 已提交
381
  // table_cache_ provides its own synchronization
I
Igor Canadi 已提交
382
  std::shared_ptr<Cache> table_cache_;
J
jorlow@chromium.org 已提交
383

384
  // Lock over the persistent DB state.  Non-nullptr iff successfully acquired.
J
jorlow@chromium.org 已提交
385 386 387 388 389
  FileLock* db_lock_;

  // State below is protected by mutex_
  port::Mutex mutex_;
  port::AtomicPointer shutting_down_;
H
hans@chromium.org 已提交
390
  port::CondVar bg_cv_;          // Signalled when background work finishes
391
  uint64_t logfile_number_;
392
  unique_ptr<log::Writer> log_;
393
  ColumnFamilyHandleImpl* default_cf_handle_;
394
  unique_ptr<ColumnFamilyMemTablesImpl> column_family_memtables_;
I
Igor Canadi 已提交
395
  std::deque<uint64_t> alive_log_files_;
I
Igor Canadi 已提交
396

397 398
  std::string host_name_;

399 400
  std::unique_ptr<Directory> db_directory_;

401 402
  // Queue of writers.
  std::deque<Writer*> writers_;
403
  WriteBatch tmp_batch_;
404

J
jorlow@chromium.org 已提交
405 406 407 408 409 410
  SnapshotList snapshots_;

  // Set of table files to protect from deletion because they are
  // part of ongoing compactions.
  std::set<uint64_t> pending_outputs_;

411
  // count how many background compactions are running or have been scheduled
412
  int bg_compaction_scheduled_;
J
jorlow@chromium.org 已提交
413

414 415 416 417 418
  // If non-zero, MaybeScheduleFlushOrCompaction() will only schedule manual
  // compactions (if manual_compaction_ is not null). This mechanism enables
  // manual compactions to wait until all other compactions are finished.
  int bg_manual_only_;

419 420 421
  // number of background memtable flush jobs, submitted to the HIGH pool
  int bg_flush_scheduled_;

422 423 424
  // Has a background stats log thread scheduled?
  bool bg_logstats_scheduled_;

H
hans@chromium.org 已提交
425 426
  // Information for a manual compaction
  struct ManualCompaction {
I
Igor Canadi 已提交
427
    ColumnFamilyData* cfd;
428 429
    int input_level;
    int output_level;
G
Gabor Cselle 已提交
430
    bool done;
L
Lei Jin 已提交
431
    Status status;
432
    bool in_progress;           // compaction request being processed?
433 434
    const InternalKey* begin;   // nullptr means beginning of key range
    const InternalKey* end;     // nullptr means end of key range
G
Gabor Cselle 已提交
435
    InternalKey tmp_storage;    // Used to keep track of compaction progress
H
hans@chromium.org 已提交
436 437
  };
  ManualCompaction* manual_compaction_;
J
jorlow@chromium.org 已提交
438 439 440 441

  // Have we encountered a background error in paranoid mode?
  Status bg_error_;

442
  std::unique_ptr<StatsLogger> logger_;
443

444
  int64_t volatile last_log_ts;
445

446
  // shall we disable deletion of obsolete files
447 448 449 450 451 452
  // if 0 the deletion is enabled.
  // if non-zero, files will not be getting deleted
  // This enables two different threads to call
  // EnableFileDeletions() and DisableFileDeletions()
  // without any synchronization
  int disable_delete_obsolete_files_;
453

454 455 456
  // last time when DeleteObsoleteFiles was invoked
  uint64_t delete_obsolete_files_last_run_;

457 458 459
  // last time when PurgeObsoleteWALFiles ran.
  uint64_t purge_wal_files_last_run_;

460
  // last time stats were dumped to LOG
H
Haobo Xu 已提交
461
  std::atomic<uint64_t> last_stats_dump_time_microsec_;
462

463 464 465 466
  // obsolete files will be deleted every this seconds if ttl deletion is
  // enabled and archive size_limit is disabled.
  uint64_t default_interval_to_delete_obsolete_WAL_;

467 468
  bool flush_on_destroy_; // Used when disableWAL is true.

H
heyongqiang 已提交
469
  static const int KEEP_LOG_FILE_NUM = 1000;
H
heyongqiang 已提交
470
  std::string db_absolute_path_;
H
heyongqiang 已提交
471

472 473 474
  // count of the number of contiguous delaying writes
  int delayed_writes_;

475
  // The options to access storage files
H
Haobo Xu 已提交
476
  const EnvOptions storage_options_;
477

478 479 480 481 482 483
  // A value of true temporarily disables scheduling of background work
  bool bg_work_gate_closed_;

  // Guard against multiple concurrent refitting
  bool refitting_level_;

484 485 486
  // Indicate DB was opened successfully
  bool opened_successfully_;

J
jorlow@chromium.org 已提交
487 488 489 490
  // No copying allowed
  DBImpl(const DBImpl&);
  void operator=(const DBImpl&);

491 492
  // dump the delayed_writes_ to the log file and reset counter.
  void DelayLoggingAndReset();
493

494 495 496 497 498 499
  // Return the earliest snapshot where seqno is visible.
  // Store the snapshot right before that, if any, in prev_snapshot
  inline SequenceNumber findEarliestVisibleSnapshot(
    SequenceNumber in,
    std::vector<SequenceNumber>& snapshots,
    SequenceNumber* prev_snapshot);
500

I
Igor Canadi 已提交
501
  // Background threads call this function, which is just a wrapper around
502
  // the cfd->InstallSuperVersion() function. Background threads carry
I
Igor Canadi 已提交
503
  // deletion_state which can have new_superversion already allocated.
504 505
  void InstallSuperVersion(ColumnFamilyData* cfd,
                           DeletionState& deletion_state);
I
Igor Canadi 已提交
506

I
Igor Canadi 已提交
507 508 509
  using DB::GetPropertiesOfAllTables;
  virtual Status GetPropertiesOfAllTables(ColumnFamilyHandle* column_family,
                                          TablePropertiesCollection* props)
510 511
      override;

512 513
  // Function that Get and KeyMayExist call with no_io true or false
  // Note: 'value_found' from KeyMayExist propagates here
514 515 516
  Status GetImpl(const ReadOptions& options, ColumnFamilyHandle* column_family,
                 const Slice& key, std::string* value,
                 bool* value_found = nullptr);
J
jorlow@chromium.org 已提交
517 518 519 520 521 522
};

// Sanitize db options.  The caller should delete result.info_log if
// it is not equal to src.info_log.
extern Options SanitizeOptions(const std::string& db,
                               const InternalKeyComparator* icmp,
S
Sanjay Ghemawat 已提交
523
                               const InternalFilterPolicy* ipolicy,
J
jorlow@chromium.org 已提交
524
                               const Options& src);
525
extern DBOptions SanitizeOptions(const std::string& db, const DBOptions& src);
S
Siying Dong 已提交
526 527 528 529 530 531 532 533 534

// Determine compression type, based on user options, level of the output
// file and whether compression is disabled.
// If enable_compression is false, then compression is always disabled no
// matter what the values of the other two parameters are.
// Otherwise, the compression type is determined based on options and level.
CompressionType GetCompressionType(const Options& options, int level,
                                   const bool enable_compression);

535 536 537
// Determine compression type for L0 file written by memtable flush.
CompressionType GetCompressionFlush(const Options& options);

538
}  // namespace rocksdb