@nxtedition/rocksdb 6.0.0 → 6.0.3

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 (488) hide show
  1. package/BUILDING.md +18 -0
  2. package/binding.cc +16 -17
  3. package/binding.gyp +2 -2
  4. package/deps/rocksdb/build_version.cc +4 -10
  5. package/deps/rocksdb/rocksdb/CMakeLists.txt +26 -3
  6. package/deps/rocksdb/rocksdb/Makefile +73 -91
  7. package/deps/rocksdb/rocksdb/TARGETS +27 -2
  8. package/deps/rocksdb/rocksdb/cache/cache_test.cc +29 -17
  9. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.cc +511 -0
  10. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.h +299 -0
  11. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +3 -0
  12. package/deps/rocksdb/rocksdb/cache/lru_cache.h +7 -0
  13. package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
  14. package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
  15. package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
  16. package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
  17. package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
  18. package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
  19. package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
  20. package/deps/rocksdb/rocksdb/cmake/modules/Finduring.cmake +26 -0
  21. package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
  22. package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
  23. package/deps/rocksdb/rocksdb/common.mk +30 -0
  24. package/deps/rocksdb/rocksdb/crash_test.mk +3 -3
  25. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +1 -1
  26. package/deps/rocksdb/rocksdb/db/blob/blob_index.h +3 -3
  27. package/deps/rocksdb/rocksdb/db/blob/db_blob_index_test.cc +7 -7
  28. package/deps/rocksdb/rocksdb/db/builder.cc +22 -7
  29. package/deps/rocksdb/rocksdb/db/c.cc +71 -0
  30. package/deps/rocksdb/rocksdb/db/c_test.c +28 -2
  31. package/deps/rocksdb/rocksdb/db/column_family.cc +12 -5
  32. package/deps/rocksdb/rocksdb/db/column_family_test.cc +23 -22
  33. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +11 -11
  34. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +2 -2
  35. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +36 -10
  36. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +4 -1
  37. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +3 -2
  38. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +54 -16
  39. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +14 -2
  40. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_stats_test.cc +3 -3
  41. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +85 -18
  42. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +7 -7
  43. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +1 -1
  44. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +23 -22
  45. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +1 -1
  46. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +151 -32
  47. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +1 -1
  48. package/deps/rocksdb/rocksdb/db/convenience.cc +8 -6
  49. package/deps/rocksdb/rocksdb/db/corruption_test.cc +209 -38
  50. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +2 -2
  51. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +404 -32
  52. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +28 -25
  53. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +85 -138
  54. package/deps/rocksdb/rocksdb/db/db_compaction_filter_test.cc +68 -3
  55. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +38 -13
  56. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +1 -1
  57. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +1 -1
  58. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +11 -20
  59. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +15 -1
  60. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +12 -9
  61. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +5 -4
  62. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +1 -1
  63. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +2 -2
  64. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +42 -10
  65. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +54 -23
  66. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +3 -0
  67. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +14 -4
  68. package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +26 -18
  69. package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +8 -7
  70. package/deps/rocksdb/rocksdb/db/db_iter_test.cc +8 -8
  71. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +6 -3
  72. package/deps/rocksdb/rocksdb/db/db_kv_checksum_test.cc +2 -2
  73. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +6 -6
  74. package/deps/rocksdb/rocksdb/db/db_memtable_test.cc +2 -2
  75. package/deps/rocksdb/rocksdb/db/db_options_test.cc +28 -12
  76. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +16 -15
  77. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +6 -4
  78. package/deps/rocksdb/rocksdb/db/db_readonly_with_timestamp_test.cc +331 -0
  79. package/deps/rocksdb/rocksdb/db/db_secondary_test.cc +11 -6
  80. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +68 -7
  81. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +6 -5
  82. package/deps/rocksdb/rocksdb/db/db_test.cc +60 -42
  83. package/deps/rocksdb/rocksdb/db/db_test2.cc +244 -111
  84. package/deps/rocksdb/rocksdb/db/db_test_util.cc +101 -19
  85. package/deps/rocksdb/rocksdb/db/db_test_util.h +52 -2
  86. package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +1 -1
  87. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +7 -7
  88. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +5 -175
  89. package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.cc +96 -0
  90. package/deps/rocksdb/rocksdb/db/db_with_timestamp_test_util.h +126 -0
  91. package/deps/rocksdb/rocksdb/db/db_write_test.cc +6 -6
  92. package/deps/rocksdb/rocksdb/db/dbformat.h +2 -1
  93. package/deps/rocksdb/rocksdb/db/deletefile_test.cc +1 -1
  94. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +8 -8
  95. package/deps/rocksdb/rocksdb/db/experimental.cc +1 -1
  96. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +91 -12
  97. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +16 -2
  98. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +2 -0
  99. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +7 -7
  100. package/deps/rocksdb/rocksdb/db/file_indexer.h +1 -4
  101. package/deps/rocksdb/rocksdb/db/flush_job.cc +28 -15
  102. package/deps/rocksdb/rocksdb/db/flush_job.h +4 -0
  103. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +98 -30
  104. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +1 -1
  105. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +14 -1
  106. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +6 -0
  107. package/deps/rocksdb/rocksdb/db/internal_stats.cc +12 -12
  108. package/deps/rocksdb/rocksdb/db/listener_test.cc +4 -3
  109. package/deps/rocksdb/rocksdb/db/memtable.cc +2 -2
  110. package/deps/rocksdb/rocksdb/db/memtable_list.h +1 -1
  111. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +37 -25
  112. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +1 -1
  113. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +18 -18
  114. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +6 -6
  115. package/deps/rocksdb/rocksdb/db/prefix_test.cc +1 -1
  116. package/deps/rocksdb/rocksdb/db/repair.cc +13 -2
  117. package/deps/rocksdb/rocksdb/db/repair_test.cc +37 -15
  118. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +1 -2
  119. package/deps/rocksdb/rocksdb/db/snapshot_impl.h +3 -1
  120. package/deps/rocksdb/rocksdb/db/table_cache.cc +20 -130
  121. package/deps/rocksdb/rocksdb/db/table_cache.h +3 -2
  122. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +140 -0
  123. package/deps/rocksdb/rocksdb/db/version_builder.cc +1 -1
  124. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +133 -133
  125. package/deps/rocksdb/rocksdb/db/version_edit.cc +22 -2
  126. package/deps/rocksdb/rocksdb/db/version_edit.h +13 -4
  127. package/deps/rocksdb/rocksdb/db/version_edit_test.cc +14 -14
  128. package/deps/rocksdb/rocksdb/db/version_set.cc +207 -214
  129. package/deps/rocksdb/rocksdb/db/version_set.h +14 -3
  130. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +154 -0
  131. package/deps/rocksdb/rocksdb/db/version_set_test.cc +10 -9
  132. package/deps/rocksdb/rocksdb/db/wal_edit.h +2 -1
  133. package/deps/rocksdb/rocksdb/db/wal_manager.cc +2 -3
  134. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +1 -1
  135. package/deps/rocksdb/rocksdb/db/write_batch.cc +178 -30
  136. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +6 -6
  137. package/deps/rocksdb/rocksdb/db/write_controller.h +1 -1
  138. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +0 -2
  139. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +9 -6
  140. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_compaction_filter.h +2 -1
  141. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +4 -3
  142. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +44 -6
  143. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.cc +4 -1
  144. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.cc +0 -10
  145. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +45 -42
  146. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +374 -275
  147. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +53 -3
  148. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +0 -12
  149. package/deps/rocksdb/rocksdb/db_stress_tool/expected_state.cc +13 -11
  150. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +276 -109
  151. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +63 -0
  152. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +45 -54
  153. package/deps/rocksdb/rocksdb/env/composite_env.cc +87 -14
  154. package/deps/rocksdb/rocksdb/env/env.cc +0 -60
  155. package/deps/rocksdb/rocksdb/env/env_encryption.cc +9 -0
  156. package/deps/rocksdb/rocksdb/env/env_encryption_ctr.h +1 -1
  157. package/deps/rocksdb/rocksdb/env/env_posix.cc +6 -5
  158. package/deps/rocksdb/rocksdb/env/env_test.cc +18 -5
  159. package/deps/rocksdb/rocksdb/env/fs_posix.cc +17 -12
  160. package/deps/rocksdb/rocksdb/env/io_posix.cc +39 -37
  161. package/deps/rocksdb/rocksdb/file/delete_scheduler_test.cc +9 -9
  162. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +159 -65
  163. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +44 -22
  164. package/deps/rocksdb/rocksdb/file/file_util.h +2 -0
  165. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +142 -17
  166. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +5 -2
  167. package/deps/rocksdb/rocksdb/file/sequence_file_reader.cc +7 -0
  168. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +60 -40
  169. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +1 -0
  170. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +23 -5
  171. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +49 -1
  172. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +5 -5
  173. package/deps/rocksdb/rocksdb/include/rocksdb/cleanable.h +59 -2
  174. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +1 -0
  175. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +2 -1
  176. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +46 -44
  177. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1 -1
  178. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +2 -0
  179. package/deps/rocksdb/rocksdb/include/rocksdb/iostats_context.h +2 -4
  180. package/deps/rocksdb/rocksdb/include/rocksdb/memtablerep.h +3 -0
  181. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +45 -3
  182. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +2 -0
  183. package/deps/rocksdb/rocksdb/include/rocksdb/snapshot.h +4 -1
  184. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +3 -0
  185. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +91 -40
  186. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +1 -2
  187. package/deps/rocksdb/rocksdb/include/rocksdb/unique_id.h +22 -13
  188. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/customizable_util.h +9 -0
  189. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +4 -0
  190. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/object_registry.h +25 -0
  191. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +378 -103
  192. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +14 -0
  193. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  194. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +18 -4
  195. package/deps/rocksdb/rocksdb/memory/arena.h +1 -1
  196. package/deps/rocksdb/rocksdb/memory/concurrent_arena.cc +1 -5
  197. package/deps/rocksdb/rocksdb/memory/concurrent_arena.h +1 -5
  198. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.cc +6 -8
  199. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +1 -1
  200. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager.cc +1 -1
  201. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager_test.cc +5 -3
  202. package/deps/rocksdb/rocksdb/microbench/db_basic_bench.cc +266 -45
  203. package/deps/rocksdb/rocksdb/monitoring/histogram.cc +2 -1
  204. package/deps/rocksdb/rocksdb/monitoring/iostats_context.cc +1 -4
  205. package/deps/rocksdb/rocksdb/monitoring/iostats_context_imp.h +4 -4
  206. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +7 -8
  207. package/deps/rocksdb/rocksdb/monitoring/perf_context_imp.h +2 -2
  208. package/deps/rocksdb/rocksdb/monitoring/perf_level.cc +1 -5
  209. package/deps/rocksdb/rocksdb/monitoring/perf_level_imp.h +1 -5
  210. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.cc +2 -2
  211. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +1 -1
  212. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.cc +2 -1
  213. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.h +1 -1
  214. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.cc +3 -3
  215. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.h +2 -2
  216. package/deps/rocksdb/rocksdb/options/cf_options.cc +47 -38
  217. package/deps/rocksdb/rocksdb/options/configurable.cc +9 -27
  218. package/deps/rocksdb/rocksdb/options/configurable_test.cc +1 -1
  219. package/deps/rocksdb/rocksdb/options/customizable.cc +3 -1
  220. package/deps/rocksdb/rocksdb/options/customizable_test.cc +379 -318
  221. package/deps/rocksdb/rocksdb/options/db_options.cc +46 -17
  222. package/deps/rocksdb/rocksdb/options/db_options.h +2 -0
  223. package/deps/rocksdb/rocksdb/options/options.cc +7 -0
  224. package/deps/rocksdb/rocksdb/options/options_helper.cc +86 -39
  225. package/deps/rocksdb/rocksdb/options/options_parser.cc +10 -10
  226. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +12 -7
  227. package/deps/rocksdb/rocksdb/options/options_test.cc +222 -68
  228. package/deps/rocksdb/rocksdb/port/port_posix.h +0 -15
  229. package/deps/rocksdb/rocksdb/port/win/env_win.cc +5 -4
  230. package/deps/rocksdb/rocksdb/port/win/env_win.h +2 -2
  231. package/deps/rocksdb/rocksdb/port/win/port_win.h +0 -31
  232. package/deps/rocksdb/rocksdb/rocksdb.pc.in +11 -0
  233. package/deps/rocksdb/rocksdb/src.mk +6 -1
  234. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +2 -1
  235. package/deps/rocksdb/rocksdb/table/block_based/block.cc +4 -2
  236. package/deps/rocksdb/rocksdb/table/block_based/block.h +21 -25
  237. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.cc +3 -4
  238. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +23 -8
  239. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +52 -15
  240. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +81 -7
  241. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +8 -2
  242. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +94 -726
  243. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +21 -15
  244. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +9 -3
  245. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +754 -0
  246. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +44 -73
  247. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +15 -5
  248. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.h +2 -1
  249. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +2 -11
  250. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +59 -1
  251. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +18 -0
  252. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +33 -17
  253. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +0 -61
  254. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +0 -13
  255. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +2 -1
  256. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +2 -2
  257. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +3 -2
  258. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +2 -1
  259. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +3 -2
  260. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.cc +4 -3
  261. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +8 -4
  262. package/deps/rocksdb/rocksdb/table/block_based/reader_common.cc +4 -4
  263. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +2 -1
  264. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +65 -7
  265. package/deps/rocksdb/rocksdb/table/block_fetcher.h +2 -0
  266. package/deps/rocksdb/rocksdb/table/cleanable_test.cc +113 -0
  267. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.cc +1 -1
  268. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.h +1 -1
  269. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader_test.cc +1 -1
  270. package/deps/rocksdb/rocksdb/table/format.cc +22 -20
  271. package/deps/rocksdb/rocksdb/table/iterator.cc +1 -81
  272. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +39 -0
  273. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +2 -2
  274. package/deps/rocksdb/rocksdb/table/multiget_context.h +60 -13
  275. package/deps/rocksdb/rocksdb/table/persistent_cache_options.h +0 -3
  276. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.cc +12 -1
  277. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.cc +4 -4
  278. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +2 -1
  279. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +1 -1
  280. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +1 -1
  281. package/deps/rocksdb/rocksdb/table/table_properties.cc +3 -5
  282. package/deps/rocksdb/rocksdb/table/table_reader.h +13 -0
  283. package/deps/rocksdb/rocksdb/table/table_test.cc +202 -78
  284. package/deps/rocksdb/rocksdb/table/unique_id.cc +84 -25
  285. package/deps/rocksdb/rocksdb/table/unique_id_impl.h +37 -4
  286. package/deps/rocksdb/rocksdb/test_util/testutil.cc +3 -1
  287. package/deps/rocksdb/rocksdb/test_util/testutil.h +11 -8
  288. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.cc +8 -4
  289. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.h +17 -0
  290. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.cc +11 -9
  291. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +3 -3
  292. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +277 -105
  293. package/deps/rocksdb/rocksdb/tools/db_sanity_test.cc +4 -4
  294. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +186 -42
  295. package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +75 -49
  296. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +9 -8
  297. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +4 -1
  298. package/deps/rocksdb/rocksdb/tools/reduce_levels_test.cc +2 -2
  299. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +26 -4
  300. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.cc +1 -1
  301. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.h +1 -1
  302. package/deps/rocksdb/rocksdb/util/async_file_reader.cc +72 -0
  303. package/deps/rocksdb/rocksdb/util/async_file_reader.h +144 -0
  304. package/deps/rocksdb/rocksdb/util/autovector_test.cc +4 -4
  305. package/deps/rocksdb/rocksdb/util/bloom_test.cc +14 -8
  306. package/deps/rocksdb/rocksdb/util/build_version.cc.in +5 -6
  307. package/deps/rocksdb/rocksdb/util/cleanable.cc +180 -0
  308. package/deps/rocksdb/rocksdb/util/comparator.cc +5 -3
  309. package/deps/rocksdb/rocksdb/util/compression.h +56 -7
  310. package/deps/rocksdb/rocksdb/util/coro_utils.h +111 -0
  311. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +148 -0
  312. package/deps/rocksdb/rocksdb/util/filelock_test.cc +2 -2
  313. package/deps/rocksdb/rocksdb/util/filter_bench.cc +12 -4
  314. package/deps/rocksdb/rocksdb/util/heap.h +5 -3
  315. package/deps/rocksdb/rocksdb/util/random.cc +1 -5
  316. package/deps/rocksdb/rocksdb/util/rate_limiter.cc +12 -9
  317. package/deps/rocksdb/rocksdb/util/rate_limiter_test.cc +1 -1
  318. package/deps/rocksdb/rocksdb/util/ribbon_alg.h +1 -1
  319. package/deps/rocksdb/rocksdb/util/ribbon_test.cc +2 -4
  320. package/deps/rocksdb/rocksdb/util/single_thread_executor.h +55 -0
  321. package/deps/rocksdb/rocksdb/util/slice.cc +8 -9
  322. package/deps/rocksdb/rocksdb/util/string_util.cc +3 -2
  323. package/deps/rocksdb/rocksdb/util/string_util.h +0 -13
  324. package/deps/rocksdb/rocksdb/util/thread_local.cc +4 -23
  325. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +99 -22
  326. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_impl.h +7 -0
  327. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +102 -59
  328. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_test.cc +38 -36
  329. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +2 -2
  330. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +28 -0
  331. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +3 -0
  332. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +1 -1
  333. package/deps/rocksdb/rocksdb/utilities/object_registry.cc +71 -0
  334. package/deps/rocksdb/rocksdb/utilities/object_registry_test.cc +71 -0
  335. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +1 -1
  336. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache_test.cc +5 -5
  337. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +3 -3
  338. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.cc +0 -13
  339. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_locking_test.cc +40 -0
  340. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc +10 -8
  341. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.h +4 -2
  342. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +17 -0
  343. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc +7 -7
  344. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +8 -1
  345. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +5 -1
  346. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +21 -15
  347. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.cc +2 -2
  348. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +69 -11
  349. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +22 -9
  350. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +26 -5
  351. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -4
  352. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_transaction_test.cc +19 -16
  353. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +7 -3
  354. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +3 -2
  355. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +2 -2
  356. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +2 -2
  357. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +6 -6
  358. package/deps/rocksdb/rocksdb.gyp +47 -37
  359. package/package-lock.json +23687 -0
  360. package/package.json +2 -30
  361. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  362. package/prebuilds/darwin-x64/node.napi.node +0 -0
  363. package/prebuilds/linux-x64/node.napi.node +0 -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/linux-arm64/node.napi.node +0 -0
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include <algorithm>
12
12
  #include <array>
13
+ #include <cstdint>
13
14
  #include <limits>
14
15
  #include <memory>
15
16
  #include <string>
@@ -73,6 +74,31 @@
73
74
  #include "util/stop_watch.h"
74
75
  #include "util/string_util.h"
75
76
 
77
+ namespace ROCKSDB_NAMESPACE {
78
+ namespace {
79
+
80
+ CacheAllocationPtr CopyBufferToHeap(MemoryAllocator* allocator, Slice& buf) {
81
+ CacheAllocationPtr heap_buf;
82
+ heap_buf = AllocateBlock(buf.size(), allocator);
83
+ memcpy(heap_buf.get(), buf.data(), buf.size());
84
+ return heap_buf;
85
+ }
86
+ } // namespace
87
+ } // namespace ROCKSDB_NAMESPACE
88
+
89
+ // Generate the regular and coroutine versions of some methods by
90
+ // including block_based_table_reader_sync_and_async.h twice
91
+ // Macros in the header will expand differently based on whether
92
+ // WITH_COROUTINES or WITHOUT_COROUTINES is defined
93
+ // clang-format off
94
+ #define WITHOUT_COROUTINES
95
+ #include "table/block_based/block_based_table_reader_sync_and_async.h"
96
+ #undef WITHOUT_COROUTINES
97
+ #define WITH_COROUTINES
98
+ #include "table/block_based/block_based_table_reader_sync_and_async.h"
99
+ #undef WITH_COROUTINES
100
+ // clang-format on
101
+
76
102
  namespace ROCKSDB_NAMESPACE {
77
103
 
78
104
  extern const uint64_t kBlockBasedTableMagicNumber;
@@ -99,7 +125,7 @@ Status ReadBlockFromFile(
99
125
  const UncompressionDict& uncompression_dict,
100
126
  const PersistentCacheOptions& cache_options, size_t read_amp_bytes_per_bit,
101
127
  MemoryAllocator* memory_allocator, bool for_compaction, bool using_zstd,
102
- const FilterPolicy* filter_policy) {
128
+ const FilterPolicy* filter_policy, bool async_read) {
103
129
  assert(result);
104
130
 
105
131
  BlockContents contents;
@@ -107,7 +133,17 @@ Status ReadBlockFromFile(
107
133
  file, prefetch_buffer, footer, options, handle, &contents, ioptions,
108
134
  do_uncompress, maybe_compressed, block_type, uncompression_dict,
109
135
  cache_options, memory_allocator, nullptr, for_compaction);
110
- Status s = block_fetcher.ReadBlockContents();
136
+ Status s;
137
+ // If prefetch_buffer is not allocated, it will fallback to synchronous
138
+ // reading of block contents.
139
+ if (async_read && prefetch_buffer != nullptr) {
140
+ s = block_fetcher.ReadAsyncBlockContents();
141
+ if (!s.ok()) {
142
+ return s;
143
+ }
144
+ } else {
145
+ s = block_fetcher.ReadBlockContents();
146
+ }
111
147
  if (s.ok()) {
112
148
  result->reset(BlocklikeTraits<TBlocklike>::Create(
113
149
  std::move(contents), read_amp_bytes_per_bit, ioptions.stats, using_zstd,
@@ -117,14 +153,6 @@ Status ReadBlockFromFile(
117
153
  return s;
118
154
  }
119
155
 
120
- // Release the cached entry and decrement its ref count.
121
- // Do not force erase
122
- void ReleaseCachedEntry(void* arg, void* h) {
123
- Cache* cache = reinterpret_cast<Cache*>(arg);
124
- Cache::Handle* handle = reinterpret_cast<Cache::Handle*>(h);
125
- cache->Release(handle, false /* erase_if_last_ref */);
126
- }
127
-
128
156
  // For hash based index, return false if table_properties->prefix_extractor_name
129
157
  // and prefix_extractor both exist and match, otherwise true.
130
158
  inline bool PrefixExtractorChangedHelper(
@@ -146,12 +174,6 @@ inline bool PrefixExtractorChangedHelper(
146
174
  }
147
175
  }
148
176
 
149
- CacheAllocationPtr CopyBufferToHeap(MemoryAllocator* allocator, Slice& buf) {
150
- CacheAllocationPtr heap_buf;
151
- heap_buf = AllocateBlock(buf.size(), allocator);
152
- memcpy(heap_buf.get(), buf.data(), buf.size());
153
- return heap_buf;
154
- }
155
177
  } // namespace
156
178
 
157
179
  void BlockBasedTable::UpdateCacheHitMetrics(BlockType block_type,
@@ -568,7 +590,7 @@ Status BlockBasedTable::Open(
568
590
  Footer footer;
569
591
  std::unique_ptr<FilePrefetchBuffer> prefetch_buffer;
570
592
 
571
- // Only retain read_options.deadline and read_options.io_timeout.
593
+ // From read_options, retain deadline, io_timeout, and rate_limiter_priority.
572
594
  // In future, we may retain more
573
595
  // options. Specifically, w ignore verify_checksums and default to
574
596
  // checksum verification anyway when creating the index and filter
@@ -576,6 +598,7 @@ Status BlockBasedTable::Open(
576
598
  ReadOptions ro;
577
599
  ro.deadline = read_options.deadline;
578
600
  ro.io_timeout = read_options.io_timeout;
601
+ ro.rate_limiter_priority = read_options.rate_limiter_priority;
579
602
 
580
603
  // prefetch both index and filters, down to all partitions
581
604
  const bool prefetch_all = prefetch_index_and_filter_in_cache || level == 0;
@@ -725,7 +748,10 @@ Status BlockBasedTable::Open(
725
748
  mem_usage, &(rep->table_reader_cache_res_handle));
726
749
  if (s.IsIncomplete()) {
727
750
  s = Status::MemoryLimit(
728
- "Can't allocate BlockBasedTableReader due to memory limit based on "
751
+ "Can't allocate " +
752
+ kCacheEntryRoleToCamelString[static_cast<std::uint32_t>(
753
+ CacheEntryRole::kBlockBasedTableReader)] +
754
+ " due to memory limit based on "
729
755
  "cache capacity for memory allocation");
730
756
  }
731
757
  }
@@ -770,7 +796,8 @@ Status BlockBasedTable::PrefetchTail(
770
796
 
771
797
  // Try file system prefetch
772
798
  if (!file->use_direct_io() && !force_direct_prefetch) {
773
- if (!file->Prefetch(prefetch_off, prefetch_len).IsNotSupported()) {
799
+ if (!file->Prefetch(prefetch_off, prefetch_len, ro.rate_limiter_priority)
800
+ .IsNotSupported()) {
774
801
  prefetch_buffer->reset(new FilePrefetchBuffer(
775
802
  0 /* readahead_size */, 0 /* max_readahead_size */,
776
803
  false /* enable */, true /* track_min_offset */));
@@ -782,6 +809,7 @@ Status BlockBasedTable::PrefetchTail(
782
809
  prefetch_buffer->reset(
783
810
  new FilePrefetchBuffer(0 /* readahead_size */, 0 /* max_readahead_size */,
784
811
  true /* enable */, true /* track_min_offset */));
812
+
785
813
  IOOptions opts;
786
814
  Status s = file->PrepareIOOptions(ro, opts);
787
815
  if (s.ok()) {
@@ -886,10 +914,12 @@ Status BlockBasedTable::ReadRangeDelBlock(
886
914
  "Error when seeking to range delete tombstones block from file: %s",
887
915
  s.ToString().c_str());
888
916
  } else if (!range_del_handle.IsNull()) {
917
+ Status tmp_status;
889
918
  std::unique_ptr<InternalIterator> iter(NewDataBlockIterator<DataBlockIter>(
890
919
  read_options, range_del_handle,
891
920
  /*input_iter=*/nullptr, BlockType::kRangeDeletion,
892
- /*get_context=*/nullptr, lookup_context, Status(), prefetch_buffer));
921
+ /*get_context=*/nullptr, lookup_context, prefetch_buffer,
922
+ /*for_compaction= */ false, /*async_read= */ false, tmp_status));
893
923
  assert(iter != nullptr);
894
924
  s = iter->status();
895
925
  if (!s.ok()) {
@@ -1159,7 +1189,7 @@ Status BlockBasedTable::ReadMetaIndexBlock(
1159
1189
  UncompressionDict::GetEmptyDict(), rep_->persistent_cache_options,
1160
1190
  0 /* read_amp_bytes_per_bit */, GetMemoryAllocator(rep_->table_options),
1161
1191
  false /* for_compaction */, rep_->blocks_definitely_zstd_compressed,
1162
- nullptr /* filter_policy */);
1192
+ nullptr /* filter_policy */, false /* async_read */);
1163
1193
 
1164
1194
  if (!s.ok()) {
1165
1195
  ROCKS_LOG_ERROR(rep_->ioptions.logger,
@@ -1490,7 +1520,7 @@ Status BlockBasedTable::MaybeReadBlockAndLoadToCache(
1490
1520
  const bool wait, const bool for_compaction,
1491
1521
  CachableEntry<TBlocklike>* block_entry, BlockType block_type,
1492
1522
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
1493
- BlockContents* contents) const {
1523
+ BlockContents* contents, bool async_read) const {
1494
1524
  assert(block_entry != nullptr);
1495
1525
  const bool no_io = (ro.read_tier == kBlockCacheTier);
1496
1526
  Cache* block_cache = rep_->table_options.block_cache.get();
@@ -1553,7 +1583,18 @@ Status BlockBasedTable::MaybeReadBlockAndLoadToCache(
1553
1583
  rep_->persistent_cache_options,
1554
1584
  GetMemoryAllocator(rep_->table_options),
1555
1585
  GetMemoryAllocatorForCompressedBlock(rep_->table_options));
1556
- s = block_fetcher.ReadBlockContents();
1586
+
1587
+ // If prefetch_buffer is not allocated, it will fallback to synchronous
1588
+ // reading of block contents.
1589
+ if (async_read && prefetch_buffer != nullptr) {
1590
+ s = block_fetcher.ReadAsyncBlockContents();
1591
+ if (!s.ok()) {
1592
+ return s;
1593
+ }
1594
+ } else {
1595
+ s = block_fetcher.ReadBlockContents();
1596
+ }
1597
+
1557
1598
  raw_block_comp_type = block_fetcher.get_compression_type();
1558
1599
  contents = &raw_block_contents;
1559
1600
  if (get_context) {
@@ -1654,304 +1695,14 @@ Status BlockBasedTable::MaybeReadBlockAndLoadToCache(
1654
1695
  return s;
1655
1696
  }
1656
1697
 
1657
- // This function reads multiple data blocks from disk using Env::MultiRead()
1658
- // and optionally inserts them into the block cache. It uses the scratch
1659
- // buffer provided by the caller, which is contiguous. If scratch is a nullptr
1660
- // it allocates a separate buffer for each block. Typically, if the blocks
1661
- // need to be uncompressed and there is no compressed block cache, callers
1662
- // can allocate a temporary scratch buffer in order to minimize memory
1663
- // allocations.
1664
- // If options.fill_cache is true, it inserts the blocks into cache. If its
1665
- // false and scratch is non-null and the blocks are uncompressed, it copies
1666
- // the buffers to heap. In any case, the CachableEntry<Block> returned will
1667
- // own the data bytes.
1668
- // If compression is enabled and also there is no compressed block cache,
1669
- // the adjacent blocks are read out in one IO (combined read)
1670
- // batch - A MultiGetRange with only those keys with unique data blocks not
1671
- // found in cache
1672
- // handles - A vector of block handles. Some of them me be NULL handles
1673
- // scratch - An optional contiguous buffer to read compressed blocks into
1674
- void BlockBasedTable::RetrieveMultipleBlocks(
1675
- const ReadOptions& options, const MultiGetRange* batch,
1676
- const autovector<BlockHandle, MultiGetContext::MAX_BATCH_SIZE>* handles,
1677
- autovector<Status, MultiGetContext::MAX_BATCH_SIZE>* statuses,
1678
- autovector<CachableEntry<Block>, MultiGetContext::MAX_BATCH_SIZE>* results,
1679
- char* scratch, const UncompressionDict& uncompression_dict) const {
1680
- RandomAccessFileReader* file = rep_->file.get();
1681
- const Footer& footer = rep_->footer;
1682
- const ImmutableOptions& ioptions = rep_->ioptions;
1683
- size_t read_amp_bytes_per_bit = rep_->table_options.read_amp_bytes_per_bit;
1684
- MemoryAllocator* memory_allocator = GetMemoryAllocator(rep_->table_options);
1685
-
1686
- if (ioptions.allow_mmap_reads) {
1687
- size_t idx_in_batch = 0;
1688
- for (auto mget_iter = batch->begin(); mget_iter != batch->end();
1689
- ++mget_iter, ++idx_in_batch) {
1690
- BlockCacheLookupContext lookup_data_block_context(
1691
- TableReaderCaller::kUserMultiGet);
1692
- const BlockHandle& handle = (*handles)[idx_in_batch];
1693
- if (handle.IsNull()) {
1694
- continue;
1695
- }
1696
-
1697
- (*statuses)[idx_in_batch] =
1698
- RetrieveBlock(nullptr, options, handle, uncompression_dict,
1699
- &(*results)[idx_in_batch], BlockType::kData,
1700
- mget_iter->get_context, &lookup_data_block_context,
1701
- /* for_compaction */ false, /* use_cache */ true,
1702
- /* wait_for_cache */ true);
1703
- }
1704
- return;
1705
- }
1706
-
1707
- // In direct IO mode, blocks share the direct io buffer.
1708
- // Otherwise, blocks share the scratch buffer.
1709
- const bool use_shared_buffer = file->use_direct_io() || scratch != nullptr;
1710
-
1711
- autovector<FSReadRequest, MultiGetContext::MAX_BATCH_SIZE> read_reqs;
1712
- size_t buf_offset = 0;
1713
- size_t idx_in_batch = 0;
1714
-
1715
- uint64_t prev_offset = 0;
1716
- size_t prev_len = 0;
1717
- autovector<size_t, MultiGetContext::MAX_BATCH_SIZE> req_idx_for_block;
1718
- autovector<size_t, MultiGetContext::MAX_BATCH_SIZE> req_offset_for_block;
1719
- for (auto mget_iter = batch->begin(); mget_iter != batch->end();
1720
- ++mget_iter, ++idx_in_batch) {
1721
- const BlockHandle& handle = (*handles)[idx_in_batch];
1722
- if (handle.IsNull()) {
1723
- continue;
1724
- }
1725
-
1726
- size_t prev_end = static_cast<size_t>(prev_offset) + prev_len;
1727
-
1728
- // If current block is adjacent to the previous one, at the same time,
1729
- // compression is enabled and there is no compressed cache, we combine
1730
- // the two block read as one.
1731
- // We don't combine block reads here in direct IO mode, because when doing
1732
- // direct IO read, the block requests will be realigned and merged when
1733
- // necessary.
1734
- if (use_shared_buffer && !file->use_direct_io() &&
1735
- prev_end == handle.offset()) {
1736
- req_offset_for_block.emplace_back(prev_len);
1737
- prev_len += BlockSizeWithTrailer(handle);
1738
- } else {
1739
- // No compression or current block and previous one is not adjacent:
1740
- // Step 1, create a new request for previous blocks
1741
- if (prev_len != 0) {
1742
- FSReadRequest req;
1743
- req.offset = prev_offset;
1744
- req.len = prev_len;
1745
- if (file->use_direct_io()) {
1746
- req.scratch = nullptr;
1747
- } else if (use_shared_buffer) {
1748
- req.scratch = scratch + buf_offset;
1749
- buf_offset += req.len;
1750
- } else {
1751
- req.scratch = new char[req.len];
1752
- }
1753
- read_reqs.emplace_back(req);
1754
- }
1755
-
1756
- // Step 2, remeber the previous block info
1757
- prev_offset = handle.offset();
1758
- prev_len = BlockSizeWithTrailer(handle);
1759
- req_offset_for_block.emplace_back(0);
1760
- }
1761
- req_idx_for_block.emplace_back(read_reqs.size());
1762
-
1763
- PERF_COUNTER_ADD(block_read_count, 1);
1764
- PERF_COUNTER_ADD(block_read_byte, BlockSizeWithTrailer(handle));
1765
- }
1766
- // Handle the last block and process the pending last request
1767
- if (prev_len != 0) {
1768
- FSReadRequest req;
1769
- req.offset = prev_offset;
1770
- req.len = prev_len;
1771
- if (file->use_direct_io()) {
1772
- req.scratch = nullptr;
1773
- } else if (use_shared_buffer) {
1774
- req.scratch = scratch + buf_offset;
1775
- } else {
1776
- req.scratch = new char[req.len];
1777
- }
1778
- read_reqs.emplace_back(req);
1779
- }
1780
-
1781
- AlignedBuf direct_io_buf;
1782
- {
1783
- IOOptions opts;
1784
- IOStatus s = file->PrepareIOOptions(options, opts);
1785
- if (s.ok()) {
1786
- s = file->MultiRead(opts, &read_reqs[0], read_reqs.size(), &direct_io_buf,
1787
- options.rate_limiter_priority);
1788
- }
1789
- if (!s.ok()) {
1790
- // Discard all the results in this batch if there is any time out
1791
- // or overall MultiRead error
1792
- for (FSReadRequest& req : read_reqs) {
1793
- req.status = s;
1794
- }
1795
- }
1796
- }
1797
-
1798
- idx_in_batch = 0;
1799
- size_t valid_batch_idx = 0;
1800
- for (auto mget_iter = batch->begin(); mget_iter != batch->end();
1801
- ++mget_iter, ++idx_in_batch) {
1802
- const BlockHandle& handle = (*handles)[idx_in_batch];
1803
-
1804
- if (handle.IsNull()) {
1805
- continue;
1806
- }
1807
-
1808
- assert(valid_batch_idx < req_idx_for_block.size());
1809
- assert(valid_batch_idx < req_offset_for_block.size());
1810
- assert(req_idx_for_block[valid_batch_idx] < read_reqs.size());
1811
- size_t& req_idx = req_idx_for_block[valid_batch_idx];
1812
- size_t& req_offset = req_offset_for_block[valid_batch_idx];
1813
- valid_batch_idx++;
1814
- if (mget_iter->get_context) {
1815
- ++(mget_iter->get_context->get_context_stats_.num_data_read);
1816
- }
1817
- FSReadRequest& req = read_reqs[req_idx];
1818
- Status s = req.status;
1819
- if (s.ok()) {
1820
- if ((req.result.size() != req.len) ||
1821
- (req_offset + BlockSizeWithTrailer(handle) > req.result.size())) {
1822
- s = Status::Corruption(
1823
- "truncated block read from " + rep_->file->file_name() +
1824
- " offset " + ToString(handle.offset()) + ", expected " +
1825
- ToString(req.len) + " bytes, got " + ToString(req.result.size()));
1826
- }
1827
- }
1828
-
1829
- BlockContents raw_block_contents;
1830
- if (s.ok()) {
1831
- if (!use_shared_buffer) {
1832
- // We allocated a buffer for this block. Give ownership of it to
1833
- // BlockContents so it can free the memory
1834
- assert(req.result.data() == req.scratch);
1835
- assert(req.result.size() == BlockSizeWithTrailer(handle));
1836
- assert(req_offset == 0);
1837
- std::unique_ptr<char[]> raw_block(req.scratch);
1838
- raw_block_contents = BlockContents(std::move(raw_block), handle.size());
1839
- } else {
1840
- // We used the scratch buffer or direct io buffer
1841
- // which are shared by the blocks.
1842
- // raw_block_contents does not have the ownership.
1843
- raw_block_contents =
1844
- BlockContents(Slice(req.result.data() + req_offset, handle.size()));
1845
- }
1846
- #ifndef NDEBUG
1847
- raw_block_contents.is_raw_block = true;
1848
- #endif
1849
-
1850
- if (options.verify_checksums) {
1851
- PERF_TIMER_GUARD(block_checksum_time);
1852
- const char* data = req.result.data();
1853
- // Since the scratch might be shared, the offset of the data block in
1854
- // the buffer might not be 0. req.result.data() only point to the
1855
- // begin address of each read request, we need to add the offset
1856
- // in each read request. Checksum is stored in the block trailer,
1857
- // beyond the payload size.
1858
- s = VerifyBlockChecksum(footer.checksum_type(), data + req_offset,
1859
- handle.size(), rep_->file->file_name(),
1860
- handle.offset());
1861
- TEST_SYNC_POINT_CALLBACK("RetrieveMultipleBlocks:VerifyChecksum", &s);
1862
- }
1863
- } else if (!use_shared_buffer) {
1864
- // Free the allocated scratch buffer.
1865
- delete[] req.scratch;
1866
- }
1867
-
1868
- if (s.ok()) {
1869
- // When the blocks share the same underlying buffer (scratch or direct io
1870
- // buffer), we may need to manually copy the block into heap if the raw
1871
- // block has to be inserted into a cache. That falls into th following
1872
- // cases -
1873
- // 1. Raw block is not compressed, it needs to be inserted into the
1874
- // uncompressed block cache if there is one
1875
- // 2. If the raw block is compressed, it needs to be inserted into the
1876
- // compressed block cache if there is one
1877
- //
1878
- // In all other cases, the raw block is either uncompressed into a heap
1879
- // buffer or there is no cache at all.
1880
- CompressionType compression_type =
1881
- GetBlockCompressionType(raw_block_contents);
1882
- if (use_shared_buffer && (compression_type == kNoCompression ||
1883
- (compression_type != kNoCompression &&
1884
- rep_->table_options.block_cache_compressed))) {
1885
- Slice raw =
1886
- Slice(req.result.data() + req_offset, BlockSizeWithTrailer(handle));
1887
- raw_block_contents = BlockContents(
1888
- CopyBufferToHeap(GetMemoryAllocator(rep_->table_options), raw),
1889
- handle.size());
1890
- #ifndef NDEBUG
1891
- raw_block_contents.is_raw_block = true;
1892
- #endif
1893
- }
1894
- }
1895
-
1896
- if (s.ok()) {
1897
- if (options.fill_cache) {
1898
- BlockCacheLookupContext lookup_data_block_context(
1899
- TableReaderCaller::kUserMultiGet);
1900
- CachableEntry<Block>* block_entry = &(*results)[idx_in_batch];
1901
- // MaybeReadBlockAndLoadToCache will insert into the block caches if
1902
- // necessary. Since we're passing the raw block contents, it will
1903
- // avoid looking up the block cache
1904
- s = MaybeReadBlockAndLoadToCache(
1905
- nullptr, options, handle, uncompression_dict, /*wait=*/true,
1906
- /*for_compaction=*/false, block_entry, BlockType::kData,
1907
- mget_iter->get_context, &lookup_data_block_context,
1908
- &raw_block_contents);
1909
-
1910
- // block_entry value could be null if no block cache is present, i.e
1911
- // BlockBasedTableOptions::no_block_cache is true and no compressed
1912
- // block cache is configured. In that case, fall
1913
- // through and set up the block explicitly
1914
- if (block_entry->GetValue() != nullptr) {
1915
- s.PermitUncheckedError();
1916
- continue;
1917
- }
1918
- }
1919
-
1920
- CompressionType compression_type =
1921
- GetBlockCompressionType(raw_block_contents);
1922
- BlockContents contents;
1923
- if (compression_type != kNoCompression) {
1924
- UncompressionContext context(compression_type);
1925
- UncompressionInfo info(context, uncompression_dict, compression_type);
1926
- s = UncompressBlockContents(
1927
- info, req.result.data() + req_offset, handle.size(), &contents,
1928
- footer.format_version(), rep_->ioptions, memory_allocator);
1929
- } else {
1930
- // There are two cases here:
1931
- // 1) caller uses the shared buffer (scratch or direct io buffer);
1932
- // 2) we use the requst buffer.
1933
- // If scratch buffer or direct io buffer is used, we ensure that
1934
- // all raw blocks are copyed to the heap as single blocks. If scratch
1935
- // buffer is not used, we also have no combined read, so the raw
1936
- // block can be used directly.
1937
- contents = std::move(raw_block_contents);
1938
- }
1939
- if (s.ok()) {
1940
- (*results)[idx_in_batch].SetOwnedValue(new Block(
1941
- std::move(contents), read_amp_bytes_per_bit, ioptions.stats));
1942
- }
1943
- }
1944
- (*statuses)[idx_in_batch] = s;
1945
- }
1946
- }
1947
-
1948
1698
  template <typename TBlocklike>
1949
1699
  Status BlockBasedTable::RetrieveBlock(
1950
1700
  FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
1951
1701
  const BlockHandle& handle, const UncompressionDict& uncompression_dict,
1952
1702
  CachableEntry<TBlocklike>* block_entry, BlockType block_type,
1953
1703
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
1954
- bool for_compaction, bool use_cache, bool wait_for_cache) const {
1704
+ bool for_compaction, bool use_cache, bool wait_for_cache,
1705
+ bool async_read) const {
1955
1706
  assert(block_entry);
1956
1707
  assert(block_entry->IsEmpty());
1957
1708
 
@@ -1960,7 +1711,7 @@ Status BlockBasedTable::RetrieveBlock(
1960
1711
  s = MaybeReadBlockAndLoadToCache(
1961
1712
  prefetch_buffer, ro, handle, uncompression_dict, wait_for_cache,
1962
1713
  for_compaction, block_entry, block_type, get_context, lookup_context,
1963
- /*contents=*/nullptr);
1714
+ /*contents=*/nullptr, async_read);
1964
1715
 
1965
1716
  if (!s.ok()) {
1966
1717
  return s;
@@ -2000,7 +1751,7 @@ Status BlockBasedTable::RetrieveBlock(
2000
1751
  : 0,
2001
1752
  GetMemoryAllocator(rep_->table_options), for_compaction,
2002
1753
  rep_->blocks_definitely_zstd_compressed,
2003
- rep_->table_options.filter_policy.get());
1754
+ rep_->table_options.filter_policy.get(), async_read);
2004
1755
 
2005
1756
  if (get_context) {
2006
1757
  switch (block_type) {
@@ -2036,28 +1787,32 @@ template Status BlockBasedTable::RetrieveBlock<BlockContents>(
2036
1787
  const BlockHandle& handle, const UncompressionDict& uncompression_dict,
2037
1788
  CachableEntry<BlockContents>* block_entry, BlockType block_type,
2038
1789
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
2039
- bool for_compaction, bool use_cache, bool wait_for_cache) const;
1790
+ bool for_compaction, bool use_cache, bool wait_for_cache,
1791
+ bool async_read) const;
2040
1792
 
2041
1793
  template Status BlockBasedTable::RetrieveBlock<ParsedFullFilterBlock>(
2042
1794
  FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
2043
1795
  const BlockHandle& handle, const UncompressionDict& uncompression_dict,
2044
1796
  CachableEntry<ParsedFullFilterBlock>* block_entry, BlockType block_type,
2045
1797
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
2046
- bool for_compaction, bool use_cache, bool wait_for_cache) const;
1798
+ bool for_compaction, bool use_cache, bool wait_for_cache,
1799
+ bool async_read) const;
2047
1800
 
2048
1801
  template Status BlockBasedTable::RetrieveBlock<Block>(
2049
1802
  FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
2050
1803
  const BlockHandle& handle, const UncompressionDict& uncompression_dict,
2051
1804
  CachableEntry<Block>* block_entry, BlockType block_type,
2052
1805
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
2053
- bool for_compaction, bool use_cache, bool wait_for_cache) const;
1806
+ bool for_compaction, bool use_cache, bool wait_for_cache,
1807
+ bool async_read) const;
2054
1808
 
2055
1809
  template Status BlockBasedTable::RetrieveBlock<UncompressionDict>(
2056
1810
  FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
2057
1811
  const BlockHandle& handle, const UncompressionDict& uncompression_dict,
2058
1812
  CachableEntry<UncompressionDict>* block_entry, BlockType block_type,
2059
1813
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
2060
- bool for_compaction, bool use_cache, bool wait_for_cache) const;
1814
+ bool for_compaction, bool use_cache, bool wait_for_cache,
1815
+ bool async_read) const;
2061
1816
 
2062
1817
  BlockBasedTable::PartitionedIndexIteratorState::PartitionedIndexIteratorState(
2063
1818
  const BlockBasedTable* table,
@@ -2426,10 +2181,11 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
2426
2181
  bool does_referenced_key_exist = false;
2427
2182
  DataBlockIter biter;
2428
2183
  uint64_t referenced_data_size = 0;
2184
+ Status tmp_status;
2429
2185
  NewDataBlockIterator<DataBlockIter>(
2430
2186
  read_options, v.handle, &biter, BlockType::kData, get_context,
2431
- &lookup_data_block_context,
2432
- /*s=*/Status(), /*prefetch_buffer*/ nullptr);
2187
+ &lookup_data_block_context, /*prefetch_buffer=*/nullptr,
2188
+ /*for_compaction=*/false, /*async_read=*/false, tmp_status);
2433
2189
 
2434
2190
  if (no_io && biter.status().IsIncomplete()) {
2435
2191
  // couldn't get block from block_cache
@@ -2525,399 +2281,6 @@ Status BlockBasedTable::Get(const ReadOptions& read_options, const Slice& key,
2525
2281
  return s;
2526
2282
  }
2527
2283
 
2528
- using MultiGetRange = MultiGetContext::Range;
2529
- void BlockBasedTable::MultiGet(const ReadOptions& read_options,
2530
- const MultiGetRange* mget_range,
2531
- const SliceTransform* prefix_extractor,
2532
- bool skip_filters) {
2533
- if (mget_range->empty()) {
2534
- // Caller should ensure non-empty (performance bug)
2535
- assert(false);
2536
- return; // Nothing to do
2537
- }
2538
-
2539
- FilterBlockReader* const filter =
2540
- !skip_filters ? rep_->filter.get() : nullptr;
2541
- MultiGetRange sst_file_range(*mget_range, mget_range->begin(),
2542
- mget_range->end());
2543
-
2544
- // First check the full filter
2545
- // If full filter not useful, Then go into each block
2546
- const bool no_io = read_options.read_tier == kBlockCacheTier;
2547
- uint64_t tracing_mget_id = BlockCacheTraceHelper::kReservedGetId;
2548
- if (sst_file_range.begin()->get_context) {
2549
- tracing_mget_id = sst_file_range.begin()->get_context->get_tracing_get_id();
2550
- }
2551
- BlockCacheLookupContext lookup_context{
2552
- TableReaderCaller::kUserMultiGet, tracing_mget_id,
2553
- /*get_from_user_specified_snapshot=*/read_options.snapshot != nullptr};
2554
- FullFilterKeysMayMatch(filter, &sst_file_range, no_io, prefix_extractor,
2555
- &lookup_context);
2556
-
2557
- if (!sst_file_range.empty()) {
2558
- IndexBlockIter iiter_on_stack;
2559
- // if prefix_extractor found in block differs from options, disable
2560
- // BlockPrefixIndex. Only do this check when index_type is kHashSearch.
2561
- bool need_upper_bound_check = false;
2562
- if (rep_->index_type == BlockBasedTableOptions::kHashSearch) {
2563
- need_upper_bound_check = PrefixExtractorChanged(prefix_extractor);
2564
- }
2565
- auto iiter =
2566
- NewIndexIterator(read_options, need_upper_bound_check, &iiter_on_stack,
2567
- sst_file_range.begin()->get_context, &lookup_context);
2568
- std::unique_ptr<InternalIteratorBase<IndexValue>> iiter_unique_ptr;
2569
- if (iiter != &iiter_on_stack) {
2570
- iiter_unique_ptr.reset(iiter);
2571
- }
2572
-
2573
- uint64_t offset = std::numeric_limits<uint64_t>::max();
2574
- autovector<BlockHandle, MultiGetContext::MAX_BATCH_SIZE> block_handles;
2575
- autovector<CachableEntry<Block>, MultiGetContext::MAX_BATCH_SIZE> results;
2576
- autovector<Status, MultiGetContext::MAX_BATCH_SIZE> statuses;
2577
- char stack_buf[kMultiGetReadStackBufSize];
2578
- std::unique_ptr<char[]> block_buf;
2579
- {
2580
- MultiGetRange data_block_range(sst_file_range, sst_file_range.begin(),
2581
- sst_file_range.end());
2582
- std::vector<Cache::Handle*> cache_handles;
2583
- bool wait_for_cache_results = false;
2584
-
2585
- CachableEntry<UncompressionDict> uncompression_dict;
2586
- Status uncompression_dict_status;
2587
- uncompression_dict_status.PermitUncheckedError();
2588
- bool uncompression_dict_inited = false;
2589
- size_t total_len = 0;
2590
- ReadOptions ro = read_options;
2591
- ro.read_tier = kBlockCacheTier;
2592
-
2593
- for (auto miter = data_block_range.begin();
2594
- miter != data_block_range.end(); ++miter) {
2595
- const Slice& key = miter->ikey;
2596
- iiter->Seek(miter->ikey);
2597
-
2598
- IndexValue v;
2599
- if (iiter->Valid()) {
2600
- v = iiter->value();
2601
- }
2602
- if (!iiter->Valid() ||
2603
- (!v.first_internal_key.empty() && !skip_filters &&
2604
- UserComparatorWrapper(rep_->internal_comparator.user_comparator())
2605
- .CompareWithoutTimestamp(
2606
- ExtractUserKey(key),
2607
- ExtractUserKey(v.first_internal_key)) < 0)) {
2608
- // The requested key falls between highest key in previous block and
2609
- // lowest key in current block.
2610
- if (!iiter->status().IsNotFound()) {
2611
- *(miter->s) = iiter->status();
2612
- }
2613
- data_block_range.SkipKey(miter);
2614
- sst_file_range.SkipKey(miter);
2615
- continue;
2616
- }
2617
-
2618
- if (!uncompression_dict_inited && rep_->uncompression_dict_reader) {
2619
- uncompression_dict_status =
2620
- rep_->uncompression_dict_reader->GetOrReadUncompressionDictionary(
2621
- nullptr /* prefetch_buffer */, no_io,
2622
- read_options.verify_checksums,
2623
- sst_file_range.begin()->get_context, &lookup_context,
2624
- &uncompression_dict);
2625
- uncompression_dict_inited = true;
2626
- }
2627
-
2628
- if (!uncompression_dict_status.ok()) {
2629
- assert(!uncompression_dict_status.IsNotFound());
2630
- *(miter->s) = uncompression_dict_status;
2631
- data_block_range.SkipKey(miter);
2632
- sst_file_range.SkipKey(miter);
2633
- continue;
2634
- }
2635
-
2636
- statuses.emplace_back();
2637
- results.emplace_back();
2638
- if (v.handle.offset() == offset) {
2639
- // We're going to reuse the block for this key later on. No need to
2640
- // look it up now. Place a null handle
2641
- block_handles.emplace_back(BlockHandle::NullBlockHandle());
2642
- continue;
2643
- }
2644
- // Lookup the cache for the given data block referenced by an index
2645
- // iterator value (i.e BlockHandle). If it exists in the cache,
2646
- // initialize block to the contents of the data block.
2647
- offset = v.handle.offset();
2648
- BlockHandle handle = v.handle;
2649
- BlockCacheLookupContext lookup_data_block_context(
2650
- TableReaderCaller::kUserMultiGet);
2651
- const UncompressionDict& dict = uncompression_dict.GetValue()
2652
- ? *uncompression_dict.GetValue()
2653
- : UncompressionDict::GetEmptyDict();
2654
- Status s = RetrieveBlock(
2655
- nullptr, ro, handle, dict, &(results.back()), BlockType::kData,
2656
- miter->get_context, &lookup_data_block_context,
2657
- /* for_compaction */ false, /* use_cache */ true,
2658
- /* wait_for_cache */ false);
2659
- if (s.IsIncomplete()) {
2660
- s = Status::OK();
2661
- }
2662
- if (s.ok() && !results.back().IsEmpty()) {
2663
- // Since we have a valid handle, check the value. If its nullptr,
2664
- // it means the cache is waiting for the final result and we're
2665
- // supposed to call WaitAll() to wait for the result.
2666
- if (results.back().GetValue() != nullptr) {
2667
- // Found it in the cache. Add NULL handle to indicate there is
2668
- // nothing to read from disk.
2669
- if (results.back().GetCacheHandle()) {
2670
- results.back().UpdateCachedValue();
2671
- }
2672
- block_handles.emplace_back(BlockHandle::NullBlockHandle());
2673
- } else {
2674
- // We have to wait for the cache lookup to finish in the
2675
- // background, and then we may have to read the block from disk
2676
- // anyway
2677
- assert(results.back().GetCacheHandle());
2678
- wait_for_cache_results = true;
2679
- block_handles.emplace_back(handle);
2680
- cache_handles.emplace_back(results.back().GetCacheHandle());
2681
- }
2682
- } else {
2683
- block_handles.emplace_back(handle);
2684
- total_len += BlockSizeWithTrailer(handle);
2685
- }
2686
- }
2687
-
2688
- if (wait_for_cache_results) {
2689
- Cache* block_cache = rep_->table_options.block_cache.get();
2690
- block_cache->WaitAll(cache_handles);
2691
- for (size_t i = 0; i < block_handles.size(); ++i) {
2692
- // If this block was a success or failure or not needed because
2693
- // the corresponding key is in the same block as a prior key, skip
2694
- if (block_handles[i] == BlockHandle::NullBlockHandle() ||
2695
- results[i].IsEmpty()) {
2696
- continue;
2697
- }
2698
- results[i].UpdateCachedValue();
2699
- void* val = results[i].GetValue();
2700
- if (!val) {
2701
- // The async cache lookup failed - could be due to an error
2702
- // or a false positive. We need to read the data block from
2703
- // the SST file
2704
- results[i].Reset();
2705
- total_len += BlockSizeWithTrailer(block_handles[i]);
2706
- } else {
2707
- block_handles[i] = BlockHandle::NullBlockHandle();
2708
- }
2709
- }
2710
- }
2711
-
2712
- if (total_len) {
2713
- char* scratch = nullptr;
2714
- const UncompressionDict& dict = uncompression_dict.GetValue()
2715
- ? *uncompression_dict.GetValue()
2716
- : UncompressionDict::GetEmptyDict();
2717
- assert(uncompression_dict_inited || !rep_->uncompression_dict_reader);
2718
- assert(uncompression_dict_status.ok());
2719
- // If using direct IO, then scratch is not used, so keep it nullptr.
2720
- // If the blocks need to be uncompressed and we don't need the
2721
- // compressed blocks, then we can use a contiguous block of
2722
- // memory to read in all the blocks as it will be temporary
2723
- // storage
2724
- // 1. If blocks are compressed and compressed block cache is there,
2725
- // alloc heap bufs
2726
- // 2. If blocks are uncompressed, alloc heap bufs
2727
- // 3. If blocks are compressed and no compressed block cache, use
2728
- // stack buf
2729
- if (!rep_->file->use_direct_io() &&
2730
- rep_->table_options.block_cache_compressed == nullptr &&
2731
- rep_->blocks_maybe_compressed) {
2732
- if (total_len <= kMultiGetReadStackBufSize) {
2733
- scratch = stack_buf;
2734
- } else {
2735
- scratch = new char[total_len];
2736
- block_buf.reset(scratch);
2737
- }
2738
- }
2739
- RetrieveMultipleBlocks(read_options, &data_block_range, &block_handles,
2740
- &statuses, &results, scratch, dict);
2741
- if (sst_file_range.begin()->get_context) {
2742
- ++(sst_file_range.begin()
2743
- ->get_context->get_context_stats_.num_sst_read);
2744
- }
2745
- }
2746
- }
2747
-
2748
- DataBlockIter first_biter;
2749
- DataBlockIter next_biter;
2750
- size_t idx_in_batch = 0;
2751
- for (auto miter = sst_file_range.begin(); miter != sst_file_range.end();
2752
- ++miter) {
2753
- Status s;
2754
- GetContext* get_context = miter->get_context;
2755
- const Slice& key = miter->ikey;
2756
- bool matched = false; // if such user key matched a key in SST
2757
- bool done = false;
2758
- bool first_block = true;
2759
- do {
2760
- DataBlockIter* biter = nullptr;
2761
- bool reusing_block = true;
2762
- uint64_t referenced_data_size = 0;
2763
- bool does_referenced_key_exist = false;
2764
- BlockCacheLookupContext lookup_data_block_context(
2765
- TableReaderCaller::kUserMultiGet, tracing_mget_id,
2766
- /*get_from_user_specified_snapshot=*/read_options.snapshot !=
2767
- nullptr);
2768
- if (first_block) {
2769
- if (!block_handles[idx_in_batch].IsNull() ||
2770
- !results[idx_in_batch].IsEmpty()) {
2771
- first_biter.Invalidate(Status::OK());
2772
- NewDataBlockIterator<DataBlockIter>(
2773
- read_options, results[idx_in_batch], &first_biter,
2774
- statuses[idx_in_batch]);
2775
- reusing_block = false;
2776
- } else {
2777
- // If handler is null and result is empty, then the status is never
2778
- // set, which should be the initial value: ok().
2779
- assert(statuses[idx_in_batch].ok());
2780
- }
2781
- biter = &first_biter;
2782
- idx_in_batch++;
2783
- } else {
2784
- IndexValue v = iiter->value();
2785
- if (!v.first_internal_key.empty() && !skip_filters &&
2786
- UserComparatorWrapper(rep_->internal_comparator.user_comparator())
2787
- .CompareWithoutTimestamp(
2788
- ExtractUserKey(key),
2789
- ExtractUserKey(v.first_internal_key)) < 0) {
2790
- // The requested key falls between highest key in previous block and
2791
- // lowest key in current block.
2792
- break;
2793
- }
2794
-
2795
- next_biter.Invalidate(Status::OK());
2796
- NewDataBlockIterator<DataBlockIter>(
2797
- read_options, iiter->value().handle, &next_biter,
2798
- BlockType::kData, get_context, &lookup_data_block_context,
2799
- Status(), nullptr);
2800
- biter = &next_biter;
2801
- reusing_block = false;
2802
- }
2803
-
2804
- if (read_options.read_tier == kBlockCacheTier &&
2805
- biter->status().IsIncomplete()) {
2806
- // couldn't get block from block_cache
2807
- // Update Saver.state to Found because we are only looking for
2808
- // whether we can guarantee the key is not there when "no_io" is set
2809
- get_context->MarkKeyMayExist();
2810
- break;
2811
- }
2812
- if (!biter->status().ok()) {
2813
- s = biter->status();
2814
- break;
2815
- }
2816
-
2817
- bool may_exist = biter->SeekForGet(key);
2818
- if (!may_exist) {
2819
- // HashSeek cannot find the key this block and the the iter is not
2820
- // the end of the block, i.e. cannot be in the following blocks
2821
- // either. In this case, the seek_key cannot be found, so we break
2822
- // from the top level for-loop.
2823
- break;
2824
- }
2825
-
2826
- // Call the *saver function on each entry/block until it returns false
2827
- for (; biter->Valid(); biter->Next()) {
2828
- ParsedInternalKey parsed_key;
2829
- Cleanable dummy;
2830
- Cleanable* value_pinner = nullptr;
2831
- Status pik_status = ParseInternalKey(
2832
- biter->key(), &parsed_key, false /* log_err_key */); // TODO
2833
- if (!pik_status.ok()) {
2834
- s = pik_status;
2835
- }
2836
- if (biter->IsValuePinned()) {
2837
- if (reusing_block) {
2838
- Cache* block_cache = rep_->table_options.block_cache.get();
2839
- assert(biter->cache_handle() != nullptr);
2840
- block_cache->Ref(biter->cache_handle());
2841
- dummy.RegisterCleanup(&ReleaseCachedEntry, block_cache,
2842
- biter->cache_handle());
2843
- value_pinner = &dummy;
2844
- } else {
2845
- value_pinner = biter;
2846
- }
2847
- }
2848
- if (!get_context->SaveValue(parsed_key, biter->value(), &matched,
2849
- value_pinner)) {
2850
- if (get_context->State() == GetContext::GetState::kFound) {
2851
- does_referenced_key_exist = true;
2852
- referenced_data_size =
2853
- biter->key().size() + biter->value().size();
2854
- }
2855
- done = true;
2856
- break;
2857
- }
2858
- s = biter->status();
2859
- }
2860
- // Write the block cache access.
2861
- if (block_cache_tracer_ && block_cache_tracer_->is_tracing_enabled()) {
2862
- // Avoid making copy of block_key, cf_name, and referenced_key when
2863
- // constructing the access record.
2864
- Slice referenced_key;
2865
- if (does_referenced_key_exist) {
2866
- referenced_key = biter->key();
2867
- } else {
2868
- referenced_key = key;
2869
- }
2870
- BlockCacheTraceRecord access_record(
2871
- rep_->ioptions.clock->NowMicros(),
2872
- /*block_key=*/"", lookup_data_block_context.block_type,
2873
- lookup_data_block_context.block_size, rep_->cf_id_for_tracing(),
2874
- /*cf_name=*/"", rep_->level_for_tracing(),
2875
- rep_->sst_number_for_tracing(), lookup_data_block_context.caller,
2876
- lookup_data_block_context.is_cache_hit,
2877
- lookup_data_block_context.no_insert,
2878
- lookup_data_block_context.get_id,
2879
- lookup_data_block_context.get_from_user_specified_snapshot,
2880
- /*referenced_key=*/"", referenced_data_size,
2881
- lookup_data_block_context.num_keys_in_block,
2882
- does_referenced_key_exist);
2883
- // TODO: Should handle status here?
2884
- block_cache_tracer_
2885
- ->WriteBlockAccess(access_record,
2886
- lookup_data_block_context.block_key,
2887
- rep_->cf_name_for_tracing(), referenced_key)
2888
- .PermitUncheckedError();
2889
- }
2890
- s = biter->status();
2891
- if (done) {
2892
- // Avoid the extra Next which is expensive in two-level indexes
2893
- break;
2894
- }
2895
- if (first_block) {
2896
- iiter->Seek(key);
2897
- }
2898
- first_block = false;
2899
- iiter->Next();
2900
- } while (iiter->Valid());
2901
-
2902
- if (matched && filter != nullptr && !filter->IsBlockBased()) {
2903
- RecordTick(rep_->ioptions.stats, BLOOM_FILTER_FULL_TRUE_POSITIVE);
2904
- PERF_COUNTER_BY_LEVEL_ADD(bloom_filter_full_true_positive, 1,
2905
- rep_->level);
2906
- }
2907
- if (s.ok() && !iiter->status().IsNotFound()) {
2908
- s = iiter->status();
2909
- }
2910
- *(miter->s) = s;
2911
- }
2912
- #ifdef ROCKSDB_ASSERT_STATUS_CHECKED
2913
- // Not sure why we need to do it. Should investigate more.
2914
- for (auto& st : statuses) {
2915
- st.PermitUncheckedError();
2916
- }
2917
- #endif // ROCKSDB_ASSERT_STATUS_CHECKED
2918
- }
2919
- }
2920
-
2921
2284
  Status BlockBasedTable::Prefetch(const Slice* const begin,
2922
2285
  const Slice* const end) {
2923
2286
  auto& comparator = rep_->internal_comparator;
@@ -2963,11 +2326,12 @@ Status BlockBasedTable::Prefetch(const Slice* const begin,
2963
2326
 
2964
2327
  // Load the block specified by the block_handle into the block cache
2965
2328
  DataBlockIter biter;
2966
-
2329
+ Status tmp_status;
2967
2330
  NewDataBlockIterator<DataBlockIter>(
2968
2331
  ReadOptions(), block_handle, &biter, /*type=*/BlockType::kData,
2969
- /*get_context=*/nullptr, &lookup_context, Status(),
2970
- /*prefetch_buffer=*/nullptr);
2332
+ /*get_context=*/nullptr, &lookup_context,
2333
+ /*prefetch_buffer=*/nullptr, /*for_compaction=*/false,
2334
+ /*async_read=*/false, tmp_status);
2971
2335
 
2972
2336
  if (!biter.status().ok()) {
2973
2337
  // there was an unexpected error while pre-fetching
@@ -3203,7 +2567,7 @@ Status BlockBasedTable::CreateIndexReader(
3203
2567
  }
3204
2568
  default: {
3205
2569
  std::string error_message =
3206
- "Unrecognized index type: " + ToString(rep_->index_type);
2570
+ "Unrecognized index type: " + std::to_string(rep_->index_type);
3207
2571
  return Status::InvalidArgument(error_message.c_str());
3208
2572
  }
3209
2573
  }
@@ -3362,11 +2726,13 @@ Status BlockBasedTable::GetKVPairsFromDataBlocks(
3362
2726
  }
3363
2727
 
3364
2728
  std::unique_ptr<InternalIterator> datablock_iter;
2729
+ Status tmp_status;
3365
2730
  datablock_iter.reset(NewDataBlockIterator<DataBlockIter>(
3366
2731
  ReadOptions(), blockhandles_iter->value().handle,
3367
2732
  /*input_iter=*/nullptr, /*type=*/BlockType::kData,
3368
- /*get_context=*/nullptr, /*lookup_context=*/nullptr, Status(),
3369
- /*prefetch_buffer=*/nullptr));
2733
+ /*get_context=*/nullptr, /*lookup_context=*/nullptr,
2734
+ /*prefetch_buffer=*/nullptr, /*for_compaction=*/false,
2735
+ /*async_read=*/false, tmp_status));
3370
2736
  s = datablock_iter->status();
3371
2737
 
3372
2738
  if (!s.ok()) {
@@ -3593,11 +2959,13 @@ Status BlockBasedTable::DumpDataBlocks(std::ostream& out_stream) {
3593
2959
  out_stream << "--------------------------------------\n";
3594
2960
 
3595
2961
  std::unique_ptr<InternalIterator> datablock_iter;
2962
+ Status tmp_status;
3596
2963
  datablock_iter.reset(NewDataBlockIterator<DataBlockIter>(
3597
2964
  ReadOptions(), blockhandles_iter->value().handle,
3598
2965
  /*input_iter=*/nullptr, /*type=*/BlockType::kData,
3599
- /*get_context=*/nullptr, /*lookup_context=*/nullptr, Status(),
3600
- /*prefetch_buffer=*/nullptr));
2966
+ /*get_context=*/nullptr, /*lookup_context=*/nullptr,
2967
+ /*prefetch_buffer=*/nullptr, /*for_compaction=*/false,
2968
+ /*async_read=*/false, tmp_status));
3601
2969
  s = datablock_iter->status();
3602
2970
 
3603
2971
  if (!s.ok()) {
@@ -3626,8 +2994,8 @@ Status BlockBasedTable::DumpDataBlocks(std::ostream& out_stream) {
3626
2994
  out_stream << " # data blocks: " << num_datablocks << "\n";
3627
2995
  out_stream << " min data block size: " << datablock_size_min << "\n";
3628
2996
  out_stream << " max data block size: " << datablock_size_max << "\n";
3629
- out_stream << " avg data block size: " << ToString(datablock_size_avg)
3630
- << "\n";
2997
+ out_stream << " avg data block size: "
2998
+ << std::to_string(datablock_size_avg) << "\n";
3631
2999
  }
3632
3000
 
3633
3001
  return Status::OK();