@nxtedition/rocksdb 6.0.1 → 7.0.0-alpha.1

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 (490) hide show
  1. package/BUILDING.md +12 -4
  2. package/binding.cc +421 -40
  3. package/deps/rocksdb/build_version.cc +4 -10
  4. package/deps/rocksdb/rocksdb/CMakeLists.txt +26 -3
  5. package/deps/rocksdb/rocksdb/Makefile +73 -91
  6. package/deps/rocksdb/rocksdb/TARGETS +27 -2
  7. package/deps/rocksdb/rocksdb/cache/cache_test.cc +29 -17
  8. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.cc +511 -0
  9. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.h +299 -0
  10. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +3 -0
  11. package/deps/rocksdb/rocksdb/cache/lru_cache.h +7 -0
  12. package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
  13. package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
  14. package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
  15. package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
  16. package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
  17. package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
  18. package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
  19. package/deps/rocksdb/rocksdb/cmake/modules/Finduring.cmake +26 -0
  20. package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
  21. package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
  22. package/deps/rocksdb/rocksdb/common.mk +30 -0
  23. package/deps/rocksdb/rocksdb/crash_test.mk +3 -3
  24. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +1 -1
  25. package/deps/rocksdb/rocksdb/db/blob/blob_index.h +3 -3
  26. package/deps/rocksdb/rocksdb/db/blob/db_blob_index_test.cc +7 -7
  27. package/deps/rocksdb/rocksdb/db/builder.cc +22 -7
  28. package/deps/rocksdb/rocksdb/db/c.cc +71 -0
  29. package/deps/rocksdb/rocksdb/db/c_test.c +28 -2
  30. package/deps/rocksdb/rocksdb/db/column_family.cc +12 -5
  31. package/deps/rocksdb/rocksdb/db/column_family_test.cc +23 -22
  32. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +11 -11
  33. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +2 -2
  34. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +36 -10
  35. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +4 -1
  36. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +3 -2
  37. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +54 -16
  38. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +14 -2
  39. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_stats_test.cc +3 -3
  40. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +85 -18
  41. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +7 -7
  42. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +1 -1
  43. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +23 -22
  44. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +1 -1
  45. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +151 -32
  46. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +1 -1
  47. package/deps/rocksdb/rocksdb/db/convenience.cc +8 -6
  48. package/deps/rocksdb/rocksdb/db/corruption_test.cc +209 -38
  49. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +2 -2
  50. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +404 -32
  51. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +28 -25
  52. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +85 -138
  53. package/deps/rocksdb/rocksdb/db/db_compaction_filter_test.cc +68 -3
  54. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +38 -13
  55. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -1
  56. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +1 -1
  57. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +11 -20
  58. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +15 -1
  59. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +12 -9
  60. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +5 -4
  61. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +1 -1
  62. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +2 -2
  63. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +42 -10
  64. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +54 -23
  65. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +3 -0
  66. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +14 -4
  67. package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +26 -18
  68. package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +8 -7
  69. package/deps/rocksdb/rocksdb/db/db_iter_test.cc +8 -8
  70. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +6 -3
  71. package/deps/rocksdb/rocksdb/db/db_kv_checksum_test.cc +2 -2
  72. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +6 -6
  73. package/deps/rocksdb/rocksdb/db/db_memtable_test.cc +2 -2
  74. package/deps/rocksdb/rocksdb/db/db_options_test.cc +28 -12
  75. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +16 -15
  76. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +6 -4
  77. package/deps/rocksdb/rocksdb/db/db_readonly_with_timestamp_test.cc +331 -0
  78. package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +11 -6
  79. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +68 -7
  80. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +6 -5
  81. package/deps/rocksdb/rocksdb/db/db_test.cc +60 -42
  82. package/deps/rocksdb/rocksdb/db/db_test2.cc +244 -111
  83. package/deps/rocksdb/rocksdb/db/db_test_util.cc +101 -19
  84. package/deps/rocksdb/rocksdb/db/db_test_util.h +52 -2
  85. package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +1 -1
  86. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +7 -7
  87. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +5 -175
  88. package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.cc +96 -0
  89. package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.h +126 -0
  90. package/deps/rocksdb/rocksdb/db/db_write_test.cc +6 -6
  91. package/deps/rocksdb/rocksdb/db/dbformat.h +2 -1
  92. package/deps/rocksdb/rocksdb/db/deletefile_test.cc +1 -1
  93. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +8 -8
  94. package/deps/rocksdb/rocksdb/db/experimental.cc +1 -1
  95. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +91 -12
  96. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +16 -2
  97. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +2 -0
  98. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +7 -7
  99. package/deps/rocksdb/rocksdb/db/file_indexer.h +1 -4
  100. package/deps/rocksdb/rocksdb/db/flush_job.cc +28 -15
  101. package/deps/rocksdb/rocksdb/db/flush_job.h +4 -0
  102. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +98 -30
  103. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +1 -1
  104. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +14 -1
  105. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +6 -0
  106. package/deps/rocksdb/rocksdb/db/internal_stats.cc +12 -12
  107. package/deps/rocksdb/rocksdb/db/listener_test.cc +4 -3
  108. package/deps/rocksdb/rocksdb/db/memtable.cc +2 -2
  109. package/deps/rocksdb/rocksdb/db/memtable_list.h +1 -1
  110. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +37 -25
  111. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +1 -1
  112. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +18 -18
  113. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +6 -6
  114. package/deps/rocksdb/rocksdb/db/prefix_test.cc +1 -1
  115. package/deps/rocksdb/rocksdb/db/repair.cc +13 -2
  116. package/deps/rocksdb/rocksdb/db/repair_test.cc +37 -15
  117. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +1 -2
  118. package/deps/rocksdb/rocksdb/db/snapshot_impl.h +3 -1
  119. package/deps/rocksdb/rocksdb/db/table_cache.cc +20 -130
  120. package/deps/rocksdb/rocksdb/db/table_cache.h +3 -2
  121. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +140 -0
  122. package/deps/rocksdb/rocksdb/db/version_builder.cc +1 -1
  123. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +133 -133
  124. package/deps/rocksdb/rocksdb/db/version_edit.cc +22 -2
  125. package/deps/rocksdb/rocksdb/db/version_edit.h +13 -4
  126. package/deps/rocksdb/rocksdb/db/version_edit_test.cc +14 -14
  127. package/deps/rocksdb/rocksdb/db/version_set.cc +207 -214
  128. package/deps/rocksdb/rocksdb/db/version_set.h +14 -3
  129. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +154 -0
  130. package/deps/rocksdb/rocksdb/db/version_set_test.cc +10 -9
  131. package/deps/rocksdb/rocksdb/db/wal_edit.h +2 -1
  132. package/deps/rocksdb/rocksdb/db/wal_manager.cc +2 -3
  133. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +1 -1
  134. package/deps/rocksdb/rocksdb/db/write_batch.cc +178 -30
  135. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +6 -6
  136. package/deps/rocksdb/rocksdb/db/write_controller.h +1 -1
  137. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +0 -2
  138. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +9 -6
  139. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_compaction_filter.h +2 -1
  140. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +4 -3
  141. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +44 -6
  142. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.cc +4 -1
  143. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.cc +0 -10
  144. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +45 -42
  145. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +374 -275
  146. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +53 -3
  147. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +0 -12
  148. package/deps/rocksdb/rocksdb/db_stress_tool/expected_state.cc +13 -11
  149. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +276 -109
  150. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +63 -0
  151. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +45 -54
  152. package/deps/rocksdb/rocksdb/env/composite_env.cc +87 -14
  153. package/deps/rocksdb/rocksdb/env/env.cc +0 -60
  154. package/deps/rocksdb/rocksdb/env/env_encryption.cc +9 -0
  155. package/deps/rocksdb/rocksdb/env/env_encryption_ctr.h +1 -1
  156. package/deps/rocksdb/rocksdb/env/env_posix.cc +6 -5
  157. package/deps/rocksdb/rocksdb/env/env_test.cc +18 -5
  158. package/deps/rocksdb/rocksdb/env/fs_posix.cc +17 -12
  159. package/deps/rocksdb/rocksdb/env/io_posix.cc +39 -37
  160. package/deps/rocksdb/rocksdb/file/delete_scheduler_test.cc +9 -9
  161. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +159 -65
  162. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +44 -22
  163. package/deps/rocksdb/rocksdb/file/file_util.h +2 -0
  164. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +142 -17
  165. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +5 -2
  166. package/deps/rocksdb/rocksdb/file/sequence_file_reader.cc +7 -0
  167. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +60 -40
  168. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +1 -0
  169. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +23 -5
  170. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +49 -1
  171. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +5 -5
  172. package/deps/rocksdb/rocksdb/include/rocksdb/cleanable.h +59 -2
  173. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +1 -0
  174. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +2 -1
  175. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +46 -44
  176. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1 -1
  177. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +2 -0
  178. package/deps/rocksdb/rocksdb/include/rocksdb/iostats_context.h +2 -4
  179. package/deps/rocksdb/rocksdb/include/rocksdb/memtablerep.h +3 -0
  180. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +45 -3
  181. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +2 -0
  182. package/deps/rocksdb/rocksdb/include/rocksdb/snapshot.h +4 -1
  183. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +3 -0
  184. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +91 -40
  185. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +1 -2
  186. package/deps/rocksdb/rocksdb/include/rocksdb/unique_id.h +22 -13
  187. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/customizable_util.h +9 -0
  188. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +4 -0
  189. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/object_registry.h +25 -0
  190. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +378 -103
  191. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +14 -0
  192. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  193. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +18 -4
  194. package/deps/rocksdb/rocksdb/memory/arena.h +1 -1
  195. package/deps/rocksdb/rocksdb/memory/concurrent_arena.cc +1 -5
  196. package/deps/rocksdb/rocksdb/memory/concurrent_arena.h +1 -5
  197. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.cc +6 -8
  198. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +1 -1
  199. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager.cc +1 -1
  200. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager_test.cc +5 -3
  201. package/deps/rocksdb/rocksdb/microbench/db_basic_bench.cc +266 -45
  202. package/deps/rocksdb/rocksdb/monitoring/histogram.cc +2 -1
  203. package/deps/rocksdb/rocksdb/monitoring/iostats_context.cc +1 -4
  204. package/deps/rocksdb/rocksdb/monitoring/iostats_context_imp.h +4 -4
  205. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +7 -8
  206. package/deps/rocksdb/rocksdb/monitoring/perf_context_imp.h +2 -2
  207. package/deps/rocksdb/rocksdb/monitoring/perf_level.cc +1 -5
  208. package/deps/rocksdb/rocksdb/monitoring/perf_level_imp.h +1 -5
  209. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.cc +2 -2
  210. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +1 -1
  211. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.cc +2 -1
  212. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.h +1 -1
  213. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.cc +3 -3
  214. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.h +2 -2
  215. package/deps/rocksdb/rocksdb/options/cf_options.cc +47 -38
  216. package/deps/rocksdb/rocksdb/options/configurable.cc +9 -27
  217. package/deps/rocksdb/rocksdb/options/configurable_test.cc +1 -1
  218. package/deps/rocksdb/rocksdb/options/customizable.cc +3 -1
  219. package/deps/rocksdb/rocksdb/options/customizable_test.cc +379 -318
  220. package/deps/rocksdb/rocksdb/options/db_options.cc +46 -17
  221. package/deps/rocksdb/rocksdb/options/db_options.h +2 -0
  222. package/deps/rocksdb/rocksdb/options/options.cc +7 -0
  223. package/deps/rocksdb/rocksdb/options/options_helper.cc +86 -39
  224. package/deps/rocksdb/rocksdb/options/options_parser.cc +10 -10
  225. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +12 -7
  226. package/deps/rocksdb/rocksdb/options/options_test.cc +222 -68
  227. package/deps/rocksdb/rocksdb/port/port_posix.h +0 -15
  228. package/deps/rocksdb/rocksdb/port/win/env_win.cc +5 -4
  229. package/deps/rocksdb/rocksdb/port/win/env_win.h +2 -2
  230. package/deps/rocksdb/rocksdb/port/win/port_win.h +0 -31
  231. package/deps/rocksdb/rocksdb/rocksdb.pc.in +11 -0
  232. package/deps/rocksdb/rocksdb/src.mk +6 -1
  233. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +2 -1
  234. package/deps/rocksdb/rocksdb/table/block_based/block.cc +4 -2
  235. package/deps/rocksdb/rocksdb/table/block_based/block.h +21 -25
  236. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.cc +3 -4
  237. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +23 -8
  238. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +52 -15
  239. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +81 -7
  240. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +8 -2
  241. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +94 -726
  242. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +21 -15
  243. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +9 -3
  244. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +754 -0
  245. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -73
  246. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +15 -5
  247. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.h +2 -1
  248. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +2 -11
  249. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +59 -1
  250. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +18 -0
  251. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +33 -17
  252. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +0 -61
  253. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +0 -13
  254. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +2 -1
  255. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +2 -2
  256. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +3 -2
  257. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +2 -1
  258. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +3 -2
  259. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.cc +4 -3
  260. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +8 -4
  261. package/deps/rocksdb/rocksdb/table/block_based/reader_common.cc +4 -4
  262. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +2 -1
  263. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +65 -7
  264. package/deps/rocksdb/rocksdb/table/block_fetcher.h +2 -0
  265. package/deps/rocksdb/rocksdb/table/cleanable_test.cc +113 -0
  266. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.cc +1 -1
  267. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.h +1 -1
  268. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader_test.cc +1 -1
  269. package/deps/rocksdb/rocksdb/table/format.cc +22 -20
  270. package/deps/rocksdb/rocksdb/table/iterator.cc +1 -81
  271. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +39 -0
  272. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +2 -2
  273. package/deps/rocksdb/rocksdb/table/multiget_context.h +60 -13
  274. package/deps/rocksdb/rocksdb/table/persistent_cache_options.h +0 -3
  275. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.cc +12 -1
  276. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.cc +4 -4
  277. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +2 -1
  278. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +1 -1
  279. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +1 -1
  280. package/deps/rocksdb/rocksdb/table/table_properties.cc +3 -5
  281. package/deps/rocksdb/rocksdb/table/table_reader.h +13 -0
  282. package/deps/rocksdb/rocksdb/table/table_test.cc +202 -78
  283. package/deps/rocksdb/rocksdb/table/unique_id.cc +84 -25
  284. package/deps/rocksdb/rocksdb/table/unique_id_impl.h +37 -4
  285. package/deps/rocksdb/rocksdb/test_util/testutil.cc +3 -1
  286. package/deps/rocksdb/rocksdb/test_util/testutil.h +11 -8
  287. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.cc +8 -4
  288. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.h +17 -0
  289. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.cc +11 -9
  290. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +3 -3
  291. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +277 -105
  292. package/deps/rocksdb/rocksdb/tools/db_sanity_test.cc +4 -4
  293. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +186 -42
  294. package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +75 -49
  295. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +9 -8
  296. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +4 -1
  297. package/deps/rocksdb/rocksdb/tools/reduce_levels_test.cc +2 -2
  298. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +26 -4
  299. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.cc +1 -1
  300. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.h +1 -1
  301. package/deps/rocksdb/rocksdb/util/async_file_reader.cc +72 -0
  302. package/deps/rocksdb/rocksdb/util/async_file_reader.h +144 -0
  303. package/deps/rocksdb/rocksdb/util/autovector_test.cc +4 -4
  304. package/deps/rocksdb/rocksdb/util/bloom_test.cc +14 -8
  305. package/deps/rocksdb/rocksdb/util/build_version.cc.in +5 -6
  306. package/deps/rocksdb/rocksdb/util/cleanable.cc +180 -0
  307. package/deps/rocksdb/rocksdb/util/comparator.cc +5 -3
  308. package/deps/rocksdb/rocksdb/util/compression.h +56 -7
  309. package/deps/rocksdb/rocksdb/util/coro_utils.h +111 -0
  310. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +148 -0
  311. package/deps/rocksdb/rocksdb/util/filelock_test.cc +2 -2
  312. package/deps/rocksdb/rocksdb/util/filter_bench.cc +12 -4
  313. package/deps/rocksdb/rocksdb/util/heap.h +5 -3
  314. package/deps/rocksdb/rocksdb/util/random.cc +1 -5
  315. package/deps/rocksdb/rocksdb/util/rate_limiter.cc +12 -9
  316. package/deps/rocksdb/rocksdb/util/rate_limiter_test.cc +1 -1
  317. package/deps/rocksdb/rocksdb/util/ribbon_alg.h +1 -1
  318. package/deps/rocksdb/rocksdb/util/ribbon_test.cc +2 -4
  319. package/deps/rocksdb/rocksdb/util/single_thread_executor.h +55 -0
  320. package/deps/rocksdb/rocksdb/util/slice.cc +8 -9
  321. package/deps/rocksdb/rocksdb/util/string_util.cc +3 -2
  322. package/deps/rocksdb/rocksdb/util/string_util.h +0 -13
  323. package/deps/rocksdb/rocksdb/util/thread_local.cc +4 -23
  324. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +99 -22
  325. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_impl.h +7 -0
  326. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +102 -59
  327. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_test.cc +38 -36
  328. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +2 -2
  329. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +28 -0
  330. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +3 -0
  331. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +1 -1
  332. package/deps/rocksdb/rocksdb/utilities/object_registry.cc +71 -0
  333. package/deps/rocksdb/rocksdb/utilities/object_registry_test.cc +71 -0
  334. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +1 -1
  335. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache_test.cc +5 -5
  336. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +3 -3
  337. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.cc +0 -13
  338. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_locking_test.cc +40 -0
  339. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc +10 -8
  340. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.h +4 -2
  341. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +17 -0
  342. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc +7 -7
  343. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +8 -1
  344. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +5 -1
  345. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +21 -15
  346. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.cc +2 -2
  347. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +69 -11
  348. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +22 -9
  349. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +26 -5
  350. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -4
  351. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_transaction_test.cc +19 -16
  352. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +7 -3
  353. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +3 -2
  354. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +2 -2
  355. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +2 -2
  356. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +6 -6
  357. package/deps/rocksdb/rocksdb.gyp +20 -13
  358. package/index.js +187 -3
  359. package/iterator.js +1 -0
  360. package/package-lock.json +23687 -0
  361. package/package.json +2 -30
  362. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  363. package/snapshot.js +23 -0
  364. package/deps/liburing/liburing/README +0 -46
  365. package/deps/liburing/liburing/test/232c93d07b74-test.c +0 -305
  366. package/deps/liburing/liburing/test/35fa71a030ca-test.c +0 -329
  367. package/deps/liburing/liburing/test/500f9fbadef8-test.c +0 -89
  368. package/deps/liburing/liburing/test/7ad0e4b2f83c-test.c +0 -93
  369. package/deps/liburing/liburing/test/8a9973408177-test.c +0 -106
  370. package/deps/liburing/liburing/test/917257daa0fe-test.c +0 -53
  371. package/deps/liburing/liburing/test/Makefile +0 -312
  372. package/deps/liburing/liburing/test/a0908ae19763-test.c +0 -58
  373. package/deps/liburing/liburing/test/a4c0b3decb33-test.c +0 -180
  374. package/deps/liburing/liburing/test/accept-link.c +0 -251
  375. package/deps/liburing/liburing/test/accept-reuse.c +0 -164
  376. package/deps/liburing/liburing/test/accept-test.c +0 -79
  377. package/deps/liburing/liburing/test/accept.c +0 -476
  378. package/deps/liburing/liburing/test/across-fork.c +0 -283
  379. package/deps/liburing/liburing/test/b19062a56726-test.c +0 -53
  380. package/deps/liburing/liburing/test/b5837bd5311d-test.c +0 -77
  381. package/deps/liburing/liburing/test/ce593a6c480a-test.c +0 -135
  382. package/deps/liburing/liburing/test/close-opath.c +0 -122
  383. package/deps/liburing/liburing/test/config +0 -10
  384. package/deps/liburing/liburing/test/connect.c +0 -398
  385. package/deps/liburing/liburing/test/cq-full.c +0 -96
  386. package/deps/liburing/liburing/test/cq-overflow.c +0 -294
  387. package/deps/liburing/liburing/test/cq-peek-batch.c +0 -102
  388. package/deps/liburing/liburing/test/cq-ready.c +0 -94
  389. package/deps/liburing/liburing/test/cq-size.c +0 -58
  390. package/deps/liburing/liburing/test/d4ae271dfaae-test.c +0 -96
  391. package/deps/liburing/liburing/test/d77a67ed5f27-test.c +0 -65
  392. package/deps/liburing/liburing/test/defer.c +0 -307
  393. package/deps/liburing/liburing/test/double-poll-crash.c +0 -186
  394. package/deps/liburing/liburing/test/eeed8b54e0df-test.c +0 -114
  395. package/deps/liburing/liburing/test/empty-eownerdead.c +0 -42
  396. package/deps/liburing/liburing/test/eventfd-disable.c +0 -151
  397. package/deps/liburing/liburing/test/eventfd-ring.c +0 -97
  398. package/deps/liburing/liburing/test/eventfd.c +0 -112
  399. package/deps/liburing/liburing/test/fadvise.c +0 -202
  400. package/deps/liburing/liburing/test/fallocate.c +0 -249
  401. package/deps/liburing/liburing/test/fc2a85cb02ef-test.c +0 -138
  402. package/deps/liburing/liburing/test/file-register.c +0 -843
  403. package/deps/liburing/liburing/test/file-update.c +0 -173
  404. package/deps/liburing/liburing/test/files-exit-hang-poll.c +0 -128
  405. package/deps/liburing/liburing/test/files-exit-hang-timeout.c +0 -134
  406. package/deps/liburing/liburing/test/fixed-link.c +0 -90
  407. package/deps/liburing/liburing/test/fsync.c +0 -224
  408. package/deps/liburing/liburing/test/hardlink.c +0 -136
  409. package/deps/liburing/liburing/test/helpers.c +0 -135
  410. package/deps/liburing/liburing/test/helpers.h +0 -67
  411. package/deps/liburing/liburing/test/io-cancel.c +0 -537
  412. package/deps/liburing/liburing/test/io_uring_enter.c +0 -296
  413. package/deps/liburing/liburing/test/io_uring_register.c +0 -664
  414. package/deps/liburing/liburing/test/io_uring_setup.c +0 -192
  415. package/deps/liburing/liburing/test/iopoll.c +0 -366
  416. package/deps/liburing/liburing/test/lfs-openat-write.c +0 -117
  417. package/deps/liburing/liburing/test/lfs-openat.c +0 -273
  418. package/deps/liburing/liburing/test/link-timeout.c +0 -1107
  419. package/deps/liburing/liburing/test/link.c +0 -496
  420. package/deps/liburing/liburing/test/link_drain.c +0 -229
  421. package/deps/liburing/liburing/test/madvise.c +0 -195
  422. package/deps/liburing/liburing/test/mkdir.c +0 -108
  423. package/deps/liburing/liburing/test/multicqes_drain.c +0 -383
  424. package/deps/liburing/liburing/test/nop-all-sizes.c +0 -107
  425. package/deps/liburing/liburing/test/nop.c +0 -115
  426. package/deps/liburing/liburing/test/open-close.c +0 -146
  427. package/deps/liburing/liburing/test/openat2.c +0 -240
  428. package/deps/liburing/liburing/test/personality.c +0 -204
  429. package/deps/liburing/liburing/test/pipe-eof.c +0 -81
  430. package/deps/liburing/liburing/test/pipe-reuse.c +0 -105
  431. package/deps/liburing/liburing/test/poll-cancel-ton.c +0 -139
  432. package/deps/liburing/liburing/test/poll-cancel.c +0 -135
  433. package/deps/liburing/liburing/test/poll-link.c +0 -227
  434. package/deps/liburing/liburing/test/poll-many.c +0 -208
  435. package/deps/liburing/liburing/test/poll-mshot-update.c +0 -273
  436. package/deps/liburing/liburing/test/poll-ring.c +0 -48
  437. package/deps/liburing/liburing/test/poll-v-poll.c +0 -353
  438. package/deps/liburing/liburing/test/poll.c +0 -109
  439. package/deps/liburing/liburing/test/probe.c +0 -137
  440. package/deps/liburing/liburing/test/read-write.c +0 -876
  441. package/deps/liburing/liburing/test/register-restrictions.c +0 -633
  442. package/deps/liburing/liburing/test/rename.c +0 -134
  443. package/deps/liburing/liburing/test/ring-leak.c +0 -173
  444. package/deps/liburing/liburing/test/ring-leak2.c +0 -249
  445. package/deps/liburing/liburing/test/rsrc_tags.c +0 -449
  446. package/deps/liburing/liburing/test/runtests-loop.sh +0 -16
  447. package/deps/liburing/liburing/test/runtests.sh +0 -170
  448. package/deps/liburing/liburing/test/rw_merge_test.c +0 -97
  449. package/deps/liburing/liburing/test/self.c +0 -91
  450. package/deps/liburing/liburing/test/send_recv.c +0 -291
  451. package/deps/liburing/liburing/test/send_recvmsg.c +0 -345
  452. package/deps/liburing/liburing/test/sendmsg_fs_cve.c +0 -198
  453. package/deps/liburing/liburing/test/shared-wq.c +0 -84
  454. package/deps/liburing/liburing/test/short-read.c +0 -75
  455. package/deps/liburing/liburing/test/shutdown.c +0 -163
  456. package/deps/liburing/liburing/test/sigfd-deadlock.c +0 -74
  457. package/deps/liburing/liburing/test/socket-rw-eagain.c +0 -156
  458. package/deps/liburing/liburing/test/socket-rw.c +0 -147
  459. package/deps/liburing/liburing/test/splice.c +0 -511
  460. package/deps/liburing/liburing/test/sq-full-cpp.cc +0 -45
  461. package/deps/liburing/liburing/test/sq-full.c +0 -45
  462. package/deps/liburing/liburing/test/sq-poll-dup.c +0 -200
  463. package/deps/liburing/liburing/test/sq-poll-kthread.c +0 -168
  464. package/deps/liburing/liburing/test/sq-poll-share.c +0 -137
  465. package/deps/liburing/liburing/test/sq-space_left.c +0 -159
  466. package/deps/liburing/liburing/test/sqpoll-cancel-hang.c +0 -159
  467. package/deps/liburing/liburing/test/sqpoll-disable-exit.c +0 -195
  468. package/deps/liburing/liburing/test/sqpoll-exit-hang.c +0 -77
  469. package/deps/liburing/liburing/test/sqpoll-sleep.c +0 -68
  470. package/deps/liburing/liburing/test/statx.c +0 -172
  471. package/deps/liburing/liburing/test/stdout.c +0 -232
  472. package/deps/liburing/liburing/test/submit-link-fail.c +0 -154
  473. package/deps/liburing/liburing/test/submit-reuse.c +0 -239
  474. package/deps/liburing/liburing/test/symlink.c +0 -116
  475. package/deps/liburing/liburing/test/teardowns.c +0 -58
  476. package/deps/liburing/liburing/test/thread-exit.c +0 -131
  477. package/deps/liburing/liburing/test/timeout-new.c +0 -246
  478. package/deps/liburing/liburing/test/timeout-overflow.c +0 -204
  479. package/deps/liburing/liburing/test/timeout.c +0 -1354
  480. package/deps/liburing/liburing/test/unlink.c +0 -111
  481. package/deps/liburing/liburing/test/wakeup-hang.c +0 -162
  482. package/deps/rocksdb/rocksdb/README.md +0 -32
  483. package/deps/rocksdb/rocksdb/microbench/README.md +0 -60
  484. package/deps/rocksdb/rocksdb/plugin/README.md +0 -43
  485. package/deps/rocksdb/rocksdb/port/README +0 -10
  486. package/deps/rocksdb/rocksdb/python.mk +0 -9
  487. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
  488. package/prebuilds/darwin-x64/node.napi.node +0 -0
  489. package/prebuilds/linux-arm64/node.napi.node +0 -0
  490. package/prebuilds/linux-x64/node.napi.node +0 -0
@@ -0,0 +1,154 @@
1
+ // Copyright (c) Meta Platforms, Inc. and its affiliates. All Rights Reserved.
2
+ // This source code is licensed under both the GPLv2 (found in the
3
+ // COPYING file in the root directory) and Apache 2.0 License
4
+ // (found in the LICENSE.Apache file in the root directory).
5
+
6
+ #include "util/coro_utils.h"
7
+
8
+ #if defined(WITHOUT_COROUTINES) || \
9
+ (defined(USE_COROUTINES) && defined(WITH_COROUTINES))
10
+
11
+ namespace ROCKSDB_NAMESPACE {
12
+
13
+ // Lookup a batch of keys in a single SST file
14
+ DEFINE_SYNC_AND_ASYNC(Status, Version::MultiGetFromSST)
15
+ (const ReadOptions& read_options, MultiGetRange file_range, int hit_file_level,
16
+ bool is_hit_file_last_in_level, FdWithKeyRange* f,
17
+ std::unordered_map<uint64_t, BlobReadRequests>& blob_rqs,
18
+ uint64_t& num_filter_read, uint64_t& num_index_read, uint64_t& num_data_read,
19
+ uint64_t& num_sst_read) {
20
+ bool timer_enabled = GetPerfLevel() >= PerfLevel::kEnableTimeExceptForMutex &&
21
+ get_perf_context()->per_level_perf_context_enabled;
22
+
23
+ Status s;
24
+ StopWatchNano timer(clock_, timer_enabled /* auto_start */);
25
+ s = CO_AWAIT(table_cache_->MultiGet)(
26
+ read_options, *internal_comparator(), *f->file_metadata, &file_range,
27
+ mutable_cf_options_.prefix_extractor,
28
+ cfd_->internal_stats()->GetFileReadHist(hit_file_level),
29
+ IsFilterSkipped(static_cast<int>(hit_file_level),
30
+ is_hit_file_last_in_level),
31
+ hit_file_level);
32
+ // TODO: examine the behavior for corrupted key
33
+ if (timer_enabled) {
34
+ PERF_COUNTER_BY_LEVEL_ADD(get_from_table_nanos, timer.ElapsedNanos(),
35
+ hit_file_level);
36
+ }
37
+ if (!s.ok()) {
38
+ // TODO: Set status for individual keys appropriately
39
+ for (auto iter = file_range.begin(); iter != file_range.end(); ++iter) {
40
+ *iter->s = s;
41
+ file_range.MarkKeyDone(iter);
42
+ }
43
+ CO_RETURN s;
44
+ }
45
+ uint64_t batch_size = 0;
46
+ for (auto iter = file_range.begin(); s.ok() && iter != file_range.end();
47
+ ++iter) {
48
+ GetContext& get_context = *iter->get_context;
49
+ Status* status = iter->s;
50
+ // The Status in the KeyContext takes precedence over GetContext state
51
+ // Status may be an error if there were any IO errors in the table
52
+ // reader. We never expect Status to be NotFound(), as that is
53
+ // determined by get_context
54
+ assert(!status->IsNotFound());
55
+ if (!status->ok()) {
56
+ file_range.MarkKeyDone(iter);
57
+ continue;
58
+ }
59
+
60
+ if (get_context.sample()) {
61
+ sample_file_read_inc(f->file_metadata);
62
+ }
63
+ batch_size++;
64
+ num_index_read += get_context.get_context_stats_.num_index_read;
65
+ num_filter_read += get_context.get_context_stats_.num_filter_read;
66
+ num_data_read += get_context.get_context_stats_.num_data_read;
67
+ num_sst_read += get_context.get_context_stats_.num_sst_read;
68
+ // Reset these stats since they're specific to a level
69
+ get_context.get_context_stats_.num_index_read = 0;
70
+ get_context.get_context_stats_.num_filter_read = 0;
71
+ get_context.get_context_stats_.num_data_read = 0;
72
+ get_context.get_context_stats_.num_sst_read = 0;
73
+
74
+ // report the counters before returning
75
+ if (get_context.State() != GetContext::kNotFound &&
76
+ get_context.State() != GetContext::kMerge &&
77
+ db_statistics_ != nullptr) {
78
+ get_context.ReportCounters();
79
+ } else {
80
+ if (iter->max_covering_tombstone_seq > 0) {
81
+ // The remaining files we look at will only contain covered keys, so
82
+ // we stop here for this key
83
+ file_range.SkipKey(iter);
84
+ }
85
+ }
86
+ switch (get_context.State()) {
87
+ case GetContext::kNotFound:
88
+ // Keep searching in other files
89
+ break;
90
+ case GetContext::kMerge:
91
+ // TODO: update per-level perfcontext user_key_return_count for kMerge
92
+ break;
93
+ case GetContext::kFound:
94
+ if (hit_file_level == 0) {
95
+ RecordTick(db_statistics_, GET_HIT_L0);
96
+ } else if (hit_file_level == 1) {
97
+ RecordTick(db_statistics_, GET_HIT_L1);
98
+ } else if (hit_file_level >= 2) {
99
+ RecordTick(db_statistics_, GET_HIT_L2_AND_UP);
100
+ }
101
+
102
+ PERF_COUNTER_BY_LEVEL_ADD(user_key_return_count, 1, hit_file_level);
103
+
104
+ file_range.MarkKeyDone(iter);
105
+
106
+ if (iter->is_blob_index) {
107
+ if (iter->value) {
108
+ TEST_SYNC_POINT_CALLBACK("Version::MultiGet::TamperWithBlobIndex",
109
+ &(*iter));
110
+
111
+ const Slice& blob_index_slice = *(iter->value);
112
+ BlobIndex blob_index;
113
+ Status tmp_s = blob_index.DecodeFrom(blob_index_slice);
114
+ if (tmp_s.ok()) {
115
+ const uint64_t blob_file_num = blob_index.file_number();
116
+ blob_rqs[blob_file_num].emplace_back(
117
+ std::make_pair(blob_index, std::cref(*iter)));
118
+ } else {
119
+ *(iter->s) = tmp_s;
120
+ }
121
+ }
122
+ } else {
123
+ file_range.AddValueSize(iter->value->size());
124
+ if (file_range.GetValueSize() > read_options.value_size_soft_limit) {
125
+ s = Status::Aborted();
126
+ break;
127
+ }
128
+ }
129
+ continue;
130
+ case GetContext::kDeleted:
131
+ // Use empty error message for speed
132
+ *status = Status::NotFound();
133
+ file_range.MarkKeyDone(iter);
134
+ continue;
135
+ case GetContext::kCorrupt:
136
+ *status =
137
+ Status::Corruption("corrupted key for ", iter->lkey->user_key());
138
+ file_range.MarkKeyDone(iter);
139
+ continue;
140
+ case GetContext::kUnexpectedBlobIndex:
141
+ ROCKS_LOG_ERROR(info_log_, "Encounter unexpected blob index.");
142
+ *status = Status::NotSupported(
143
+ "Encounter unexpected blob index. Please open DB with "
144
+ "ROCKSDB_NAMESPACE::blob_db::BlobDB instead.");
145
+ file_range.MarkKeyDone(iter);
146
+ continue;
147
+ }
148
+ }
149
+
150
+ RecordInHistogram(db_statistics_, SST_BATCH_SIZE, batch_size);
151
+ CO_RETURN s;
152
+ }
153
+ } // namespace ROCKSDB_NAMESPACE
154
+ #endif
@@ -18,6 +18,7 @@
18
18
  #include "rocksdb/file_system.h"
19
19
  #include "table/block_based/block_based_table_factory.h"
20
20
  #include "table/mock_table.h"
21
+ #include "table/unique_id_impl.h"
21
22
  #include "test_util/testharness.h"
22
23
  #include "test_util/testutil.h"
23
24
  #include "util/string_util.h"
@@ -49,7 +50,7 @@ class GenerateLevelFilesBriefTest : public testing::Test {
49
50
  kInvalidBlobFileNumber, kUnknownOldestAncesterTime,
50
51
  kUnknownFileCreationTime, kUnknownFileChecksum,
51
52
  kUnknownFileChecksumFuncName, kDisableUserTimestamp,
52
- kDisableUserTimestamp);
53
+ kDisableUserTimestamp, kNullUniqueId64x2);
53
54
  files_.push_back(f);
54
55
  }
55
56
 
@@ -158,7 +159,7 @@ class VersionStorageInfoTestBase : public testing::Test {
158
159
  Temperature::kUnknown, oldest_blob_file_number,
159
160
  kUnknownOldestAncesterTime, kUnknownFileCreationTime,
160
161
  kUnknownFileChecksum, kUnknownFileChecksumFuncName,
161
- kDisableUserTimestamp, kDisableUserTimestamp);
162
+ kDisableUserTimestamp, kDisableUserTimestamp, kNullUniqueId64x2);
162
163
  f->compensated_file_size = file_size;
163
164
  vstorage_.AddFile(level, f);
164
165
  }
@@ -3222,11 +3223,11 @@ class VersionSetTestMissingFiles : public VersionSetTestBase,
3222
3223
  s = fs_->GetFileSize(fname, IOOptions(), &file_size, nullptr);
3223
3224
  ASSERT_OK(s);
3224
3225
  ASSERT_NE(0, file_size);
3225
- file_metas->emplace_back(file_num, /*file_path_id=*/0, file_size, ikey,
3226
- ikey, 0, 0, false, Temperature::kUnknown, 0, 0,
3227
- 0, kUnknownFileChecksum,
3228
- kUnknownFileChecksumFuncName,
3229
- kDisableUserTimestamp, kDisableUserTimestamp);
3226
+ file_metas->emplace_back(
3227
+ file_num, /*file_path_id=*/0, file_size, ikey, ikey, 0, 0, false,
3228
+ Temperature::kUnknown, 0, 0, 0, kUnknownFileChecksum,
3229
+ kUnknownFileChecksumFuncName, kDisableUserTimestamp,
3230
+ kDisableUserTimestamp, kNullUniqueId64x2);
3230
3231
  }
3231
3232
  }
3232
3233
 
@@ -3282,7 +3283,7 @@ TEST_F(VersionSetTestMissingFiles, ManifestFarBehindSst) {
3282
3283
  file_num, /*file_path_id=*/0, /*file_size=*/12, smallest_ikey,
3283
3284
  largest_ikey, 0, 0, false, Temperature::kUnknown, 0, 0, 0,
3284
3285
  kUnknownFileChecksum, kUnknownFileChecksumFuncName,
3285
- kDisableUserTimestamp, kDisableUserTimestamp);
3286
+ kDisableUserTimestamp, kDisableUserTimestamp, kNullUniqueId64x2);
3286
3287
  added_files.emplace_back(0, meta);
3287
3288
  }
3288
3289
  WriteFileAdditionAndDeletionToManifest(
@@ -3338,7 +3339,7 @@ TEST_F(VersionSetTestMissingFiles, ManifestAheadofSst) {
3338
3339
  file_num, /*file_path_id=*/0, /*file_size=*/12, smallest_ikey,
3339
3340
  largest_ikey, 0, 0, false, Temperature::kUnknown, 0, 0, 0,
3340
3341
  kUnknownFileChecksum, kUnknownFileChecksumFuncName,
3341
- kDisableUserTimestamp, kDisableUserTimestamp);
3342
+ kDisableUserTimestamp, kDisableUserTimestamp, kNullUniqueId64x2);
3342
3343
  added_files.emplace_back(0, meta);
3343
3344
  }
3344
3345
  WriteFileAdditionAndDeletionToManifest(
@@ -44,7 +44,8 @@ class WalMetadata {
44
44
  private:
45
45
  // The size of WAL is unknown, used when the WAL is not synced yet or is
46
46
  // empty.
47
- constexpr static uint64_t kUnknownWalSize = port::kMaxUint64;
47
+ constexpr static uint64_t kUnknownWalSize =
48
+ std::numeric_limits<uint64_t>::max();
48
49
 
49
50
  // Size of the most recently synced WAL in bytes.
50
51
  uint64_t synced_size_bytes_ = kUnknownWalSize;
@@ -378,9 +378,8 @@ Status WalManager::ReadFirstRecord(const WalFileType type,
378
378
  *sequence = 0;
379
379
  if (type != kAliveLogFile && type != kArchivedLogFile) {
380
380
  ROCKS_LOG_ERROR(db_options_.info_log, "[WalManger] Unknown file type %s",
381
- ToString(type).c_str());
382
- return Status::NotSupported(
383
- "File Type Not Known " + ToString(type));
381
+ std::to_string(type).c_str());
382
+ return Status::NotSupported("File Type Not Known " + std::to_string(type));
384
383
  }
385
384
  {
386
385
  MutexLock l(&read_first_record_cache_mutex_);
@@ -94,7 +94,7 @@ class WalManagerTest : public testing::Test {
94
94
  for (int i = 1; i <= num_logs; ++i) {
95
95
  RollTheLog(true);
96
96
  for (int k = 0; k < entries_per_log; ++k) {
97
- Put(ToString(k), std::string(1024, 'a'));
97
+ Put(std::to_string(k), std::string(1024, 'a'));
98
98
  }
99
99
  }
100
100
  }
@@ -152,14 +152,6 @@ struct SavePoints {
152
152
  std::stack<SavePoint, autovector<SavePoint>> stack;
153
153
  };
154
154
 
155
- WriteBatch::WriteBatch(size_t reserved_bytes, size_t max_bytes)
156
- : content_flags_(0), max_bytes_(max_bytes), rep_() {
157
- rep_.reserve((reserved_bytes > WriteBatchInternal::kHeader)
158
- ? reserved_bytes
159
- : WriteBatchInternal::kHeader);
160
- rep_.resize(WriteBatchInternal::kHeader);
161
- }
162
-
163
155
  WriteBatch::WriteBatch(size_t reserved_bytes, size_t max_bytes,
164
156
  size_t protection_bytes_per_key, size_t default_cf_ts_sz)
165
157
  : content_flags_(0),
@@ -580,14 +572,16 @@ Status WriteBatchInternal::Iterate(const WriteBatch* wb,
580
572
  s = handler->MarkBeginPrepare();
581
573
  assert(s.ok());
582
574
  empty_batch = false;
583
- if (!handler->WriteAfterCommit()) {
575
+ if (handler->WriteAfterCommit() ==
576
+ WriteBatch::Handler::OptionState::kDisabled) {
584
577
  s = Status::NotSupported(
585
578
  "WriteCommitted txn tag when write_after_commit_ is disabled (in "
586
579
  "WritePrepared/WriteUnprepared mode). If it is not due to "
587
580
  "corruption, the WAL must be emptied before changing the "
588
581
  "WritePolicy.");
589
582
  }
590
- if (handler->WriteBeforePrepare()) {
583
+ if (handler->WriteBeforePrepare() ==
584
+ WriteBatch::Handler::OptionState::kEnabled) {
591
585
  s = Status::NotSupported(
592
586
  "WriteCommitted txn tag when write_before_prepare_ is enabled "
593
587
  "(in WriteUnprepared mode). If it is not due to corruption, the "
@@ -600,7 +594,8 @@ Status WriteBatchInternal::Iterate(const WriteBatch* wb,
600
594
  s = handler->MarkBeginPrepare();
601
595
  assert(s.ok());
602
596
  empty_batch = false;
603
- if (handler->WriteAfterCommit()) {
597
+ if (handler->WriteAfterCommit() ==
598
+ WriteBatch::Handler::OptionState::kEnabled) {
604
599
  s = Status::NotSupported(
605
600
  "WritePrepared/WriteUnprepared txn tag when write_after_commit_ "
606
601
  "is enabled (in default WriteCommitted mode). If it is not due "
@@ -614,13 +609,15 @@ Status WriteBatchInternal::Iterate(const WriteBatch* wb,
614
609
  s = handler->MarkBeginPrepare(true /* unprepared */);
615
610
  assert(s.ok());
616
611
  empty_batch = false;
617
- if (handler->WriteAfterCommit()) {
612
+ if (handler->WriteAfterCommit() ==
613
+ WriteBatch::Handler::OptionState::kEnabled) {
618
614
  s = Status::NotSupported(
619
615
  "WriteUnprepared txn tag when write_after_commit_ is enabled (in "
620
616
  "default WriteCommitted mode). If it is not due to corruption, "
621
617
  "the WAL must be emptied before changing the WritePolicy.");
622
618
  }
623
- if (!handler->WriteBeforePrepare()) {
619
+ if (handler->WriteBeforePrepare() ==
620
+ WriteBatch::Handler::OptionState::kDisabled) {
624
621
  s = Status::NotSupported(
625
622
  "WriteUnprepared txn tag when write_before_prepare_ is disabled "
626
623
  "(in WriteCommitted/WritePrepared mode). If it is not due to "
@@ -748,10 +745,10 @@ Status CheckColumnFamilyTimestampSize(ColumnFamilyHandle* column_family,
748
745
 
749
746
  Status WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
750
747
  const Slice& key, const Slice& value) {
751
- if (key.size() > size_t{port::kMaxUint32}) {
748
+ if (key.size() > size_t{std::numeric_limits<uint32_t>::max()}) {
752
749
  return Status::InvalidArgument("key is too large");
753
750
  }
754
- if (value.size() > size_t{port::kMaxUint32}) {
751
+ if (value.size() > size_t{std::numeric_limits<uint32_t>::max()}) {
755
752
  return Status::InvalidArgument("value is too large");
756
753
  }
757
754
 
@@ -828,7 +825,7 @@ Status WriteBatchInternal::CheckSlicePartsLength(const SliceParts& key,
828
825
  for (int i = 0; i < key.num_parts; ++i) {
829
826
  total_key_bytes += key.parts[i].size();
830
827
  }
831
- if (total_key_bytes >= size_t{port::kMaxUint32}) {
828
+ if (total_key_bytes >= size_t{std::numeric_limits<uint32_t>::max()}) {
832
829
  return Status::InvalidArgument("key is too large");
833
830
  }
834
831
 
@@ -836,7 +833,7 @@ Status WriteBatchInternal::CheckSlicePartsLength(const SliceParts& key,
836
833
  for (int i = 0; i < value.num_parts; ++i) {
837
834
  total_value_bytes += value.parts[i].size();
838
835
  }
839
- if (total_value_bytes >= size_t{port::kMaxUint32}) {
836
+ if (total_value_bytes >= size_t{std::numeric_limits<uint32_t>::max()}) {
840
837
  return Status::InvalidArgument("value is too large");
841
838
  }
842
839
  return Status::OK();
@@ -1295,10 +1292,10 @@ Status WriteBatch::DeleteRange(ColumnFamilyHandle* column_family,
1295
1292
 
1296
1293
  Status WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
1297
1294
  const Slice& key, const Slice& value) {
1298
- if (key.size() > size_t{port::kMaxUint32}) {
1295
+ if (key.size() > size_t{std::numeric_limits<uint32_t>::max()}) {
1299
1296
  return Status::InvalidArgument("key is too large");
1300
1297
  }
1301
- if (value.size() > size_t{port::kMaxUint32}) {
1298
+ if (value.size() > size_t{std::numeric_limits<uint32_t>::max()}) {
1302
1299
  return Status::InvalidArgument("value is too large");
1303
1300
  }
1304
1301
 
@@ -1494,6 +1491,8 @@ Status WriteBatch::UpdateTimestamps(
1494
1491
  return s;
1495
1492
  }
1496
1493
 
1494
+ namespace {
1495
+
1497
1496
  class MemTableInserter : public WriteBatch::Handler {
1498
1497
 
1499
1498
  SequenceNumber sequence_;
@@ -1581,9 +1580,24 @@ class MemTableInserter : public WriteBatch::Handler {
1581
1580
  return res;
1582
1581
  }
1583
1582
 
1583
+ void DecrementProtectionInfoIdxForTryAgain() {
1584
+ if (prot_info_ != nullptr) --prot_info_idx_;
1585
+ }
1586
+
1587
+ void ResetProtectionInfo() {
1588
+ prot_info_idx_ = 0;
1589
+ prot_info_ = nullptr;
1590
+ }
1591
+
1584
1592
  protected:
1585
- bool WriteBeforePrepare() const override { return write_before_prepare_; }
1586
- bool WriteAfterCommit() const override { return write_after_commit_; }
1593
+ Handler::OptionState WriteBeforePrepare() const override {
1594
+ return write_before_prepare_ ? Handler::OptionState::kEnabled
1595
+ : Handler::OptionState::kDisabled;
1596
+ }
1597
+ Handler::OptionState WriteAfterCommit() const override {
1598
+ return write_after_commit_ ? Handler::OptionState::kEnabled
1599
+ : Handler::OptionState::kDisabled;
1600
+ }
1587
1601
 
1588
1602
  public:
1589
1603
  // cf_mems should not be shared with concurrent inserters
@@ -1871,15 +1885,25 @@ class MemTableInserter : public WriteBatch::Handler {
1871
1885
  Status PutCF(uint32_t column_family_id, const Slice& key,
1872
1886
  const Slice& value) override {
1873
1887
  const auto* kv_prot_info = NextProtectionInfo();
1888
+ Status ret_status;
1874
1889
  if (kv_prot_info != nullptr) {
1875
1890
  // Memtable needs seqno, doesn't need CF ID
1876
1891
  auto mem_kv_prot_info =
1877
1892
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
1878
- return PutCFImpl(column_family_id, key, value, kTypeValue,
1879
- &mem_kv_prot_info);
1893
+ ret_status = PutCFImpl(column_family_id, key, value, kTypeValue,
1894
+ &mem_kv_prot_info);
1895
+ } else {
1896
+ ret_status = PutCFImpl(column_family_id, key, value, kTypeValue,
1897
+ nullptr /* kv_prot_info */);
1880
1898
  }
1881
- return PutCFImpl(column_family_id, key, value, kTypeValue,
1882
- nullptr /* kv_prot_info */);
1899
+ // TODO: this assumes that if TryAgain status is returned to the caller,
1900
+ // the operation is actually tried again. The proper way to do this is to
1901
+ // pass a `try_again` parameter to the operation itself and decrement
1902
+ // prot_info_idx_ based on that
1903
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1904
+ DecrementProtectionInfoIdxForTryAgain();
1905
+ }
1906
+ return ret_status;
1883
1907
  }
1884
1908
 
1885
1909
  Status DeleteImpl(uint32_t /*column_family_id*/, const Slice& key,
@@ -1926,6 +1950,9 @@ class MemTableInserter : public WriteBatch::Handler {
1926
1950
  } else if (ret_status.ok()) {
1927
1951
  MaybeAdvanceSeq(false /* batch_boundary */);
1928
1952
  }
1953
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1954
+ DecrementProtectionInfoIdxForTryAgain();
1955
+ }
1929
1956
  return ret_status;
1930
1957
  }
1931
1958
 
@@ -1957,6 +1984,9 @@ class MemTableInserter : public WriteBatch::Handler {
1957
1984
  ret_status =
1958
1985
  WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
1959
1986
  }
1987
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1988
+ DecrementProtectionInfoIdxForTryAgain();
1989
+ }
1960
1990
  return ret_status;
1961
1991
  }
1962
1992
 
@@ -1985,6 +2015,9 @@ class MemTableInserter : public WriteBatch::Handler {
1985
2015
  } else if (ret_status.ok()) {
1986
2016
  MaybeAdvanceSeq(false /* batch_boundary */);
1987
2017
  }
2018
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2019
+ DecrementProtectionInfoIdxForTryAgain();
2020
+ }
1988
2021
  return ret_status;
1989
2022
  }
1990
2023
  assert(ret_status.ok());
@@ -2009,6 +2042,9 @@ class MemTableInserter : public WriteBatch::Handler {
2009
2042
  ret_status = WriteBatchInternal::SingleDelete(rebuilding_trx_,
2010
2043
  column_family_id, key);
2011
2044
  }
2045
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2046
+ DecrementProtectionInfoIdxForTryAgain();
2047
+ }
2012
2048
  return ret_status;
2013
2049
  }
2014
2050
 
@@ -2038,6 +2074,9 @@ class MemTableInserter : public WriteBatch::Handler {
2038
2074
  } else if (ret_status.ok()) {
2039
2075
  MaybeAdvanceSeq(false /* batch_boundary */);
2040
2076
  }
2077
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2078
+ DecrementProtectionInfoIdxForTryAgain();
2079
+ }
2041
2080
  return ret_status;
2042
2081
  }
2043
2082
  assert(ret_status.ok());
@@ -2092,6 +2131,9 @@ class MemTableInserter : public WriteBatch::Handler {
2092
2131
  ret_status = WriteBatchInternal::DeleteRange(
2093
2132
  rebuilding_trx_, column_family_id, begin_key, end_key);
2094
2133
  }
2134
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2135
+ DecrementProtectionInfoIdxForTryAgain();
2136
+ }
2095
2137
  return ret_status;
2096
2138
  }
2097
2139
 
@@ -2121,6 +2163,9 @@ class MemTableInserter : public WriteBatch::Handler {
2121
2163
  } else if (ret_status.ok()) {
2122
2164
  MaybeAdvanceSeq(false /* batch_boundary */);
2123
2165
  }
2166
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2167
+ DecrementProtectionInfoIdxForTryAgain();
2168
+ }
2124
2169
  return ret_status;
2125
2170
  }
2126
2171
  assert(ret_status.ok());
@@ -2242,23 +2287,31 @@ class MemTableInserter : public WriteBatch::Handler {
2242
2287
  ret_status = WriteBatchInternal::Merge(rebuilding_trx_, column_family_id,
2243
2288
  key, value);
2244
2289
  }
2290
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2291
+ DecrementProtectionInfoIdxForTryAgain();
2292
+ }
2245
2293
  return ret_status;
2246
2294
  }
2247
2295
 
2248
2296
  Status PutBlobIndexCF(uint32_t column_family_id, const Slice& key,
2249
2297
  const Slice& value) override {
2250
2298
  const auto* kv_prot_info = NextProtectionInfo();
2299
+ Status ret_status;
2251
2300
  if (kv_prot_info != nullptr) {
2252
2301
  // Memtable needs seqno, doesn't need CF ID
2253
2302
  auto mem_kv_prot_info =
2254
2303
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
2255
2304
  // Same as PutCF except for value type.
2256
- return PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2257
- &mem_kv_prot_info);
2305
+ ret_status = PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2306
+ &mem_kv_prot_info);
2258
2307
  } else {
2259
- return PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2260
- nullptr /* kv_prot_info */);
2308
+ ret_status = PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2309
+ nullptr /* kv_prot_info */);
2261
2310
  }
2311
+ if (UNLIKELY(ret_status.IsTryAgain())) {
2312
+ DecrementProtectionInfoIdxForTryAgain();
2313
+ }
2314
+ return ret_status;
2262
2315
  }
2263
2316
 
2264
2317
  void CheckMemtableFull() {
@@ -2401,6 +2454,7 @@ class MemTableInserter : public WriteBatch::Handler {
2401
2454
  const auto& batch_info = trx->batches_.begin()->second;
2402
2455
  // all inserts must reference this trx log number
2403
2456
  log_number_ref_ = batch_info.log_number_;
2457
+ ResetProtectionInfo();
2404
2458
  s = batch_info.batch_->Iterate(this);
2405
2459
  log_number_ref_ = 0;
2406
2460
  }
@@ -2422,6 +2476,10 @@ class MemTableInserter : public WriteBatch::Handler {
2422
2476
  const bool batch_boundry = true;
2423
2477
  MaybeAdvanceSeq(batch_boundry);
2424
2478
 
2479
+ if (UNLIKELY(s.IsTryAgain())) {
2480
+ DecrementProtectionInfoIdxForTryAgain();
2481
+ }
2482
+
2425
2483
  return s;
2426
2484
  }
2427
2485
 
@@ -2466,6 +2524,7 @@ class MemTableInserter : public WriteBatch::Handler {
2466
2524
  return ucmp->timestamp_size();
2467
2525
  });
2468
2526
  if (s.ok()) {
2527
+ ResetProtectionInfo();
2469
2528
  s = batch_info.batch_->Iterate(this);
2470
2529
  log_number_ref_ = 0;
2471
2530
  }
@@ -2488,6 +2547,10 @@ class MemTableInserter : public WriteBatch::Handler {
2488
2547
  constexpr bool batch_boundary = true;
2489
2548
  MaybeAdvanceSeq(batch_boundary);
2490
2549
 
2550
+ if (UNLIKELY(s.IsTryAgain())) {
2551
+ DecrementProtectionInfoIdxForTryAgain();
2552
+ }
2553
+
2491
2554
  return s;
2492
2555
  }
2493
2556
 
@@ -2523,6 +2586,8 @@ class MemTableInserter : public WriteBatch::Handler {
2523
2586
  }
2524
2587
  };
2525
2588
 
2589
+ } // namespace
2590
+
2526
2591
  // This function can only be called in these conditions:
2527
2592
  // 1) During Recovery()
2528
2593
  // 2) During Write(), in a single-threaded write thread
@@ -2613,11 +2678,94 @@ Status WriteBatchInternal::InsertInto(
2613
2678
  return s;
2614
2679
  }
2615
2680
 
2681
+ namespace {
2682
+
2683
+ // This class updates protection info for a WriteBatch.
2684
+ class ProtectionInfoUpdater : public WriteBatch::Handler {
2685
+ public:
2686
+ explicit ProtectionInfoUpdater(WriteBatch::ProtectionInfo* prot_info)
2687
+ : prot_info_(prot_info) {}
2688
+
2689
+ ~ProtectionInfoUpdater() override {}
2690
+
2691
+ Status PutCF(uint32_t cf, const Slice& key, const Slice& val) override {
2692
+ return UpdateProtInfo(cf, key, val, kTypeValue);
2693
+ }
2694
+
2695
+ Status DeleteCF(uint32_t cf, const Slice& key) override {
2696
+ return UpdateProtInfo(cf, key, "", kTypeDeletion);
2697
+ }
2698
+
2699
+ Status SingleDeleteCF(uint32_t cf, const Slice& key) override {
2700
+ return UpdateProtInfo(cf, key, "", kTypeSingleDeletion);
2701
+ }
2702
+
2703
+ Status DeleteRangeCF(uint32_t cf, const Slice& begin_key,
2704
+ const Slice& end_key) override {
2705
+ return UpdateProtInfo(cf, begin_key, end_key, kTypeRangeDeletion);
2706
+ }
2707
+
2708
+ Status MergeCF(uint32_t cf, const Slice& key, const Slice& val) override {
2709
+ return UpdateProtInfo(cf, key, val, kTypeMerge);
2710
+ }
2711
+
2712
+ Status PutBlobIndexCF(uint32_t cf, const Slice& key,
2713
+ const Slice& val) override {
2714
+ return UpdateProtInfo(cf, key, val, kTypeBlobIndex);
2715
+ }
2716
+
2717
+ Status MarkBeginPrepare(bool /* unprepare */) override {
2718
+ return Status::OK();
2719
+ }
2720
+
2721
+ Status MarkEndPrepare(const Slice& /* xid */) override {
2722
+ return Status::OK();
2723
+ }
2724
+
2725
+ Status MarkCommit(const Slice& /* xid */) override { return Status::OK(); }
2726
+
2727
+ Status MarkCommitWithTimestamp(const Slice& /* xid */,
2728
+ const Slice& /* ts */) override {
2729
+ return Status::OK();
2730
+ }
2731
+
2732
+ Status MarkRollback(const Slice& /* xid */) override { return Status::OK(); }
2733
+
2734
+ Status MarkNoop(bool /* empty_batch */) override { return Status::OK(); }
2735
+
2736
+ private:
2737
+ Status UpdateProtInfo(uint32_t cf, const Slice& key, const Slice& val,
2738
+ const ValueType op_type) {
2739
+ if (prot_info_) {
2740
+ prot_info_->entries_.emplace_back(
2741
+ ProtectionInfo64().ProtectKVO(key, val, op_type).ProtectC(cf));
2742
+ }
2743
+ return Status::OK();
2744
+ }
2745
+
2746
+ // No copy or move.
2747
+ ProtectionInfoUpdater(const ProtectionInfoUpdater&) = delete;
2748
+ ProtectionInfoUpdater(ProtectionInfoUpdater&&) = delete;
2749
+ ProtectionInfoUpdater& operator=(const ProtectionInfoUpdater&) = delete;
2750
+ ProtectionInfoUpdater& operator=(ProtectionInfoUpdater&&) = delete;
2751
+
2752
+ WriteBatch::ProtectionInfo* const prot_info_ = nullptr;
2753
+ };
2754
+
2755
+ } // namespace
2756
+
2616
2757
  Status WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) {
2617
2758
  assert(contents.size() >= WriteBatchInternal::kHeader);
2618
- assert(b->prot_info_ == nullptr);
2759
+
2619
2760
  b->rep_.assign(contents.data(), contents.size());
2620
2761
  b->content_flags_.store(ContentFlags::DEFERRED, std::memory_order_relaxed);
2762
+
2763
+ // If we have a prot_info_, update protection info entries for the batch.
2764
+ if (b->prot_info_) {
2765
+ ProtectionInfoUpdater prot_info_updater(b->prot_info_.get());
2766
+ return b->Iterate(&prot_info_updater);
2767
+ }
2768
+
2621
2769
  return Status::OK();
2622
2770
  }
2623
2771