@nxtedition/rocksdb 7.1.33 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BUILDING.md +2 -2
- package/binding.cc +0 -147
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +402 -345
- package/deps/rocksdb/rocksdb/cache/clock_cache.h +121 -64
- package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +28 -18
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +1 -0
- package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +2 -0
- package/deps/rocksdb/rocksdb/db/builder.cc +2 -1
- package/deps/rocksdb/rocksdb/db/c.cc +563 -673
- package/deps/rocksdb/rocksdb/db/c_test.c +168 -169
- package/deps/rocksdb/rocksdb/db/column_family.cc +16 -15
- package/deps/rocksdb/rocksdb/db/column_family.h +7 -7
- package/deps/rocksdb/rocksdb/db/column_family_test.cc +17 -28
- package/deps/rocksdb/rocksdb/db/compact_files_test.cc +4 -9
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +8 -3
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +114 -0
- package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +2 -3
- package/deps/rocksdb/rocksdb/db/convenience.cc +3 -5
- package/deps/rocksdb/rocksdb/db/corruption_test.cc +10 -14
- package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +9 -13
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +2 -2
- package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +2 -2
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +14 -16
- package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +52 -72
- package/deps/rocksdb/rocksdb/db/db_dynamic_level_test.cc +2 -2
- package/deps/rocksdb/rocksdb/db/db_encryption_test.cc +12 -12
- package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -2
- package/deps/rocksdb/rocksdb/db/db_flush_test.cc +3 -3
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +1 -12
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +3 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +26 -0
- package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +1 -0
- package/deps/rocksdb/rocksdb/db/db_iter.cc +12 -6
- package/deps/rocksdb/rocksdb/db/db_iter.h +1 -0
- package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +6 -7
- package/deps/rocksdb/rocksdb/db/db_iter_test.cc +10 -8
- package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +15 -13
- package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +7 -9
- package/deps/rocksdb/rocksdb/db/db_logical_block_size_cache_test.cc +4 -4
- package/deps/rocksdb/rocksdb/db/db_merge_operand_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +2 -4
- package/deps/rocksdb/rocksdb/db/db_options_test.cc +4 -4
- package/deps/rocksdb/rocksdb/db/db_properties_test.cc +7 -4
- package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +7 -5
- package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_statistics_test.cc +8 -6
- package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +18 -23
- package/deps/rocksdb/rocksdb/db/db_tailing_iter_test.cc +3 -5
- package/deps/rocksdb/rocksdb/db/db_test.cc +10 -5
- package/deps/rocksdb/rocksdb/db/db_test2.cc +172 -169
- package/deps/rocksdb/rocksdb/db/db_test_util.cc +68 -66
- package/deps/rocksdb/rocksdb/db/db_test_util.h +1 -3
- package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +31 -39
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +182 -2
- package/deps/rocksdb/rocksdb/db/db_write_test.cc +43 -40
- package/deps/rocksdb/rocksdb/db/dbformat.h +15 -0
- package/deps/rocksdb/rocksdb/db/dbformat_test.cc +35 -34
- package/deps/rocksdb/rocksdb/db/deletefile_test.cc +10 -11
- package/deps/rocksdb/rocksdb/db/error_handler.cc +6 -6
- package/deps/rocksdb/rocksdb/db/error_handler.h +93 -94
- package/deps/rocksdb/rocksdb/db/event_helpers.cc +1 -1
- package/deps/rocksdb/rocksdb/db/event_helpers.h +3 -3
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +16 -17
- package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +2 -2
- package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +1 -2
- package/deps/rocksdb/rocksdb/db/file_indexer.cc +2 -0
- package/deps/rocksdb/rocksdb/db/file_indexer.h +2 -1
- package/deps/rocksdb/rocksdb/db/file_indexer_test.cc +4 -2
- package/deps/rocksdb/rocksdb/db/filename_test.cc +27 -29
- package/deps/rocksdb/rocksdb/db/flush_job.cc +7 -13
- package/deps/rocksdb/rocksdb/db/flush_job_test.cc +2 -2
- package/deps/rocksdb/rocksdb/db/forward_iterator.cc +15 -21
- package/deps/rocksdb/rocksdb/db/forward_iterator.h +7 -6
- package/deps/rocksdb/rocksdb/db/forward_iterator_bench.cc +4 -2
- package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +2 -2
- package/deps/rocksdb/rocksdb/db/internal_stats.cc +59 -14
- package/deps/rocksdb/rocksdb/db/internal_stats.h +27 -11
- package/deps/rocksdb/rocksdb/db/job_context.h +5 -6
- package/deps/rocksdb/rocksdb/db/listener_test.cc +21 -23
- package/deps/rocksdb/rocksdb/db/log_reader.cc +7 -11
- package/deps/rocksdb/rocksdb/db/log_reader.h +4 -6
- package/deps/rocksdb/rocksdb/db/log_test.cc +6 -12
- package/deps/rocksdb/rocksdb/db/log_writer.h +1 -1
- package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.h +0 -1
- package/deps/rocksdb/rocksdb/db/lookup_key.h +4 -1
- package/deps/rocksdb/rocksdb/db/malloc_stats.cc +2 -1
- package/deps/rocksdb/rocksdb/db/manual_compaction_test.cc +3 -5
- package/deps/rocksdb/rocksdb/db/memtable.cc +34 -22
- package/deps/rocksdb/rocksdb/db/memtable.h +4 -6
- package/deps/rocksdb/rocksdb/db/memtable_list.cc +7 -0
- package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +37 -13
- package/deps/rocksdb/rocksdb/db/merge_context.h +1 -0
- package/deps/rocksdb/rocksdb/db/merge_helper.cc +128 -14
- package/deps/rocksdb/rocksdb/db/merge_helper.h +15 -7
- package/deps/rocksdb/rocksdb/db/merge_helper_test.cc +2 -1
- package/deps/rocksdb/rocksdb/db/merge_operator.cc +5 -6
- package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +4 -3
- package/deps/rocksdb/rocksdb/db/options_file_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/perf_context_test.cc +55 -43
- package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +288 -299
- package/deps/rocksdb/rocksdb/db/prefix_test.cc +22 -27
- package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +1 -1
- package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/repair.cc +7 -8
- package/deps/rocksdb/rocksdb/db/repair_test.cc +3 -4
- package/deps/rocksdb/rocksdb/db/snapshot_impl.cc +4 -5
- package/deps/rocksdb/rocksdb/db/snapshot_impl.h +10 -4
- package/deps/rocksdb/rocksdb/db/table_cache.cc +3 -4
- package/deps/rocksdb/rocksdb/db/table_properties_collector.cc +6 -7
- package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +22 -22
- package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +12 -12
- package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +6 -8
- package/deps/rocksdb/rocksdb/db/trim_history_scheduler.h +2 -0
- package/deps/rocksdb/rocksdb/db/version_builder_test.cc +3 -3
- package/deps/rocksdb/rocksdb/db/version_edit.cc +2 -5
- package/deps/rocksdb/rocksdb/db/version_edit.h +8 -12
- package/deps/rocksdb/rocksdb/db/version_set.cc +74 -102
- package/deps/rocksdb/rocksdb/db/version_set.h +8 -10
- package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +0 -5
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +47 -45
- package/deps/rocksdb/rocksdb/db/wal_manager.cc +6 -5
- package/deps/rocksdb/rocksdb/db/wal_manager.h +2 -2
- package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +4 -3
- package/deps/rocksdb/rocksdb/db/wide/db_wide_basic_test.cc +144 -61
- package/deps/rocksdb/rocksdb/db/write_batch.cc +41 -24
- package/deps/rocksdb/rocksdb/db/write_batch_internal.h +2 -7
- package/deps/rocksdb/rocksdb/db/write_batch_test.cc +105 -104
- package/deps/rocksdb/rocksdb/db/write_callback_test.cc +5 -4
- package/deps/rocksdb/rocksdb/db/write_controller.h +1 -0
- package/deps/rocksdb/rocksdb/db/write_controller_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/write_thread.cc +8 -6
- package/deps/rocksdb/rocksdb/env/io_posix.h +6 -0
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +134 -65
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +29 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +1 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/db.h +1 -4
- package/deps/rocksdb/rocksdb/include/rocksdb/merge_operator.h +1 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +4 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +14 -4
- package/deps/rocksdb/rocksdb/table/get_context.cc +52 -7
- package/deps/rocksdb/rocksdb/table/get_context.h +1 -2
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +13 -0
- package/deps/rocksdb/rocksdb/util/crc32c_arm64.cc +36 -4
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +6 -6
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +23 -28
- package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +11 -1
- package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +19 -17
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +10 -7
- package/index.js +3 -195
- package/package.json +2 -4
- package/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/prebuilds/linux-x64/node.napi.node +0 -0
- package/common.js +0 -7
|
@@ -93,23 +93,19 @@ namespace {
|
|
|
93
93
|
// Find File in LevelFilesBrief data structure
|
|
94
94
|
// Within an index range defined by left and right
|
|
95
95
|
int FindFileInRange(const InternalKeyComparator& icmp,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
uint32_t left,
|
|
99
|
-
uint32_t right) {
|
|
96
|
+
const LevelFilesBrief& file_level, const Slice& key,
|
|
97
|
+
uint32_t left, uint32_t right) {
|
|
100
98
|
auto cmp = [&](const FdWithKeyRange& f, const Slice& k) -> bool {
|
|
101
99
|
return icmp.InternalKeyComparator::Compare(f.largest_key, k) < 0;
|
|
102
100
|
};
|
|
103
|
-
const auto
|
|
104
|
-
return static_cast<int>(std::lower_bound(b + left,
|
|
105
|
-
b + right, key, cmp) - b);
|
|
101
|
+
const auto& b = file_level.files;
|
|
102
|
+
return static_cast<int>(std::lower_bound(b + left, b + right, key, cmp) - b);
|
|
106
103
|
}
|
|
107
104
|
|
|
108
105
|
Status OverlapWithIterator(const Comparator* ucmp,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
bool* overlap) {
|
|
106
|
+
const Slice& smallest_user_key,
|
|
107
|
+
const Slice& largest_user_key,
|
|
108
|
+
InternalIterator* iter, bool* overlap) {
|
|
113
109
|
InternalKey range_start(smallest_user_key, kMaxSequenceNumber,
|
|
114
110
|
kValueTypeForSeek);
|
|
115
111
|
iter->Seek(range_start.Encode());
|
|
@@ -187,9 +183,9 @@ class FilePicker {
|
|
|
187
183
|
// Do key range filtering of files or/and fractional cascading if:
|
|
188
184
|
// (1) not all the files are in level 0, or
|
|
189
185
|
// (2) there are more than 3 current level files
|
|
190
|
-
// If there are only 3 or less current level files in the system, we
|
|
191
|
-
// the key range filtering. In this case, more likely, the system
|
|
192
|
-
// highly tuned to minimize number of tables queried by each query,
|
|
186
|
+
// If there are only 3 or less current level files in the system, we
|
|
187
|
+
// skip the key range filtering. In this case, more likely, the system
|
|
188
|
+
// is highly tuned to minimize number of tables queried by each query,
|
|
193
189
|
// so it is unlikely that key range filtering is more efficient than
|
|
194
190
|
// querying the files.
|
|
195
191
|
if (num_levels_ > 1 || curr_file_level_->num_files > 3) {
|
|
@@ -211,11 +207,9 @@ class FilePicker {
|
|
|
211
207
|
// Setup file search bound for the next level based on the
|
|
212
208
|
// comparison results
|
|
213
209
|
if (curr_level_ > 0) {
|
|
214
|
-
file_indexer_->GetNextLevelIndex(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
&search_left_bound_,
|
|
218
|
-
&search_right_bound_);
|
|
210
|
+
file_indexer_->GetNextLevelIndex(
|
|
211
|
+
curr_level_, curr_index_in_curr_level_, cmp_smallest,
|
|
212
|
+
cmp_largest, &search_left_bound_, &search_right_bound_);
|
|
219
213
|
}
|
|
220
214
|
// Key falls out of current file's range
|
|
221
215
|
if (cmp_smallest < 0 || cmp_largest > 0) {
|
|
@@ -846,22 +840,21 @@ Version::~Version() {
|
|
|
846
840
|
}
|
|
847
841
|
|
|
848
842
|
int FindFile(const InternalKeyComparator& icmp,
|
|
849
|
-
const LevelFilesBrief& file_level,
|
|
850
|
-
const Slice& key) {
|
|
843
|
+
const LevelFilesBrief& file_level, const Slice& key) {
|
|
851
844
|
return FindFileInRange(icmp, file_level, key, 0,
|
|
852
845
|
static_cast<uint32_t>(file_level.num_files));
|
|
853
846
|
}
|
|
854
847
|
|
|
855
848
|
void DoGenerateLevelFilesBrief(LevelFilesBrief* file_level,
|
|
856
|
-
|
|
857
|
-
|
|
849
|
+
const std::vector<FileMetaData*>& files,
|
|
850
|
+
Arena* arena) {
|
|
858
851
|
assert(file_level);
|
|
859
852
|
assert(arena);
|
|
860
853
|
|
|
861
854
|
size_t num = files.size();
|
|
862
855
|
file_level->num_files = num;
|
|
863
856
|
char* mem = arena->AllocateAligned(num * sizeof(FdWithKeyRange));
|
|
864
|
-
file_level->files = new (mem)FdWithKeyRange[num];
|
|
857
|
+
file_level->files = new (mem) FdWithKeyRange[num];
|
|
865
858
|
|
|
866
859
|
for (size_t i = 0; i < num; i++) {
|
|
867
860
|
Slice smallest_key = files[i]->smallest.Encode();
|
|
@@ -882,28 +875,27 @@ void DoGenerateLevelFilesBrief(LevelFilesBrief* file_level,
|
|
|
882
875
|
}
|
|
883
876
|
}
|
|
884
877
|
|
|
885
|
-
static bool AfterFile(const Comparator* ucmp,
|
|
886
|
-
const
|
|
878
|
+
static bool AfterFile(const Comparator* ucmp, const Slice* user_key,
|
|
879
|
+
const FdWithKeyRange* f) {
|
|
887
880
|
// nullptr user_key occurs before all keys and is therefore never after *f
|
|
888
881
|
return (user_key != nullptr &&
|
|
889
882
|
ucmp->CompareWithoutTimestamp(*user_key,
|
|
890
883
|
ExtractUserKey(f->largest_key)) > 0);
|
|
891
884
|
}
|
|
892
885
|
|
|
893
|
-
static bool BeforeFile(const Comparator* ucmp,
|
|
894
|
-
const
|
|
886
|
+
static bool BeforeFile(const Comparator* ucmp, const Slice* user_key,
|
|
887
|
+
const FdWithKeyRange* f) {
|
|
895
888
|
// nullptr user_key occurs after all keys and is therefore never before *f
|
|
896
889
|
return (user_key != nullptr &&
|
|
897
890
|
ucmp->CompareWithoutTimestamp(*user_key,
|
|
898
891
|
ExtractUserKey(f->smallest_key)) < 0);
|
|
899
892
|
}
|
|
900
893
|
|
|
901
|
-
bool SomeFileOverlapsRange(
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
const Slice* largest_user_key) {
|
|
894
|
+
bool SomeFileOverlapsRange(const InternalKeyComparator& icmp,
|
|
895
|
+
bool disjoint_sorted_files,
|
|
896
|
+
const LevelFilesBrief& file_level,
|
|
897
|
+
const Slice* smallest_user_key,
|
|
898
|
+
const Slice* largest_user_key) {
|
|
907
899
|
const Comparator* ucmp = icmp.user_comparator();
|
|
908
900
|
if (!disjoint_sorted_files) {
|
|
909
901
|
// Need to check against all files
|
|
@@ -1025,9 +1017,7 @@ class LevelIterator final : public InternalIterator {
|
|
|
1025
1017
|
return file_iter_.iter() ? file_iter_.status() : Status::OK();
|
|
1026
1018
|
}
|
|
1027
1019
|
|
|
1028
|
-
bool PrepareValue() override {
|
|
1029
|
-
return file_iter_.PrepareValue();
|
|
1030
|
-
}
|
|
1020
|
+
bool PrepareValue() override { return file_iter_.PrepareValue(); }
|
|
1031
1021
|
|
|
1032
1022
|
inline bool MayBeOutOfLowerBound() override {
|
|
1033
1023
|
assert(Valid());
|
|
@@ -1561,9 +1551,8 @@ Status Version::GetTableProperties(std::shared_ptr<const TableProperties>* tp,
|
|
|
1561
1551
|
if (fname != nullptr) {
|
|
1562
1552
|
file_name = *fname;
|
|
1563
1553
|
} else {
|
|
1564
|
-
file_name =
|
|
1565
|
-
|
|
1566
|
-
file_meta->fd.GetPathId());
|
|
1554
|
+
file_name = TableFileName(ioptions->cf_paths, file_meta->fd.GetNumber(),
|
|
1555
|
+
file_meta->fd.GetPathId());
|
|
1567
1556
|
}
|
|
1568
1557
|
s = ioptions->fs->NewRandomAccessFile(file_name, file_options_, &file,
|
|
1569
1558
|
nullptr);
|
|
@@ -1690,8 +1679,8 @@ Status Version::GetPropertiesOfTablesInRange(
|
|
|
1690
1679
|
false);
|
|
1691
1680
|
for (const auto& file_meta : files) {
|
|
1692
1681
|
auto fname =
|
|
1693
|
-
TableFileName(cfd_->ioptions()->cf_paths,
|
|
1694
|
-
file_meta->fd.
|
|
1682
|
+
TableFileName(cfd_->ioptions()->cf_paths, file_meta->fd.GetNumber(),
|
|
1683
|
+
file_meta->fd.GetPathId());
|
|
1695
1684
|
if (props->count(fname) == 0) {
|
|
1696
1685
|
// 1. If the table is already present in table cache, load table
|
|
1697
1686
|
// properties from there.
|
|
@@ -1788,8 +1777,7 @@ void Version::GetColumnFamilyMetaData(ColumnFamilyMetaData* cf_meta) {
|
|
|
1788
1777
|
files.back().num_deletions = file->num_deletions;
|
|
1789
1778
|
level_size += file->fd.GetFileSize();
|
|
1790
1779
|
}
|
|
1791
|
-
cf_meta->levels.emplace_back(
|
|
1792
|
-
level, level_size, std::move(files));
|
|
1780
|
+
cf_meta->levels.emplace_back(level, level_size, std::move(files));
|
|
1793
1781
|
cf_meta->size += level_size;
|
|
1794
1782
|
}
|
|
1795
1783
|
for (const auto& meta : vstorage->GetBlobFiles()) {
|
|
@@ -1880,10 +1868,8 @@ uint64_t VersionStorageInfo::GetEstimatedActiveKeys() const {
|
|
|
1880
1868
|
|
|
1881
1869
|
if (current_num_samples_ < file_count) {
|
|
1882
1870
|
// casting to avoid overflowing
|
|
1883
|
-
return
|
|
1884
|
-
|
|
1885
|
-
(est * static_cast<double>(file_count) / current_num_samples_)
|
|
1886
|
-
);
|
|
1871
|
+
return static_cast<uint64_t>(
|
|
1872
|
+
(est * static_cast<double>(file_count) / current_num_samples_));
|
|
1887
1873
|
} else {
|
|
1888
1874
|
return est;
|
|
1889
1875
|
}
|
|
@@ -2020,8 +2006,8 @@ Status Version::OverlapWithLevelIterator(const ReadOptions& read_options,
|
|
|
2020
2006
|
/*smallest_compaction_key=*/nullptr,
|
|
2021
2007
|
/*largest_compaction_key=*/nullptr,
|
|
2022
2008
|
/*allow_unprepared_value=*/false));
|
|
2023
|
-
status = OverlapWithIterator(
|
|
2024
|
-
|
|
2009
|
+
status = OverlapWithIterator(ucmp, smallest_user_key, largest_user_key,
|
|
2010
|
+
iter.get(), overlap);
|
|
2025
2011
|
if (!status.ok() || *overlap) {
|
|
2026
2012
|
break;
|
|
2027
2013
|
}
|
|
@@ -2035,8 +2021,8 @@ Status Version::OverlapWithLevelIterator(const ReadOptions& read_options,
|
|
|
2035
2021
|
cfd_->internal_stats()->GetFileReadHist(level),
|
|
2036
2022
|
TableReaderCaller::kUserIterator, IsFilterSkipped(level), level,
|
|
2037
2023
|
&range_del_agg));
|
|
2038
|
-
status = OverlapWithIterator(
|
|
2039
|
-
|
|
2024
|
+
status = OverlapWithIterator(ucmp, smallest_user_key, largest_user_key,
|
|
2025
|
+
iter.get(), overlap);
|
|
2040
2026
|
}
|
|
2041
2027
|
|
|
2042
2028
|
if (status.ok() && *overlap == false &&
|
|
@@ -2380,10 +2366,6 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
|
|
|
2380
2366
|
"Encounter unexpected blob index. Please open DB with "
|
|
2381
2367
|
"ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
|
|
2382
2368
|
return;
|
|
2383
|
-
case GetContext::kUnexpectedWideColumnEntity:
|
|
2384
|
-
*status =
|
|
2385
|
-
Status::NotSupported("Encountered unexpected wide-column entity");
|
|
2386
|
-
return;
|
|
2387
2369
|
}
|
|
2388
2370
|
f = fp.GetNextFile();
|
|
2389
2371
|
}
|
|
@@ -2396,7 +2378,7 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
|
|
|
2396
2378
|
return;
|
|
2397
2379
|
}
|
|
2398
2380
|
if (!merge_operator_) {
|
|
2399
|
-
*status =
|
|
2381
|
+
*status = Status::InvalidArgument(
|
|
2400
2382
|
"merge_operator is not properly initialized.");
|
|
2401
2383
|
return;
|
|
2402
2384
|
}
|
|
@@ -2407,7 +2389,7 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
|
|
|
2407
2389
|
*status = MergeHelper::TimedFullMerge(
|
|
2408
2390
|
merge_operator_, user_key, nullptr, merge_context->GetOperands(),
|
|
2409
2391
|
str_value, columns, info_log_, db_statistics_, clock_,
|
|
2410
|
-
nullptr /*
|
|
2392
|
+
/* result_operand */ nullptr, /* update_num_ops_stats */ true);
|
|
2411
2393
|
if (status->ok()) {
|
|
2412
2394
|
if (LIKELY(value != nullptr)) {
|
|
2413
2395
|
value->PinSelf();
|
|
@@ -2418,7 +2400,7 @@ void Version::Get(const ReadOptions& read_options, const LookupKey& k,
|
|
|
2418
2400
|
if (key_exists != nullptr) {
|
|
2419
2401
|
*key_exists = false;
|
|
2420
2402
|
}
|
|
2421
|
-
*status = Status::NotFound();
|
|
2403
|
+
*status = Status::NotFound(); // Use an empty error message for speed
|
|
2422
2404
|
}
|
|
2423
2405
|
}
|
|
2424
2406
|
|
|
@@ -2648,7 +2630,7 @@ void Version::MultiGet(const ReadOptions& read_options, MultiGetRange* range,
|
|
|
2648
2630
|
*status = MergeHelper::TimedFullMerge(
|
|
2649
2631
|
merge_operator_, user_key, nullptr, iter->merge_context.GetOperands(),
|
|
2650
2632
|
str_value, info_log_, db_statistics_, clock_,
|
|
2651
|
-
nullptr /*
|
|
2633
|
+
/* result_operand */ nullptr, /* update_num_ops_stats */ true);
|
|
2652
2634
|
if (LIKELY(iter->value != nullptr)) {
|
|
2653
2635
|
iter->value->PinSelf();
|
|
2654
2636
|
range->AddValueSize(iter->value->size());
|
|
@@ -2905,8 +2887,8 @@ bool Version::IsFilterSkipped(int level, bool is_file_last_in_level) {
|
|
|
2905
2887
|
void VersionStorageInfo::GenerateLevelFilesBrief() {
|
|
2906
2888
|
level_files_brief_.resize(num_non_empty_levels_);
|
|
2907
2889
|
for (int level = 0; level < num_non_empty_levels_; level++) {
|
|
2908
|
-
DoGenerateLevelFilesBrief(
|
|
2909
|
-
|
|
2890
|
+
DoGenerateLevelFilesBrief(&level_files_brief_[level], files_[level],
|
|
2891
|
+
&arena_);
|
|
2910
2892
|
}
|
|
2911
2893
|
}
|
|
2912
2894
|
|
|
@@ -2940,8 +2922,7 @@ void Version::PrepareAppend(const MutableCFOptions& mutable_cf_options,
|
|
|
2940
2922
|
}
|
|
2941
2923
|
|
|
2942
2924
|
bool Version::MaybeInitializeFileMetaData(FileMetaData* file_meta) {
|
|
2943
|
-
if (file_meta->init_stats_from_file ||
|
|
2944
|
-
file_meta->compensated_file_size > 0) {
|
|
2925
|
+
if (file_meta->init_stats_from_file || file_meta->compensated_file_size > 0) {
|
|
2945
2926
|
return false;
|
|
2946
2927
|
}
|
|
2947
2928
|
std::shared_ptr<const TableProperties> tp;
|
|
@@ -3608,9 +3589,9 @@ struct Fsize {
|
|
|
3608
3589
|
// In normal mode: descending size
|
|
3609
3590
|
bool CompareCompensatedSizeDescending(const Fsize& first, const Fsize& second) {
|
|
3610
3591
|
return (first.file->compensated_file_size >
|
|
3611
|
-
|
|
3592
|
+
second.file->compensated_file_size);
|
|
3612
3593
|
}
|
|
3613
|
-
}
|
|
3594
|
+
} // anonymous namespace
|
|
3614
3595
|
|
|
3615
3596
|
void VersionStorageInfo::AddFile(int level, FileMetaData* f) {
|
|
3616
3597
|
auto& level_files = files_[level];
|
|
@@ -3662,13 +3643,9 @@ void VersionStorageInfo::SetFinalized() {
|
|
|
3662
3643
|
assert(MaxBytesForLevel(level) >= max_bytes_prev_level);
|
|
3663
3644
|
max_bytes_prev_level = MaxBytesForLevel(level);
|
|
3664
3645
|
}
|
|
3665
|
-
int num_empty_non_l0_level = 0;
|
|
3666
3646
|
for (int level = 0; level < num_levels(); level++) {
|
|
3667
3647
|
assert(LevelFiles(level).size() == 0 ||
|
|
3668
3648
|
LevelFiles(level).size() == LevelFilesBrief(level).num_files);
|
|
3669
|
-
if (level > 0 && NumLevelBytes(level) > 0) {
|
|
3670
|
-
num_empty_non_l0_level++;
|
|
3671
|
-
}
|
|
3672
3649
|
if (LevelFiles(level).size() > 0) {
|
|
3673
3650
|
assert(level < num_non_empty_levels());
|
|
3674
3651
|
}
|
|
@@ -3810,7 +3787,7 @@ void SortFileByRoundRobin(const InternalKeyComparator& icmp,
|
|
|
3810
3787
|
}
|
|
3811
3788
|
}
|
|
3812
3789
|
}
|
|
3813
|
-
} // namespace
|
|
3790
|
+
} // anonymous namespace
|
|
3814
3791
|
|
|
3815
3792
|
void VersionStorageInfo::UpdateFilesByCompactionPri(
|
|
3816
3793
|
const ImmutableOptions& ioptions, const MutableCFOptions& options) {
|
|
@@ -3982,9 +3959,7 @@ void VersionStorageInfo::ComputeBottommostFilesMarkedForCompaction() {
|
|
|
3982
3959
|
}
|
|
3983
3960
|
}
|
|
3984
3961
|
|
|
3985
|
-
void Version::Ref() {
|
|
3986
|
-
++refs_;
|
|
3987
|
-
}
|
|
3962
|
+
void Version::Ref() { ++refs_; }
|
|
3988
3963
|
|
|
3989
3964
|
bool Version::Unref() {
|
|
3990
3965
|
assert(refs_ >= 1);
|
|
@@ -4116,9 +4091,8 @@ void VersionStorageInfo::GetCleanInputsWithinInterval(
|
|
|
4116
4091
|
return;
|
|
4117
4092
|
}
|
|
4118
4093
|
|
|
4119
|
-
GetOverlappingInputsRangeBinarySearch(level, begin, end, inputs,
|
|
4120
|
-
|
|
4121
|
-
true /* within_interval */);
|
|
4094
|
+
GetOverlappingInputsRangeBinarySearch(level, begin, end, inputs, hint_index,
|
|
4095
|
+
file_index, true /* within_interval */);
|
|
4122
4096
|
}
|
|
4123
4097
|
|
|
4124
4098
|
// Store in "*inputs" all files in "level" that overlap [begin,end]
|
|
@@ -4281,8 +4255,7 @@ const char* VersionStorageInfo::LevelFileSummary(FileSummaryStorage* scratch,
|
|
|
4281
4255
|
"#%" PRIu64 "(seq=%" PRIu64 ",sz=%s,%d) ",
|
|
4282
4256
|
f->fd.GetNumber(), f->fd.smallest_seqno, sztxt,
|
|
4283
4257
|
static_cast<int>(f->being_compacted));
|
|
4284
|
-
if (ret < 0 || ret >= sz)
|
|
4285
|
-
break;
|
|
4258
|
+
if (ret < 0 || ret >= sz) break;
|
|
4286
4259
|
len += ret;
|
|
4287
4260
|
}
|
|
4288
4261
|
// overwrite the last space (only if files_[level].size() is non-zero)
|
|
@@ -4460,13 +4433,13 @@ uint64_t VersionStorageInfo::EstimateLiveDataSize() const {
|
|
|
4460
4433
|
// no potential overlap, we can safely insert the rest of this level
|
|
4461
4434
|
// (if the level is not 0) into the map without checking again because
|
|
4462
4435
|
// the elements in the level are sorted and non-overlapping.
|
|
4463
|
-
auto lb = (found_end && l != 0) ?
|
|
4464
|
-
|
|
4436
|
+
auto lb = (found_end && l != 0) ? ranges.end()
|
|
4437
|
+
: ranges.lower_bound(&file->smallest);
|
|
4465
4438
|
found_end = (lb == ranges.end());
|
|
4466
4439
|
if (found_end || internal_comparator_->Compare(
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4440
|
+
file->largest, (*lb).second->smallest) < 0) {
|
|
4441
|
+
ranges.emplace_hint(lb, &file->largest, file);
|
|
4442
|
+
size += file->fd.file_size;
|
|
4470
4443
|
}
|
|
4471
4444
|
}
|
|
4472
4445
|
}
|
|
@@ -5678,7 +5651,7 @@ std::string ManifestPicker::GetNextManifest(uint64_t* number,
|
|
|
5678
5651
|
}
|
|
5679
5652
|
return ret;
|
|
5680
5653
|
}
|
|
5681
|
-
} // namespace
|
|
5654
|
+
} // anonymous namespace
|
|
5682
5655
|
|
|
5683
5656
|
Status VersionSet::TryRecover(
|
|
5684
5657
|
const std::vector<ColumnFamilyDescriptor>& column_families, bool read_only,
|
|
@@ -5880,7 +5853,7 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
|
|
|
5880
5853
|
}
|
|
5881
5854
|
}
|
|
5882
5855
|
|
|
5883
|
-
delete[] vstorage
|
|
5856
|
+
delete[] vstorage->files_;
|
|
5884
5857
|
vstorage->files_ = new_files_list;
|
|
5885
5858
|
vstorage->num_levels_ = new_levels;
|
|
5886
5859
|
vstorage->ResizeCompactCursors(new_levels);
|
|
@@ -5889,9 +5862,9 @@ Status VersionSet::ReduceNumberOfLevels(const std::string& dbname,
|
|
|
5889
5862
|
VersionEdit ve;
|
|
5890
5863
|
InstrumentedMutex dummy_mutex;
|
|
5891
5864
|
InstrumentedMutexLock l(&dummy_mutex);
|
|
5892
|
-
return versions.LogAndApply(
|
|
5893
|
-
|
|
5894
|
-
|
|
5865
|
+
return versions.LogAndApply(versions.GetColumnFamilySet()->GetDefault(),
|
|
5866
|
+
mutable_cf_options, &ve, &dummy_mutex, nullptr,
|
|
5867
|
+
true);
|
|
5895
5868
|
}
|
|
5896
5869
|
|
|
5897
5870
|
// Get the checksum information including the checksum and checksum function
|
|
@@ -5977,9 +5950,7 @@ Status VersionSet::DumpManifest(Options& options, std::string& dscname,
|
|
|
5977
5950
|
std::unique_ptr<FSSequentialFile> file;
|
|
5978
5951
|
const std::shared_ptr<FileSystem>& fs = options.env->GetFileSystem();
|
|
5979
5952
|
s = fs->NewSequentialFile(
|
|
5980
|
-
dscname,
|
|
5981
|
-
fs->OptimizeForManifestRead(file_options_), &file,
|
|
5982
|
-
nullptr);
|
|
5953
|
+
dscname, fs->OptimizeForManifestRead(file_options_), &file, nullptr);
|
|
5983
5954
|
if (!s.ok()) {
|
|
5984
5955
|
return s;
|
|
5985
5956
|
}
|
|
@@ -6082,8 +6053,8 @@ Status VersionSet::WriteCurrentStateToManifest(
|
|
|
6082
6053
|
cfd->internal_comparator().user_comparator()->Name());
|
|
6083
6054
|
std::string record;
|
|
6084
6055
|
if (!edit.EncodeTo(&record)) {
|
|
6085
|
-
return Status::Corruption(
|
|
6086
|
-
|
|
6056
|
+
return Status::Corruption("Unable to Encode VersionEdit:" +
|
|
6057
|
+
edit.DebugString(true));
|
|
6087
6058
|
}
|
|
6088
6059
|
io_s = log->AddRecord(record);
|
|
6089
6060
|
if (!io_s.ok()) {
|
|
@@ -6141,9 +6112,10 @@ Status VersionSet::WriteCurrentStateToManifest(
|
|
|
6141
6112
|
edit.SetLogNumber(log_number);
|
|
6142
6113
|
|
|
6143
6114
|
if (cfd->GetID() == 0) {
|
|
6144
|
-
// min_log_number_to_keep is for the whole db, not for specific column
|
|
6145
|
-
// So it does not need to be set for every column family, just
|
|
6146
|
-
// Since default CF can never be dropped, we set
|
|
6115
|
+
// min_log_number_to_keep is for the whole db, not for specific column
|
|
6116
|
+
// family. So it does not need to be set for every column family, just
|
|
6117
|
+
// need to be set once. Since default CF can never be dropped, we set
|
|
6118
|
+
// the min_log to the default CF here.
|
|
6147
6119
|
uint64_t min_log = min_log_number_to_keep();
|
|
6148
6120
|
if (min_log != 0) {
|
|
6149
6121
|
edit.SetMinLogNumberToKeep(min_log);
|
|
@@ -6159,8 +6131,8 @@ Status VersionSet::WriteCurrentStateToManifest(
|
|
|
6159
6131
|
|
|
6160
6132
|
std::string record;
|
|
6161
6133
|
if (!edit.EncodeTo(&record)) {
|
|
6162
|
-
return Status::Corruption(
|
|
6163
|
-
|
|
6134
|
+
return Status::Corruption("Unable to Encode VersionEdit:" +
|
|
6135
|
+
edit.DebugString(true));
|
|
6164
6136
|
}
|
|
6165
6137
|
io_s = log->AddRecord(record);
|
|
6166
6138
|
if (!io_s.ok()) {
|
|
@@ -6483,7 +6455,7 @@ InternalIterator* VersionSet::MakeInputIterator(
|
|
|
6483
6455
|
const size_t space = (c->level() == 0 ? c->input_levels(0)->num_files +
|
|
6484
6456
|
c->num_input_levels() - 1
|
|
6485
6457
|
: c->num_input_levels());
|
|
6486
|
-
InternalIterator** list = new InternalIterator*
|
|
6458
|
+
InternalIterator** list = new InternalIterator*[space];
|
|
6487
6459
|
size_t num = 0;
|
|
6488
6460
|
for (size_t which = 0; which < c->num_input_levels(); which++) {
|
|
6489
6461
|
if (c->input_levels(which)->num_files != 0) {
|
|
@@ -6592,8 +6564,8 @@ void VersionSet::GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata) {
|
|
|
6592
6564
|
filemetadata.largestkey = file->largest.user_key().ToString();
|
|
6593
6565
|
filemetadata.smallest_seqno = file->fd.smallest_seqno;
|
|
6594
6566
|
filemetadata.largest_seqno = file->fd.largest_seqno;
|
|
6595
|
-
filemetadata.num_reads_sampled =
|
|
6596
|
-
std::memory_order_relaxed);
|
|
6567
|
+
filemetadata.num_reads_sampled =
|
|
6568
|
+
file->stats.num_reads_sampled.load(std::memory_order_relaxed);
|
|
6597
6569
|
filemetadata.being_compacted = file->being_compacted;
|
|
6598
6570
|
filemetadata.num_entries = file->num_entries;
|
|
6599
6571
|
filemetadata.num_deletions = file->num_deletions;
|
|
@@ -230,9 +230,7 @@ class VersionStorageInfo {
|
|
|
230
230
|
double blob_garbage_collection_age_cutoff,
|
|
231
231
|
double blob_garbage_collection_force_threshold);
|
|
232
232
|
|
|
233
|
-
bool level0_non_overlapping() const {
|
|
234
|
-
return level0_non_overlapping_;
|
|
235
|
-
}
|
|
233
|
+
bool level0_non_overlapping() const { return level0_non_overlapping_; }
|
|
236
234
|
|
|
237
235
|
// Updates the oldest snapshot and related internal state, like the bottommost
|
|
238
236
|
// files marked for compaction.
|
|
@@ -814,8 +812,8 @@ class Version {
|
|
|
814
812
|
|
|
815
813
|
Status OverlapWithLevelIterator(const ReadOptions&, const FileOptions&,
|
|
816
814
|
const Slice& smallest_user_key,
|
|
817
|
-
const Slice& largest_user_key,
|
|
818
|
-
|
|
815
|
+
const Slice& largest_user_key, int level,
|
|
816
|
+
bool* overlap);
|
|
819
817
|
|
|
820
818
|
// Lookup the value for key or get all merge operands for key.
|
|
821
819
|
// If do_merge = true (default) then lookup value for key.
|
|
@@ -1032,10 +1030,10 @@ class Version {
|
|
|
1032
1030
|
const MergeOperator* merge_operator_;
|
|
1033
1031
|
|
|
1034
1032
|
VersionStorageInfo storage_info_;
|
|
1035
|
-
VersionSet* vset_;
|
|
1036
|
-
Version* next_;
|
|
1037
|
-
Version* prev_;
|
|
1038
|
-
int refs_;
|
|
1033
|
+
VersionSet* vset_; // VersionSet to which this Version belongs
|
|
1034
|
+
Version* next_; // Next version in linked list
|
|
1035
|
+
Version* prev_; // Previous version in linked list
|
|
1036
|
+
int refs_; // Number of live refs to this version
|
|
1039
1037
|
const FileOptions file_options_;
|
|
1040
1038
|
const MutableCFOptions mutable_cf_options_;
|
|
1041
1039
|
// Cached value to avoid recomputing it on every read.
|
|
@@ -1398,7 +1396,7 @@ class VersionSet {
|
|
|
1398
1396
|
FileMetaData** metadata, ColumnFamilyData** cfd);
|
|
1399
1397
|
|
|
1400
1398
|
// This function doesn't support leveldb SST filenames
|
|
1401
|
-
void GetLiveFilesMetaData(std::vector<LiveFileMetaData
|
|
1399
|
+
void GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata);
|
|
1402
1400
|
|
|
1403
1401
|
void AddObsoleteBlobFile(uint64_t blob_file_number, std::string path) {
|
|
1404
1402
|
assert(table_cache_);
|
|
@@ -141,11 +141,6 @@ DEFINE_SYNC_AND_ASYNC(Status, Version::MultiGetFromSST)
|
|
|
141
141
|
"ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
|
|
142
142
|
file_range.MarkKeyDone(iter);
|
|
143
143
|
continue;
|
|
144
|
-
case GetContext::kUnexpectedWideColumnEntity:
|
|
145
|
-
*status =
|
|
146
|
-
Status::NotSupported("Encountered unexpected wide-column entity");
|
|
147
|
-
file_range.MarkKeyDone(iter);
|
|
148
|
-
continue;
|
|
149
144
|
}
|
|
150
145
|
}
|
|
151
146
|
|