@nxtedition/rocksdb 15.4.0 → 15.5.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 (402) hide show
  1. package/binding.cc +24 -19
  2. package/cache.js +1 -1
  3. package/chained-batch.js +12 -3
  4. package/deps/rocksdb/rocksdb/.clang-tidy +86 -0
  5. package/deps/rocksdb/rocksdb/BUCK +42 -0
  6. package/deps/rocksdb/rocksdb/CMakeLists.txt +11 -0
  7. package/deps/rocksdb/rocksdb/Makefile +59 -32
  8. package/deps/rocksdb/rocksdb/cache/cache.cc +0 -5
  9. package/deps/rocksdb/rocksdb/cache/cache_entry_stats.h +9 -9
  10. package/deps/rocksdb/rocksdb/cache/cache_key.cc +3 -3
  11. package/deps/rocksdb/rocksdb/cache/cache_key.h +5 -5
  12. package/deps/rocksdb/rocksdb/cache/cache_reservation_manager.h +16 -16
  13. package/deps/rocksdb/rocksdb/cache/cache_test.cc +1 -1
  14. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +258 -294
  15. package/deps/rocksdb/rocksdb/cache/clock_cache.h +98 -49
  16. package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.cc +1 -5
  17. package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache_test.cc +2 -3
  18. package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +18 -18
  19. package/deps/rocksdb/rocksdb/crash_test.mk +5 -1
  20. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.cc +23 -22
  21. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.h +6 -1
  22. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder_test.cc +14 -16
  23. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.cc +38 -26
  24. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.h +5 -1
  25. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader_test.cc +101 -18
  26. package/deps/rocksdb/rocksdb/db/blob/blob_index.h +12 -0
  27. package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +6 -9
  28. package/deps/rocksdb/rocksdb/db/builder.cc +23 -0
  29. package/deps/rocksdb/rocksdb/db/builder.h +7 -0
  30. package/deps/rocksdb/rocksdb/db/c.cc +373 -57
  31. package/deps/rocksdb/rocksdb/db/c_test.c +101 -1
  32. package/deps/rocksdb/rocksdb/db/column_family.cc +31 -3
  33. package/deps/rocksdb/rocksdb/db/column_family_test.cc +10 -13
  34. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +35 -48
  35. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +13 -5
  36. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +201 -39
  37. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +15 -10
  38. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_stats_test.cc +7 -7
  39. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +2 -455
  40. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.cc +4 -2
  41. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +19 -0
  42. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +72 -9
  43. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +12 -10
  44. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +405 -83
  45. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +25 -1
  46. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +23 -10
  47. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +1 -0
  48. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +1410 -106
  49. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +12 -5
  50. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +2 -1
  51. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +19 -10
  52. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +505 -45
  53. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +2 -2
  54. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +9 -1
  55. package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +4 -4
  56. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +7 -9
  57. package/deps/rocksdb/rocksdb/db/convenience.cc +4 -4
  58. package/deps/rocksdb/rocksdb/db/convenience_impl.h +2 -1
  59. package/deps/rocksdb/rocksdb/db/corruption_test.cc +60 -88
  60. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +10 -12
  61. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +471 -40
  62. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +116 -2
  63. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +5 -15
  64. package/deps/rocksdb/rocksdb/db/db_compaction_abort_test.cc +993 -0
  65. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +329 -29
  66. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +155 -13
  67. package/deps/rocksdb/rocksdb/db/db_impl/compacted_db_impl.cc +54 -31
  68. package/deps/rocksdb/rocksdb/db/db_impl/compacted_db_impl.h +1 -0
  69. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +232 -70
  70. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +57 -9
  71. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +224 -31
  72. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  73. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +4 -2
  74. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +1 -1
  75. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_follower.cc +1 -0
  76. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +164 -8
  77. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +6 -0
  78. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +5 -0
  79. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +47 -35
  80. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +22 -9
  81. package/deps/rocksdb/rocksdb/db/db_iter.cc +9 -0
  82. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +371 -6
  83. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +7 -5
  84. package/deps/rocksdb/rocksdb/db/db_logical_block_size_cache_test.cc +22 -23
  85. package/deps/rocksdb/rocksdb/db/db_memtable_test.cc +0 -2
  86. package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +4 -4
  87. package/deps/rocksdb/rocksdb/db/db_options_test.cc +40 -0
  88. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +32 -13
  89. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +1 -1
  90. package/deps/rocksdb/rocksdb/db/db_readonly_with_timestamp_test.cc +4 -4
  91. package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +68 -15
  92. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +1 -1
  93. package/deps/rocksdb/rocksdb/db/db_statistics_test.cc +2 -3
  94. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +6 -21
  95. package/deps/rocksdb/rocksdb/db/db_test.cc +644 -128
  96. package/deps/rocksdb/rocksdb/db/db_test2.cc +198 -81
  97. package/deps/rocksdb/rocksdb/db/db_test_util.cc +35 -10
  98. package/deps/rocksdb/rocksdb/db/db_test_util.h +8 -2
  99. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +36 -32
  100. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +11 -7
  101. package/deps/rocksdb/rocksdb/db/db_with_timestamp_compaction_test.cc +499 -0
  102. package/deps/rocksdb/rocksdb/db/db_write_buffer_manager_test.cc +284 -20
  103. package/deps/rocksdb/rocksdb/db/db_write_test.cc +3 -3
  104. package/deps/rocksdb/rocksdb/db/dbformat.h +0 -5
  105. package/deps/rocksdb/rocksdb/db/error_handler.cc +24 -0
  106. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +12 -14
  107. package/deps/rocksdb/rocksdb/db/experimental.cc +13 -10
  108. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +1 -1
  109. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +22 -3
  110. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +21 -15
  111. package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +4 -6
  112. package/deps/rocksdb/rocksdb/db/flush_job.cc +11 -3
  113. package/deps/rocksdb/rocksdb/db/forward_iterator_bench.cc +5 -6
  114. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +4 -2
  115. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +17 -17
  116. package/deps/rocksdb/rocksdb/db/internal_stats.cc +13 -0
  117. package/deps/rocksdb/rocksdb/db/internal_stats.h +2 -0
  118. package/deps/rocksdb/rocksdb/db/listener_test.cc +154 -27
  119. package/deps/rocksdb/rocksdb/db/manual_compaction_test.cc +6 -6
  120. package/deps/rocksdb/rocksdb/db/memtable.cc +197 -51
  121. package/deps/rocksdb/rocksdb/db/memtable.h +6 -0
  122. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +3 -4
  123. package/deps/rocksdb/rocksdb/db/merge_test.cc +37 -35
  124. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +2 -1
  125. package/deps/rocksdb/rocksdb/db/options_file_test.cc +4 -4
  126. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +9 -11
  127. package/deps/rocksdb/rocksdb/db/periodic_task_scheduler.cc +10 -1
  128. package/deps/rocksdb/rocksdb/db/periodic_task_scheduler_test.cc +292 -15
  129. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +10 -17
  130. package/deps/rocksdb/rocksdb/db/prefix_test.cc +6 -8
  131. package/deps/rocksdb/rocksdb/db/repair.cc +10 -10
  132. package/deps/rocksdb/rocksdb/db/seqno_time_test.cc +5 -5
  133. package/deps/rocksdb/rocksdb/db/table_cache.cc +142 -135
  134. package/deps/rocksdb/rocksdb/db/table_cache.h +30 -6
  135. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +7 -7
  136. package/deps/rocksdb/rocksdb/db/version_builder.cc +11 -50
  137. package/deps/rocksdb/rocksdb/db/version_builder.h +2 -1
  138. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +2 -1
  139. package/deps/rocksdb/rocksdb/db/version_edit.cc +51 -2
  140. package/deps/rocksdb/rocksdb/db/version_edit.h +91 -29
  141. package/deps/rocksdb/rocksdb/db/version_edit_handler.h +7 -7
  142. package/deps/rocksdb/rocksdb/db/version_set.cc +211 -50
  143. package/deps/rocksdb/rocksdb/db/version_set.h +40 -3
  144. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +5 -0
  145. package/deps/rocksdb/rocksdb/db/version_set_test.cc +294 -21
  146. package/deps/rocksdb/rocksdb/db/version_util.cc +96 -0
  147. package/deps/rocksdb/rocksdb/db/version_util.h +24 -0
  148. package/deps/rocksdb/rocksdb/db/wide/db_wide_basic_test.cc +5 -5
  149. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.cc +647 -31
  150. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.h +219 -1
  151. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization_test.cc +549 -12
  152. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +3 -3
  153. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +1 -1
  154. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +19 -0
  155. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +21 -4
  156. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +32 -0
  157. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +74 -22
  158. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.h +9 -0
  159. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +143 -61
  160. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +15 -2
  161. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +76 -2
  162. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +92 -72
  163. package/deps/rocksdb/rocksdb/env/env.cc +1 -0
  164. package/deps/rocksdb/rocksdb/env/env_test.cc +365 -2
  165. package/deps/rocksdb/rocksdb/env/fs_posix.cc +31 -30
  166. package/deps/rocksdb/rocksdb/env/io_posix.cc +8 -11
  167. package/deps/rocksdb/rocksdb/env/io_posix.h +30 -1
  168. package/deps/rocksdb/rocksdb/env/io_posix_test.cc +43 -0
  169. package/deps/rocksdb/rocksdb/file/delete_scheduler.cc +1 -1
  170. package/deps/rocksdb/rocksdb/file/delete_scheduler_test.cc +108 -0
  171. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +32 -4
  172. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +4 -4
  173. package/deps/rocksdb/rocksdb/file/file_util.cc +8 -2
  174. package/deps/rocksdb/rocksdb/file/file_util.h +2 -1
  175. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +331 -12
  176. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +52 -35
  177. package/deps/rocksdb/rocksdb/folly.mk +22 -5
  178. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_cache.h +1 -1
  179. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_compression.h +100 -54
  180. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +67 -2
  181. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +149 -13
  182. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +1 -12
  183. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +78 -97
  184. package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +3 -3
  185. package/deps/rocksdb/rocksdb/include/rocksdb/external_table.h +2 -2
  186. package/deps/rocksdb/rocksdb/include/rocksdb/file_checksum.h +5 -0
  187. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +17 -2
  188. package/deps/rocksdb/rocksdb/include/rocksdb/functor_wrapper.h +1 -1
  189. package/deps/rocksdb/rocksdb/include/rocksdb/io_dispatcher.h +358 -0
  190. package/deps/rocksdb/rocksdb/include/rocksdb/iostats_context.h +13 -0
  191. package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +43 -0
  192. package/deps/rocksdb/rocksdb/include/rocksdb/memtablerep.h +20 -0
  193. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +63 -21
  194. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +10 -1
  195. package/deps/rocksdb/rocksdb/include/rocksdb/rate_limiter.h +1 -1
  196. package/deps/rocksdb/rocksdb/include/rocksdb/slice_transform.h +2 -7
  197. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_reader.h +13 -0
  198. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +3 -14
  199. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +49 -9
  200. package/deps/rocksdb/rocksdb/include/rocksdb/status.h +8 -0
  201. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +77 -6
  202. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +15 -0
  203. package/deps/rocksdb/rocksdb/include/rocksdb/tool_hooks.h +16 -10
  204. package/deps/rocksdb/rocksdb/include/rocksdb/unique_id.h +5 -5
  205. package/deps/rocksdb/rocksdb/include/rocksdb/universal_compaction.h +2 -4
  206. package/deps/rocksdb/rocksdb/include/rocksdb/user_defined_index.h +106 -46
  207. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/db_ttl.h +1 -1
  208. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +14 -1
  209. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/memory_util.h +5 -1
  210. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/optimistic_transaction_db.h +2 -1
  211. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +7 -9
  212. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  213. package/deps/rocksdb/rocksdb/logging/auto_roll_logger_test.cc +1 -2
  214. package/deps/rocksdb/rocksdb/memory/memory_allocator_test.cc +2 -2
  215. package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +226 -8
  216. package/deps/rocksdb/rocksdb/memtable/inlineskiplist_test.cc +490 -0
  217. package/deps/rocksdb/rocksdb/memtable/skiplist.h +3 -3
  218. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +11 -0
  219. package/deps/rocksdb/rocksdb/microbench/db_basic_bench.cc +4 -12
  220. package/deps/rocksdb/rocksdb/microbench/ribbon_bench.cc +5 -5
  221. package/deps/rocksdb/rocksdb/monitoring/file_read_sample.h +21 -4
  222. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +9 -3
  223. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +21 -2
  224. package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +2 -2
  225. package/deps/rocksdb/rocksdb/options/cf_options.cc +21 -1
  226. package/deps/rocksdb/rocksdb/options/cf_options.h +2 -0
  227. package/deps/rocksdb/rocksdb/options/customizable_test.cc +0 -2
  228. package/deps/rocksdb/rocksdb/options/db_options.cc +26 -5
  229. package/deps/rocksdb/rocksdb/options/db_options.h +3 -1
  230. package/deps/rocksdb/rocksdb/options/options.cc +5 -1
  231. package/deps/rocksdb/rocksdb/options/options_helper.cc +7 -2
  232. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +109 -103
  233. package/deps/rocksdb/rocksdb/options/options_test.cc +14 -0
  234. package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +15 -17
  235. package/deps/rocksdb/rocksdb/port/lang.h +4 -0
  236. package/deps/rocksdb/rocksdb/port/port_example.h +0 -23
  237. package/deps/rocksdb/rocksdb/port/stack_trace.cc +36 -0
  238. package/deps/rocksdb/rocksdb/port/stack_trace.h +9 -0
  239. package/deps/rocksdb/rocksdb/src.mk +12 -0
  240. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.cc +1 -2
  241. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +2 -1
  242. package/deps/rocksdb/rocksdb/table/block_based/block.cc +571 -292
  243. package/deps/rocksdb/rocksdb/table/block_based/block.h +143 -53
  244. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +154 -90
  245. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +5 -1
  246. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +51 -14
  247. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.h +0 -2
  248. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +147 -734
  249. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +30 -233
  250. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +178 -108
  251. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +13 -0
  252. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +17 -4
  253. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -2
  254. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +70 -0
  255. package/deps/rocksdb/rocksdb/table/block_based/block_builder.cc +168 -24
  256. package/deps/rocksdb/rocksdb/table/block_based/block_builder.h +25 -9
  257. package/deps/rocksdb/rocksdb/table/block_based/block_cache.cc +7 -4
  258. package/deps/rocksdb/rocksdb/table/block_based/block_cache.h +9 -2
  259. package/deps/rocksdb/rocksdb/table/block_based/block_test.cc +548 -169
  260. package/deps/rocksdb/rocksdb/table/block_based/block_type.h +30 -0
  261. package/deps/rocksdb/rocksdb/table/block_based/block_util.h +156 -0
  262. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.cc +73 -30
  263. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.h +74 -7
  264. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index.h +1 -1
  265. package/deps/rocksdb/rocksdb/table/block_based/index_builder.cc +20 -14
  266. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +22 -12
  267. package/deps/rocksdb/rocksdb/table/block_based/mock_block_based_table.h +1 -1
  268. package/deps/rocksdb/rocksdb/table/block_based/multi_scan_index_iterator.cc +332 -0
  269. package/deps/rocksdb/rocksdb/table/block_based/multi_scan_index_iterator.h +133 -0
  270. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +4 -2
  271. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +1 -1
  272. package/deps/rocksdb/rocksdb/table/block_based/reader_common.cc +3 -2
  273. package/deps/rocksdb/rocksdb/table/block_based/reader_common.h +4 -1
  274. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.h +0 -1
  275. package/deps/rocksdb/rocksdb/table/block_based/user_defined_index_wrapper.h +126 -46
  276. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +31 -3
  277. package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +1 -2
  278. package/deps/rocksdb/rocksdb/table/cleanable_test.cc +3 -1
  279. package/deps/rocksdb/rocksdb/table/external_table.cc +25 -4
  280. package/deps/rocksdb/rocksdb/table/format.cc +27 -15
  281. package/deps/rocksdb/rocksdb/table/format.h +41 -15
  282. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +1 -0
  283. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +22 -12
  284. package/deps/rocksdb/rocksdb/table/meta_blocks.h +0 -1
  285. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +7 -21
  286. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +0 -1
  287. package/deps/rocksdb/rocksdb/table/sst_file_reader.cc +88 -13
  288. package/deps/rocksdb/rocksdb/table/sst_file_reader_test.cc +53 -42
  289. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +3 -12
  290. package/deps/rocksdb/rocksdb/table/table_builder.h +0 -4
  291. package/deps/rocksdb/rocksdb/table/table_properties.cc +18 -0
  292. package/deps/rocksdb/rocksdb/table/table_reader_bench.cc +2 -3
  293. package/deps/rocksdb/rocksdb/table/table_test.cc +848 -172
  294. package/deps/rocksdb/rocksdb/table/unique_id.cc +24 -20
  295. package/deps/rocksdb/rocksdb/table/unique_id_impl.h +8 -8
  296. package/deps/rocksdb/rocksdb/test_util/sync_point.h +5 -4
  297. package/deps/rocksdb/rocksdb/test_util/testutil.cc +2 -1
  298. package/deps/rocksdb/rocksdb/test_util/testutil.h +2 -2
  299. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +2 -1
  300. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +238 -120
  301. package/deps/rocksdb/rocksdb/tools/db_repl_stress.cc +2 -2
  302. package/deps/rocksdb/rocksdb/tools/db_sanity_test.cc +2 -4
  303. package/deps/rocksdb/rocksdb/tools/dump/db_dump_tool.cc +4 -8
  304. package/deps/rocksdb/rocksdb/tools/dump/rocksdb_undump.cc +1 -1
  305. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_test.cc +2 -3
  306. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +82 -20
  307. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +41 -47
  308. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +9 -0
  309. package/deps/rocksdb/rocksdb/tools/reduce_levels_test.cc +5 -6
  310. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +1 -1
  311. package/deps/rocksdb/rocksdb/tools/tool_hooks.cc +6 -5
  312. package/deps/rocksdb/rocksdb/tools/trace_analyzer_test.cc +4 -4
  313. package/deps/rocksdb/rocksdb/tools/write_stress.cc +1 -3
  314. package/deps/rocksdb/rocksdb/util/atomic.h +30 -23
  315. package/deps/rocksdb/rocksdb/util/auto_tune_compressor.cc +6 -7
  316. package/deps/rocksdb/rocksdb/util/auto_tune_compressor.h +3 -3
  317. package/deps/rocksdb/rocksdb/util/bit_fields.h +68 -46
  318. package/deps/rocksdb/rocksdb/util/bloom_impl.h +16 -16
  319. package/deps/rocksdb/rocksdb/util/coding.h +14 -27
  320. package/deps/rocksdb/rocksdb/util/compression.cc +365 -207
  321. package/deps/rocksdb/rocksdb/util/compression.h +16 -1298
  322. package/deps/rocksdb/rocksdb/util/compression_test.cc +347 -61
  323. package/deps/rocksdb/rocksdb/util/crc32c_arm64.cc +8 -9
  324. package/deps/rocksdb/rocksdb/util/crc32c_arm64.h +1 -1
  325. package/deps/rocksdb/rocksdb/util/crc32c_ppc.h +1 -1
  326. package/deps/rocksdb/rocksdb/util/dynamic_bloom_test.cc +3 -3
  327. package/deps/rocksdb/rocksdb/util/filter_bench.cc +18 -18
  328. package/deps/rocksdb/rocksdb/util/gflags_compat.h +3 -3
  329. package/deps/rocksdb/rocksdb/util/hash_test.cc +19 -7
  330. package/deps/rocksdb/rocksdb/util/io_dispatcher_imp.cc +1099 -0
  331. package/deps/rocksdb/rocksdb/util/io_dispatcher_imp.h +36 -0
  332. package/deps/rocksdb/rocksdb/util/io_dispatcher_test.cc +1919 -0
  333. package/deps/rocksdb/rocksdb/util/math.h +3 -1
  334. package/deps/rocksdb/rocksdb/util/mutexlock.h +19 -19
  335. package/deps/rocksdb/rocksdb/util/ribbon_alg.h +25 -25
  336. package/deps/rocksdb/rocksdb/util/simple_mixed_compressor.cc +5 -7
  337. package/deps/rocksdb/rocksdb/util/simple_mixed_compressor.h +4 -5
  338. package/deps/rocksdb/rocksdb/util/slice.cc +0 -10
  339. package/deps/rocksdb/rocksdb/util/slice_test.cc +35 -1
  340. package/deps/rocksdb/rocksdb/util/slice_transform_test.cc +5 -7
  341. package/deps/rocksdb/rocksdb/util/status.cc +3 -1
  342. package/deps/rocksdb/rocksdb/util/stop_watch.h +2 -0
  343. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +4 -1
  344. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +123 -78
  345. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.cc +12 -93
  346. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.h +1 -4
  347. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.cc +0 -21
  348. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.h +6 -48
  349. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.cc +94 -307
  350. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.h +12 -58
  351. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +2 -8
  352. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_listener.h +2 -3
  353. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_test.cc +205 -811
  354. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +18 -9
  355. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.cc +2 -7
  356. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.h +1 -9
  357. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_functional_test.cc +17 -11
  358. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.cc +1 -1
  359. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.h +1 -1
  360. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.cc +1 -1
  361. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +68 -61
  362. package/deps/rocksdb/rocksdb/utilities/debug.cc +2 -1
  363. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +105 -59
  364. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +274 -7
  365. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs_test.cc +94 -0
  366. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +13 -17
  367. package/deps/rocksdb/rocksdb/utilities/memory/memory_util.cc +16 -3
  368. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend_test.cc +25 -25
  369. package/deps/rocksdb/rocksdb/utilities/object_registry.cc +40 -40
  370. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration.cc +2 -5
  371. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +17 -19
  372. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.cc +2 -2
  373. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.h +2 -2
  374. package/deps/rocksdb/rocksdb/utilities/persistent_cache/volatile_tier_impl.cc +1 -1
  375. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.cc +2 -2
  376. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.h +4 -13
  377. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +3 -3
  378. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +6 -0
  379. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_seqno_test.cc +431 -0
  380. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +1 -2
  381. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.h +91 -0
  382. package/deps/rocksdb/rocksdb/utilities/trie_index/bitvector.cc +562 -0
  383. package/deps/rocksdb/rocksdb/utilities/trie_index/bitvector.h +615 -0
  384. package/deps/rocksdb/rocksdb/utilities/trie_index/louds_trie.cc +2575 -0
  385. package/deps/rocksdb/rocksdb/utilities/trie_index/louds_trie.h +685 -0
  386. package/deps/rocksdb/rocksdb/utilities/trie_index/trie_index_db_test.cc +2843 -0
  387. package/deps/rocksdb/rocksdb/utilities/trie_index/trie_index_factory.cc +567 -0
  388. package/deps/rocksdb/rocksdb/utilities/trie_index/trie_index_factory.h +275 -0
  389. package/deps/rocksdb/rocksdb/utilities/trie_index/trie_index_test.cc +5183 -0
  390. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +4 -3
  391. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.h +1 -1
  392. package/deps/rocksdb/rocksdb/utilities/ttl/ttl_test.cc +2 -2
  393. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +3 -3
  394. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +93 -88
  395. package/deps/rocksdb/rocksdb.gyp +7 -0
  396. package/index.js +11 -2
  397. package/iterator.js +15 -7
  398. package/package.json +1 -1
  399. package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
  400. package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
  401. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_custom_library.h +0 -43
  402. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_util.h +0 -55
@@ -19,7 +19,7 @@ namespace ROCKSDB_NAMESPACE {
19
19
  // fields into atomic variables to reduce the need for locking in concurrent
20
20
  // code and/or to simplify reasoning on and accommodation of different
21
21
  // interesting, bug-prone interleavings. Convenient atomic wrappers
22
- // (RelaxedAtomic, AcqRelAtomic) are provided below to aid usage with atomics,
22
+ // (RelaxedAtomic, Atomic) are provided below to aid usage with atomics,
23
23
  // especially for CAS updates, but it is even possible to combine operations on
24
24
  // multiple bit fields into a single non-CAS atomic operation using Transforms
25
25
  // below.
@@ -70,7 +70,7 @@ struct BitFields {
70
70
 
71
71
  // Return a copy with the given field modified
72
72
  template <typename BitFieldT>
73
- Derived With(typename BitFieldT::V value) const {
73
+ constexpr Derived With(typename BitFieldT::V value) const {
74
74
  static_assert(std::is_same_v<typename BitFieldT::Parent, Derived>);
75
75
  Derived rv = static_cast<const Derived&>(*this);
76
76
  BitFieldT::SetIn(rv, value);
@@ -125,24 +125,26 @@ struct BitFields {
125
125
  // For building atomic updates affecting one or more fields, assuming all the
126
126
  // updates are bitwise-or.
127
127
  template <typename BitFieldsT>
128
- struct OrTransform {
128
+ struct OrTransformer {
129
129
  using U = typename BitFieldsT::U;
130
130
  U to_or = 0;
131
131
  // + for general combine
132
- OrTransform<BitFieldsT> operator+(OrTransform<BitFieldsT> other) const {
133
- return OrTransform<BitFieldsT>{to_or | other.to_or};
132
+ OrTransformer<BitFieldsT> operator+(
133
+ const OrTransformer<BitFieldsT>& other) const {
134
+ return OrTransformer<BitFieldsT>{to_or | other.to_or};
134
135
  }
135
136
  };
136
137
 
137
138
  // For building atomic updates affecting one or more fields, assuming all the
138
139
  // updates are bitwise-and.
139
140
  template <typename BitFieldsT>
140
- struct AndTransform {
141
+ struct AndTransformer {
141
142
  using U = typename BitFieldsT::U;
142
143
  U to_and = 0;
143
144
  // + for general combine
144
- AndTransform<BitFieldsT> operator+(AndTransform<BitFieldsT> other) const {
145
- return AndTransform<BitFieldsT>{to_and & other.to_and};
145
+ AndTransformer<BitFieldsT> operator+(
146
+ const AndTransformer<BitFieldsT>& other) const {
147
+ return AndTransformer<BitFieldsT>{to_and & other.to_and};
146
148
  }
147
149
  };
148
150
 
@@ -152,7 +154,7 @@ struct AndTransform {
152
154
  // corresponding preconditions. (NOTE that when representing a subtraction, we
153
155
  // rely on overflow of the unsigned representation.)
154
156
  template <typename BitFieldsT>
155
- struct AddTransform {
157
+ struct AddTransformer {
156
158
  using U = typename BitFieldsT::U;
157
159
  U to_add = 0;
158
160
  #ifndef NDEBUG
@@ -162,7 +164,7 @@ struct AddTransform {
162
164
  };
163
165
  std::vector<Precondition> preconditions;
164
166
  #endif // NDEBUG
165
- void AssertPreconditions([[maybe_unused]] U from) {
167
+ void AssertPreconditions([[maybe_unused]] U from) const {
166
168
  #ifndef NDEBUG
167
169
  for (auto p : preconditions) {
168
170
  U tmp = (from & p.mask) + p.piece;
@@ -174,8 +176,9 @@ struct AddTransform {
174
176
  #endif // NDEBUG
175
177
  }
176
178
  // + for general combine
177
- AddTransform<BitFieldsT> operator+(AddTransform<BitFieldsT> other) const {
178
- AddTransform<BitFieldsT> rv{to_add + other.to_add};
179
+ AddTransformer<BitFieldsT> operator+(
180
+ const AddTransformer<BitFieldsT>& other) const {
181
+ AddTransformer<BitFieldsT> rv{to_add + other.to_add};
179
182
  #ifndef NDEBUG
180
183
  rv.preconditions = preconditions;
181
184
  rv.preconditions.insert(rv.preconditions.end(), other.preconditions.begin(),
@@ -214,14 +217,18 @@ struct BoolBitField {
214
217
  return (bf.underlying & (U{1} << kBitOffset)) != 0;
215
218
  }
216
219
  static void SetIn(ParentBase& bf, bool value) {
220
+ // NOTE: avoiding conditional branches is usually best for speed on modern
221
+ // processors
217
222
  bf.underlying =
218
223
  (bf.underlying & ~(U{1} << kBitOffset)) | (U{value} << kBitOffset);
219
224
  }
220
- static OrTransform<BitFieldsT> SetTransform() {
221
- return OrTransform<BitFieldsT>{U{1} << kBitOffset};
225
+ static OrTransformer<BitFieldsT> SetTransform() { return Or(true); }
226
+ static OrTransformer<BitFieldsT> Or(bool b) {
227
+ return OrTransformer<BitFieldsT>{U{b} << kBitOffset};
222
228
  }
223
- static AndTransform<BitFieldsT> ClearTransform() {
224
- return AndTransform<BitFieldsT>{~(U{1} << kBitOffset)};
229
+ static AndTransformer<BitFieldsT> ClearTransform() { return And(false); }
230
+ static AndTransformer<BitFieldsT> And(bool b) {
231
+ return AndTransformer<BitFieldsT>{~(U{!b} << kBitOffset)};
225
232
  }
226
233
  };
227
234
 
@@ -258,18 +265,31 @@ struct UnsignedBitField {
258
265
  bf.underlying |= static_cast<U>(value & kMask) << kBitOffset;
259
266
  }
260
267
 
261
- // Create a transfor for clearing this field to zero.
262
- static AndTransform<BitFieldsT> ClearTransform() {
263
- return AndTransform<BitFieldsT>{~(static_cast<U>(kMask) << kBitOffset)};
268
+ // Create a transform for clearing this field to zero.
269
+ static AndTransformer<BitFieldsT> ClearTransform() {
270
+ return AndTransformer<BitFieldsT>{~(static_cast<U>(kMask) << kBitOffset)};
271
+ }
272
+
273
+ // Create a transform for bitwise-and
274
+ static AndTransformer<BitFieldsT> AndTransform(V value) {
275
+ assert((value & ~kMask) == 0);
276
+ return AndTransformer<BitFieldsT>{
277
+ ~(static_cast<U>(value ^ kMask) << kBitOffset)};
278
+ }
279
+
280
+ // Create a transform for bitwise-or
281
+ static OrTransformer<BitFieldsT> OrTransform(V value) {
282
+ assert((value & ~kMask) == 0);
283
+ return OrTransformer<BitFieldsT>{static_cast<U>(value) << kBitOffset};
264
284
  }
265
285
 
266
286
  // Create a transform for adding a particular value, but with the precondition
267
287
  // that adding the value will not overflow the field. This applies for fields
268
288
  // that do not include the top bit of the underlying representation. Can be
269
289
  // combined with other additive transforms for other fields.
270
- static AddTransform<BitFieldsT> PlusTransformPromiseNoOverflow(V value) {
290
+ static AddTransformer<BitFieldsT> PlusTransformPromiseNoOverflow(V value) {
271
291
  static_assert(!kIncludesTopBit);
272
- AddTransform<BitFieldsT> rv{static_cast<U>(value) << kBitOffset};
292
+ AddTransformer<BitFieldsT> rv{static_cast<U>(value) << kBitOffset};
273
293
  #ifndef NDEBUG
274
294
  rv.preconditions.push_back(
275
295
  {static_cast<U>(kMask) << kBitOffset, rv.to_add});
@@ -281,9 +301,9 @@ struct UnsignedBitField {
281
301
  // in that field. This applies for fields that include the top bit of the
282
302
  // underlying representation. Can be combined with other additive transforms
283
303
  // for other fields.
284
- static AddTransform<BitFieldsT> PlusTransformIgnoreOverflow(V value) {
304
+ static AddTransformer<BitFieldsT> PlusTransformIgnoreOverflow(V value) {
285
305
  static_assert(kIncludesTopBit);
286
- AddTransform<BitFieldsT> rv{static_cast<U>(value) << kBitOffset};
306
+ AddTransformer<BitFieldsT> rv{static_cast<U>(value) << kBitOffset};
287
307
  return rv;
288
308
  }
289
309
 
@@ -292,9 +312,9 @@ struct UnsignedBitField {
292
312
  // applies for fields that do not include the top bit of the underlying
293
313
  // representation. Can be combined with other additive transforms for other
294
314
  // fields.
295
- static AddTransform<BitFieldsT> MinusTransformPromiseNoUnderflow(V value) {
315
+ static AddTransformer<BitFieldsT> MinusTransformPromiseNoUnderflow(V value) {
296
316
  static_assert(!kIncludesTopBit);
297
- AddTransform<BitFieldsT> rv{U{0} - (static_cast<U>(value) << kBitOffset)};
317
+ AddTransformer<BitFieldsT> rv{U{0} - (static_cast<U>(value) << kBitOffset)};
298
318
  #ifndef NDEBUG
299
319
  rv.preconditions.push_back(
300
320
  {static_cast<U>(kMask) << kBitOffset, rv.to_add});
@@ -306,17 +326,18 @@ struct UnsignedBitField {
306
326
  // underflow in that field. This applies for fields that include the top bit
307
327
  // of the underlying representation. Can be combined with other additive
308
328
  // transforms for other fields.
309
- static AddTransform<BitFieldsT> MinusTransformIgnoreUnderflow(V value) {
329
+ static AddTransformer<BitFieldsT> MinusTransformIgnoreUnderflow(V value) {
310
330
  static_assert(kIncludesTopBit);
311
- AddTransform<BitFieldsT> rv{U{0} - (static_cast<U>(value) << kBitOffset)};
331
+ AddTransformer<BitFieldsT> rv{U{0} - (static_cast<U>(value) << kBitOffset)};
312
332
  return rv;
313
333
  }
314
334
  };
315
335
 
316
- // A handy wrapper for a relaxed atomic on some BitFields type (unlike
317
- // RelaxedAtomic for arithmetic types). For encapsulation, usual arithmetic
318
- // atomic operations are only available by calling Apply[Relaxed]() on
319
- // Transforms returned from field classes. Extending an example from BitFields:
336
+ // A handy wrapper for a relaxed atomic on some BitFields type, like
337
+ // RelaxedAtomic but without direct arithmetic operations. For encapsulation,
338
+ // usual arithmetic atomic operations are only available by calling
339
+ // ApplyRelaxed() on Transforms returned from field classes. Extending an
340
+ // example from BitFields:
320
341
  //
321
342
  // auto transform = Field2::ClearTransform() + Field4::ClearTransform();
322
343
  // MyState old_state;
@@ -347,22 +368,22 @@ class RelaxedBitFieldsAtomic {
347
368
  return BitFieldsT{
348
369
  v_.exchange(desired.underlying, std::memory_order_relaxed)};
349
370
  }
350
- void ApplyRelaxed(OrTransform<BitFieldsT> transform,
371
+ void ApplyRelaxed(const OrTransformer<BitFieldsT>& transform,
351
372
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
352
373
  ApplyImpl<std::memory_order_relaxed>(transform, before, after);
353
374
  }
354
- void ApplyRelaxed(AndTransform<BitFieldsT> transform,
375
+ void ApplyRelaxed(const AndTransformer<BitFieldsT>& transform,
355
376
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
356
377
  ApplyImpl<std::memory_order_relaxed>(transform, before, after);
357
378
  }
358
- void ApplyRelaxed(AddTransform<BitFieldsT> transform,
379
+ void ApplyRelaxed(const AddTransformer<BitFieldsT>& transform,
359
380
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
360
381
  ApplyImpl<std::memory_order_relaxed>(transform, before, after);
361
382
  }
362
383
 
363
384
  protected: // fns
364
385
  template <std::memory_order kOrder>
365
- void ApplyImpl(OrTransform<BitFieldsT> transform,
386
+ void ApplyImpl(const OrTransformer<BitFieldsT>& transform,
366
387
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
367
388
  U before_val = v_.fetch_or(transform.to_or, kOrder);
368
389
  if (before) {
@@ -373,7 +394,7 @@ class RelaxedBitFieldsAtomic {
373
394
  }
374
395
  }
375
396
  template <std::memory_order kOrder>
376
- void ApplyImpl(AndTransform<BitFieldsT> transform,
397
+ void ApplyImpl(const AndTransformer<BitFieldsT>& transform,
377
398
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
378
399
  U before_val = v_.fetch_and(transform.to_and, kOrder);
379
400
  if (before) {
@@ -384,7 +405,7 @@ class RelaxedBitFieldsAtomic {
384
405
  }
385
406
  }
386
407
  template <std::memory_order kOrder>
387
- void ApplyImpl(AddTransform<BitFieldsT> transform,
408
+ void ApplyImpl(const AddTransformer<BitFieldsT>& transform,
388
409
  BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
389
410
  U before_val = v_.fetch_add(transform.to_add, kOrder);
390
411
  transform.AssertPreconditions(before_val);
@@ -401,14 +422,15 @@ class RelaxedBitFieldsAtomic {
401
422
  };
402
423
 
403
424
  // A handy wrapper for an aquire-release atomic (also relaxed semantics
404
- // available) on some BitFields type. See RelaxedBitFieldsAtomic for more info.
425
+ // available) on some BitFields type. See RelaxedBitFieldsAtomic and
426
+ // Atomic in atomic.h for more info.
405
427
  template <typename BitFieldsT>
406
- class AcqRelBitFieldsAtomic : public RelaxedBitFieldsAtomic<BitFieldsT> {
428
+ class BitFieldsAtomic : public RelaxedBitFieldsAtomic<BitFieldsT> {
407
429
  public:
408
430
  using Base = RelaxedBitFieldsAtomic<BitFieldsT>;
409
431
  using U = typename BitFieldsT::U;
410
432
 
411
- explicit AcqRelBitFieldsAtomic(BitFieldsT initial = {}) : Base(initial) {}
433
+ explicit BitFieldsAtomic(BitFieldsT initial = {}) : Base(initial) {}
412
434
 
413
435
  void Store(BitFieldsT desired) {
414
436
  Base::v_.store(desired.underlying, std::memory_order_release);
@@ -428,18 +450,18 @@ class AcqRelBitFieldsAtomic : public RelaxedBitFieldsAtomic<BitFieldsT> {
428
450
  return BitFieldsT{
429
451
  Base::v_.exchange(desired.underlying, std::memory_order_acq_rel)};
430
452
  }
431
- void Apply(OrTransform<BitFieldsT> transform, BitFieldsT* before = nullptr,
432
- BitFieldsT* after = nullptr) {
453
+ void Apply(const OrTransformer<BitFieldsT>& transform,
454
+ BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
433
455
  Base::template ApplyImpl<std::memory_order_acq_rel>(transform, before,
434
456
  after);
435
457
  }
436
- void Apply(AndTransform<BitFieldsT> transform, BitFieldsT* before = nullptr,
437
- BitFieldsT* after = nullptr) {
458
+ void Apply(const AndTransformer<BitFieldsT>& transform,
459
+ BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
438
460
  Base::template ApplyImpl<std::memory_order_acq_rel>(transform, before,
439
461
  after);
440
462
  }
441
- void Apply(AddTransform<BitFieldsT> transform, BitFieldsT* before = nullptr,
442
- BitFieldsT* after = nullptr) {
463
+ void Apply(const AddTransformer<BitFieldsT>& transform,
464
+ BitFieldsT* before = nullptr, BitFieldsT* after = nullptr) {
443
465
  Base::template ApplyImpl<std::memory_order_acq_rel>(transform, before,
444
466
  after);
445
467
  }
@@ -198,13 +198,13 @@ class FastLocalBloomImpl {
198
198
  }
199
199
 
200
200
  static inline void AddHash(uint32_t h1, uint32_t h2, uint32_t len_bytes,
201
- int num_probes, char *data) {
201
+ int num_probes, char* data) {
202
202
  uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
203
203
  AddHashPrepared(h2, num_probes, data + bytes_to_cache_line);
204
204
  }
205
205
 
206
206
  static inline void AddHashPrepared(uint32_t h2, int num_probes,
207
- char *data_at_cache_line) {
207
+ char* data_at_cache_line) {
208
208
  uint32_t h = h2;
209
209
  for (int i = 0; i < num_probes; ++i, h *= uint32_t{0x9e3779b9}) {
210
210
  // 9-bit address within 512 bit cache line
@@ -214,8 +214,8 @@ class FastLocalBloomImpl {
214
214
  }
215
215
 
216
216
  static inline void PrepareHash(uint32_t h1, uint32_t len_bytes,
217
- const char *data,
218
- uint32_t /*out*/ *byte_offset) {
217
+ const char* data,
218
+ uint32_t /*out*/* byte_offset) {
219
219
  uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
220
220
  PREFETCH(data + bytes_to_cache_line, 0 /* rw */, 1 /* locality */);
221
221
  PREFETCH(data + bytes_to_cache_line + 63, 0 /* rw */, 1 /* locality */);
@@ -223,13 +223,13 @@ class FastLocalBloomImpl {
223
223
  }
224
224
 
225
225
  static inline bool HashMayMatch(uint32_t h1, uint32_t h2, uint32_t len_bytes,
226
- int num_probes, const char *data) {
226
+ int num_probes, const char* data) {
227
227
  uint32_t bytes_to_cache_line = FastRange32(h1, len_bytes >> 6) << 6;
228
228
  return HashMayMatchPrepared(h2, num_probes, data + bytes_to_cache_line);
229
229
  }
230
230
 
231
231
  static inline bool HashMayMatchPrepared(uint32_t h2, int num_probes,
232
- const char *data_at_cache_line) {
232
+ const char* data_at_cache_line) {
233
233
  uint32_t h = h2;
234
234
  #ifdef __AVX2__
235
235
  int rem_probes = num_probes;
@@ -277,8 +277,8 @@ class FastLocalBloomImpl {
277
277
  // /*bytes / i32*/ 4);
278
278
  // END Option 1
279
279
  // Potentially unaligned as we're not *always* cache-aligned -> loadu
280
- const __m256i *mm_data =
281
- reinterpret_cast<const __m256i *>(data_at_cache_line);
280
+ const __m256i* mm_data =
281
+ reinterpret_cast<const __m256i*>(data_at_cache_line);
282
282
  __m256i lower = _mm256_loadu_si256(mm_data);
283
283
  __m256i upper = _mm256_loadu_si256(mm_data + 1);
284
284
  // Option 2: AVX512VL permute hack
@@ -362,7 +362,7 @@ class LegacyNoLocalityBloomImpl {
362
362
  }
363
363
 
364
364
  static inline void AddHash(uint32_t h, uint32_t total_bits, int num_probes,
365
- char *data) {
365
+ char* data) {
366
366
  const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
367
367
  for (int i = 0; i < num_probes; i++) {
368
368
  const uint32_t bitpos = h % total_bits;
@@ -372,7 +372,7 @@ class LegacyNoLocalityBloomImpl {
372
372
  }
373
373
 
374
374
  static inline bool HashMayMatch(uint32_t h, uint32_t total_bits,
375
- int num_probes, const char *data) {
375
+ int num_probes, const char* data) {
376
376
  const uint32_t delta = (h >> 17) | (h << 15); // Rotate right 17 bits
377
377
  for (int i = 0; i < num_probes; i++) {
378
378
  const uint32_t bitpos = h % total_bits;
@@ -430,10 +430,10 @@ class LegacyLocalityBloomImpl {
430
430
  }
431
431
 
432
432
  static inline void AddHash(uint32_t h, uint32_t num_lines, int num_probes,
433
- char *data, int log2_cache_line_bytes) {
433
+ char* data, int log2_cache_line_bytes) {
434
434
  const int log2_cache_line_bits = log2_cache_line_bytes + 3;
435
435
 
436
- char *data_at_offset =
436
+ char* data_at_offset =
437
437
  data + (GetLine(h, num_lines) << log2_cache_line_bytes);
438
438
  const uint32_t delta = (h >> 17) | (h << 15);
439
439
  for (int i = 0; i < num_probes; ++i) {
@@ -448,8 +448,8 @@ class LegacyLocalityBloomImpl {
448
448
  }
449
449
 
450
450
  static inline void PrepareHashMayMatch(uint32_t h, uint32_t num_lines,
451
- const char *data,
452
- uint32_t /*out*/ *byte_offset,
451
+ const char* data,
452
+ uint32_t /*out*/* byte_offset,
453
453
  int log2_cache_line_bytes) {
454
454
  uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
455
455
  PREFETCH(data + b, 0 /* rw */, 1 /* locality */);
@@ -459,14 +459,14 @@ class LegacyLocalityBloomImpl {
459
459
  }
460
460
 
461
461
  static inline bool HashMayMatch(uint32_t h, uint32_t num_lines,
462
- int num_probes, const char *data,
462
+ int num_probes, const char* data,
463
463
  int log2_cache_line_bytes) {
464
464
  uint32_t b = GetLine(h, num_lines) << log2_cache_line_bytes;
465
465
  return HashMayMatchPrepared(h, num_probes, data + b, log2_cache_line_bytes);
466
466
  }
467
467
 
468
468
  static inline bool HashMayMatchPrepared(uint32_t h, int num_probes,
469
- const char *data_at_offset,
469
+ const char* data_at_offset,
470
470
  int log2_cache_line_bytes) {
471
471
  const int log2_cache_line_bits = log2_cache_line_bytes + 3;
472
472
 
@@ -18,6 +18,7 @@
18
18
  #pragma once
19
19
  #include <algorithm>
20
20
  #include <string>
21
+ #include <type_traits>
21
22
 
22
23
  #include "port/port.h"
23
24
  #include "rocksdb/slice.h"
@@ -38,10 +39,9 @@ const uint32_t kMaxVarint64Length = 10;
38
39
  void PutFixed16(std::string* dst, uint16_t value);
39
40
  void PutFixed32(std::string* dst, uint32_t value);
40
41
  void PutFixed64(std::string* dst, uint64_t value);
41
- void PutVarint32(std::string* dst, uint32_t value);
42
- void PutVarint32Varint32(std::string* dst, uint32_t value1, uint32_t value2);
43
- void PutVarint32Varint32Varint32(std::string* dst, uint32_t value1,
44
- uint32_t value2, uint32_t value3);
42
+
43
+ template <typename... Args>
44
+ void PutVarint32(std::string* dst, Args... args);
45
45
  void PutVarint64(std::string* dst, uint64_t value);
46
46
  void PutVarint64Varint64(std::string* dst, uint64_t value1, uint64_t value2);
47
47
  void PutVarint32Varint64(std::string* dst, uint32_t value1, uint64_t value2);
@@ -149,25 +149,14 @@ inline void PutFixed64(std::string* dst, uint64_t value) {
149
149
  }
150
150
  }
151
151
 
152
- inline void PutVarint32(std::string* dst, uint32_t v) {
153
- char buf[5];
154
- char* ptr = EncodeVarint32(buf, v);
155
- dst->append(buf, static_cast<size_t>(ptr - buf));
156
- }
157
-
158
- inline void PutVarint32Varint32(std::string* dst, uint32_t v1, uint32_t v2) {
159
- char buf[10];
160
- char* ptr = EncodeVarint32(buf, v1);
161
- ptr = EncodeVarint32(ptr, v2);
162
- dst->append(buf, static_cast<size_t>(ptr - buf));
163
- }
164
-
165
- inline void PutVarint32Varint32Varint32(std::string* dst, uint32_t v1,
166
- uint32_t v2, uint32_t v3) {
167
- char buf[15];
168
- char* ptr = EncodeVarint32(buf, v1);
169
- ptr = EncodeVarint32(ptr, v2);
170
- ptr = EncodeVarint32(ptr, v3);
152
+ template <typename... Args>
153
+ inline void PutVarint32(std::string* dst, Args... args) {
154
+ static_assert((std::is_convertible_v<Args, uint32_t> && ...),
155
+ "All arguments must be convertible to uint32_t");
156
+ constexpr size_t kMaxBytesPerVarint32 = 5;
157
+ char buf[sizeof...(args) * kMaxBytesPerVarint32];
158
+ char* ptr = buf;
159
+ ((ptr = EncodeVarint32(ptr, static_cast<uint32_t>(args))), ...);
171
160
  dst->append(buf, static_cast<size_t>(ptr - buf));
172
161
  }
173
162
 
@@ -355,8 +344,7 @@ __attribute__((__no_sanitize__("alignment")))
355
344
  __attribute__((__no_sanitize_undefined__))
356
345
  #endif
357
346
  #endif
358
- inline void
359
- PutUnaligned(T* memory, const T& value) {
347
+ inline void PutUnaligned(T* memory, const T& value) {
360
348
  #if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
361
349
  char* nonAlignedMemory = reinterpret_cast<char*>(memory);
362
350
  memcpy(nonAlignedMemory, reinterpret_cast<const char*>(&value), sizeof(T));
@@ -373,8 +361,7 @@ __attribute__((__no_sanitize__("alignment")))
373
361
  __attribute__((__no_sanitize_undefined__))
374
362
  #endif
375
363
  #endif
376
- inline void
377
- GetUnaligned(const T* memory, T* value) {
364
+ inline void GetUnaligned(const T* memory, T* value) {
378
365
  #if defined(PLATFORM_UNALIGNED_ACCESS_NOT_ALLOWED)
379
366
  char* nonAlignedMemory = reinterpret_cast<char*>(value);
380
367
  memcpy(nonAlignedMemory, reinterpret_cast<const char*>(memory), sizeof(T));