rocksdb-native 2.2.0 → 2.3.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 (261) hide show
  1. package/binding.c +92 -10
  2. package/index.js +9 -0
  3. package/lib/batch.js +11 -1
  4. package/lib/iterator.js +3 -1
  5. package/lib/snapshot.js +21 -0
  6. package/package.json +1 -1
  7. package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
  8. package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
  9. package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
  10. package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
  11. package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
  12. package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
  13. package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
  14. package/prebuilds/linux-x64/rocksdb-native.node +0 -0
  15. package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
  16. package/prebuilds/win32-x64/rocksdb-native.node +0 -0
  17. package/vendor/librocksdb/include/rocksdb.h +38 -4
  18. package/vendor/librocksdb/src/rocksdb.cc +114 -14
  19. package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
  20. package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
  21. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  22. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  23. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
  24. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
  25. package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
  26. package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
  27. package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
  28. package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
  29. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
  30. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
  31. package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
  32. package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
  33. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
  34. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
  35. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
  36. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
  37. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
  38. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
  39. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
  40. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
  41. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
  42. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
  43. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
  44. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
  45. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  46. package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
  47. package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
  48. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
  49. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
  50. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
  51. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  52. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
  53. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
  54. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
  55. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
  56. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
  57. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
  58. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
  59. package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
  60. package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
  61. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
  62. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
  63. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
  64. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
  65. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
  66. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
  67. package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
  68. package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
  69. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
  70. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  71. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
  72. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
  73. package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
  74. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
  75. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
  76. package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
  77. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
  78. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
  79. package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
  80. package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
  81. package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
  82. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
  83. package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  84. package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
  85. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  86. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
  87. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
  88. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
  89. package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
  90. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
  91. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
  92. package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
  93. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
  94. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
  95. package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
  96. package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
  97. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
  98. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
  99. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
  100. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  101. package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
  102. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
  103. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
  104. package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
  105. package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
  106. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
  107. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
  108. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
  109. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
  110. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
  111. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
  112. package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
  113. package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
  114. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
  115. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
  116. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
  117. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
  118. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
  119. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
  120. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
  121. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
  122. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
  123. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
  124. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
  125. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
  126. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
  127. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
  128. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
  129. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
  130. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
  131. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
  132. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
  133. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
  134. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
  135. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
  136. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
  137. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
  138. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
  139. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  140. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  141. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
  142. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  143. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  144. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
  145. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
  146. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
  147. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
  148. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  149. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
  150. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
  151. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
  152. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
  153. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
  154. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
  155. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
  156. package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
  157. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
  158. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
  159. package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
  160. package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
  161. package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
  162. package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
  163. package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
  164. package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
  165. package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
  166. package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  167. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
  168. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
  169. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
  170. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
  171. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  172. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  173. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  174. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  175. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
  176. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  177. package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
  178. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
  179. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  180. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  181. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
  182. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
  183. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
  184. package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  185. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
  186. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
  187. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
  188. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
  189. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
  190. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
  191. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  192. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  193. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  194. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  195. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
  196. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
  197. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
  198. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
  199. package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
  200. package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
  201. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
  202. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
  203. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
  204. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
  205. package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
  206. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
  207. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
  208. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
  209. package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
  210. package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
  211. package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
  212. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
  213. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
  214. package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
  215. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
  216. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
  217. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
  218. package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
  219. package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
  220. package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
  221. package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
  222. package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
  223. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
  224. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
  225. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
  226. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
  227. package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
  228. package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
  229. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
  230. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
  231. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
  232. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
  233. package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
  234. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
  235. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
  236. package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
  237. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  238. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  239. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  240. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
  241. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
  242. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
  243. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
  244. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
  245. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
  246. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
  247. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
  248. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
  249. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
  250. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
  251. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
  252. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  253. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
  254. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
  255. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  256. package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
  257. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
  258. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
  259. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  260. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
  261. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
@@ -235,19 +235,19 @@ void MemTableListVersion::AddIterators(
235
235
  SequenceNumber read_seq = options.snapshot != nullptr
236
236
  ? options.snapshot->GetSequenceNumber()
237
237
  : kMaxSequenceNumber;
238
- TruncatedRangeDelIterator* mem_tombstone_iter = nullptr;
238
+ std::unique_ptr<TruncatedRangeDelIterator> mem_tombstone_iter;
239
239
  auto range_del_iter = m->NewRangeTombstoneIterator(
240
240
  options, read_seq, true /* immutale_memtable */);
241
241
  if (range_del_iter == nullptr || range_del_iter->empty()) {
242
242
  delete range_del_iter;
243
243
  } else {
244
- mem_tombstone_iter = new TruncatedRangeDelIterator(
244
+ mem_tombstone_iter = std::make_unique<TruncatedRangeDelIterator>(
245
245
  std::unique_ptr<FragmentedRangeTombstoneIterator>(range_del_iter),
246
246
  &m->GetInternalKeyComparator(), nullptr /* smallest */,
247
247
  nullptr /* largest */);
248
248
  }
249
- merge_iter_builder->AddPointAndTombstoneIterator(mem_iter,
250
- mem_tombstone_iter);
249
+ merge_iter_builder->AddPointAndTombstoneIterator(
250
+ mem_iter, std::move(mem_tombstone_iter));
251
251
  }
252
252
  }
253
253
  }
@@ -558,11 +558,12 @@ Status MemTableList::TryInstallMemtableFlushResults(
558
558
  batch_file_number = m->file_number_;
559
559
  if (m->edit_.GetBlobFileAdditions().empty()) {
560
560
  ROCKS_LOG_BUFFER(log_buffer,
561
- "[%s] Level-0 commit table #%" PRIu64 " started",
561
+ "[%s] Level-0 commit flush result of table #%" PRIu64
562
+ " started",
562
563
  cfd->GetName().c_str(), m->file_number_);
563
564
  } else {
564
565
  ROCKS_LOG_BUFFER(log_buffer,
565
- "[%s] Level-0 commit table #%" PRIu64
566
+ "[%s] Level-0 commit flush result of table #%" PRIu64
566
567
  " (+%zu blob files) started",
567
568
  cfd->GetName().c_str(), m->file_number_,
568
569
  m->edit_.GetBlobFileAdditions().size());
@@ -757,12 +758,12 @@ void MemTableList::RemoveMemTablesOrRestoreFlags(
757
758
  MemTable* m = current_->memlist_.back();
758
759
  if (m->edit_.GetBlobFileAdditions().empty()) {
759
760
  ROCKS_LOG_BUFFER(log_buffer,
760
- "[%s] Level-0 commit table #%" PRIu64
761
+ "[%s] Level-0 commit flush result of table #%" PRIu64
761
762
  ": memtable #%" PRIu64 " done",
762
763
  cfd->GetName().c_str(), m->file_number_, mem_id);
763
764
  } else {
764
765
  ROCKS_LOG_BUFFER(log_buffer,
765
- "[%s] Level-0 commit table #%" PRIu64
766
+ "[%s] Level-0 commit flush result of table #%" PRIu64
766
767
  " (+%zu blob files)"
767
768
  ": memtable #%" PRIu64 " done",
768
769
  cfd->GetName().c_str(), m->file_number_,
@@ -0,0 +1,296 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
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
+ #pragma once
7
+
8
+ #include <functional>
9
+ #include <variant>
10
+
11
+ #include "rocksdb/comparator.h"
12
+ #include "rocksdb/iterator.h"
13
+ #include "rocksdb/options.h"
14
+ #include "util/heap.h"
15
+
16
+ namespace ROCKSDB_NAMESPACE {
17
+
18
+ struct MultiCfIteratorInfo {
19
+ ColumnFamilyHandle* cfh;
20
+ Iterator* iterator;
21
+ int order;
22
+ };
23
+
24
+ class MultiCfIteratorImpl {
25
+ public:
26
+ MultiCfIteratorImpl(
27
+ const Comparator* comparator,
28
+ const std::vector<ColumnFamilyHandle*>& column_families,
29
+ const std::vector<Iterator*>& child_iterators,
30
+ std::function<void()> reset_func,
31
+ std::function<void(const autovector<MultiCfIteratorInfo>&)> populate_func)
32
+ : comparator_(comparator),
33
+ heap_(MultiCfMinHeap(
34
+ MultiCfHeapItemComparator<std::greater<int>>(comparator_))),
35
+ reset_func_(std::move(reset_func)),
36
+ populate_func_(std::move(populate_func)) {
37
+ assert(column_families.size() > 0 &&
38
+ column_families.size() == child_iterators.size());
39
+ cfh_iter_pairs_.reserve(column_families.size());
40
+ for (size_t i = 0; i < column_families.size(); ++i) {
41
+ cfh_iter_pairs_.emplace_back(
42
+ column_families[i], std::unique_ptr<Iterator>(child_iterators[i]));
43
+ }
44
+ }
45
+ ~MultiCfIteratorImpl() { status_.PermitUncheckedError(); }
46
+
47
+ // No copy allowed
48
+ MultiCfIteratorImpl(const MultiCfIteratorImpl&) = delete;
49
+ MultiCfIteratorImpl& operator=(const MultiCfIteratorImpl&) = delete;
50
+
51
+ Slice key() const {
52
+ assert(Valid());
53
+ return current()->key();
54
+ }
55
+
56
+ bool Valid() const {
57
+ if (std::holds_alternative<MultiCfMaxHeap>(heap_)) {
58
+ auto& max_heap = std::get<MultiCfMaxHeap>(heap_);
59
+ return !max_heap.empty() && status_.ok();
60
+ }
61
+ auto& min_heap = std::get<MultiCfMinHeap>(heap_);
62
+ return !min_heap.empty() && status_.ok();
63
+ }
64
+
65
+ Status status() const { return status_; }
66
+
67
+ void SeekToFirst() {
68
+ auto& min_heap = GetHeap<MultiCfMinHeap>([this]() { InitMinHeap(); });
69
+ SeekCommon(min_heap, [](Iterator* iter) { iter->SeekToFirst(); });
70
+ }
71
+ void Seek(const Slice& target) {
72
+ auto& min_heap = GetHeap<MultiCfMinHeap>([this]() { InitMinHeap(); });
73
+ SeekCommon(min_heap, [&target](Iterator* iter) { iter->Seek(target); });
74
+ }
75
+ void SeekToLast() {
76
+ auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() { InitMaxHeap(); });
77
+ SeekCommon(max_heap, [](Iterator* iter) { iter->SeekToLast(); });
78
+ }
79
+ void SeekForPrev(const Slice& target) {
80
+ auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() { InitMaxHeap(); });
81
+ SeekCommon(max_heap,
82
+ [&target](Iterator* iter) { iter->SeekForPrev(target); });
83
+ }
84
+
85
+ void Next() {
86
+ assert(Valid());
87
+ auto& min_heap = GetHeap<MultiCfMinHeap>([this]() {
88
+ std::string target(key().data(), key().size());
89
+ InitMinHeap();
90
+ Seek(target);
91
+ });
92
+ AdvanceIterator(min_heap, [](Iterator* iter) { iter->Next(); });
93
+ }
94
+ void Prev() {
95
+ assert(Valid());
96
+ auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() {
97
+ std::string target(key().data(), key().size());
98
+ InitMaxHeap();
99
+ SeekForPrev(target);
100
+ });
101
+ AdvanceIterator(max_heap, [](Iterator* iter) { iter->Prev(); });
102
+ }
103
+
104
+ private:
105
+ std::vector<std::pair<ColumnFamilyHandle*, std::unique_ptr<Iterator>>>
106
+ cfh_iter_pairs_;
107
+ Status status_;
108
+
109
+ template <typename CompareOp>
110
+ class MultiCfHeapItemComparator {
111
+ public:
112
+ explicit MultiCfHeapItemComparator(const Comparator* comparator)
113
+ : comparator_(comparator) {}
114
+ bool operator()(const MultiCfIteratorInfo& a,
115
+ const MultiCfIteratorInfo& b) const {
116
+ assert(a.iterator);
117
+ assert(b.iterator);
118
+ assert(a.iterator->Valid());
119
+ assert(b.iterator->Valid());
120
+ int c = comparator_->Compare(a.iterator->key(), b.iterator->key());
121
+ assert(c != 0 || a.order != b.order);
122
+ return c == 0 ? a.order - b.order > 0 : CompareOp()(c, 0);
123
+ }
124
+
125
+ private:
126
+ const Comparator* comparator_;
127
+ };
128
+ const Comparator* comparator_;
129
+ using MultiCfMinHeap =
130
+ BinaryHeap<MultiCfIteratorInfo,
131
+ MultiCfHeapItemComparator<std::greater<int>>>;
132
+ using MultiCfMaxHeap = BinaryHeap<MultiCfIteratorInfo,
133
+ MultiCfHeapItemComparator<std::less<int>>>;
134
+
135
+ using MultiCfIterHeap = std::variant<MultiCfMinHeap, MultiCfMaxHeap>;
136
+
137
+ MultiCfIterHeap heap_;
138
+
139
+ std::function<void()> reset_func_;
140
+ std::function<void(autovector<MultiCfIteratorInfo>)> populate_func_;
141
+
142
+ Iterator* current() const {
143
+ if (std::holds_alternative<MultiCfMaxHeap>(heap_)) {
144
+ auto& max_heap = std::get<MultiCfMaxHeap>(heap_);
145
+ return max_heap.top().iterator;
146
+ }
147
+ auto& min_heap = std::get<MultiCfMinHeap>(heap_);
148
+ return min_heap.top().iterator;
149
+ }
150
+
151
+ void considerStatus(Status s) {
152
+ if (!s.ok() && status_.ok()) {
153
+ status_ = std::move(s);
154
+ }
155
+ }
156
+
157
+ template <typename HeapType, typename InitFunc>
158
+ HeapType& GetHeap(InitFunc initFunc) {
159
+ if (!std::holds_alternative<HeapType>(heap_)) {
160
+ initFunc();
161
+ }
162
+ return std::get<HeapType>(heap_);
163
+ }
164
+
165
+ void InitMinHeap() {
166
+ heap_.emplace<MultiCfMinHeap>(
167
+ MultiCfHeapItemComparator<std::greater<int>>(comparator_));
168
+ }
169
+ void InitMaxHeap() {
170
+ heap_.emplace<MultiCfMaxHeap>(
171
+ MultiCfHeapItemComparator<std::less<int>>(comparator_));
172
+ }
173
+
174
+ template <typename BinaryHeap, typename ChildSeekFuncType>
175
+ void SeekCommon(BinaryHeap& heap, ChildSeekFuncType child_seek_func) {
176
+ reset_func_();
177
+ heap.clear();
178
+ int i = 0;
179
+ for (auto& [cfh, iter] : cfh_iter_pairs_) {
180
+ child_seek_func(iter.get());
181
+ if (iter->Valid()) {
182
+ assert(iter->status().ok());
183
+ heap.push(MultiCfIteratorInfo{cfh, iter.get(), i});
184
+ } else {
185
+ considerStatus(iter->status());
186
+ if (!status_.ok()) {
187
+ // Non-OK status from the iterator. Bail out early
188
+ heap.clear();
189
+ break;
190
+ }
191
+ }
192
+ ++i;
193
+ }
194
+ if (!heap.empty()) {
195
+ PopulateIterator(heap);
196
+ }
197
+ }
198
+
199
+ template <typename BinaryHeap, typename AdvanceFuncType>
200
+ void AdvanceIterator(BinaryHeap& heap, AdvanceFuncType advance_func) {
201
+ reset_func_();
202
+ // It is possible for one or more child iters are at invalid keys due to
203
+ // manual prefix iteration. For such cases, we consider the result of the
204
+ // multi-cf-iter is also undefined.
205
+ // https://github.com/facebook/rocksdb/wiki/Prefix-Seek#manual-prefix-iterating
206
+ // for details about manual prefix iteration
207
+ if (heap.empty()) {
208
+ return;
209
+ }
210
+
211
+ // 1. Keep the top iterator (by popping it from the heap)
212
+ // 2. Make sure all others have iterated past the top iterator key slice
213
+ // 3. Advance the top iterator, and add it back to the heap if valid
214
+ auto top = heap.top();
215
+ heap.pop();
216
+ if (!heap.empty()) {
217
+ auto current = heap.top();
218
+ assert(current.iterator);
219
+ while (current.iterator->Valid() &&
220
+ comparator_->Compare(top.iterator->key(),
221
+ current.iterator->key()) == 0) {
222
+ assert(current.iterator->status().ok());
223
+ advance_func(current.iterator);
224
+ if (current.iterator->Valid()) {
225
+ heap.replace_top(heap.top());
226
+ } else {
227
+ considerStatus(current.iterator->status());
228
+ if (!status_.ok()) {
229
+ heap.clear();
230
+ return;
231
+ } else {
232
+ heap.pop();
233
+ }
234
+ }
235
+ if (!heap.empty()) {
236
+ current = heap.top();
237
+ }
238
+ }
239
+ }
240
+ advance_func(top.iterator);
241
+ if (top.iterator->Valid()) {
242
+ assert(top.iterator->status().ok());
243
+ heap.push(top);
244
+ } else {
245
+ considerStatus(top.iterator->status());
246
+ if (!status_.ok()) {
247
+ heap.clear();
248
+ return;
249
+ }
250
+ }
251
+
252
+ if (!heap.empty()) {
253
+ PopulateIterator(heap);
254
+ }
255
+ }
256
+
257
+ template <typename BinaryHeap>
258
+ void PopulateIterator(BinaryHeap& heap) {
259
+ // 1. Keep the top iterator (by popping it from the heap) and add it to list
260
+ // to populate
261
+ // 2. For all non-top iterators having the same key as top iter popped
262
+ // from the previous step, add them to the same list and pop it
263
+ // temporarily from the heap
264
+ // 3. Once no other iters have the same key as the top iter from step 1,
265
+ // populate the value/columns and attribute_groups from the list
266
+ // collected in step 1 and 2 and add all the iters back to the heap
267
+ assert(!heap.empty());
268
+ auto top = heap.top();
269
+ heap.pop();
270
+ autovector<MultiCfIteratorInfo> to_populate;
271
+ to_populate.push_back(top);
272
+ if (!heap.empty()) {
273
+ auto current = heap.top();
274
+ assert(current.iterator);
275
+ while (current.iterator->Valid() &&
276
+ comparator_->Compare(top.iterator->key(),
277
+ current.iterator->key()) == 0) {
278
+ assert(current.iterator->status().ok());
279
+ to_populate.push_back(current);
280
+ heap.pop();
281
+ if (!heap.empty()) {
282
+ current = heap.top();
283
+ } else {
284
+ break;
285
+ }
286
+ }
287
+ }
288
+ // Add the items back to the heap
289
+ for (auto& item : to_populate) {
290
+ heap.push(item);
291
+ }
292
+ populate_func_(to_populate);
293
+ }
294
+ };
295
+
296
+ } // namespace ROCKSDB_NAMESPACE
@@ -17,16 +17,6 @@
17
17
  #include "table/internal_iterator.h"
18
18
 
19
19
  namespace ROCKSDB_NAMESPACE {
20
- struct FragmentedRangeTombstoneList;
21
-
22
- struct FragmentedRangeTombstoneListCache {
23
- // ensure only the first reader needs to initialize l
24
- std::mutex reader_mutex;
25
- std::unique_ptr<FragmentedRangeTombstoneList> tombstones = nullptr;
26
- // readers will first check this bool to avoid
27
- std::atomic<bool> initialized = false;
28
- };
29
-
30
20
  struct FragmentedRangeTombstoneList {
31
21
  public:
32
22
  // A compact representation of a "stack" of range tombstone fragments, which
@@ -124,6 +114,14 @@ struct FragmentedRangeTombstoneList {
124
114
  uint64_t total_tombstone_payload_bytes_;
125
115
  };
126
116
 
117
+ struct FragmentedRangeTombstoneListCache {
118
+ // ensure only the first reader needs to initialize l
119
+ std::mutex reader_mutex;
120
+ std::unique_ptr<FragmentedRangeTombstoneList> tombstones = nullptr;
121
+ // readers will first check this bool to avoid
122
+ std::atomic<bool> initialized = false;
123
+ };
124
+
127
125
  // FragmentedRangeTombstoneIterator converts an InternalIterator of a range-del
128
126
  // meta block into an iterator over non-overlapping tombstone fragments. The
129
127
  // tombstone fragmentation process should be more efficient than the range
@@ -480,9 +480,10 @@ class Repairer {
480
480
  dbname_, /* versions */ nullptr, immutable_db_options_, tboptions,
481
481
  file_options_, table_cache_.get(), iter.get(),
482
482
  std::move(range_del_iters), &meta, nullptr /* blob_file_additions */,
483
- {}, kMaxSequenceNumber, kMaxSequenceNumber, snapshot_checker,
484
- false /* paranoid_file_checks*/, nullptr /* internal_stats */, &io_s,
485
- nullptr /*IOTracer*/, BlobFileCreationReason::kRecovery,
483
+ {}, kMaxSequenceNumber, kMaxSequenceNumber, kMaxSequenceNumber,
484
+ snapshot_checker, false /* paranoid_file_checks*/,
485
+ nullptr /* internal_stats */, &io_s, nullptr /*IOTracer*/,
486
+ BlobFileCreationReason::kRecovery,
486
487
  nullptr /* seqno_to_time_mapping */, nullptr /* event_logger */,
487
488
  0 /* job_id */, nullptr /* table_properties */, write_hint);
488
489
  ROCKS_LOG_INFO(db_options_.info_log,
@@ -69,6 +69,36 @@ SequenceNumber SeqnoToTimeMapping::GetProximalSeqnoBeforeTime(
69
69
  return it->seqno;
70
70
  }
71
71
 
72
+ void SeqnoToTimeMapping::GetCurrentTieringCutoffSeqnos(
73
+ uint64_t current_time, uint64_t preserve_internal_time_seconds,
74
+ uint64_t preclude_last_level_data_seconds,
75
+ SequenceNumber* preserve_time_min_seqno,
76
+ SequenceNumber* preclude_last_level_min_seqno) const {
77
+ uint64_t preserve_time_duration = std::max(preserve_internal_time_seconds,
78
+ preclude_last_level_data_seconds);
79
+ if (preserve_time_duration <= 0) {
80
+ return;
81
+ }
82
+ uint64_t preserve_time = current_time > preserve_time_duration
83
+ ? current_time - preserve_time_duration
84
+ : 0;
85
+ // GetProximalSeqnoBeforeTime tells us the last seqno known to have been
86
+ // written at or before the given time. + 1 to get the minimum we should
87
+ // preserve without excluding anything that might have been written on or
88
+ // after the given time.
89
+ if (preserve_time_min_seqno) {
90
+ *preserve_time_min_seqno = GetProximalSeqnoBeforeTime(preserve_time) + 1;
91
+ }
92
+ if (preclude_last_level_data_seconds > 0 && preclude_last_level_min_seqno) {
93
+ uint64_t preclude_last_level_time =
94
+ current_time > preclude_last_level_data_seconds
95
+ ? current_time - preclude_last_level_data_seconds
96
+ : 0;
97
+ *preclude_last_level_min_seqno =
98
+ GetProximalSeqnoBeforeTime(preclude_last_level_time) + 1;
99
+ }
100
+ }
101
+
72
102
  void SeqnoToTimeMapping::EnforceMaxTimeSpan(uint64_t now) {
73
103
  assert(enforced_); // at least sorted
74
104
  uint64_t cutoff_time;
@@ -213,6 +213,15 @@ class SeqnoToTimeMapping {
213
213
  // must be in enforced state as a precondition.
214
214
  SequenceNumber GetProximalSeqnoBeforeTime(uint64_t time) const;
215
215
 
216
+ // Given current time, the configured `preserve_internal_time_seconds`, and
217
+ // `preclude_last_level_data_seconds`, find the relevant cutoff sequence
218
+ // numbers for tiering.
219
+ void GetCurrentTieringCutoffSeqnos(
220
+ uint64_t current_time, uint64_t preserve_internal_time_seconds,
221
+ uint64_t preclude_last_level_data_seconds,
222
+ SequenceNumber* preserve_time_min_seqno,
223
+ SequenceNumber* preclude_last_level_min_seqno) const;
224
+
216
225
  // Encode to a binary string by appending to `dest`.
217
226
  // Because this is a const operation depending on sortedness, the structure
218
227
  // must be in enforced state as a precondition.
@@ -163,6 +163,11 @@ Status TableCache::GetTableReader(
163
163
  return s;
164
164
  }
165
165
 
166
+ Cache::Handle* TableCache::Lookup(Cache* cache, uint64_t file_number) {
167
+ Slice key = GetSliceForFileNumber(&file_number);
168
+ return cache->Lookup(key);
169
+ }
170
+
166
171
  Status TableCache::FindTable(
167
172
  const ReadOptions& ro, const FileOptions& file_options,
168
173
  const InternalKeyComparator& internal_comparator,
@@ -225,7 +230,7 @@ InternalIterator* TableCache::NewIterator(
225
230
  const InternalKey* smallest_compaction_key,
226
231
  const InternalKey* largest_compaction_key, bool allow_unprepared_value,
227
232
  uint8_t block_protection_bytes_per_key, const SequenceNumber* read_seqno,
228
- TruncatedRangeDelIterator** range_del_iter) {
233
+ std::unique_ptr<TruncatedRangeDelIterator>* range_del_iter) {
229
234
  PERF_TIMER_GUARD(new_table_iterator_nanos);
230
235
 
231
236
  Status s;
@@ -280,7 +285,7 @@ InternalIterator* TableCache::NewIterator(
280
285
  delete new_range_del_iter;
281
286
  *range_del_iter = nullptr;
282
287
  } else {
283
- *range_del_iter = new TruncatedRangeDelIterator(
288
+ *range_del_iter = std::make_unique<TruncatedRangeDelIterator>(
284
289
  std::unique_ptr<FragmentedRangeTombstoneIterator>(
285
290
  new_range_del_iter),
286
291
  &icomparator, &file_meta.smallest, &file_meta.largest);
@@ -727,4 +732,14 @@ uint64_t TableCache::ApproximateSize(
727
732
 
728
733
  return result;
729
734
  }
735
+
736
+ void TableCache::ReleaseObsolete(Cache* cache, Cache::Handle* h,
737
+ uint32_t uncache_aggressiveness) {
738
+ CacheInterface typed_cache(cache);
739
+ TypedHandle* table_handle = reinterpret_cast<TypedHandle*>(h);
740
+ TableReader* table_reader = typed_cache.Value(table_handle);
741
+ table_reader->MarkObsolete(uncache_aggressiveness);
742
+ typed_cache.ReleaseAndEraseIfLastRef(table_handle);
743
+ }
744
+
730
745
  } // namespace ROCKSDB_NAMESPACE
@@ -100,7 +100,7 @@ class TableCache {
100
100
  const InternalKey* largest_compaction_key, bool allow_unprepared_value,
101
101
  uint8_t protection_bytes_per_key,
102
102
  const SequenceNumber* range_del_read_seqno = nullptr,
103
- TruncatedRangeDelIterator** range_del_iter = nullptr);
103
+ std::unique_ptr<TruncatedRangeDelIterator>* range_del_iter = nullptr);
104
104
 
105
105
  // If a seek to internal key "k" in specified file finds an entry,
106
106
  // call get_context->SaveValue() repeatedly until
@@ -165,6 +165,14 @@ class TableCache {
165
165
  // Evict any entry for the specified file number
166
166
  static void Evict(Cache* cache, uint64_t file_number);
167
167
 
168
+ // Handles releasing, erasing, etc. of what should be the last reference
169
+ // to an obsolete file.
170
+ static void ReleaseObsolete(Cache* cache, Cache::Handle* handle,
171
+ uint32_t uncache_aggressiveness);
172
+
173
+ // Return handle to an existing cache entry if there is one
174
+ static Cache::Handle* Lookup(Cache* cache, uint64_t file_number);
175
+
168
176
  // Find table reader
169
177
  // @param skip_filters Disables loading/accessing the filter block
170
178
  // @param level == -1 means not specified
@@ -44,7 +44,9 @@ class InternalTblPropCollFactory {
44
44
  virtual ~InternalTblPropCollFactory() {}
45
45
  // has to be thread-safe
46
46
  virtual InternalTblPropColl* CreateInternalTblPropColl(
47
- uint32_t column_family_id, int level_at_creation) = 0;
47
+ uint32_t column_family_id, int level_at_creation, int num_levels,
48
+ SequenceNumber last_level_inclusive_max_seqno_threshold =
49
+ kMaxSequenceNumber) = 0;
48
50
 
49
51
  // The name of the properties collector can be used for debugging purpose.
50
52
  virtual const char* Name() const = 0;
@@ -92,10 +94,15 @@ class UserKeyTablePropertiesCollectorFactory
92
94
  std::shared_ptr<TablePropertiesCollectorFactory> user_collector_factory)
93
95
  : user_collector_factory_(user_collector_factory) {}
94
96
  InternalTblPropColl* CreateInternalTblPropColl(
95
- uint32_t column_family_id, int level_at_creation) override {
97
+ uint32_t column_family_id, int level_at_creation, int num_levels,
98
+ SequenceNumber last_level_inclusive_max_seqno_threshold =
99
+ kMaxSequenceNumber) override {
96
100
  TablePropertiesCollectorFactory::Context context;
97
101
  context.column_family_id = column_family_id;
98
102
  context.level_at_creation = level_at_creation;
103
+ context.num_levels = num_levels;
104
+ context.last_level_inclusive_max_seqno_threshold =
105
+ last_level_inclusive_max_seqno_threshold;
99
106
  TablePropertiesCollector* collector =
100
107
  user_collector_factory_->CreateTablePropertiesCollector(context);
101
108
  if (collector) {
@@ -18,7 +18,7 @@ TransactionLogIteratorImpl::TransactionLogIteratorImpl(
18
18
  const std::string& dir, const ImmutableDBOptions* options,
19
19
  const TransactionLogIterator::ReadOptions& read_options,
20
20
  const EnvOptions& soptions, const SequenceNumber seq,
21
- std::unique_ptr<VectorLogPtr> files, VersionSet const* const versions,
21
+ std::unique_ptr<VectorWalPtr> files, VersionSet const* const versions,
22
22
  const bool seq_per_batch, const std::shared_ptr<IOTracer>& io_tracer)
23
23
  : dir_(dir),
24
24
  options_(options),
@@ -44,7 +44,7 @@ TransactionLogIteratorImpl::TransactionLogIteratorImpl(
44
44
  }
45
45
 
46
46
  Status TransactionLogIteratorImpl::OpenLogFile(
47
- const LogFile* log_file,
47
+ const WalFile* log_file,
48
48
  std::unique_ptr<SequentialFileReader>* file_reader) {
49
49
  FileSystemPtr fs(options_->fs, io_tracer_);
50
50
  std::unique_ptr<FSSequentialFile> file;
@@ -281,7 +281,7 @@ void TransactionLogIteratorImpl::UpdateCurrentWriteBatch(const Slice& record) {
281
281
  current_status_ = Status::OK();
282
282
  }
283
283
 
284
- Status TransactionLogIteratorImpl::OpenLogReader(const LogFile* log_file) {
284
+ Status TransactionLogIteratorImpl::OpenLogReader(const WalFile* log_file) {
285
285
  std::unique_ptr<SequentialFileReader> file;
286
286
  Status s = OpenLogFile(log_file, &file);
287
287
  if (!s.ok()) {
@@ -19,9 +19,9 @@
19
19
 
20
20
  namespace ROCKSDB_NAMESPACE {
21
21
 
22
- class LogFileImpl : public LogFile {
22
+ class WalFileImpl : public WalFile {
23
23
  public:
24
- LogFileImpl(uint64_t logNum, WalFileType logType, SequenceNumber startSeq,
24
+ WalFileImpl(uint64_t logNum, WalFileType logType, SequenceNumber startSeq,
25
25
  uint64_t sizeBytes)
26
26
  : logNumber_(logNum),
27
27
  type_(logType),
@@ -43,7 +43,7 @@ class LogFileImpl : public LogFile {
43
43
 
44
44
  uint64_t SizeFileBytes() const override { return sizeFileBytes_; }
45
45
 
46
- bool operator<(const LogFile& that) const {
46
+ bool operator<(const WalFile& that) const {
47
47
  return LogNumber() < that.LogNumber();
48
48
  }
49
49
 
@@ -60,7 +60,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
60
60
  const std::string& dir, const ImmutableDBOptions* options,
61
61
  const TransactionLogIterator::ReadOptions& read_options,
62
62
  const EnvOptions& soptions, const SequenceNumber seqNum,
63
- std::unique_ptr<VectorLogPtr> files, VersionSet const* const versions,
63
+ std::unique_ptr<VectorWalPtr> files, VersionSet const* const versions,
64
64
  const bool seq_per_batch, const std::shared_ptr<IOTracer>& io_tracer);
65
65
 
66
66
  bool Valid() override;
@@ -77,7 +77,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
77
77
  const TransactionLogIterator::ReadOptions read_options_;
78
78
  const EnvOptions& soptions_;
79
79
  SequenceNumber starting_sequence_number_;
80
- std::unique_ptr<VectorLogPtr> files_;
80
+ std::unique_ptr<VectorWalPtr> files_;
81
81
  // Used only to get latest seq. num
82
82
  // TODO(icanadi) can this be just a callback?
83
83
  VersionSet const* const versions_;
@@ -92,7 +92,7 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
92
92
  std::unique_ptr<WriteBatch> current_batch_;
93
93
  std::unique_ptr<log::Reader> current_log_reader_;
94
94
  std::string scratch_;
95
- Status OpenLogFile(const LogFile* log_file,
95
+ Status OpenLogFile(const WalFile* log_file,
96
96
  std::unique_ptr<SequentialFileReader>* file);
97
97
 
98
98
  struct LogReporter : public log::Reader::Reporter {
@@ -123,6 +123,6 @@ class TransactionLogIteratorImpl : public TransactionLogIterator {
123
123
  bool IsBatchExpected(const WriteBatch* batch, SequenceNumber expected_seq);
124
124
  // Update current batch if a continuous batch is found.
125
125
  void UpdateCurrentWriteBatch(const Slice& record);
126
- Status OpenLogReader(const LogFile* file);
126
+ Status OpenLogReader(const WalFile* file);
127
127
  };
128
128
  } // namespace ROCKSDB_NAMESPACE
@@ -255,7 +255,6 @@ bool VersionEdit::EncodeTo(std::string* dst,
255
255
  char p = static_cast<char>(0);
256
256
  PutLengthPrefixedSlice(dst, Slice(&p, 1));
257
257
  }
258
-
259
258
  TEST_SYNC_POINT_CALLBACK("VersionEdit::EncodeTo:NewFile4:CustomizeFields",
260
259
  dst);
261
260