@nxtedition/rocksdb 13.1.4 → 13.2.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.
Files changed (237) hide show
  1. package/binding.cc +43 -16
  2. package/deps/rocksdb/rocksdb/{TARGETS → BUCK} +27 -0
  3. package/deps/rocksdb/rocksdb/CMakeLists.txt +3 -1
  4. package/deps/rocksdb/rocksdb/Makefile +2 -2
  5. package/deps/rocksdb/rocksdb/cache/cache.cc +3 -1
  6. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +2 -0
  7. package/deps/rocksdb/rocksdb/db/attribute_group_iterator_impl.h +34 -9
  8. package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +7 -6
  9. package/deps/rocksdb/rocksdb/db/blob/blob_source.h +5 -1
  10. package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +22 -14
  11. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +149 -0
  12. package/deps/rocksdb/rocksdb/db/builder.cc +13 -24
  13. package/deps/rocksdb/rocksdb/db/coalescing_iterator.h +35 -10
  14. package/deps/rocksdb/rocksdb/db/column_family.cc +21 -10
  15. package/deps/rocksdb/rocksdb/db/column_family.h +15 -8
  16. package/deps/rocksdb/rocksdb/db/column_family_test.cc +98 -7
  17. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +126 -16
  18. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +51 -5
  19. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +2 -2
  20. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +2 -8
  21. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +24 -0
  22. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +52 -22
  23. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +9 -7
  24. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +36 -9
  25. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +6 -0
  26. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +30 -17
  27. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +26 -23
  28. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +43 -33
  29. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +6 -5
  30. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +19 -9
  31. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +6 -5
  32. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +632 -411
  33. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +171 -51
  34. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +7 -5
  35. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +37 -10
  36. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +51 -11
  37. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +10 -3
  38. package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +350 -154
  39. package/deps/rocksdb/rocksdb/db/convenience.cc +1 -1
  40. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +62 -27
  41. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +68 -1
  42. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +91 -0
  43. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +134 -70
  44. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +71 -23
  45. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +43 -16
  46. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +47 -33
  47. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +27 -19
  48. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +38 -25
  49. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +3 -3
  50. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +7 -4
  51. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +258 -42
  52. package/deps/rocksdb/rocksdb/db/db_io_failure_test.cc +161 -9
  53. package/deps/rocksdb/rocksdb/db/db_iter.cc +118 -86
  54. package/deps/rocksdb/rocksdb/db/db_iter.h +44 -17
  55. package/deps/rocksdb/rocksdb/db/db_options_test.cc +27 -6
  56. package/deps/rocksdb/rocksdb/db/db_test.cc +48 -16
  57. package/deps/rocksdb/rocksdb/db/db_test2.cc +60 -15
  58. package/deps/rocksdb/rocksdb/db/db_test_util.cc +97 -44
  59. package/deps/rocksdb/rocksdb/db/db_test_util.h +7 -1
  60. package/deps/rocksdb/rocksdb/db/dbformat.cc +15 -5
  61. package/deps/rocksdb/rocksdb/db/dbformat.h +137 -55
  62. package/deps/rocksdb/rocksdb/db/event_helpers.cc +1 -0
  63. package/deps/rocksdb/rocksdb/db/experimental.cc +54 -0
  64. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +663 -8
  65. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +152 -91
  66. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +134 -11
  67. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +55 -9
  68. package/deps/rocksdb/rocksdb/db/flush_job.cc +52 -29
  69. package/deps/rocksdb/rocksdb/db/flush_job.h +5 -3
  70. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +18 -12
  71. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +23 -29
  72. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +3 -2
  73. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +2 -0
  74. package/deps/rocksdb/rocksdb/db/internal_stats.cc +9 -6
  75. package/deps/rocksdb/rocksdb/db/internal_stats.h +54 -0
  76. package/deps/rocksdb/rocksdb/db/job_context.h +1 -1
  77. package/deps/rocksdb/rocksdb/db/log_reader.cc +6 -7
  78. package/deps/rocksdb/rocksdb/db/manifest_ops.cc +47 -0
  79. package/deps/rocksdb/rocksdb/db/manifest_ops.h +20 -0
  80. package/deps/rocksdb/rocksdb/db/memtable.cc +165 -64
  81. package/deps/rocksdb/rocksdb/db/memtable.h +422 -243
  82. package/deps/rocksdb/rocksdb/db/memtable_list.cc +99 -68
  83. package/deps/rocksdb/rocksdb/db/memtable_list.h +63 -38
  84. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +28 -25
  85. package/deps/rocksdb/rocksdb/db/multi_cf_iterator_impl.h +118 -60
  86. package/deps/rocksdb/rocksdb/db/multi_cf_iterator_test.cc +344 -89
  87. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +2 -3
  88. package/deps/rocksdb/rocksdb/db/repair.cc +15 -14
  89. package/deps/rocksdb/rocksdb/db/repair_test.cc +0 -13
  90. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +7 -0
  91. package/deps/rocksdb/rocksdb/db/table_cache.cc +62 -65
  92. package/deps/rocksdb/rocksdb/db/table_cache.h +70 -76
  93. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +5 -6
  94. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +1 -1
  95. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +8 -7
  96. package/deps/rocksdb/rocksdb/db/version_builder.cc +17 -19
  97. package/deps/rocksdb/rocksdb/db/version_builder.h +13 -12
  98. package/deps/rocksdb/rocksdb/db/version_edit.h +30 -0
  99. package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +3 -5
  100. package/deps/rocksdb/rocksdb/db/version_set.cc +89 -129
  101. package/deps/rocksdb/rocksdb/db/version_set.h +12 -4
  102. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +1 -2
  103. package/deps/rocksdb/rocksdb/db/version_set_test.cc +12 -8
  104. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.cc +0 -15
  105. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.h +0 -2
  106. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization_test.cc +9 -7
  107. package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.cc +0 -8
  108. package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.h +28 -2
  109. package/deps/rocksdb/rocksdb/db/write_batch.cc +32 -10
  110. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +9 -0
  111. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +2 -1
  112. package/deps/rocksdb/rocksdb/db/write_thread.cc +3 -1
  113. package/deps/rocksdb/rocksdb/db/write_thread.h +6 -2
  114. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +15 -0
  115. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +7 -0
  116. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +4 -0
  117. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +18 -2
  118. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +100 -22
  119. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +15 -4
  120. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +34 -8
  121. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +223 -78
  122. package/deps/rocksdb/rocksdb/env/file_system.cc +6 -1
  123. package/deps/rocksdb/rocksdb/env/fs_posix.cc +53 -0
  124. package/deps/rocksdb/rocksdb/env/io_posix.cc +63 -17
  125. package/deps/rocksdb/rocksdb/env/io_posix.h +30 -1
  126. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +132 -48
  127. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +92 -24
  128. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +727 -109
  129. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +3 -4
  130. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +1 -1
  131. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +8 -0
  132. package/deps/rocksdb/rocksdb/include/rocksdb/attribute_groups.h +20 -1
  133. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_job_stats.h +9 -0
  134. package/deps/rocksdb/rocksdb/include/rocksdb/configurable.h +9 -5
  135. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +2 -0
  136. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +10 -2
  137. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1 -0
  138. package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +7 -0
  139. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +34 -37
  140. package/deps/rocksdb/rocksdb/include/rocksdb/iterator_base.h +21 -0
  141. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +56 -28
  142. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +3 -0
  143. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +36 -28
  144. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +11 -0
  145. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +1 -0
  146. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +84 -60
  147. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/secondary_index.h +102 -0
  148. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +89 -2
  149. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +32 -0
  150. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +30 -1
  151. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +23 -2
  152. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  153. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +2 -0
  154. package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +79 -21
  155. package/deps/rocksdb/rocksdb/memtable/skiplist.h +41 -18
  156. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +1 -5
  157. package/deps/rocksdb/rocksdb/memtable/wbwi_memtable.cc +169 -0
  158. package/deps/rocksdb/rocksdb/memtable/wbwi_memtable.h +400 -0
  159. package/deps/rocksdb/rocksdb/monitoring/thread_status_util_debug.cc +2 -0
  160. package/deps/rocksdb/rocksdb/options/cf_options.cc +137 -82
  161. package/deps/rocksdb/rocksdb/options/cf_options.h +18 -6
  162. package/deps/rocksdb/rocksdb/options/configurable.cc +31 -17
  163. package/deps/rocksdb/rocksdb/options/configurable_helper.h +7 -6
  164. package/deps/rocksdb/rocksdb/options/options_helper.cc +10 -8
  165. package/deps/rocksdb/rocksdb/options/options_parser.cc +74 -54
  166. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +89 -0
  167. package/deps/rocksdb/rocksdb/options/options_test.cc +112 -26
  168. package/deps/rocksdb/rocksdb/port/port.h +5 -9
  169. package/deps/rocksdb/rocksdb/src.mk +8 -0
  170. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.h +4 -0
  171. package/deps/rocksdb/rocksdb/table/block_based/block.h +1 -7
  172. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +2 -0
  173. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +62 -80
  174. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.h +13 -3
  175. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +16 -5
  176. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +38 -7
  177. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +12 -4
  178. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +4 -1
  179. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +4 -1
  180. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +204 -1
  181. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index_test.cc +3 -3
  182. package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +2 -1
  183. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.h +4 -0
  184. package/deps/rocksdb/rocksdb/table/format.cc +3 -3
  185. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +4 -1
  186. package/deps/rocksdb/rocksdb/table/mock_table.cc +0 -50
  187. package/deps/rocksdb/rocksdb/table/mock_table.h +53 -0
  188. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.h +4 -0
  189. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +1 -1
  190. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +10 -5
  191. package/deps/rocksdb/rocksdb/table/table_builder.h +3 -1
  192. package/deps/rocksdb/rocksdb/table/table_properties.cc +181 -0
  193. package/deps/rocksdb/rocksdb/table/table_reader_bench.cc +5 -5
  194. package/deps/rocksdb/rocksdb/table/table_test.cc +71 -64
  195. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.py +45 -45
  196. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim_test.py +35 -35
  197. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_plot.py +43 -43
  198. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +41 -4
  199. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +1 -0
  200. package/deps/rocksdb/rocksdb/tools/sst_dump_test.cc +1 -1
  201. package/deps/rocksdb/rocksdb/unreleased_history/add.sh +13 -0
  202. package/deps/rocksdb/rocksdb/util/aligned_buffer.h +24 -5
  203. package/deps/rocksdb/rocksdb/util/compaction_job_stats_impl.cc +7 -0
  204. package/deps/rocksdb/rocksdb/util/file_checksum_helper.cc +0 -52
  205. package/deps/rocksdb/rocksdb/util/file_checksum_helper.h +1 -10
  206. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +92 -0
  207. package/deps/rocksdb/rocksdb/util/thread_operation.h +1 -0
  208. package/deps/rocksdb/rocksdb/util/udt_util.cc +50 -4
  209. package/deps/rocksdb/rocksdb/util/udt_util.h +24 -11
  210. package/deps/rocksdb/rocksdb/util/udt_util_test.cc +26 -13
  211. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +1 -16
  212. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +2 -0
  213. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index.cc +214 -0
  214. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index.h +60 -0
  215. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index_test.cc +124 -0
  216. package/deps/rocksdb/rocksdb/utilities/secondary_index/secondary_index_mixin.h +441 -0
  217. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +34 -3
  218. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +7 -2
  219. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +437 -0
  220. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +34 -11
  221. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +14 -7
  222. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +7 -1
  223. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +17 -0
  224. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +69 -0
  225. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +20 -0
  226. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +1290 -0
  227. package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +324 -0
  228. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -1
  229. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.h +8 -1
  230. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +57 -12
  231. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +32 -3
  232. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +33 -2
  233. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +721 -9
  234. package/deps/rocksdb/rocksdb.gyp +2 -0
  235. package/package.json +1 -1
  236. package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
  237. package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
@@ -16,6 +16,7 @@
16
16
  #include <vector>
17
17
 
18
18
  #include "db/compaction/compaction.h"
19
+ #include "db/snapshot_checker.h"
19
20
  #include "db/version_set.h"
20
21
  #include "options/cf_options.h"
21
22
  #include "rocksdb/env.h"
@@ -55,17 +56,17 @@ class CompactionPicker {
55
56
  // Returns nullptr if there is no compaction to be done.
56
57
  // Otherwise returns a pointer to a heap-allocated object that
57
58
  // describes the compaction. Caller should delete the result.
58
- virtual Compaction* PickCompaction(const std::string& cf_name,
59
- const MutableCFOptions& mutable_cf_options,
60
- const MutableDBOptions& mutable_db_options,
61
- VersionStorageInfo* vstorage,
62
- LogBuffer* log_buffer) = 0;
63
-
64
- // Return a compaction object for compacting the range [begin,end] in
65
- // the specified level. Returns nullptr if there is nothing in that
66
- // level that overlaps the specified range. Caller should delete
67
- // the result.
68
- //
59
+ // Currently, only universal compaction will query existing snapshots and
60
+ // pass it to aid compaction picking. And it's only passed when user-defined
61
+ // timestamps is not enabled. The other compaction styles do not pass or use
62
+ // `existing_snapshots` or `snapshot_checker`.
63
+ virtual Compaction* PickCompaction(
64
+ const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
65
+ const MutableDBOptions& mutable_db_options,
66
+ const std::vector<SequenceNumber>& existing_snapshots,
67
+ const SnapshotChecker* snapshot_checker, VersionStorageInfo* vstorage,
68
+ LogBuffer* log_buffer) = 0;
69
+
69
70
  // The returned Compaction might not include the whole requested range.
70
71
  // In that case, compaction_end will be set to the next key that needs
71
72
  // compacting. In case the compaction will compact the whole range,
@@ -96,9 +97,8 @@ class CompactionPicker {
96
97
  // non-ok status with specific reason.
97
98
  //
98
99
  Status SanitizeAndConvertCompactionInputFiles(
99
- std::unordered_set<uint64_t>* input_files,
100
- const ColumnFamilyMetaData& cf_meta, const int output_level,
101
- const VersionStorageInfo* vstorage,
100
+ std::unordered_set<uint64_t>* input_files, const int output_level,
101
+ Version* version,
102
102
  std::vector<CompactionInputFiles>* converted_input_files) const;
103
103
 
104
104
  // Free up the files that participated in a compaction
@@ -203,10 +203,11 @@ class CompactionPicker {
203
203
  const CompactionInputFiles& output_level_inputs,
204
204
  std::vector<FileMetaData*>* grandparents);
205
205
 
206
- void PickFilesMarkedForCompaction(const std::string& cf_name,
207
- VersionStorageInfo* vstorage,
208
- int* start_level, int* output_level,
209
- CompactionInputFiles* start_level_inputs);
206
+ void PickFilesMarkedForCompaction(
207
+ const std::string& cf_name, VersionStorageInfo* vstorage,
208
+ int* start_level, int* output_level,
209
+ CompactionInputFiles* start_level_inputs,
210
+ std::function<bool(const FileMetaData*)> skip_marked_file);
210
211
 
211
212
  bool GetOverlappingL0Files(VersionStorageInfo* vstorage,
212
213
  CompactionInputFiles* start_level_inputs,
@@ -257,11 +258,13 @@ class NullCompactionPicker : public CompactionPicker {
257
258
  virtual ~NullCompactionPicker() {}
258
259
 
259
260
  // Always return "nullptr"
260
- Compaction* PickCompaction(const std::string& /*cf_name*/,
261
- const MutableCFOptions& /*mutable_cf_options*/,
262
- const MutableDBOptions& /*mutable_db_options*/,
263
- VersionStorageInfo* /*vstorage*/,
264
- LogBuffer* /* log_buffer */) override {
261
+ Compaction* PickCompaction(
262
+ const std::string& /*cf_name*/,
263
+ const MutableCFOptions& /*mutable_cf_options*/,
264
+ const MutableDBOptions& /*mutable_db_options*/,
265
+ const std::vector<SequenceNumber>& /*existing_snapshots*/,
266
+ const SnapshotChecker* /*snapshot_checker*/,
267
+ VersionStorageInfo* /*vstorage*/, LogBuffer* /* log_buffer */) override {
265
268
  return nullptr;
266
269
  }
267
270
 
@@ -79,10 +79,14 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction(
79
79
  FileMetaData* f = *ritr;
80
80
  assert(f);
81
81
  if (f->fd.table_reader && f->fd.table_reader->GetTableProperties()) {
82
+ uint64_t newest_key_time = f->TryGetNewestKeyTime();
82
83
  uint64_t creation_time =
83
84
  f->fd.table_reader->GetTableProperties()->creation_time;
84
- if (creation_time == 0 ||
85
- creation_time >= (current_time - mutable_cf_options.ttl)) {
85
+ uint64_t est_newest_key_time = newest_key_time == kUnknownNewestKeyTime
86
+ ? creation_time
87
+ : newest_key_time;
88
+ if (est_newest_key_time == kUnknownNewestKeyTime ||
89
+ est_newest_key_time >= (current_time - mutable_cf_options.ttl)) {
86
90
  break;
87
91
  }
88
92
  }
@@ -102,15 +106,19 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction(
102
106
  }
103
107
 
104
108
  for (const auto& f : inputs[0].files) {
105
- uint64_t creation_time = 0;
106
109
  assert(f);
110
+ uint64_t newest_key_time = f->TryGetNewestKeyTime();
111
+ uint64_t creation_time = 0;
107
112
  if (f->fd.table_reader && f->fd.table_reader->GetTableProperties()) {
108
113
  creation_time = f->fd.table_reader->GetTableProperties()->creation_time;
109
114
  }
115
+ uint64_t est_newest_key_time = newest_key_time == kUnknownNewestKeyTime
116
+ ? creation_time
117
+ : newest_key_time;
110
118
  ROCKS_LOG_BUFFER(log_buffer,
111
119
  "[%s] FIFO compaction: picking file %" PRIu64
112
- " with creation time %" PRIu64 " for deletion",
113
- cf_name.c_str(), f->fd.GetNumber(), creation_time);
120
+ " with estimated newest key time %" PRIu64 " for deletion",
121
+ cf_name.c_str(), f->fd.GetNumber(), est_newest_key_time);
114
122
  }
115
123
 
116
124
  Compaction* c = new Compaction(
@@ -118,7 +126,9 @@ Compaction* FIFOCompactionPicker::PickTTLCompaction(
118
126
  std::move(inputs), 0, 0, 0, 0, kNoCompression,
119
127
  mutable_cf_options.compression_opts,
120
128
  mutable_cf_options.default_write_temperature,
121
- /* max_subcompactions */ 0, {}, /* is manual */ false,
129
+ /* max_subcompactions */ 0, {}, /* earliest_snapshot */ std::nullopt,
130
+ /* snapshot_checker */ nullptr,
131
+ /* is manual */ false,
122
132
  /* trim_ts */ "", vstorage->CompactionScore(0),
123
133
  /* is deletion compaction */ true, /* l0_files_might_overlap */ true,
124
134
  CompactionReason::kFIFOTtl);
@@ -188,7 +198,9 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction(
188
198
  0 /* output path ID */, mutable_cf_options.compression,
189
199
  mutable_cf_options.compression_opts,
190
200
  mutable_cf_options.default_write_temperature,
191
- 0 /* max_subcompactions */, {}, /* is manual */ false,
201
+ 0 /* max_subcompactions */, {},
202
+ /* earliest_snapshot */ std::nullopt,
203
+ /* snapshot_checker */ nullptr, /* is manual */ false,
192
204
  /* trim_ts */ "", vstorage->CompactionScore(0),
193
205
  /* is deletion compaction */ false,
194
206
  /* l0_files_might_overlap */ true,
@@ -284,7 +296,9 @@ Compaction* FIFOCompactionPicker::PickSizeCompaction(
284
296
  /* output_path_id */ 0, kNoCompression,
285
297
  mutable_cf_options.compression_opts,
286
298
  mutable_cf_options.default_write_temperature,
287
- /* max_subcompactions */ 0, {}, /* is manual */ false,
299
+ /* max_subcompactions */ 0, {}, /* earliest_snapshot */ std::nullopt,
300
+ /* snapshot_checker */ nullptr,
301
+ /* is manual */ false,
288
302
  /* trim_ts */ "", vstorage->CompactionScore(0),
289
303
  /* is deletion compaction */ true,
290
304
  /* l0_files_might_overlap */ true, CompactionReason::kFIFOMaxSize);
@@ -344,38 +358,29 @@ Compaction* FIFOCompactionPicker::PickTemperatureChangeCompaction(
344
358
  Temperature compaction_target_temp = Temperature::kLastTemperature;
345
359
  if (current_time > min_age) {
346
360
  uint64_t create_time_threshold = current_time - min_age;
347
- // We will ideally identify a file qualifying for temperature change by
348
- // knowing the timestamp for the youngest entry in the file. However, right
349
- // now we don't have the information. We infer it by looking at timestamp of
350
- // the previous file's (which is just younger) oldest entry's timestamp.
351
- // avoid index underflow
352
361
  assert(level_files.size() >= 1);
353
- for (size_t index = level_files.size() - 1; index >= 1; --index) {
362
+ for (size_t index = level_files.size(); index >= 1; --index) {
354
363
  // Try to add cur_file to compaction inputs.
355
- FileMetaData* cur_file = level_files[index];
356
- // prev_file is just younger than cur_file
357
- FileMetaData* prev_file = level_files[index - 1];
364
+ FileMetaData* cur_file = level_files[index - 1];
365
+ FileMetaData* prev_file = index < 2 ? nullptr : level_files[index - 2];
358
366
  if (cur_file->being_compacted) {
359
367
  // Should not happen since we check for
360
368
  // `level0_compactions_in_progress_` above. Here we simply just don't
361
369
  // schedule anything.
362
370
  return nullptr;
363
371
  }
364
- uint64_t oldest_ancestor_time = prev_file->TryGetOldestAncesterTime();
365
- if (oldest_ancestor_time == kUnknownOldestAncesterTime) {
366
- // Older files might not have enough information. It is possible to
367
- // handle these files by looking at newer files, but maintaining the
368
- // logic isn't worth it.
369
- break;
372
+ uint64_t est_newest_key_time = cur_file->TryGetNewestKeyTime(prev_file);
373
+ // Newer file could have newest_key_time populated
374
+ if (est_newest_key_time == kUnknownNewestKeyTime) {
375
+ continue;
370
376
  }
371
- if (oldest_ancestor_time > create_time_threshold) {
372
- // cur_file is too fresh
377
+ if (est_newest_key_time > create_time_threshold) {
373
378
  break;
374
379
  }
375
380
  Temperature cur_target_temp = ages[0].temperature;
376
381
  for (size_t i = 1; i < ages.size(); ++i) {
377
382
  if (current_time >= ages[i].age &&
378
- oldest_ancestor_time <= current_time - ages[i].age) {
383
+ est_newest_key_time <= current_time - ages[i].age) {
379
384
  cur_target_temp = ages[i].temperature;
380
385
  }
381
386
  }
@@ -390,8 +395,8 @@ Compaction* FIFOCompactionPicker::PickTemperatureChangeCompaction(
390
395
  ROCKS_LOG_BUFFER(
391
396
  log_buffer,
392
397
  "[%s] FIFO compaction: picking file %" PRIu64
393
- " with next file's oldest time %" PRIu64 " for temperature %s.",
394
- cf_name.c_str(), cur_file->fd.GetNumber(), oldest_ancestor_time,
398
+ " with estimated newest key time %" PRIu64 " for temperature %s.",
399
+ cf_name.c_str(), cur_file->fd.GetNumber(), est_newest_key_time,
395
400
  temperature_to_string[cur_target_temp].c_str());
396
401
  break;
397
402
  }
@@ -410,8 +415,9 @@ Compaction* FIFOCompactionPicker::PickTemperatureChangeCompaction(
410
415
  0 /* max compaction bytes, not applicable */, 0 /* output path ID */,
411
416
  mutable_cf_options.compression, mutable_cf_options.compression_opts,
412
417
  compaction_target_temp,
413
- /* max_subcompactions */ 0, {}, /* is manual */ false, /* trim_ts */ "",
414
- vstorage->CompactionScore(0),
418
+ /* max_subcompactions */ 0, {}, /* earliest_snapshot */ std::nullopt,
419
+ /* snapshot_checker */ nullptr,
420
+ /* is manual */ false, /* trim_ts */ "", vstorage->CompactionScore(0),
415
421
  /* is deletion compaction */ false, /* l0_files_might_overlap */ true,
416
422
  CompactionReason::kChangeTemperature);
417
423
  return c;
@@ -419,7 +425,9 @@ Compaction* FIFOCompactionPicker::PickTemperatureChangeCompaction(
419
425
 
420
426
  Compaction* FIFOCompactionPicker::PickCompaction(
421
427
  const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
422
- const MutableDBOptions& mutable_db_options, VersionStorageInfo* vstorage,
428
+ const MutableDBOptions& mutable_db_options,
429
+ const std::vector<SequenceNumber>& /* existing_snapshots */,
430
+ const SnapshotChecker* /* snapshot_checker */, VersionStorageInfo* vstorage,
423
431
  LogBuffer* log_buffer) {
424
432
  Compaction* c = nullptr;
425
433
  if (mutable_cf_options.ttl > 0) {
@@ -454,8 +462,10 @@ Compaction* FIFOCompactionPicker::CompactRange(
454
462
  assert(output_level == 0);
455
463
  *compaction_end = nullptr;
456
464
  LogBuffer log_buffer(InfoLogLevel::INFO_LEVEL, ioptions_.logger);
457
- Compaction* c = PickCompaction(cf_name, mutable_cf_options,
458
- mutable_db_options, vstorage, &log_buffer);
465
+ Compaction* c =
466
+ PickCompaction(cf_name, mutable_cf_options, mutable_db_options,
467
+ /*existing_snapshots*/ {}, /*snapshot_checker*/ nullptr,
468
+ vstorage, &log_buffer);
459
469
  log_buffer.FlushBufferToLog();
460
470
  return c;
461
471
  }
@@ -18,11 +18,12 @@ class FIFOCompactionPicker : public CompactionPicker {
18
18
  const InternalKeyComparator* icmp)
19
19
  : CompactionPicker(ioptions, icmp) {}
20
20
 
21
- Compaction* PickCompaction(const std::string& cf_name,
22
- const MutableCFOptions& mutable_cf_options,
23
- const MutableDBOptions& mutable_db_options,
24
- VersionStorageInfo* version,
25
- LogBuffer* log_buffer) override;
21
+ Compaction* PickCompaction(
22
+ const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
23
+ const MutableDBOptions& mutable_db_options,
24
+ const std::vector<SequenceNumber>& /* existing_snapshots */,
25
+ const SnapshotChecker* /* snapshot_checker */,
26
+ VersionStorageInfo* version, LogBuffer* log_buffer) override;
26
27
 
27
28
  Compaction* CompactRange(const std::string& cf_name,
28
29
  const MutableCFOptions& mutable_cf_options,
@@ -262,7 +262,10 @@ void LevelCompactionBuilder::SetupInitialFiles() {
262
262
  parent_index_ = base_index_ = -1;
263
263
 
264
264
  compaction_picker_->PickFilesMarkedForCompaction(
265
- cf_name_, vstorage_, &start_level_, &output_level_, &start_level_inputs_);
265
+ cf_name_, vstorage_, &start_level_, &output_level_, &start_level_inputs_,
266
+ /*skip_marked_file*/ [](const FileMetaData* /* file */) {
267
+ return false;
268
+ });
266
269
  if (!start_level_inputs_.empty()) {
267
270
  compaction_reason_ = CompactionReason::kFilesMarkedForCompaction;
268
271
  return;
@@ -411,8 +414,9 @@ void LevelCompactionBuilder::SetupOtherFilesWithRoundRobinExpansion() {
411
414
  &tmp_start_level_inputs) ||
412
415
  compaction_picker_->FilesRangeOverlapWithCompaction(
413
416
  {tmp_start_level_inputs}, output_level_,
414
- Compaction::EvaluatePenultimateLevel(
415
- vstorage_, ioptions_, start_level_, output_level_))) {
417
+ Compaction::EvaluatePenultimateLevel(vstorage_, mutable_cf_options_,
418
+ ioptions_, start_level_,
419
+ output_level_))) {
416
420
  // Constraint 1a
417
421
  tmp_start_level_inputs.clear();
418
422
  return;
@@ -486,8 +490,9 @@ bool LevelCompactionBuilder::SetupOtherInputsIfNeeded() {
486
490
  // We need to disallow this from happening.
487
491
  if (compaction_picker_->FilesRangeOverlapWithCompaction(
488
492
  compaction_inputs_, output_level_,
489
- Compaction::EvaluatePenultimateLevel(
490
- vstorage_, ioptions_, start_level_, output_level_))) {
493
+ Compaction::EvaluatePenultimateLevel(vstorage_, mutable_cf_options_,
494
+ ioptions_, start_level_,
495
+ output_level_))) {
491
496
  // This compaction output could potentially conflict with the output
492
497
  // of a currently running compaction, we cannot run it.
493
498
  return false;
@@ -554,7 +559,9 @@ Compaction* LevelCompactionBuilder::GetCompaction() {
554
559
  vstorage_->base_level()),
555
560
  GetCompressionOptions(mutable_cf_options_, vstorage_, output_level_),
556
561
  mutable_cf_options_.default_write_temperature,
557
- /* max_subcompactions */ 0, std::move(grandparents_), is_manual_,
562
+ /* max_subcompactions */ 0, std::move(grandparents_),
563
+ /* earliest_snapshot */ std::nullopt, /* snapshot_checker */ nullptr,
564
+ is_manual_,
558
565
  /* trim_ts */ "", start_level_score_, false /* deletion_compaction */,
559
566
  l0_files_might_overlap, compaction_reason_);
560
567
 
@@ -839,8 +846,9 @@ bool LevelCompactionBuilder::PickFileToCompact() {
839
846
  &start_level_inputs_) ||
840
847
  compaction_picker_->FilesRangeOverlapWithCompaction(
841
848
  {start_level_inputs_}, output_level_,
842
- Compaction::EvaluatePenultimateLevel(
843
- vstorage_, ioptions_, start_level_, output_level_))) {
849
+ Compaction::EvaluatePenultimateLevel(vstorage_, mutable_cf_options_,
850
+ ioptions_, start_level_,
851
+ output_level_))) {
844
852
  // A locked (pending compaction) input-level file was pulled in due to
845
853
  // user-key overlap.
846
854
  start_level_inputs_.clear();
@@ -967,7 +975,9 @@ bool LevelCompactionBuilder::PickSizeBasedIntraL0Compaction() {
967
975
 
968
976
  Compaction* LevelCompactionPicker::PickCompaction(
969
977
  const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
970
- const MutableDBOptions& mutable_db_options, VersionStorageInfo* vstorage,
978
+ const MutableDBOptions& mutable_db_options,
979
+ const std::vector<SequenceNumber>& /*existing_snapshots */,
980
+ const SnapshotChecker* /*snapshot_checker*/, VersionStorageInfo* vstorage,
971
981
  LogBuffer* log_buffer) {
972
982
  LevelCompactionBuilder builder(cf_name, vstorage, this, log_buffer,
973
983
  mutable_cf_options, ioptions_,
@@ -20,11 +20,12 @@ class LevelCompactionPicker : public CompactionPicker {
20
20
  LevelCompactionPicker(const ImmutableOptions& ioptions,
21
21
  const InternalKeyComparator* icmp)
22
22
  : CompactionPicker(ioptions, icmp) {}
23
- Compaction* PickCompaction(const std::string& cf_name,
24
- const MutableCFOptions& mutable_cf_options,
25
- const MutableDBOptions& mutable_db_options,
26
- VersionStorageInfo* vstorage,
27
- LogBuffer* log_buffer) override;
23
+ Compaction* PickCompaction(
24
+ const std::string& cf_name, const MutableCFOptions& mutable_cf_options,
25
+ const MutableDBOptions& mutable_db_options,
26
+ const std::vector<SequenceNumber>& /* existing_snapshots */,
27
+ const SnapshotChecker* /* snapshot_checker */,
28
+ VersionStorageInfo* vstorage, LogBuffer* log_buffer) override;
28
29
 
29
30
  bool NeedsCompaction(const VersionStorageInfo* vstorage) const override;
30
31
  };