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).
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.
14 #include "rocksdb/file_system.h"
15 #include "rocksdb/slice_transform.h"
17 namespace ROCKSDB_NAMESPACE
{
19 struct ImmutableCFOptions
;
21 class VersionStorageInfo
;
27 class ColumnFamilyData
;
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
{
34 VersionBuilder(const FileOptions
& file_options
,
35 const ImmutableCFOptions
* ioptions
, TableCache
* table_cache
,
36 VersionStorageInfo
* base_vstorage
, VersionSet
* version_set
);
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
,
45 const SliceTransform
* prefix_extractor
,
46 size_t max_file_size_for_l0_meta_pin
);
50 std::unique_ptr
<Rep
> rep_
;
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
{
58 explicit BaseReferencedVersionBuilder(ColumnFamilyData
* cfd
);
59 BaseReferencedVersionBuilder(ColumnFamilyData
* cfd
, Version
* v
);
60 ~BaseReferencedVersionBuilder();
61 VersionBuilder
* version_builder() const { return version_builder_
.get(); }
64 std::unique_ptr
<VersionBuilder
> version_builder_
;
68 extern bool NewestFirstBySeqNo(FileMetaData
* a
, FileMetaData
* b
);
69 } // namespace ROCKSDB_NAMESPACE