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
@@ -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;
@@ -241,7 +241,7 @@ inline void BlockFetcher::GetBlockContents() {
241
241
  // Read a block from the file and verify its checksum. Upon return, io_status_
242
242
  // will be updated with the status of the read, and slice_ will be updated
243
243
  // with a pointer to the data.
244
- void BlockFetcher::ReadBlock(bool retry, FSAllocationPtr& fs_buf) {
244
+ void BlockFetcher::ReadBlock(bool retry) {
245
245
  FSReadRequest read_req;
246
246
  IOOptions opts;
247
247
  io_status_ = file_->PrepareIOOptions(read_options_, opts);
@@ -336,7 +336,7 @@ void BlockFetcher::ReadBlock(bool retry, FSAllocationPtr& fs_buf) {
336
336
 
337
337
  if (io_status_.ok()) {
338
338
  InsertCompressedBlockToPersistentCacheIfNeeded();
339
- fs_buf = std::move(read_req.fs_scratch);
339
+ fs_buf_ = std::move(read_req.fs_scratch);
340
340
  } else {
341
341
  ReleaseFileSystemProvidedBuffer(&read_req);
342
342
  direct_io_buf_.reset();
@@ -347,7 +347,6 @@ void BlockFetcher::ReadBlock(bool retry, FSAllocationPtr& fs_buf) {
347
347
  }
348
348
 
349
349
  IOStatus BlockFetcher::ReadBlockContents() {
350
- FSAllocationPtr fs_buf;
351
350
  if (TryGetUncompressBlockFromPersistentCache()) {
352
351
  compression_type_ = kNoCompression;
353
352
  #ifndef NDEBUG
@@ -360,15 +359,15 @@ IOStatus BlockFetcher::ReadBlockContents() {
360
359
  return io_status_;
361
360
  }
362
361
  } else if (!TryGetSerializedBlockFromPersistentCache()) {
363
- ReadBlock(/*retry =*/false, fs_buf);
362
+ ReadBlock(/*retry =*/false);
364
363
  // If the file system supports retry after corruption, then try to
365
364
  // re-read the block and see if it succeeds.
366
365
  if (io_status_.IsCorruption() && retry_corrupt_read_) {
367
- assert(!fs_buf);
368
- ReadBlock(/*retry=*/true, fs_buf);
366
+ assert(!fs_buf_);
367
+ ReadBlock(/*retry=*/true);
369
368
  }
370
369
  if (!io_status_.ok()) {
371
- assert(!fs_buf);
370
+ assert(!fs_buf_);
372
371
  return io_status_;
373
372
  }
374
373
  }
@@ -417,16 +416,15 @@ IOStatus BlockFetcher::ReadAsyncBlockContents() {
417
416
  return io_s;
418
417
  }
419
418
  if (io_s.ok()) {
420
- FSAllocationPtr fs_buf;
421
419
  // Data Block is already in prefetch.
422
420
  got_from_prefetch_buffer_ = true;
423
421
  ProcessTrailerIfPresent();
424
422
  if (io_status_.IsCorruption() && retry_corrupt_read_) {
425
423
  got_from_prefetch_buffer_ = false;
426
- ReadBlock(/*retry = */ true, fs_buf);
424
+ ReadBlock(/*retry = */ true);
427
425
  }
428
426
  if (!io_status_.ok()) {
429
- assert(!fs_buf);
427
+ assert(!fs_buf_);
430
428
  return io_status_;
431
429
  }
432
430
  used_buf_ = const_cast<char*>(slice_.data());
@@ -137,6 +137,7 @@ class BlockFetcher {
137
137
  bool for_compaction_ = false;
138
138
  bool use_fs_scratch_ = false;
139
139
  bool retry_corrupt_read_ = false;
140
+ FSAllocationPtr fs_buf_;
140
141
 
141
142
  // return true if found
142
143
  bool TryGetUncompressBlockFromPersistentCache();
@@ -152,7 +153,7 @@ class BlockFetcher {
152
153
  void InsertCompressedBlockToPersistentCacheIfNeeded();
153
154
  void InsertUncompressedBlockToPersistentCacheIfNeeded();
154
155
  void ProcessTrailerIfPresent();
155
- void ReadBlock(bool retry, FSAllocationPtr& fs_buf);
156
+ void ReadBlock(bool retry);
156
157
 
157
158
  void ReleaseFileSystemProvidedBuffer(FSReadRequest* read_req) {
158
159
  if (use_fs_scratch_) {
@@ -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
@@ -487,7 +487,7 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
487
487
  file->file_name());
488
488
  }
489
489
 
490
- std::string footer_buf;
490
+ std::array<char, Footer::kMaxEncodedLength + 1> footer_buf;
491
491
  AlignedBuf internal_buf;
492
492
  Slice footer_input;
493
493
  uint64_t read_offset = (file_size > Footer::kMaxEncodedLength)
@@ -508,7 +508,6 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
508
508
  s = file->Read(opts, read_offset, Footer::kMaxEncodedLength,
509
509
  &footer_input, nullptr, &internal_buf);
510
510
  } else {
511
- footer_buf.reserve(Footer::kMaxEncodedLength);
512
511
  s = file->Read(opts, read_offset, Footer::kMaxEncodedLength,
513
512
  &footer_input, footer_buf.data(), nullptr);
514
513
  }
@@ -23,6 +23,10 @@ Status Iterator::GetProperty(std::string prop_name, std::string* prop) {
23
23
  *prop = "0";
24
24
  return Status::OK();
25
25
  }
26
+ if (prop_name == "rocksdb.iterator.is-value-pinned") {
27
+ *prop = "0";
28
+ return Status::OK();
29
+ }
26
30
  return Status::InvalidArgument("Unidentified property.");
27
31
  }
28
32
 
@@ -96,8 +96,9 @@ class MergingIterator : public InternalIterator {
96
96
  // could be updated. In that case, this merging iterator is only responsible
97
97
  // for freeing the new range tombstone iterator that it has pointers to in
98
98
  // range_tombstone_iters_.
99
- void AddRangeTombstoneIterator(TruncatedRangeDelIterator* iter) {
100
- range_tombstone_iters_.emplace_back(iter);
99
+ void AddRangeTombstoneIterator(
100
+ std::unique_ptr<TruncatedRangeDelIterator>&& iter) {
101
+ range_tombstone_iters_.emplace_back(std::move(iter));
101
102
  }
102
103
 
103
104
  // Called by MergingIteratorBuilder when all point iterators and range
@@ -125,9 +126,7 @@ class MergingIterator : public InternalIterator {
125
126
  }
126
127
 
127
128
  ~MergingIterator() override {
128
- for (auto child : range_tombstone_iters_) {
129
- delete child;
130
- }
129
+ range_tombstone_iters_.clear();
131
130
 
132
131
  for (auto& child : children_) {
133
132
  child.iter.DeleteIter(is_arena_mode_);
@@ -624,7 +623,8 @@ class MergingIterator : public InternalIterator {
624
623
  // Invariant(rti): pinned_heap_item_[i] is in minHeap_ iff
625
624
  // range_tombstone_iters_[i]->Valid() and at most one pinned_heap_item_[i] is
626
625
  // in minHeap_.
627
- std::vector<TruncatedRangeDelIterator*> range_tombstone_iters_;
626
+ std::vector<std::unique_ptr<TruncatedRangeDelIterator>>
627
+ range_tombstone_iters_;
628
628
 
629
629
  // Levels (indices into range_tombstone_iters_/children_ ) that currently have
630
630
  // "active" range tombstones. See comments above MergingIterator for meaning
@@ -841,7 +841,8 @@ void MergingIterator::SeekImpl(const Slice& target, size_t starting_level,
841
841
  prefetched_target.emplace_back(
842
842
  level, current_search_key.GetInternalKey().ToString());
843
843
  }
844
- auto range_tombstone_iter = range_tombstone_iters_[level];
844
+ UnownedPtr<TruncatedRangeDelIterator> range_tombstone_iter =
845
+ range_tombstone_iters_[level].get();
845
846
  if (range_tombstone_iter) {
846
847
  range_tombstone_iter->SeekInternalKey(
847
848
  current_search_key.GetInternalKey());
@@ -1125,7 +1126,8 @@ void MergingIterator::SeekForPrevImpl(const Slice& target,
1125
1126
  prefetched_target.emplace_back(
1126
1127
  level, current_search_key.GetInternalKey().ToString());
1127
1128
  }
1128
- auto range_tombstone_iter = range_tombstone_iters_[level];
1129
+ UnownedPtr<TruncatedRangeDelIterator> range_tombstone_iter =
1130
+ range_tombstone_iters_[level].get();
1129
1131
  if (range_tombstone_iter) {
1130
1132
  range_tombstone_iter->SeekForPrev(current_search_key.GetUserKey());
1131
1133
  if (range_tombstone_iter->Valid()) {
@@ -1349,7 +1351,8 @@ void MergingIterator::SwitchToForward() {
1349
1351
  ParseInternalKey(target, &pik, false /* log_err_key */)
1350
1352
  .PermitUncheckedError();
1351
1353
  for (size_t i = 0; i < range_tombstone_iters_.size(); ++i) {
1352
- auto iter = range_tombstone_iters_[i];
1354
+ UnownedPtr<TruncatedRangeDelIterator> iter =
1355
+ range_tombstone_iters_[i].get();
1353
1356
  if (iter) {
1354
1357
  iter->Seek(pik.user_key);
1355
1358
  // The while loop is needed as the Seek() call above is only for user
@@ -1395,7 +1398,8 @@ void MergingIterator::SwitchToBackward() {
1395
1398
  ParseInternalKey(target, &pik, false /* log_err_key */)
1396
1399
  .PermitUncheckedError();
1397
1400
  for (size_t i = 0; i < range_tombstone_iters_.size(); ++i) {
1398
- auto iter = range_tombstone_iters_[i];
1401
+ UnownedPtr<TruncatedRangeDelIterator> iter =
1402
+ range_tombstone_iters_[i].get();
1399
1403
  if (iter) {
1400
1404
  iter->SeekForPrev(pik.user_key);
1401
1405
  // Since the SeekForPrev() call above is only for user key,
@@ -1690,8 +1694,9 @@ void MergeIteratorBuilder::AddIterator(InternalIterator* iter) {
1690
1694
  }
1691
1695
 
1692
1696
  void MergeIteratorBuilder::AddPointAndTombstoneIterator(
1693
- InternalIterator* point_iter, TruncatedRangeDelIterator* tombstone_iter,
1694
- TruncatedRangeDelIterator*** tombstone_iter_ptr) {
1697
+ InternalIterator* point_iter,
1698
+ std::unique_ptr<TruncatedRangeDelIterator>&& tombstone_iter,
1699
+ std::unique_ptr<TruncatedRangeDelIterator>** tombstone_iter_ptr) {
1695
1700
  // tombstone_iter_ptr != nullptr means point_iter is a LevelIterator.
1696
1701
  bool add_range_tombstone = tombstone_iter ||
1697
1702
  !merge_iter->range_tombstone_iters_.empty() ||
@@ -1711,7 +1716,7 @@ void MergeIteratorBuilder::AddPointAndTombstoneIterator(
1711
1716
  merge_iter->children_.size() - 1) {
1712
1717
  merge_iter->AddRangeTombstoneIterator(nullptr);
1713
1718
  }
1714
- merge_iter->AddRangeTombstoneIterator(tombstone_iter);
1719
+ merge_iter->AddRangeTombstoneIterator(std::move(tombstone_iter));
1715
1720
  }
1716
1721
 
1717
1722
  if (tombstone_iter_ptr) {
@@ -70,8 +70,10 @@ class MergeIteratorBuilder {
70
70
  // point iterators are not LevelIterator, then range tombstone iterator is
71
71
  // only added to the merging iter if there is a non-null `tombstone_iter`.
72
72
  void AddPointAndTombstoneIterator(
73
- InternalIterator* point_iter, TruncatedRangeDelIterator* tombstone_iter,
74
- TruncatedRangeDelIterator*** tombstone_iter_ptr = nullptr);
73
+ InternalIterator* point_iter,
74
+ std::unique_ptr<TruncatedRangeDelIterator>&& tombstone_iter,
75
+ std::unique_ptr<TruncatedRangeDelIterator>** tombstone_iter_ptr =
76
+ nullptr);
75
77
 
76
78
  // Get arena used to build the merging iterator. It is called one a child
77
79
  // iterator needs to be allocated.
@@ -91,7 +93,7 @@ class MergeIteratorBuilder {
91
93
  Arena* arena;
92
94
  // Used to set LevelIterator.range_tombstone_iter_.
93
95
  // See AddRangeTombstoneIterator() implementation for more detail.
94
- std::vector<std::pair<size_t, TruncatedRangeDelIterator***>>
96
+ std::vector<std::pair<size_t, std::unique_ptr<TruncatedRangeDelIterator>**>>
95
97
  range_del_iter_ptrs_;
96
98
  };
97
99
 
@@ -59,12 +59,11 @@ PropertyBlockBuilder::PropertyBlockBuilder()
59
59
 
60
60
  void PropertyBlockBuilder::Add(const std::string& name,
61
61
  const std::string& val) {
62
+ assert(props_.find(name) == props_.end());
62
63
  props_.insert({name, val});
63
64
  }
64
65
 
65
66
  void PropertyBlockBuilder::Add(const std::string& name, uint64_t val) {
66
- assert(props_.find(name) == props_.end());
67
-
68
67
  std::string dst;
69
68
  PutVarint64(&dst, val);
70
69
 
@@ -168,7 +167,12 @@ void PropertyBlockBuilder::AddTableProperty(const TableProperties& props) {
168
167
 
169
168
  Slice PropertyBlockBuilder::Finish() {
170
169
  for (const auto& prop : props_) {
170
+ assert(last_prop_added_to_block_.empty() ||
171
+ comparator_->Compare(prop.first, last_prop_added_to_block_) > 0);
171
172
  properties_block_->Add(prop.first, prop.second);
173
+ #ifndef NDEBUG
174
+ last_prop_added_to_block_ = prop.first;
175
+ #endif /* !NDEBUG */
172
176
  }
173
177
 
174
178
  return properties_block_->Finish();
@@ -218,12 +222,21 @@ bool NotifyCollectTableCollectorsOnFinish(
218
222
  UserCollectedProperties& readable_properties) {
219
223
  bool all_succeeded = true;
220
224
  for (auto& collector : collectors) {
221
- Status s = collector->Finish(&user_collected_properties);
225
+ UserCollectedProperties user_properties;
226
+ Status s = collector->Finish(&user_properties);
222
227
  if (s.ok()) {
223
228
  for (const auto& prop : collector->GetReadableProperties()) {
224
229
  readable_properties.insert(prop);
225
230
  }
226
- builder->Add(user_collected_properties);
231
+ #ifndef NDEBUG
232
+ // Check different user properties collectors are not adding properties of
233
+ // the same name.
234
+ for (const auto& pair : user_properties) {
235
+ assert(user_collected_properties.find(pair.first) ==
236
+ user_collected_properties.end());
237
+ }
238
+ #endif /* !NDEBUG */
239
+ user_collected_properties.merge(user_properties);
227
240
  } else {
228
241
  LogPropertiesCollectionError(info_log, "Finish" /* method */,
229
242
  collector->Name());
@@ -232,6 +245,7 @@ bool NotifyCollectTableCollectorsOnFinish(
232
245
  }
233
246
  }
234
247
  }
248
+ builder->Add(user_collected_properties);
235
249
  return all_succeeded;
236
250
  }
237
251
 
@@ -73,6 +73,10 @@ class PropertyBlockBuilder {
73
73
  private:
74
74
  std::unique_ptr<BlockBuilder> properties_block_;
75
75
  stl_wrappers::KVMap props_;
76
+ #ifndef NDEBUG
77
+ const Comparator* comparator_ = BytewiseComparator();
78
+ Slice last_prop_added_to_block_;
79
+ #endif /* !NDEBUG */
76
80
  };
77
81
 
78
82
  // Were we encounter any error occurs during user-defined statistics collection,
@@ -119,8 +119,8 @@ PlainTableBuilder::PlainTableBuilder(
119
119
  assert(factory);
120
120
 
121
121
  std::unique_ptr<InternalTblPropColl> collector{
122
- factory->CreateInternalTblPropColl(column_family_id,
123
- level_at_creation)};
122
+ factory->CreateInternalTblPropColl(column_family_id, level_at_creation,
123
+ ioptions.num_levels)};
124
124
  if (collector) {
125
125
  table_properties_collectors_.emplace_back(std::move(collector));
126
126
  }
@@ -521,22 +521,22 @@ Status SstFileDumper::ReadSequential(bool print_kv, uint64_t read_num_limit,
521
521
  iter->value(), oss, output_hex_);
522
522
  if (!s.ok()) {
523
523
  fprintf(stderr, "%s => error deserializing wide columns\n",
524
- ikey.DebugString(true, output_hex_).c_str());
524
+ ikey.DebugString(true, output_hex_, ucmp).c_str());
525
525
  continue;
526
526
  }
527
527
  fprintf(stdout, "%s => %s\n",
528
- ikey.DebugString(true, output_hex_).c_str(),
528
+ ikey.DebugString(true, output_hex_, ucmp).c_str(),
529
529
  oss.str().c_str());
530
530
  } else if (ikey.type == kTypeValuePreferredSeqno) {
531
531
  auto [unpacked_value, preferred_seqno] =
532
532
  ParsePackedValueWithSeqno(value);
533
533
  fprintf(stdout, "%s => %s, %llu\n",
534
- ikey.DebugString(true, output_hex_).c_str(),
534
+ ikey.DebugString(true, output_hex_, ucmp).c_str(),
535
535
  unpacked_value.ToString(output_hex_).c_str(),
536
536
  static_cast<unsigned long long>(preferred_seqno));
537
537
  } else {
538
538
  fprintf(stdout, "%s => %s\n",
539
- ikey.DebugString(true, output_hex_).c_str(),
539
+ ikey.DebugString(true, output_hex_, ucmp).c_str(),
540
540
  value.ToString(output_hex_).c_str());
541
541
  }
542
542
  } else {
@@ -545,12 +545,12 @@ Status SstFileDumper::ReadSequential(bool print_kv, uint64_t read_num_limit,
545
545
  const Status s = blob_index.DecodeFrom(value);
546
546
  if (!s.ok()) {
547
547
  fprintf(stderr, "%s => error decoding blob index\n",
548
- ikey.DebugString(true, output_hex_).c_str());
548
+ ikey.DebugString(true, output_hex_, ucmp).c_str());
549
549
  continue;
550
550
  }
551
551
 
552
552
  fprintf(stdout, "%s => %s\n",
553
- ikey.DebugString(true, output_hex_).c_str(),
553
+ ikey.DebugString(true, output_hex_, ucmp).c_str(),
554
554
  blob_index.DebugString(output_hex_).c_str());
555
555
  }
556
556
  }
@@ -15,6 +15,7 @@
15
15
  #include "rocksdb/file_system.h"
16
16
  #include "table/get_context.h"
17
17
  #include "table/table_builder.h"
18
+ #include "table/table_iterator.h"
18
19
  #include "table/table_reader.h"
19
20
 
20
21
  namespace ROCKSDB_NAMESPACE {
@@ -24,6 +25,9 @@ struct SstFileReader::Rep {
24
25
  EnvOptions soptions;
25
26
  ImmutableOptions ioptions;
26
27
  MutableCFOptions moptions;
28
+ // Keep a member variable for this, since `NewIterator()` uses a const
29
+ // reference of `ReadOptions`.
30
+ ReadOptions roptions_for_table_iter;
27
31
 
28
32
  std::unique_ptr<TableReader> table_reader;
29
33
 
@@ -31,7 +35,10 @@ struct SstFileReader::Rep {
31
35
  : options(opts),
32
36
  soptions(options),
33
37
  ioptions(options),
34
- moptions(ColumnFamilyOptions(options)) {}
38
+ moptions(ColumnFamilyOptions(options)) {
39
+ roptions_for_table_iter =
40
+ ReadOptions(/*_verify_checksums=*/true, /*_fill_cache=*/false);
41
+ }
35
42
  };
36
43
 
37
44
  SstFileReader::SstFileReader(const Options& options) : rep_(new Rep(options)) {}
@@ -94,6 +101,21 @@ Iterator* SstFileReader::NewIterator(const ReadOptions& roptions) {
94
101
  return res;
95
102
  }
96
103
 
104
+ std::unique_ptr<Iterator> SstFileReader::NewTableIterator() {
105
+ auto r = rep_.get();
106
+ InternalIterator* internal_iter = r->table_reader->NewIterator(
107
+ r->roptions_for_table_iter, r->moptions.prefix_extractor.get(),
108
+ /*arena*/ nullptr, false /* skip_filters */,
109
+ TableReaderCaller::kSSTFileReader);
110
+ assert(internal_iter);
111
+ if (internal_iter == nullptr) {
112
+ // Do not attempt to create a TableIterator if we cannot get a valid
113
+ // InternalIterator.
114
+ return nullptr;
115
+ }
116
+ return std::make_unique<TableIterator>(internal_iter);
117
+ }
118
+
97
119
  std::shared_ptr<const TableProperties> SstFileReader::GetTableProperties()
98
120
  const {
99
121
  return rep_->table_reader->GetTableProperties();
@@ -118,7 +140,7 @@ Status SstFileReader::VerifyNumEntries(const ReadOptions& read_options) {
118
140
  uint64_t num_read = 0;
119
141
  for (; internal_iter->Valid(); internal_iter->Next()) {
120
142
  ++num_read;
121
- };
143
+ }
122
144
  s = internal_iter->status();
123
145
  if (!s.ok()) {
124
146
  return s;
@@ -79,7 +79,9 @@ class SstFileWriterPropertiesCollectorFactory
79
79
  : version_(version), global_seqno_(global_seqno) {}
80
80
 
81
81
  InternalTblPropColl* CreateInternalTblPropColl(
82
- uint32_t /*column_family_id*/, int /* level_at_creation */) override {
82
+ uint32_t /*column_family_id*/, int /* level_at_creation */,
83
+ int /* num_levels */,
84
+ SequenceNumber /* last_level_inclusive_max_seqno_threshold */) override {
83
85
  return new SstFileWriterPropertiesCollector(version_, global_seqno_);
84
86
  }
85
87