version_builder.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. //
  6. // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
  7. // Use of this source code is governed by a BSD-style license that can be
  8. // found in the LICENSE file. See the AUTHORS file for names of contributors.
  9. //
  10. #pragma once
  11. #include "rocksdb/file_system.h"
  12. #include "rocksdb/slice_transform.h"
  13. namespace ROCKSDB_NAMESPACE {
  14. class TableCache;
  15. class VersionStorageInfo;
  16. class VersionEdit;
  17. struct FileMetaData;
  18. class InternalStats;
  19. // A helper class so we can efficiently apply a whole sequence
  20. // of edits to a particular state without creating intermediate
  21. // Versions that contain full copies of the intermediate state.
  22. class VersionBuilder {
  23. public:
  24. VersionBuilder(const FileOptions& file_options, TableCache* table_cache,
  25. VersionStorageInfo* base_vstorage, Logger* info_log = nullptr);
  26. ~VersionBuilder();
  27. Status CheckConsistency(VersionStorageInfo* vstorage);
  28. Status CheckConsistencyForDeletes(VersionEdit* edit, uint64_t number,
  29. int level);
  30. bool CheckConsistencyForNumLevels();
  31. Status Apply(VersionEdit* edit);
  32. Status SaveTo(VersionStorageInfo* vstorage);
  33. Status LoadTableHandlers(InternalStats* internal_stats, int max_threads,
  34. bool prefetch_index_and_filter_in_cache,
  35. bool is_initial_load,
  36. const SliceTransform* prefix_extractor);
  37. void MaybeAddFile(VersionStorageInfo* vstorage, int level, FileMetaData* f);
  38. private:
  39. class Rep;
  40. Rep* rep_;
  41. };
  42. extern bool NewestFirstBySeqNo(FileMetaData* a, FileMetaData* b);
  43. } // namespace ROCKSDB_NAMESPACE