]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/db/version_builder.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / db / version_builder.h
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
12 #include <memory>
13
14 #include "rocksdb/file_system.h"
15 #include "rocksdb/slice_transform.h"
16
17 namespace ROCKSDB_NAMESPACE {
18
19 struct ImmutableCFOptions;
20 class TableCache;
21 class VersionStorageInfo;
22 class VersionEdit;
23 struct FileMetaData;
24 class InternalStats;
25 class Version;
26 class VersionSet;
27 class ColumnFamilyData;
28
29 // A helper class so we can efficiently apply a whole sequence
30 // of edits to a particular state without creating intermediate
31 // Versions that contain full copies of the intermediate state.
32 class VersionBuilder {
33 public:
34 VersionBuilder(const FileOptions& file_options,
35 const ImmutableCFOptions* ioptions, TableCache* table_cache,
36 VersionStorageInfo* base_vstorage, VersionSet* version_set);
37 ~VersionBuilder();
38
39 bool CheckConsistencyForNumLevels();
40 Status Apply(VersionEdit* edit);
41 Status SaveTo(VersionStorageInfo* vstorage);
42 Status LoadTableHandlers(InternalStats* internal_stats, int max_threads,
43 bool prefetch_index_and_filter_in_cache,
44 bool is_initial_load,
45 const SliceTransform* prefix_extractor,
46 size_t max_file_size_for_l0_meta_pin);
47
48 private:
49 class Rep;
50 std::unique_ptr<Rep> rep_;
51 };
52
53 // A wrapper of version builder which references the current version in
54 // constructor and unref it in the destructor.
55 // Both of the constructor and destructor need to be called inside DB Mutex.
56 class BaseReferencedVersionBuilder {
57 public:
58 explicit BaseReferencedVersionBuilder(ColumnFamilyData* cfd);
59 BaseReferencedVersionBuilder(ColumnFamilyData* cfd, Version* v);
60 ~BaseReferencedVersionBuilder();
61 VersionBuilder* version_builder() const { return version_builder_.get(); }
62
63 private:
64 std::unique_ptr<VersionBuilder> version_builder_;
65 Version* version_;
66 };
67
68 extern bool NewestFirstBySeqNo(FileMetaData* a, FileMetaData* b);
69 } // namespace ROCKSDB_NAMESPACE