rocksdb-native 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/binding.c +92 -10
  2. package/index.js +9 -0
  3. package/lib/batch.js +11 -1
  4. package/lib/iterator.js +3 -1
  5. package/lib/snapshot.js +21 -0
  6. package/package.json +1 -1
  7. package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
  8. package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
  9. package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
  10. package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
  11. package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
  12. package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
  13. package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
  14. package/prebuilds/linux-x64/rocksdb-native.node +0 -0
  15. package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
  16. package/prebuilds/win32-x64/rocksdb-native.node +0 -0
  17. package/vendor/librocksdb/include/rocksdb.h +38 -4
  18. package/vendor/librocksdb/src/rocksdb.cc +114 -14
  19. package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
  20. package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
  21. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  22. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  23. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
  24. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
  25. package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
  26. package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
  27. package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
  28. package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
  29. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
  30. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
  31. package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
  32. package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
  33. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
  34. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
  35. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
  36. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
  37. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
  38. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
  39. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
  40. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
  41. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
  42. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
  43. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
  44. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
  45. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  46. package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
  47. package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
  48. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
  49. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
  50. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
  51. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  52. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
  53. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
  54. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
  55. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
  56. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
  57. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
  58. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
  59. package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
  60. package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
  61. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
  62. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
  63. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
  64. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
  65. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
  66. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
  67. package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
  68. package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
  69. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
  70. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  71. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
  72. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
  73. package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
  74. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
  75. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
  76. package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
  77. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
  78. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
  79. package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
  80. package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
  81. package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
  82. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
  83. package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  84. package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
  85. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  86. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
  87. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
  88. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
  89. package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
  90. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
  91. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
  92. package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
  93. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
  94. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
  95. package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
  96. package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
  97. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
  98. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
  99. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
  100. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  101. package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
  102. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
  103. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
  104. package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
  105. package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
  106. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
  107. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
  108. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
  109. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
  110. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
  111. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
  112. package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
  113. package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
  114. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
  115. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
  116. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
  117. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
  118. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
  119. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
  120. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
  121. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
  122. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
  123. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
  124. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
  125. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
  126. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
  127. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
  128. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
  129. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
  130. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
  131. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
  132. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
  133. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
  134. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
  135. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
  136. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
  137. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
  138. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
  139. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  140. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  141. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
  142. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  143. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  144. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
  145. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
  146. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
  147. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
  148. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  149. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
  150. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
  151. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
  152. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
  153. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
  154. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
  155. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
  156. package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
  157. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
  158. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
  159. package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
  160. package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
  161. package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
  162. package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
  163. package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
  164. package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
  165. package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
  166. package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  167. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
  168. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
  169. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
  170. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
  171. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  172. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  173. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  174. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  175. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
  176. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  177. package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
  178. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
  179. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  180. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  181. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
  182. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
  183. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
  184. package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  185. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
  186. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
  187. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
  188. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
  189. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
  190. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
  191. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  192. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  193. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  194. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  195. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
  196. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
  197. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
  198. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
  199. package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
  200. package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
  201. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
  202. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
  203. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
  204. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
  205. package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
  206. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
  207. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
  208. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
  209. package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
  210. package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
  211. package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
  212. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
  213. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
  214. package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
  215. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
  216. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
  217. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
  218. package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
  219. package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
  220. package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
  221. package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
  222. package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
  223. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
  224. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
  225. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
  226. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
  227. package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
  228. package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
  229. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
  230. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
  231. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
  232. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
  233. package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
  234. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
  235. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
  236. package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
  237. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  238. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  239. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  240. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
  241. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
  242. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
  243. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
  244. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
  245. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
  246. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
  247. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
  248. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
  249. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
  250. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
  251. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
  252. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  253. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
  254. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
  255. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  256. package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
  257. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
  258. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
  259. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  260. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
  261. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
@@ -30,6 +30,7 @@ PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder(
30
30
  const bool persist_user_defined_timestamps)
31
31
  : FullFilterBlockBuilder(_prefix_extractor, whole_key_filtering,
32
32
  filter_bits_builder),
33
+ p_index_builder_(p_index_builder),
33
34
  index_on_filter_block_builder_(
34
35
  index_block_restart_interval, true /*use_delta_encoding*/,
35
36
  use_value_delta_encoding,
@@ -41,10 +42,10 @@ PartitionedFilterBlockBuilder::PartitionedFilterBlockBuilder(
41
42
  use_value_delta_encoding,
42
43
  BlockBasedTableOptions::kDataBlockBinarySearch /* index_type */,
43
44
  0.75 /* data_block_hash_table_util_ratio */, ts_sz,
44
- persist_user_defined_timestamps, true /* is_user_key */),
45
- p_index_builder_(p_index_builder),
46
- keys_added_to_partition_(0),
47
- total_added_in_built_(0) {
45
+ persist_user_defined_timestamps, true /* is_user_key */) {
46
+ // See FullFilterBlockBuilder::AddPrefix
47
+ need_last_prefix_ = prefix_extractor() != nullptr;
48
+ // Compute keys_per_partition_
48
49
  keys_per_partition_ = static_cast<uint32_t>(
49
50
  filter_bits_builder_->ApproximateNumEntries(partition_size));
50
51
  if (keys_per_partition_ < 1) {
@@ -75,8 +76,9 @@ PartitionedFilterBlockBuilder::~PartitionedFilterBlockBuilder() {
75
76
 
76
77
  void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
77
78
  const Slice* next_key) {
78
- // Use == to send the request only once
79
- if (keys_added_to_partition_ == keys_per_partition_) {
79
+ // (NOTE: Can't just use ==, because keys_added_to_partition_ might be
80
+ // incremented by more than one.)
81
+ if (keys_added_to_partition_ >= keys_per_partition_) {
80
82
  // Currently only index builder is in charge of cutting a partition. We keep
81
83
  // requesting until it is granted.
82
84
  p_index_builder_->RequestPartitionCut();
@@ -86,7 +88,7 @@ void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
86
88
  }
87
89
 
88
90
  // 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
91
+ // updating last_prefix_str_. This hack fixes a bug with format_verison=3
90
92
  // where seeking for the prefix would lead us to the previous partition.
91
93
  const bool maybe_add_prefix =
92
94
  next_key && prefix_extractor() && prefix_extractor()->InDomain(*next_key);
@@ -105,19 +107,17 @@ void PartitionedFilterBlockBuilder::MaybeCutAFilterBlock(
105
107
  if (filter_construction_status.ok()) {
106
108
  filter_construction_status = filter_bits_builder_->MaybePostVerify(filter);
107
109
  }
108
- std::string& index_key = p_index_builder_->GetPartitionKey();
109
- filters.push_back({index_key, std::move(filter_data), filter});
110
- if (!filter_construction_status.ok() &&
111
- partitioned_filters_construction_status_.ok()) {
112
- partitioned_filters_construction_status_ = filter_construction_status;
113
- }
110
+ filters_.push_back(
111
+ {p_index_builder_->GetPartitionKey(), std::move(filter_data), filter});
112
+ partitioned_filters_construction_status_.UpdateIfOk(
113
+ filter_construction_status);
114
114
  keys_added_to_partition_ = 0;
115
115
  Reset();
116
116
  }
117
117
 
118
- void PartitionedFilterBlockBuilder::Add(const Slice& key) {
119
- MaybeCutAFilterBlock(&key);
120
- FullFilterBlockBuilder::Add(key);
118
+ void PartitionedFilterBlockBuilder::Add(const Slice& key_without_ts) {
119
+ MaybeCutAFilterBlock(&key_without_ts);
120
+ FullFilterBlockBuilder::Add(key_without_ts);
121
121
  }
122
122
 
123
123
  void PartitionedFilterBlockBuilder::AddKey(const Slice& key) {
@@ -129,10 +129,14 @@ size_t PartitionedFilterBlockBuilder::EstimateEntriesAdded() {
129
129
  return total_added_in_built_ + filter_bits_builder_->EstimateEntriesAdded();
130
130
  }
131
131
 
132
- Slice PartitionedFilterBlockBuilder::Finish(
133
- const BlockHandle& last_partition_block_handle, Status* status,
134
- std::unique_ptr<const char[]>* filter_data) {
135
- if (finishing_filters == true) {
132
+ Status PartitionedFilterBlockBuilder::Finish(
133
+ const BlockHandle& last_partition_block_handle, Slice* filter,
134
+ std::unique_ptr<const char[]>* filter_owner) {
135
+ if (finishing_front_filter_) {
136
+ assert(!filters_.empty());
137
+ auto& e = filters_.front();
138
+
139
+ assert(last_partition_block_handle != BlockHandle{});
136
140
  // Record the handle of the last written filter block in the index
137
141
  std::string handle_encoding;
138
142
  last_partition_block_handle.EncodeTo(&handle_encoding);
@@ -142,54 +146,53 @@ Slice PartitionedFilterBlockBuilder::Finish(
142
146
  last_partition_block_handle.size() - last_encoded_handle_.size());
143
147
  last_encoded_handle_ = last_partition_block_handle;
144
148
  const Slice handle_delta_encoding_slice(handle_delta_encoding);
145
- index_on_filter_block_builder_.Add(last_filter_entry_key, handle_encoding,
149
+
150
+ index_on_filter_block_builder_.Add(e.ikey, handle_encoding,
146
151
  &handle_delta_encoding_slice);
147
152
  if (!p_index_builder_->seperator_is_key_plus_seq()) {
148
153
  index_on_filter_block_builder_without_seq_.Add(
149
- ExtractUserKey(last_filter_entry_key), handle_encoding,
154
+ ExtractUserKey(e.ikey), handle_encoding,
150
155
  &handle_delta_encoding_slice);
151
156
  }
157
+
158
+ filters_.pop_front();
152
159
  } else {
160
+ assert(last_partition_block_handle == BlockHandle{});
153
161
  MaybeCutAFilterBlock(nullptr);
154
162
  }
155
163
 
156
- if (!partitioned_filters_construction_status_.ok()) {
157
- *status = partitioned_filters_construction_status_;
158
- return Slice();
159
- }
160
-
161
- // If there is no filter partition left, then return the index on filter
162
- // partitions
163
- if (UNLIKELY(filters.empty())) {
164
- *status = Status::OK();
165
- last_filter_data.reset();
166
- if (finishing_filters) {
167
- // Simplest to just add them all at the end
168
- total_added_in_built_ = 0;
169
- if (p_index_builder_->seperator_is_key_plus_seq()) {
170
- return index_on_filter_block_builder_.Finish();
164
+ Status s = partitioned_filters_construction_status_;
165
+ assert(!s.IsIncomplete());
166
+
167
+ if (s.ok()) {
168
+ // If there is no filter partition left, then return the index on filter
169
+ // partitions
170
+ if (UNLIKELY(filters_.empty())) {
171
+ if (!index_on_filter_block_builder_.empty()) {
172
+ // Simplest to just add them all at the end
173
+ if (p_index_builder_->seperator_is_key_plus_seq()) {
174
+ *filter = index_on_filter_block_builder_.Finish();
175
+ } else {
176
+ *filter = index_on_filter_block_builder_without_seq_.Finish();
177
+ }
171
178
  } else {
172
- return index_on_filter_block_builder_without_seq_.Finish();
179
+ // This is the rare case where no key was added to the filter
180
+ *filter = Slice{};
173
181
  }
174
182
  } else {
175
- // This is the rare case where no key was added to the filter
176
- return Slice();
177
- }
178
- } else {
179
- // Return the next filter partition in line and set Incomplete() status to
180
- // indicate we expect more calls to Finish
181
- *status = Status::Incomplete();
182
- finishing_filters = true;
183
-
184
- last_filter_entry_key = filters.front().key;
185
- Slice filter = filters.front().filter;
186
- last_filter_data = std::move(filters.front().filter_data);
187
- if (filter_data != nullptr) {
188
- *filter_data = std::move(last_filter_data);
183
+ // Return the next filter partition in line and set Incomplete() status to
184
+ // indicate we expect more calls to Finish
185
+ s = Status::Incomplete();
186
+ finishing_front_filter_ = true;
187
+
188
+ auto& e = filters_.front();
189
+ if (filter_owner != nullptr) {
190
+ *filter_owner = std::move(e.filter_owner);
191
+ }
192
+ *filter = e.filter;
189
193
  }
190
- filters.pop_front();
191
- return filter;
192
194
  }
195
+ return s;
193
196
  }
194
197
 
195
198
  PartitionedFilterBlockReader::PartitionedFilterBlockReader(
@@ -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());
@@ -37,17 +37,17 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
37
37
  virtual ~PartitionedFilterBlockBuilder();
38
38
 
39
39
  void AddKey(const Slice& key) override;
40
- void Add(const Slice& key) override;
40
+ void Add(const Slice& key_without_ts) override;
41
41
  size_t EstimateEntriesAdded() override;
42
42
 
43
- Slice Finish(const BlockHandle& last_partition_block_handle, Status* status,
44
- std::unique_ptr<const char[]>* filter_data = nullptr) override;
43
+ Status Finish(const BlockHandle& last_partition_block_handle, Slice* filter,
44
+ std::unique_ptr<const char[]>* filter_owner = nullptr) override;
45
45
 
46
46
  void ResetFilterBitsBuilder() override {
47
- // Previously constructed partitioned filters by
48
- // this to-be-reset FiterBitsBuilder can also be
49
- // cleared
50
- filters.clear();
47
+ filters_.clear();
48
+ total_added_in_built_ = 0;
49
+ index_on_filter_block_builder_.Reset();
50
+ index_on_filter_block_builder_without_seq_.Reset();
51
51
  FullFilterBlockBuilder::ResetFilterBitsBuilder();
52
52
  }
53
53
 
@@ -59,44 +59,51 @@ class PartitionedFilterBlockBuilder : public FullFilterBlockBuilder {
59
59
  return Status::OK();
60
60
  }
61
61
 
62
- private:
63
- // Filter data
64
- BlockBuilder index_on_filter_block_builder_; // top-level index builder
65
- BlockBuilder
66
- index_on_filter_block_builder_without_seq_; // same for user keys
67
- struct FilterEntry {
68
- std::string key;
69
- std::unique_ptr<const char[]> filter_data;
70
- Slice filter;
71
- };
72
- std::deque<FilterEntry> filters; // list of partitioned filters and keys used
73
- // in building the index
74
-
75
- // Set to the first non-okay status if any of the filter
76
- // partitions experiences construction error.
77
- // If partitioned_filters_construction_status_ is non-okay,
78
- // then the whole partitioned filters should not be used.
79
- Status partitioned_filters_construction_status_;
80
- std::string last_filter_entry_key;
81
- std::unique_ptr<const char[]> last_filter_data;
82
- std::unique_ptr<IndexBuilder> value;
83
- bool finishing_filters =
84
- false; // true if Finish is called once but not complete yet.
62
+ private: // fns
85
63
  // The policy of when cut a filter block and Finish it
86
64
  void MaybeCutAFilterBlock(const Slice* next_key);
65
+
66
+ private: // data
87
67
  // Currently we keep the same number of partitions for filters and indexes.
88
68
  // This would allow for some potentioal optimizations in future. If such
89
69
  // optimizations did not realize we can use different number of partitions and
90
70
  // eliminate p_index_builder_
91
71
  PartitionedIndexBuilder* const p_index_builder_;
72
+
73
+ // Filter data
74
+ struct FilterEntry {
75
+ std::string ikey; // internal key or separator *after* this filter
76
+ std::unique_ptr<const char[]> filter_owner;
77
+ Slice filter;
78
+ };
79
+ std::deque<FilterEntry> filters_; // list of partitioned filters and keys
80
+ // used in building the index
92
81
  // The desired number of keys per partition
93
82
  uint32_t keys_per_partition_;
94
83
  // The number of keys added to the last partition so far
95
- uint32_t keys_added_to_partition_;
84
+ uint32_t keys_added_to_partition_ = 0;
96
85
  // According to the bits builders, how many keys/prefixes added
97
86
  // in all the filters we have fully built
98
- uint64_t total_added_in_built_;
87
+ uint64_t total_added_in_built_ = 0;
88
+
89
+ // Set to the first non-okay status if any of the filter
90
+ // partitions experiences construction error.
91
+ // If partitioned_filters_construction_status_ is non-okay,
92
+ // then the whole partitioned filters should not be used.
93
+ Status partitioned_filters_construction_status_;
94
+
95
+ // ===== State for Finish() =====
96
+
97
+ // top-level index builder on internal keys
98
+ BlockBuilder index_on_filter_block_builder_;
99
+ // same for user keys
100
+ BlockBuilder index_on_filter_block_builder_without_seq_;
101
+ // For delta-encoding handles
99
102
  BlockHandle last_encoded_handle_;
103
+ // True if we are between two calls to Finish(), because we have returned
104
+ // the filter at the front of filters_ but haven't yet added it to the
105
+ // partition index.
106
+ bool finishing_front_filter_ = false;
100
107
  };
101
108
 
102
109
  class PartitionedFilterBlockReader
@@ -111,22 +118,20 @@ class PartitionedFilterBlockReader
111
118
  FilePrefetchBuffer* prefetch_buffer, bool use_cache, bool prefetch,
112
119
  bool pin, BlockCacheLookupContext* lookup_context);
113
120
 
114
- bool KeyMayMatch(const Slice& key, const bool no_io,
115
- const Slice* const const_ikey_ptr, GetContext* get_context,
121
+ bool KeyMayMatch(const Slice& key, const Slice* const const_ikey_ptr,
122
+ GetContext* get_context,
116
123
  BlockCacheLookupContext* lookup_context,
117
124
  const ReadOptions& read_options) override;
118
- void KeysMayMatch(MultiGetRange* range, const bool no_io,
125
+ void KeysMayMatch(MultiGetRange* range,
119
126
  BlockCacheLookupContext* lookup_context,
120
127
  const ReadOptions& read_options) override;
121
128
 
122
- bool PrefixMayMatch(const Slice& prefix, const bool no_io,
123
- const Slice* const const_ikey_ptr,
129
+ bool PrefixMayMatch(const Slice& prefix, const Slice* const const_ikey_ptr,
124
130
  GetContext* get_context,
125
131
  BlockCacheLookupContext* lookup_context,
126
132
  const ReadOptions& read_options) override;
127
133
  void PrefixesMayMatch(MultiGetRange* range,
128
134
  const SliceTransform* prefix_extractor,
129
- const bool no_io,
130
135
  BlockCacheLookupContext* lookup_context,
131
136
  const ReadOptions& read_options) override;
132
137
 
@@ -138,35 +143,36 @@ class PartitionedFilterBlockReader
138
143
  const Slice& entry) const;
139
144
  Status GetFilterPartitionBlock(
140
145
  FilePrefetchBuffer* prefetch_buffer, const BlockHandle& handle,
141
- bool no_io, GetContext* get_context,
142
- BlockCacheLookupContext* lookup_context, const ReadOptions& read_options,
146
+ GetContext* get_context, BlockCacheLookupContext* lookup_context,
147
+ const ReadOptions& read_options,
143
148
  CachableEntry<ParsedFullFilterBlock>* filter_block) const;
144
149
 
145
150
  using FilterFunction = bool (FullFilterBlockReader::*)(
146
- const Slice& slice, const bool no_io, const Slice* const const_ikey_ptr,
151
+ const Slice& slice, const Slice* const const_ikey_ptr,
147
152
  GetContext* get_context, BlockCacheLookupContext* lookup_context,
148
153
  const ReadOptions& read_options);
149
- bool MayMatch(const Slice& slice, bool no_io, const Slice* const_ikey_ptr,
154
+ bool MayMatch(const Slice& slice, const Slice* const_ikey_ptr,
150
155
  GetContext* get_context,
151
156
  BlockCacheLookupContext* lookup_context,
152
157
  const ReadOptions& read_options,
153
158
  FilterFunction filter_function) const;
154
159
  using FilterManyFunction = void (FullFilterBlockReader::*)(
155
160
  MultiGetRange* range, const SliceTransform* prefix_extractor,
156
- const bool no_io, BlockCacheLookupContext* lookup_context,
157
- const ReadOptions& read_options);
161
+ BlockCacheLookupContext* lookup_context, const ReadOptions& read_options);
158
162
  void MayMatch(MultiGetRange* range, const SliceTransform* prefix_extractor,
159
- bool no_io, BlockCacheLookupContext* lookup_context,
163
+ BlockCacheLookupContext* lookup_context,
160
164
  const ReadOptions& read_options,
161
165
  FilterManyFunction filter_function) const;
162
166
  void MayMatchPartition(MultiGetRange* range,
163
167
  const SliceTransform* prefix_extractor,
164
- BlockHandle filter_handle, bool no_io,
168
+ BlockHandle filter_handle,
165
169
  BlockCacheLookupContext* lookup_context,
166
170
  const ReadOptions& read_options,
167
171
  FilterManyFunction filter_function) const;
168
172
  Status CacheDependencies(const ReadOptions& ro, bool pin,
169
173
  FilePrefetchBuffer* tail_prefetch_buffer) override;
174
+ void EraseFromCacheBeforeDestruction(
175
+ uint32_t /*uncache_aggressiveness*/) override;
170
176
 
171
177
  const InternalKeyComparator* internal_comparator() const;
172
178
  bool index_key_includes_seq() const;