@nxtedition/rocksdb 10.1.5 → 10.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/binding.cc +19 -11
  2. package/deps/rocksdb/rocksdb/CMakeLists.txt +16 -5
  3. package/deps/rocksdb/rocksdb/Makefile +38 -15
  4. package/deps/rocksdb/rocksdb/TARGETS +10 -0
  5. package/deps/rocksdb/rocksdb/cache/cache_test.cc +58 -0
  6. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  7. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  8. package/deps/rocksdb/rocksdb/db/builder.cc +2 -2
  9. package/deps/rocksdb/rocksdb/db/builder.h +1 -1
  10. package/deps/rocksdb/rocksdb/db/c.cc +205 -6
  11. package/deps/rocksdb/rocksdb/db/c_test.c +189 -1
  12. package/deps/rocksdb/rocksdb/db/column_family.cc +28 -0
  13. package/deps/rocksdb/rocksdb/db/column_family.h +17 -0
  14. package/deps/rocksdb/rocksdb/db/column_family_test.cc +234 -60
  15. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +8 -1
  16. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +11 -9
  17. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +4 -4
  18. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +2 -0
  19. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +1 -0
  20. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +22 -25
  21. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +2 -0
  22. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +112 -0
  23. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +72 -21
  24. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  25. package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +77 -0
  26. package/deps/rocksdb/rocksdb/db/convenience.cc +3 -0
  27. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +269 -112
  28. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +107 -43
  29. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +93 -24
  30. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +5 -5
  31. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +157 -68
  32. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +56 -15
  33. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +78 -105
  34. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +39 -9
  35. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_follower.cc +1 -0
  36. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +21 -14
  37. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +107 -63
  38. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +43 -2
  39. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +4 -0
  40. package/deps/rocksdb/rocksdb/db/db_rate_limiter_test.cc +6 -0
  41. package/deps/rocksdb/rocksdb/db/db_test.cc +10 -2
  42. package/deps/rocksdb/rocksdb/db/db_test2.cc +1 -1
  43. package/deps/rocksdb/rocksdb/db/db_test_util.cc +5 -0
  44. package/deps/rocksdb/rocksdb/db/db_test_util.h +7 -6
  45. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +92 -2
  46. package/deps/rocksdb/rocksdb/db/error_handler.cc +34 -39
  47. package/deps/rocksdb/rocksdb/db/error_handler.h +3 -4
  48. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +8 -4
  49. package/deps/rocksdb/rocksdb/db/event_helpers.cc +6 -3
  50. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +71 -15
  51. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  52. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +383 -4
  53. package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +88 -72
  54. package/deps/rocksdb/rocksdb/db/flush_job.cc +30 -3
  55. package/deps/rocksdb/rocksdb/db/flush_job.h +14 -0
  56. package/deps/rocksdb/rocksdb/db/internal_stats.cc +60 -1
  57. package/deps/rocksdb/rocksdb/db/internal_stats.h +20 -1
  58. package/deps/rocksdb/rocksdb/db/log_writer.cc +24 -0
  59. package/deps/rocksdb/rocksdb/db/log_writer.h +5 -0
  60. package/deps/rocksdb/rocksdb/db/memtable.cc +6 -4
  61. package/deps/rocksdb/rocksdb/db/memtable.h +10 -10
  62. package/deps/rocksdb/rocksdb/db/memtable_list.cc +4 -4
  63. package/deps/rocksdb/rocksdb/db/multi_cf_iterator_impl.h +10 -3
  64. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  65. package/deps/rocksdb/rocksdb/db/repair.cc +4 -3
  66. package/deps/rocksdb/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  67. package/deps/rocksdb/rocksdb/db/seqno_to_time_mapping.h +9 -0
  68. package/deps/rocksdb/rocksdb/db/table_cache.cc +17 -2
  69. package/deps/rocksdb/rocksdb/db/table_cache.h +9 -1
  70. package/deps/rocksdb/rocksdb/db/table_properties_collector.h +9 -2
  71. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +3 -1
  72. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +3 -3
  73. package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +7 -7
  74. package/deps/rocksdb/rocksdb/db/version_edit.cc +0 -1
  75. package/deps/rocksdb/rocksdb/db/version_edit_handler.h +7 -6
  76. package/deps/rocksdb/rocksdb/db/version_set.cc +54 -31
  77. package/deps/rocksdb/rocksdb/db/version_set.h +14 -7
  78. package/deps/rocksdb/rocksdb/db/wal_manager.cc +37 -29
  79. package/deps/rocksdb/rocksdb/db/wal_manager.h +6 -5
  80. package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  81. package/deps/rocksdb/rocksdb/db/write_batch.cc +54 -23
  82. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +46 -5
  83. package/deps/rocksdb/rocksdb/db/write_thread.cc +53 -5
  84. package/deps/rocksdb/rocksdb/db/write_thread.h +36 -4
  85. package/deps/rocksdb/rocksdb/db_stress_tool/CMakeLists.txt +1 -0
  86. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +5 -0
  87. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +57 -17
  88. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +11 -3
  89. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +8 -4
  90. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +10 -25
  91. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +25 -88
  92. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_filters.cc +93 -0
  93. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_filters.h +16 -0
  94. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +43 -0
  95. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.h +109 -21
  96. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +8 -0
  97. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +666 -205
  98. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +55 -10
  99. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +18 -16
  100. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +19 -0
  101. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +5 -0
  102. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +782 -494
  103. package/deps/rocksdb/rocksdb/env/composite_env_wrapper.h +21 -0
  104. package/deps/rocksdb/rocksdb/env/env.cc +6 -0
  105. package/deps/rocksdb/rocksdb/env/io_posix.cc +0 -1
  106. package/deps/rocksdb/rocksdb/file/file_util.cc +8 -2
  107. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +34 -19
  108. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +29 -32
  109. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +41 -15
  110. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +4 -2
  111. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +63 -0
  112. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +16 -5
  113. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +5 -0
  114. package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +0 -16
  115. package/deps/rocksdb/rocksdb/include/rocksdb/iterator_base.h +16 -0
  116. package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +21 -0
  117. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +76 -3
  118. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +17 -0
  119. package/deps/rocksdb/rocksdb/include/rocksdb/transaction_log.h +12 -6
  120. package/deps/rocksdb/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  121. package/deps/rocksdb/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  122. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  123. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  124. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +17 -8
  125. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +2 -2
  126. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  127. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +7 -0
  128. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  129. package/deps/rocksdb/rocksdb/options/cf_options.cc +13 -2
  130. package/deps/rocksdb/rocksdb/options/cf_options.h +6 -2
  131. package/deps/rocksdb/rocksdb/options/db_options.cc +8 -0
  132. package/deps/rocksdb/rocksdb/options/db_options.h +9 -5
  133. package/deps/rocksdb/rocksdb/options/options.cc +3 -0
  134. package/deps/rocksdb/rocksdb/options/options_helper.cc +1 -0
  135. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +3 -1
  136. package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +2 -2
  137. package/deps/rocksdb/rocksdb/port/stack_trace.cc +1 -0
  138. package/deps/rocksdb/rocksdb/port/win/port_win.cc +3 -2
  139. package/deps/rocksdb/rocksdb/src.mk +4 -0
  140. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  141. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +4 -2
  142. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +15 -0
  143. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  144. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  145. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  146. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  147. package/deps/rocksdb/rocksdb/table/block_based/block_cache.h +31 -0
  148. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  149. package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +10 -5
  150. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +11 -15
  151. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  152. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  153. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +28 -21
  154. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +9 -11
  155. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +16 -16
  156. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  157. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +14 -9
  158. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +4 -1
  159. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +82 -41
  160. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +13 -14
  161. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +18 -22
  162. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  163. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  164. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  165. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  166. package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.cc +9 -10
  167. package/deps/rocksdb/rocksdb/table/compaction_merging_iterator.h +3 -2
  168. package/deps/rocksdb/rocksdb/table/format.cc +1 -2
  169. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +18 -13
  170. package/deps/rocksdb/rocksdb/table/merging_iterator.h +5 -3
  171. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.cc +2 -2
  172. package/deps/rocksdb/rocksdb/table/sst_file_reader.cc +1 -1
  173. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +3 -1
  174. package/deps/rocksdb/rocksdb/table/table_builder.h +8 -7
  175. package/deps/rocksdb/rocksdb/table/table_reader.h +9 -0
  176. package/deps/rocksdb/rocksdb/test_util/testutil.cc +1 -0
  177. package/deps/rocksdb/rocksdb/test_util/testutil.h +6 -0
  178. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +19 -0
  179. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +434 -110
  180. package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +3 -1
  181. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +3 -0
  182. package/deps/rocksdb/rocksdb/util/aligned_storage.h +24 -0
  183. package/deps/rocksdb/rocksdb/util/filter_bench.cc +1 -1
  184. package/deps/rocksdb/rocksdb/util/random.cc +2 -1
  185. package/deps/rocksdb/rocksdb/util/stderr_logger.h +1 -1
  186. package/deps/rocksdb/rocksdb/util/udt_util.cc +33 -0
  187. package/deps/rocksdb/rocksdb/util/udt_util.h +7 -0
  188. package/deps/rocksdb/rocksdb/util/udt_util_test.cc +33 -0
  189. package/deps/rocksdb/rocksdb/util/write_batch_util.h +5 -0
  190. package/deps/rocksdb/rocksdb/util/xxhash.h +10 -3
  191. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +13 -13
  192. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +104 -48
  193. package/deps/rocksdb/rocksdb/utilities/debug.cc +16 -4
  194. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +647 -235
  195. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +274 -157
  196. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  197. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  198. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector_test.cc +139 -0
  199. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  200. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc +3 -0
  201. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +105 -6
  202. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +64 -8
  203. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +5 -0
  204. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +43 -5
  205. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +5 -0
  206. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +154 -6
  207. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +1 -1
  208. package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +158 -2
  209. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +16 -11
  210. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  211. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +9 -8
  212. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  213. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +43 -7
  214. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +2 -0
  215. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  216. package/package.json +1 -1
  217. package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
  218. package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
  219. package/.tap/test-results/node_modules/abstract-level/test/chained-batch-test.js.tap +0 -0
  220. package/.tap/test-results/node_modules/abstract-level/test/get-test.js.tap +0 -0
  221. package/.tap/test-results/test/abstract-level-test.js.tap +0 -1077
  222. package/.tap/test-results/test/batch-test.js.tap +0 -12
  223. package/.tap/test-results/test/chained-batch-gc-test.js.tap +0 -11
  224. package/.tap/test-results/test/cleanup-hanging-iterators-test.js.tap +0 -135
  225. package/.tap/test-results/test/clear-gc-test.js.tap +0 -13
  226. package/.tap/test-results/test/column-test.js.tap +0 -55
  227. package/.tap/test-results/test/common.js.tap +0 -0
  228. package/.tap/test-results/test/compression-test.js.tap +0 -30
  229. package/.tap/test-results/test/db-identity.js.tap +0 -12
  230. package/.tap/test-results/test/electron.js.tap +0 -0
  231. package/.tap/test-results/test/env-cleanup-hook-test.js.tap +0 -40
  232. package/.tap/test-results/test/env-cleanup-hook.js.tap +0 -0
  233. package/.tap/test-results/test/gc.js.tap +0 -0
  234. package/.tap/test-results/test/getproperty-test.js.tap +0 -29
  235. package/.tap/test-results/test/iterator-gc-test.js.tap +0 -15
  236. package/.tap/test-results/test/iterator-hwm-test.js.tap +0 -131
  237. package/.tap/test-results/test/iterator-recursion-test.js.tap +0 -12
  238. package/.tap/test-results/test/iterator-starvation-test.js.tap +0 -73
  239. package/.tap/test-results/test/iterator-test.js.tap +0 -6
  240. package/.tap/test-results/test/leak-tester-batch.js.tap +0 -0
  241. package/.tap/test-results/test/leak-tester-iterator.js.tap +0 -0
  242. package/.tap/test-results/test/leak-tester.js.tap +0 -0
  243. package/.tap/test-results/test/lock-test.js.tap +0 -18
  244. package/.tap/test-results/test/lock.js.tap +0 -0
  245. package/.tap/test-results/test/make.js.tap +0 -0
  246. package/.tap/test-results/test/max-rev-merge.js.tap +0 -0
  247. package/.tap/test-results/test/merge-operator-test.js.tap +0 -12
  248. package/.tap/test-results/test/mkdir-test.js.tap +0 -15
  249. package/.tap/test-results/test/segfault-test.js.tap +0 -76
  250. package/.tap/test-results/test/stack-blower.js.tap +0 -0
  251. package/deps/rocksdb/rocksdb/README.md +0 -29
  252. package/deps/rocksdb/rocksdb/microbench/README.md +0 -60
  253. package/deps/rocksdb/rocksdb/plugin/README.md +0 -43
  254. package/deps/rocksdb/rocksdb/port/README +0 -10
  255. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/README +0 -13
@@ -24,6 +24,9 @@ class BlockBasedTable::IndexReaderCommon : public BlockBasedTable::IndexReader {
24
24
  assert(table_ != nullptr);
25
25
  }
26
26
 
27
+ void EraseFromCacheBeforeDestruction(
28
+ uint32_t /*uncache_aggressiveness*/) override;
29
+
27
30
  protected:
28
31
  static Status ReadIndexBlock(const BlockBasedTable* table,
29
32
  FilePrefetchBuffer* prefetch_buffer,
@@ -71,7 +74,7 @@ class BlockBasedTable::IndexReaderCommon : public BlockBasedTable::IndexReader {
71
74
  return table_->get_rep()->user_defined_timestamps_persisted;
72
75
  }
73
76
 
74
- Status GetOrReadIndexBlock(bool no_io, GetContext* get_context,
77
+ Status GetOrReadIndexBlock(GetContext* get_context,
75
78
  BlockCacheLookupContext* lookup_context,
76
79
  CachableEntry<Block>* index_block,
77
80
  const ReadOptions& read_options) const;
@@ -45,6 +45,9 @@ PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder(
45
45
  p_index_builder_(p_index_builder),
46
46
  keys_added_to_partition_(0),
47
47
  total_added_in_built_(0) {
48
+ // See FullFilterBlockBuilder::AddPrefix
49
+ need_last_prefix_ = prefix_extractor() != nullptr;
50
+ // Compute keys_per_partition_
48
51
  keys_per_partition_ = static_cast<uint32_t>(
49
52
  filter_bits_builder_->ApproximateNumEntries(partition_size));
50
53
  if (keys_per_partition_ < 1) {
@@ -86,7 +89,7 @@ void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
86
89
  }
87
90
 
88
91
  // Add the prefix of the next key before finishing the partition without
89
- // updating last_prefix_str_. This hack, fixes a bug with format_verison=3
92
+ // updating last_prefix_str_. This hack fixes a bug with format_verison=3
90
93
  // where seeking for the prefix would lead us to the previous partition.
91
94
  const bool maybe_add_prefix =
92
95
  next_key && prefix_extractor() && prefix_extractor()->InDomain(*next_key);
@@ -225,7 +228,7 @@ std::unique_ptr<FilterBlockReader> PartitionedFilterBlockReader::Create(
225
228
  }
226
229
 
227
230
  bool PartitionedFilterBlockReader::KeyMayMatch(
228
- const Slice& key, const bool no_io, const Slice* const const_ikey_ptr,
231
+ const Slice& key, const Slice* const const_ikey_ptr,
229
232
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
230
233
  const ReadOptions& read_options) {
231
234
  assert(const_ikey_ptr != nullptr);
@@ -233,36 +236,35 @@ bool PartitionedFilterBlockReader::KeyMayMatch(
233
236
  return true;
234
237
  }
235
238
 
236
- return MayMatch(key, no_io, const_ikey_ptr, get_context, lookup_context,
239
+ return MayMatch(key, const_ikey_ptr, get_context, lookup_context,
237
240
  read_options, &FullFilterBlockReader::KeyMayMatch);
238
241
  }
239
242
 
240
243
  void PartitionedFilterBlockReader::KeysMayMatch(
241
- MultiGetRange* range, const bool no_io,
242
- BlockCacheLookupContext* lookup_context, const ReadOptions& read_options) {
244
+ MultiGetRange* range, BlockCacheLookupContext* lookup_context,
245
+ const ReadOptions& read_options) {
243
246
  if (!whole_key_filtering()) {
244
247
  return; // Any/all may match
245
248
  }
246
249
 
247
- MayMatch(range, nullptr, no_io, lookup_context, read_options,
250
+ MayMatch(range, nullptr, lookup_context, read_options,
248
251
  &FullFilterBlockReader::KeysMayMatch2);
249
252
  }
250
253
 
251
254
  bool PartitionedFilterBlockReader::PrefixMayMatch(
252
- const Slice& prefix, const bool no_io, const Slice* const const_ikey_ptr,
255
+ const Slice& prefix, const Slice* const const_ikey_ptr,
253
256
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
254
257
  const ReadOptions& read_options) {
255
258
  assert(const_ikey_ptr != nullptr);
256
- return MayMatch(prefix, no_io, const_ikey_ptr, get_context, lookup_context,
259
+ return MayMatch(prefix, const_ikey_ptr, get_context, lookup_context,
257
260
  read_options, &FullFilterBlockReader::PrefixMayMatch);
258
261
  }
259
262
 
260
263
  void PartitionedFilterBlockReader::PrefixesMayMatch(
261
264
  MultiGetRange* range, const SliceTransform* prefix_extractor,
262
- const bool no_io, BlockCacheLookupContext* lookup_context,
263
- const ReadOptions& read_options) {
265
+ BlockCacheLookupContext* lookup_context, const ReadOptions& read_options) {
264
266
  assert(prefix_extractor);
265
- MayMatch(range, prefix_extractor, no_io, lookup_context, read_options,
267
+ MayMatch(range, prefix_extractor, lookup_context, read_options,
266
268
  &FullFilterBlockReader::PrefixesMayMatch);
267
269
  }
268
270
 
@@ -295,8 +297,8 @@ BlockHandle PartitionedFilterBlockReader::GetFilterPartitionHandle(
295
297
 
296
298
  Status PartitionedFilterBlockReader::GetFilterPartitionBlock(
297
299
  FilePrefetchBuffer* prefetch_buffer, const BlockHandle& fltr_blk_handle,
298
- bool no_io, GetContext* get_context,
299
- BlockCacheLookupContext* lookup_context, const ReadOptions& _read_options,
300
+ GetContext* get_context, BlockCacheLookupContext* lookup_context,
301
+ const ReadOptions& read_options,
300
302
  CachableEntry<ParsedFullFilterBlock>* filter_block) const {
301
303
  assert(table());
302
304
  assert(filter_block);
@@ -312,11 +314,6 @@ Status PartitionedFilterBlockReader::GetFilterPartitionBlock(
312
314
  }
313
315
  }
314
316
 
315
- ReadOptions read_options = _read_options;
316
- if (no_io) {
317
- read_options.read_tier = kBlockCacheTier;
318
- }
319
-
320
317
  const Status s = table()->RetrieveBlock(
321
318
  prefetch_buffer, read_options, fltr_blk_handle,
322
319
  UncompressionDict::GetEmptyDict(), filter_block, get_context,
@@ -328,12 +325,12 @@ Status PartitionedFilterBlockReader::GetFilterPartitionBlock(
328
325
  }
329
326
 
330
327
  bool PartitionedFilterBlockReader::MayMatch(
331
- const Slice& slice, bool no_io, const Slice* const_ikey_ptr,
332
- GetContext* get_context, BlockCacheLookupContext* lookup_context,
333
- const ReadOptions& read_options, FilterFunction filter_function) const {
328
+ const Slice& slice, const Slice* const_ikey_ptr, GetContext* get_context,
329
+ BlockCacheLookupContext* lookup_context, const ReadOptions& read_options,
330
+ FilterFunction filter_function) const {
334
331
  CachableEntry<Block_kFilterPartitionIndex> filter_block;
335
- Status s = GetOrReadFilterBlock(no_io, get_context, lookup_context,
336
- &filter_block, read_options);
332
+ Status s = GetOrReadFilterBlock(get_context, lookup_context, &filter_block,
333
+ read_options);
337
334
  if (UNLIKELY(!s.ok())) {
338
335
  IGNORE_STATUS_IF_ERROR(s);
339
336
  return true;
@@ -350,7 +347,7 @@ bool PartitionedFilterBlockReader::MayMatch(
350
347
 
351
348
  CachableEntry<ParsedFullFilterBlock> filter_partition_block;
352
349
  s = GetFilterPartitionBlock(nullptr /* prefetch_buffer */, filter_handle,
353
- no_io, get_context, lookup_context, read_options,
350
+ get_context, lookup_context, read_options,
354
351
  &filter_partition_block);
355
352
  if (UNLIKELY(!s.ok())) {
356
353
  IGNORE_STATUS_IF_ERROR(s);
@@ -359,17 +356,17 @@ bool PartitionedFilterBlockReader::MayMatch(
359
356
 
360
357
  FullFilterBlockReader filter_partition(table(),
361
358
  std::move(filter_partition_block));
362
- return (filter_partition.*filter_function)(
363
- slice, no_io, const_ikey_ptr, get_context, lookup_context, read_options);
359
+ return (filter_partition.*filter_function)(slice, const_ikey_ptr, get_context,
360
+ lookup_context, read_options);
364
361
  }
365
362
 
366
363
  void PartitionedFilterBlockReader::MayMatch(
367
- MultiGetRange* range, const SliceTransform* prefix_extractor, bool no_io,
364
+ MultiGetRange* range, const SliceTransform* prefix_extractor,
368
365
  BlockCacheLookupContext* lookup_context, const ReadOptions& read_options,
369
366
  FilterManyFunction filter_function) const {
370
367
  CachableEntry<Block_kFilterPartitionIndex> filter_block;
371
- Status s = GetOrReadFilterBlock(no_io, range->begin()->get_context,
372
- lookup_context, &filter_block, read_options);
368
+ Status s = GetOrReadFilterBlock(range->begin()->get_context, lookup_context,
369
+ &filter_block, read_options);
373
370
  if (UNLIKELY(!s.ok())) {
374
371
  IGNORE_STATUS_IF_ERROR(s);
375
372
  return; // Any/all may match
@@ -392,7 +389,7 @@ void PartitionedFilterBlockReader::MayMatch(
392
389
  if (!prev_filter_handle.IsNull() &&
393
390
  this_filter_handle != prev_filter_handle) {
394
391
  MultiGetRange subrange(*range, start_iter_same_handle, iter);
395
- MayMatchPartition(&subrange, prefix_extractor, prev_filter_handle, no_io,
392
+ MayMatchPartition(&subrange, prefix_extractor, prev_filter_handle,
396
393
  lookup_context, read_options, filter_function);
397
394
  range->AddSkipsFrom(subrange);
398
395
  start_iter_same_handle = iter;
@@ -408,7 +405,7 @@ void PartitionedFilterBlockReader::MayMatch(
408
405
  }
409
406
  if (!prev_filter_handle.IsNull()) {
410
407
  MultiGetRange subrange(*range, start_iter_same_handle, range->end());
411
- MayMatchPartition(&subrange, prefix_extractor, prev_filter_handle, no_io,
408
+ MayMatchPartition(&subrange, prefix_extractor, prev_filter_handle,
412
409
  lookup_context, read_options, filter_function);
413
410
  range->AddSkipsFrom(subrange);
414
411
  }
@@ -416,14 +413,12 @@ void PartitionedFilterBlockReader::MayMatch(
416
413
 
417
414
  void PartitionedFilterBlockReader::MayMatchPartition(
418
415
  MultiGetRange* range, const SliceTransform* prefix_extractor,
419
- BlockHandle filter_handle, bool no_io,
420
- BlockCacheLookupContext* lookup_context, const ReadOptions& read_options,
421
- FilterManyFunction filter_function) const {
416
+ BlockHandle filter_handle, BlockCacheLookupContext* lookup_context,
417
+ const ReadOptions& read_options, FilterManyFunction filter_function) const {
422
418
  CachableEntry<ParsedFullFilterBlock> filter_partition_block;
423
419
  Status s = GetFilterPartitionBlock(
424
- nullptr /* prefetch_buffer */, filter_handle, no_io,
425
- range->begin()->get_context, lookup_context, read_options,
426
- &filter_partition_block);
420
+ nullptr /* prefetch_buffer */, filter_handle, range->begin()->get_context,
421
+ lookup_context, read_options, &filter_partition_block);
427
422
  if (UNLIKELY(!s.ok())) {
428
423
  IGNORE_STATUS_IF_ERROR(s);
429
424
  return; // Any/all may match
@@ -431,8 +426,8 @@ void PartitionedFilterBlockReader::MayMatchPartition(
431
426
 
432
427
  FullFilterBlockReader filter_partition(table(),
433
428
  std::move(filter_partition_block));
434
- (filter_partition.*filter_function)(range, prefix_extractor, no_io,
435
- lookup_context, read_options);
429
+ (filter_partition.*filter_function)(range, prefix_extractor, lookup_context,
430
+ read_options);
436
431
  }
437
432
 
438
433
  size_t PartitionedFilterBlockReader::ApproximateMemoryUsage() const {
@@ -458,8 +453,8 @@ Status PartitionedFilterBlockReader::CacheDependencies(
458
453
 
459
454
  CachableEntry<Block_kFilterPartitionIndex> filter_block;
460
455
 
461
- Status s = GetOrReadFilterBlock(false /* no_io */, nullptr /* get_context */,
462
- &lookup_context, &filter_block, ro);
456
+ Status s = GetOrReadFilterBlock(nullptr /* get_context */, &lookup_context,
457
+ &filter_block, ro);
463
458
  if (!s.ok()) {
464
459
  ROCKS_LOG_ERROR(rep->ioptions.logger,
465
460
  "Error retrieving top-level filter block while trying to "
@@ -538,6 +533,52 @@ Status PartitionedFilterBlockReader::CacheDependencies(
538
533
  return biter.status();
539
534
  }
540
535
 
536
+ void PartitionedFilterBlockReader::EraseFromCacheBeforeDestruction(
537
+ uint32_t uncache_aggressiveness) {
538
+ // NOTE: essentially a copy of
539
+ // PartitionIndexReader::EraseFromCacheBeforeDestruction
540
+ if (uncache_aggressiveness > 0) {
541
+ CachableEntry<Block_kFilterPartitionIndex> top_level_block;
542
+
543
+ ReadOptions ro;
544
+ ro.read_tier = ReadTier::kBlockCacheTier;
545
+ GetOrReadFilterBlock(/*get_context=*/nullptr,
546
+ /*lookup_context=*/nullptr, &top_level_block, ro)
547
+ .PermitUncheckedError();
548
+
549
+ if (!filter_map_.empty()) {
550
+ // All partitions present if any
551
+ for (auto& e : filter_map_) {
552
+ e.second.ResetEraseIfLastRef();
553
+ }
554
+ } else if (!top_level_block.IsEmpty()) {
555
+ IndexBlockIter biter;
556
+ const InternalKeyComparator* const comparator = internal_comparator();
557
+ Statistics* kNullStats = nullptr;
558
+ top_level_block.GetValue()->NewIndexIterator(
559
+ comparator->user_comparator(),
560
+ table()->get_rep()->get_global_seqno(
561
+ BlockType::kFilterPartitionIndex),
562
+ &biter, kNullStats, true /* total_order_seek */,
563
+ false /* have_first_key */, index_key_includes_seq(),
564
+ index_value_is_full(), false /* block_contents_pinned */,
565
+ user_defined_timestamps_persisted());
566
+
567
+ UncacheAggressivenessAdvisor advisor(uncache_aggressiveness);
568
+ for (biter.SeekToFirst(); biter.Valid() && advisor.ShouldContinue();
569
+ biter.Next()) {
570
+ bool erased = table()->EraseFromCache(biter.value().handle);
571
+ advisor.Report(erased);
572
+ }
573
+ biter.status().PermitUncheckedError();
574
+ }
575
+ top_level_block.ResetEraseIfLastRef();
576
+ }
577
+ // Might be needed to un-cache a pinned top-level block
578
+ FilterBlockReaderCommon<Block_kFilterPartitionIndex>::
579
+ EraseFromCacheBeforeDestruction(uncache_aggressiveness);
580
+ }
581
+
541
582
  const InternalKeyComparator* PartitionedFilterBlockReader::internal_comparator()
542
583
  const {
543
584
  assert(table());
@@ -111,22 +111,20 @@ class PartitionedFilterBlockReader
111
111
  FilePrefetchBuffer* prefetch_buffer, bool use_cache, bool prefetch,
112
112
  bool pin, BlockCacheLookupContext* lookup_context);
113
113
 
114
- bool KeyMayMatch(const Slice& key, const bool no_io,
115
- const Slice* const const_ikey_ptr, GetContext* get_context,
114
+ bool KeyMayMatch(const Slice& key, const Slice* const const_ikey_ptr,
115
+ GetContext* get_context,
116
116
  BlockCacheLookupContext* lookup_context,
117
117
  const ReadOptions& read_options) override;
118
- void KeysMayMatch(MultiGetRange* range, const bool no_io,
118
+ void KeysMayMatch(MultiGetRange* range,
119
119
  BlockCacheLookupContext* lookup_context,
120
120
  const ReadOptions& read_options) override;
121
121
 
122
- bool PrefixMayMatch(const Slice& prefix, const bool no_io,
123
- const Slice* const const_ikey_ptr,
122
+ bool PrefixMayMatch(const Slice& prefix, const Slice* const const_ikey_ptr,
124
123
  GetContext* get_context,
125
124
  BlockCacheLookupContext* lookup_context,
126
125
  const ReadOptions& read_options) override;
127
126
  void PrefixesMayMatch(MultiGetRange* range,
128
127
  const SliceTransform* prefix_extractor,
129
- const bool no_io,
130
128
  BlockCacheLookupContext* lookup_context,
131
129
  const ReadOptions& read_options) override;
132
130
 
@@ -138,35 +136,36 @@ class PartitionedFilterBlockReader
138
136
  const Slice& entry) const;
139
137
  Status GetFilterPartitionBlock(
140
138
  FilePrefetchBuffer* prefetch_buffer, const BlockHandle& handle,
141
- bool no_io, GetContext* get_context,
142
- BlockCacheLookupContext* lookup_context, const ReadOptions& read_options,
139
+ GetContext* get_context, BlockCacheLookupContext* lookup_context,
140
+ const ReadOptions& read_options,
143
141
  CachableEntry<ParsedFullFilterBlock>* filter_block) const;
144
142
 
145
143
  using FilterFunction = bool (FullFilterBlockReader::*)(
146
- const Slice& slice, const bool no_io, const Slice* const const_ikey_ptr,
144
+ const Slice& slice, const Slice* const const_ikey_ptr,
147
145
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
148
146
  const ReadOptions& read_options);
149
- bool MayMatch(const Slice& slice, bool no_io, const Slice* const_ikey_ptr,
147
+ bool MayMatch(const Slice& slice, const Slice* const_ikey_ptr,
150
148
  GetContext* get_context,
151
149
  BlockCacheLookupContext* lookup_context,
152
150
  const ReadOptions& read_options,
153
151
  FilterFunction filter_function) const;
154
152
  using FilterManyFunction = void (FullFilterBlockReader::*)(
155
153
  MultiGetRange* range, const SliceTransform* prefix_extractor,
156
- const bool no_io, BlockCacheLookupContext* lookup_context,
157
- const ReadOptions& read_options);
154
+ BlockCacheLookupContext* lookup_context, const ReadOptions& read_options);
158
155
  void MayMatch(MultiGetRange* range, const SliceTransform* prefix_extractor,
159
- bool no_io, BlockCacheLookupContext* lookup_context,
156
+ BlockCacheLookupContext* lookup_context,
160
157
  const ReadOptions& read_options,
161
158
  FilterManyFunction filter_function) const;
162
159
  void MayMatchPartition(MultiGetRange* range,
163
160
  const SliceTransform* prefix_extractor,
164
- BlockHandle filter_handle, bool no_io,
161
+ BlockHandle filter_handle,
165
162
  BlockCacheLookupContext* lookup_context,
166
163
  const ReadOptions& read_options,
167
164
  FilterManyFunction filter_function) const;
168
165
  Status CacheDependencies(const ReadOptions& ro, bool pin,
169
166
  FilePrefetchBuffer* tail_prefetch_buffer) override;
167
+ void EraseFromCacheBeforeDestruction(
168
+ uint32_t /*uncache_aggressiveness*/) override;
170
169
 
171
170
  const InternalKeyComparator* internal_comparator() const;
172
171
  bool index_key_includes_seq() const;
@@ -198,24 +198,23 @@ class PartitionedFilterBlockTest
198
198
  std::unique_ptr<PartitionedFilterBlockReader> reader(
199
199
  NewReader(builder, pib));
200
200
  // Querying added keys
201
- const bool no_io = true;
202
201
  std::vector<std::string> keys = PrepareKeys(keys_without_ts, kKeyNum);
203
202
  for (const auto& key : keys) {
204
203
  auto ikey = InternalKey(key, 0, ValueType::kTypeValue);
205
204
  const Slice ikey_slice = Slice(*ikey.rep());
206
205
  ASSERT_TRUE(reader->KeyMayMatch(
207
- StripTimestampFromUserKey(key, ts_sz_), !no_io, &ikey_slice,
206
+ StripTimestampFromUserKey(key, ts_sz_), &ikey_slice,
208
207
  /*get_context=*/nullptr,
209
- /*lookup_context=*/nullptr, ReadOptions()));
208
+ /*lookup_context=*/nullptr, test::kReadOptionsNoIo));
210
209
  }
211
210
  {
212
211
  // querying a key twice
213
212
  auto ikey = InternalKey(keys[0], 0, ValueType::kTypeValue);
214
213
  const Slice ikey_slice = Slice(*ikey.rep());
215
214
  ASSERT_TRUE(reader->KeyMayMatch(
216
- StripTimestampFromUserKey(keys[0], ts_sz_), !no_io, &ikey_slice,
215
+ StripTimestampFromUserKey(keys[0], ts_sz_), &ikey_slice,
217
216
  /*get_context=*/nullptr,
218
- /*lookup_context=*/nullptr, ReadOptions()));
217
+ /*lookup_context=*/nullptr, test::kReadOptionsNoIo));
219
218
  }
220
219
  // querying missing keys
221
220
  std::vector<std::string> missing_keys =
@@ -225,15 +224,15 @@ class PartitionedFilterBlockTest
225
224
  const Slice ikey_slice = Slice(*ikey.rep());
226
225
  if (empty) {
227
226
  ASSERT_TRUE(reader->KeyMayMatch(
228
- StripTimestampFromUserKey(key, ts_sz_), !no_io, &ikey_slice,
227
+ StripTimestampFromUserKey(key, ts_sz_), &ikey_slice,
229
228
  /*get_context=*/nullptr,
230
- /*lookup_context=*/nullptr, ReadOptions()));
229
+ /*lookup_context=*/nullptr, test::kReadOptionsNoIo));
231
230
  } else {
232
231
  // assuming a good hash function
233
232
  ASSERT_FALSE(reader->KeyMayMatch(
234
- StripTimestampFromUserKey(key, ts_sz_), !no_io, &ikey_slice,
233
+ StripTimestampFromUserKey(key, ts_sz_), &ikey_slice,
235
234
  /*get_context=*/nullptr,
236
- /*lookup_context=*/nullptr, ReadOptions()));
235
+ /*lookup_context=*/nullptr, test::kReadOptionsNoIo));
237
236
  }
238
237
  }
239
238
  }
@@ -389,11 +388,10 @@ TEST_P(PartitionedFilterBlockTest, SamePrefixInMultipleBlocks) {
389
388
  for (const auto& key : pkeys) {
390
389
  auto ikey = InternalKey(key, 0, ValueType::kTypeValue);
391
390
  const Slice ikey_slice = Slice(*ikey.rep());
392
- ASSERT_TRUE(reader->PrefixMayMatch(prefix_extractor->Transform(key),
393
- /*no_io=*/false, &ikey_slice,
394
- /*get_context=*/nullptr,
395
- /*lookup_context=*/nullptr,
396
- ReadOptions()));
391
+ ASSERT_TRUE(
392
+ reader->PrefixMayMatch(prefix_extractor->Transform(key), &ikey_slice,
393
+ /*get_context=*/nullptr,
394
+ /*lookup_context=*/nullptr, ReadOptions()));
397
395
  }
398
396
  // Non-existent keys but with the same prefix
399
397
  const std::string pnonkeys_without_ts[4] = {"p-key9", "p-key11", "p-key21",
@@ -403,11 +401,10 @@ TEST_P(PartitionedFilterBlockTest, SamePrefixInMultipleBlocks) {
403
401
  for (const auto& key : pnonkeys) {
404
402
  auto ikey = InternalKey(key, 0, ValueType::kTypeValue);
405
403
  const Slice ikey_slice = Slice(*ikey.rep());
406
- ASSERT_TRUE(reader->PrefixMayMatch(prefix_extractor->Transform(key),
407
- /*no_io=*/false, &ikey_slice,
408
- /*get_context=*/nullptr,
409
- /*lookup_context=*/nullptr,
410
- ReadOptions()));
404
+ ASSERT_TRUE(
405
+ reader->PrefixMayMatch(prefix_extractor->Transform(key), &ikey_slice,
406
+ /*get_context=*/nullptr,
407
+ /*lookup_context=*/nullptr, ReadOptions()));
411
408
  }
412
409
  }
413
410
 
@@ -444,8 +441,7 @@ TEST_P(PartitionedFilterBlockTest, PrefixInWrongPartitionBug) {
444
441
  auto prefix = prefix_extractor->Transform(key);
445
442
  auto ikey = InternalKey(key, 0, ValueType::kTypeValue);
446
443
  const Slice ikey_slice = Slice(*ikey.rep());
447
- ASSERT_TRUE(reader->PrefixMayMatch(prefix,
448
- /*no_io=*/false, &ikey_slice,
444
+ ASSERT_TRUE(reader->PrefixMayMatch(prefix, &ikey_slice,
449
445
  /*get_context=*/nullptr,
450
446
  /*lookup_context=*/nullptr,
451
447
  ReadOptions()));
@@ -477,4 +473,4 @@ int main(int argc, char** argv) {
477
473
  ROCKSDB_NAMESPACE::port::InstallStackTraceHandler();
478
474
  ::testing::InitGoogleTest(&argc, argv);
479
475
  return RUN_ALL_TESTS();
480
- }
476
+ }
@@ -47,9 +47,8 @@ InternalIteratorBase<IndexValue>* PartitionIndexReader::NewIterator(
47
47
  const ReadOptions& read_options, bool /* disable_prefix_seek */,
48
48
  IndexBlockIter* iter, GetContext* get_context,
49
49
  BlockCacheLookupContext* lookup_context) {
50
- const bool no_io = (read_options.read_tier == kBlockCacheTier);
51
50
  CachableEntry<Block> index_block;
52
- const Status s = GetOrReadIndexBlock(no_io, get_context, lookup_context,
51
+ const Status s = GetOrReadIndexBlock(get_context, lookup_context,
53
52
  &index_block, read_options);
54
53
  if (!s.ok()) {
55
54
  if (iter != nullptr) {
@@ -78,15 +77,10 @@ InternalIteratorBase<IndexValue>* PartitionIndexReader::NewIterator(
78
77
  index_value_is_full(), false /* block_contents_pinned */,
79
78
  user_defined_timestamps_persisted()));
80
79
  } else {
81
- ReadOptions ro;
82
- ro.fill_cache = read_options.fill_cache;
83
- ro.deadline = read_options.deadline;
84
- ro.io_timeout = read_options.io_timeout;
85
- ro.adaptive_readahead = read_options.adaptive_readahead;
86
- ro.async_io = read_options.async_io;
87
- ro.rate_limiter_priority = read_options.rate_limiter_priority;
88
- ro.verify_checksums = read_options.verify_checksums;
89
- ro.io_activity = read_options.io_activity;
80
+ ReadOptions ro{read_options};
81
+ // FIXME? Possible regression seen in prefetch_test if this field is
82
+ // propagated
83
+ ro.readahead_size = ReadOptions{}.readahead_size;
90
84
 
91
85
  // We don't return pinned data from index blocks, so no need
92
86
  // to set `block_contents_pinned`.
@@ -130,8 +124,8 @@ Status PartitionIndexReader::CacheDependencies(
130
124
 
131
125
  CachableEntry<Block> index_block;
132
126
  {
133
- Status s = GetOrReadIndexBlock(false /* no_io */, nullptr /* get_context */,
134
- &lookup_context, &index_block, ro);
127
+ Status s = GetOrReadIndexBlock(nullptr /* get_context */, &lookup_context,
128
+ &index_block, ro);
135
129
  if (!s.ok()) {
136
130
  return s;
137
131
  }
@@ -223,4 +217,48 @@ Status PartitionIndexReader::CacheDependencies(
223
217
  return s;
224
218
  }
225
219
 
220
+ void PartitionIndexReader::EraseFromCacheBeforeDestruction(
221
+ uint32_t uncache_aggressiveness) {
222
+ // NOTE: essentially a copy of
223
+ // PartitionedFilterBlockReader::EraseFromCacheBeforeDestruction
224
+ if (uncache_aggressiveness > 0) {
225
+ CachableEntry<Block> top_level_block;
226
+
227
+ ReadOptions ro_no_io;
228
+ ro_no_io.read_tier = ReadTier::kBlockCacheTier;
229
+ GetOrReadIndexBlock(/*get_context=*/nullptr,
230
+ /*lookup_context=*/nullptr, &top_level_block, ro_no_io)
231
+ .PermitUncheckedError();
232
+
233
+ if (!partition_map_.empty()) {
234
+ // All partitions present if any
235
+ for (auto& e : partition_map_) {
236
+ e.second.ResetEraseIfLastRef();
237
+ }
238
+ } else if (!top_level_block.IsEmpty()) {
239
+ IndexBlockIter biter;
240
+ const InternalKeyComparator* const comparator = internal_comparator();
241
+ Statistics* kNullStats = nullptr;
242
+ top_level_block.GetValue()->NewIndexIterator(
243
+ comparator->user_comparator(),
244
+ table()->get_rep()->get_global_seqno(BlockType::kIndex), &biter,
245
+ kNullStats, true /* total_order_seek */, index_has_first_key(),
246
+ index_key_includes_seq(), index_value_is_full(),
247
+ false /* block_contents_pinned */,
248
+ user_defined_timestamps_persisted());
249
+
250
+ UncacheAggressivenessAdvisor advisor(uncache_aggressiveness);
251
+ for (biter.SeekToFirst(); biter.Valid() && advisor.ShouldContinue();
252
+ biter.Next()) {
253
+ bool erased = table()->EraseFromCache(biter.value().handle);
254
+ advisor.Report(erased);
255
+ }
256
+ biter.status().PermitUncheckedError();
257
+ }
258
+ top_level_block.ResetEraseIfLastRef();
259
+ }
260
+ // Might be needed to un-cache a pinned top-level block
261
+ BlockBasedTable::IndexReaderCommon::EraseFromCacheBeforeDestruction(
262
+ uncache_aggressiveness);
263
+ }
226
264
  } // namespace ROCKSDB_NAMESPACE
@@ -42,6 +42,8 @@ class PartitionIndexReader : public BlockBasedTable::IndexReaderCommon {
42
42
  // TODO(myabandeh): more accurate estimate of partition_map_ mem usage
43
43
  return usage;
44
44
  }
45
+ void EraseFromCacheBeforeDestruction(
46
+ uint32_t /*uncache_aggressiveness*/) override;
45
47
 
46
48
  private:
47
49
  PartitionIndexReader(const BlockBasedTable* t,
@@ -77,9 +77,8 @@ Status UncompressionDictReader::ReadUncompressionDictionary(
77
77
  }
78
78
 
79
79
  Status UncompressionDictReader::GetOrReadUncompressionDictionary(
80
- FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro, bool no_io,
81
- bool verify_checksums, GetContext* get_context,
82
- BlockCacheLookupContext* lookup_context,
80
+ FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
81
+ GetContext* get_context, BlockCacheLookupContext* lookup_context,
83
82
  CachableEntry<UncompressionDict>* uncompression_dict) const {
84
83
  assert(uncompression_dict);
85
84
 
@@ -88,14 +87,7 @@ Status UncompressionDictReader::GetOrReadUncompressionDictionary(
88
87
  return Status::OK();
89
88
  }
90
89
 
91
- ReadOptions read_options;
92
- if (no_io) {
93
- read_options.read_tier = kBlockCacheTier;
94
- }
95
- read_options.verify_checksums = verify_checksums;
96
- read_options.io_activity = ro.io_activity;
97
-
98
- return ReadUncompressionDictionary(table_, prefetch_buffer, read_options,
90
+ return ReadUncompressionDictionary(table_, prefetch_buffer, ro,
99
91
  cache_dictionary_blocks(), get_context,
100
92
  lookup_context, uncompression_dict);
101
93
  }
@@ -32,9 +32,8 @@ class UncompressionDictReader {
32
32
  std::unique_ptr<UncompressionDictReader>* uncompression_dict_reader);
33
33
 
34
34
  Status GetOrReadUncompressionDictionary(
35
- FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro, bool no_io,
36
- bool verify_checksums, GetContext* get_context,
37
- BlockCacheLookupContext* lookup_context,
35
+ FilePrefetchBuffer* prefetch_buffer, const ReadOptions& ro,
36
+ GetContext* get_context, BlockCacheLookupContext* lookup_context,
38
37
  CachableEntry<UncompressionDict>* uncompression_dict) const;
39
38
 
40
39
  size_t ApproximateMemoryUsage() const;
@@ -11,8 +11,8 @@ class CompactionMergingIterator : public InternalIterator {
11
11
  CompactionMergingIterator(
12
12
  const InternalKeyComparator* comparator, InternalIterator** children,
13
13
  int n, bool is_arena_mode,
14
- std::vector<
15
- std::pair<TruncatedRangeDelIterator*, TruncatedRangeDelIterator***>>
14
+ std::vector<std::pair<std::unique_ptr<TruncatedRangeDelIterator>,
15
+ std::unique_ptr<TruncatedRangeDelIterator>**>>&
16
16
  range_tombstones)
17
17
  : is_arena_mode_(is_arena_mode),
18
18
  comparator_(comparator),
@@ -27,7 +27,7 @@ class CompactionMergingIterator : public InternalIterator {
27
27
  }
28
28
  assert(range_tombstones.size() == static_cast<size_t>(n));
29
29
  for (auto& p : range_tombstones) {
30
- range_tombstone_iters_.push_back(p.first);
30
+ range_tombstone_iters_.push_back(std::move(p.first));
31
31
  }
32
32
  pinned_heap_item_.resize(n);
33
33
  for (int i = 0; i < n; ++i) {
@@ -47,10 +47,7 @@ class CompactionMergingIterator : public InternalIterator {
47
47
  }
48
48
 
49
49
  ~CompactionMergingIterator() override {
50
- // TODO: use unique_ptr for range_tombstone_iters_
51
- for (auto child : range_tombstone_iters_) {
52
- delete child;
53
- }
50
+ range_tombstone_iters_.clear();
54
51
 
55
52
  for (auto& child : children_) {
56
53
  child.iter.DeleteIter(is_arena_mode_);
@@ -197,7 +194,8 @@ class CompactionMergingIterator : public InternalIterator {
197
194
  // nullptr means the sorted run of children_[i] does not have range
198
195
  // tombstones (or the current SSTable does not have range tombstones in the
199
196
  // case of LevelIterator).
200
- std::vector<TruncatedRangeDelIterator*> range_tombstone_iters_;
197
+ std::vector<std::unique_ptr<TruncatedRangeDelIterator>>
198
+ range_tombstone_iters_;
201
199
  // Used as value for range tombstone keys
202
200
  std::string dummy_tombstone_val{};
203
201
 
@@ -349,8 +347,9 @@ void CompactionMergingIterator::AddToMinHeapOrCheckStatus(HeapItem* child) {
349
347
 
350
348
  InternalIterator* NewCompactionMergingIterator(
351
349
  const InternalKeyComparator* comparator, InternalIterator** children, int n,
352
- std::vector<std::pair<TruncatedRangeDelIterator*,
353
- TruncatedRangeDelIterator***>>& range_tombstone_iters,
350
+ std::vector<std::pair<std::unique_ptr<TruncatedRangeDelIterator>,
351
+ std::unique_ptr<TruncatedRangeDelIterator>**>>&
352
+ range_tombstone_iters,
354
353
  Arena* arena) {
355
354
  assert(n >= 0);
356
355
  if (n == 0) {
@@ -38,7 +38,8 @@ class CompactionMergingIterator;
38
38
 
39
39
  InternalIterator* NewCompactionMergingIterator(
40
40
  const InternalKeyComparator* comparator, InternalIterator** children, int n,
41
- std::vector<std::pair<TruncatedRangeDelIterator*,
42
- TruncatedRangeDelIterator***>>& range_tombstone_iters,
41
+ std::vector<std::pair<std::unique_ptr<TruncatedRangeDelIterator>,
42
+ std::unique_ptr<TruncatedRangeDelIterator>**>>&
43
+ range_tombstone_iters,
43
44
  Arena* arena = nullptr);
44
45
  } // namespace ROCKSDB_NAMESPACE