rocksdb-native 2.2.0 → 2.3.1

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
@@ -567,43 +567,62 @@ Status WriteBatchWithIndex::GetFromBatchAndDB(DB* db,
567
567
  nullptr);
568
568
  }
569
569
 
570
- void WriteBatchWithIndex::MergeAcrossBatchAndDB(
570
+ void WriteBatchWithIndex::MergeAcrossBatchAndDBImpl(
571
571
  ColumnFamilyHandle* column_family, const Slice& key,
572
572
  const PinnableWideColumns& existing, const MergeContext& merge_context,
573
- PinnableSlice* value, Status* status) {
574
- assert(value);
573
+ std::string* value, PinnableWideColumns* columns, Status* status) {
574
+ assert(value || columns);
575
+ assert(!value || !columns);
575
576
  assert(status);
576
- assert(status->ok() || status->IsNotFound());
577
-
578
- std::string result_value;
579
577
 
580
578
  if (status->ok()) {
581
579
  if (WideColumnsHelper::HasDefaultColumnOnly(existing.columns())) {
582
580
  *status = WriteBatchWithIndexInternal::MergeKeyWithBaseValue(
583
581
  column_family, key, MergeHelper::kPlainBaseValue,
584
582
  WideColumnsHelper::GetDefaultColumn(existing.columns()),
585
- merge_context, &result_value,
586
- static_cast<PinnableWideColumns*>(nullptr));
583
+ merge_context, value, columns);
587
584
  } else {
588
585
  *status = WriteBatchWithIndexInternal::MergeKeyWithBaseValue(
589
586
  column_family, key, MergeHelper::kWideBaseValue, existing.columns(),
590
- merge_context, &result_value,
591
- static_cast<PinnableWideColumns*>(nullptr));
587
+ merge_context, value, columns);
592
588
  }
593
589
  } else {
594
590
  assert(status->IsNotFound());
595
591
  *status = WriteBatchWithIndexInternal::MergeKeyWithNoBaseValue(
596
- column_family, key, merge_context, &result_value,
597
- static_cast<PinnableWideColumns*>(nullptr));
592
+ column_family, key, merge_context, value, columns);
598
593
  }
594
+ }
595
+
596
+ void WriteBatchWithIndex::MergeAcrossBatchAndDB(
597
+ ColumnFamilyHandle* column_family, const Slice& key,
598
+ const PinnableWideColumns& existing, const MergeContext& merge_context,
599
+ PinnableSlice* value, Status* status) {
600
+ assert(value);
601
+ assert(status);
602
+
603
+ std::string result_value;
604
+ constexpr PinnableWideColumns* result_entity = nullptr;
605
+ MergeAcrossBatchAndDBImpl(column_family, key, existing, merge_context,
606
+ &result_value, result_entity, status);
599
607
 
600
608
  if (status->ok()) {
601
- value->Reset();
602
609
  *value->GetSelf() = std::move(result_value);
603
610
  value->PinSelf();
604
611
  }
605
612
  }
606
613
 
614
+ void WriteBatchWithIndex::MergeAcrossBatchAndDB(
615
+ ColumnFamilyHandle* column_family, const Slice& key,
616
+ const PinnableWideColumns& existing, const MergeContext& merge_context,
617
+ PinnableWideColumns* columns, Status* status) {
618
+ assert(columns);
619
+ assert(status);
620
+
621
+ constexpr std::string* value = nullptr;
622
+ MergeAcrossBatchAndDBImpl(column_family, key, existing, merge_context, value,
623
+ columns, status);
624
+ }
625
+
607
626
  Status WriteBatchWithIndex::GetFromBatchAndDB(
608
627
  DB* db, const ReadOptions& read_options, ColumnFamilyHandle* column_family,
609
628
  const Slice& key, PinnableSlice* pinnable_val, ReadCallback* callback) {
@@ -620,6 +639,8 @@ Status WriteBatchWithIndex::GetFromBatchAndDB(
620
639
  return Status::InvalidArgument("Must specify timestamp");
621
640
  }
622
641
 
642
+ pinnable_val->Reset();
643
+
623
644
  // Since the lifetime of the WriteBatch is the same as that of the transaction
624
645
  // we cannot pin it as otherwise the returned value will not be available
625
646
  // after the transaction finishes.
@@ -634,7 +655,8 @@ Status WriteBatchWithIndex::GetFromBatchAndDB(
634
655
  return s;
635
656
  }
636
657
 
637
- if (!s.ok() || result == WBWIIteratorImpl::kError) {
658
+ assert(!s.ok() == (result == WBWIIteratorImpl::kError));
659
+ if (result == WBWIIteratorImpl::kError) {
638
660
  return s;
639
661
  }
640
662
 
@@ -800,6 +822,283 @@ void WriteBatchWithIndex::MultiGetFromBatchAndDB(
800
822
  }
801
823
  }
802
824
 
825
+ Status WriteBatchWithIndex::GetEntityFromBatchAndDB(
826
+ DB* db, const ReadOptions& _read_options, ColumnFamilyHandle* column_family,
827
+ const Slice& key, PinnableWideColumns* columns, ReadCallback* callback) {
828
+ if (!db) {
829
+ return Status::InvalidArgument(
830
+ "Cannot call GetEntityFromBatchAndDB without a DB object");
831
+ }
832
+
833
+ if (_read_options.io_activity != Env::IOActivity::kUnknown &&
834
+ _read_options.io_activity != Env::IOActivity::kGetEntity) {
835
+ return Status::InvalidArgument(
836
+ "Can only call GetEntityFromBatchAndDB with `ReadOptions::io_activity` "
837
+ "set to `Env::IOActivity::kUnknown` or `Env::IOActivity::kGetEntity`");
838
+ }
839
+
840
+ ReadOptions read_options(_read_options);
841
+ if (read_options.io_activity == Env::IOActivity::kUnknown) {
842
+ read_options.io_activity = Env::IOActivity::kGetEntity;
843
+ }
844
+
845
+ if (!column_family) {
846
+ return Status::InvalidArgument(
847
+ "Cannot call GetEntityFromBatchAndDB without a column family handle");
848
+ }
849
+
850
+ const Comparator* const ucmp = rep->comparator.GetComparator(column_family);
851
+ size_t ts_sz = ucmp ? ucmp->timestamp_size() : 0;
852
+ if (ts_sz > 0) {
853
+ if (!read_options.timestamp) {
854
+ return Status::InvalidArgument("Must specify timestamp");
855
+ }
856
+
857
+ if (read_options.timestamp->size() != ts_sz) {
858
+ return Status::InvalidArgument(
859
+ "Timestamp size does not match the timestamp size of the "
860
+ "column family");
861
+ }
862
+ } else {
863
+ if (read_options.timestamp) {
864
+ return Status::InvalidArgument(
865
+ "Cannot specify timestamp since the column family does not have "
866
+ "timestamps enabled");
867
+ }
868
+ }
869
+
870
+ if (!columns) {
871
+ return Status::InvalidArgument(
872
+ "Cannot call GetEntityFromBatchAndDB without a PinnableWideColumns "
873
+ "object");
874
+ }
875
+
876
+ columns->Reset();
877
+
878
+ MergeContext merge_context;
879
+ Status s;
880
+
881
+ auto result = WriteBatchWithIndexInternal::GetEntityFromBatch(
882
+ this, column_family, key, &merge_context, columns, &s);
883
+
884
+ assert(!s.ok() == (result == WBWIIteratorImpl::kError));
885
+
886
+ if (result == WBWIIteratorImpl::kFound ||
887
+ result == WBWIIteratorImpl::kError) {
888
+ return s;
889
+ }
890
+
891
+ if (result == WBWIIteratorImpl::kDeleted) {
892
+ return Status::NotFound();
893
+ }
894
+
895
+ assert(result == WBWIIteratorImpl::kMergeInProgress ||
896
+ result == WBWIIteratorImpl::kNotFound);
897
+
898
+ PinnableWideColumns existing;
899
+
900
+ DBImpl::GetImplOptions get_impl_options;
901
+ get_impl_options.column_family = column_family;
902
+ get_impl_options.columns =
903
+ (result == WBWIIteratorImpl::kMergeInProgress) ? &existing : columns;
904
+ get_impl_options.callback = callback;
905
+
906
+ s = static_cast_with_check<DBImpl>(db->GetRootDB())
907
+ ->GetImpl(read_options, key, get_impl_options);
908
+
909
+ if (result == WBWIIteratorImpl::kMergeInProgress) {
910
+ if (s.ok() || s.IsNotFound()) { // DB lookup succeeded
911
+ MergeAcrossBatchAndDB(column_family, key, existing, merge_context,
912
+ columns, &s);
913
+ }
914
+ }
915
+
916
+ return s;
917
+ }
918
+
919
+ void WriteBatchWithIndex::MultiGetEntityFromBatchAndDB(
920
+ DB* db, const ReadOptions& _read_options, ColumnFamilyHandle* column_family,
921
+ size_t num_keys, const Slice* keys, PinnableWideColumns* results,
922
+ Status* statuses, bool sorted_input, ReadCallback* callback) {
923
+ assert(statuses);
924
+
925
+ if (!db) {
926
+ const Status s = Status::InvalidArgument(
927
+ "Cannot call MultiGetEntityFromBatchAndDB without a DB object");
928
+ for (size_t i = 0; i < num_keys; ++i) {
929
+ statuses[i] = s;
930
+ }
931
+ return;
932
+ }
933
+
934
+ if (_read_options.io_activity != Env::IOActivity::kUnknown &&
935
+ _read_options.io_activity != Env::IOActivity::kMultiGetEntity) {
936
+ const Status s = Status::InvalidArgument(
937
+ "Can only call MultiGetEntityFromBatchAndDB with "
938
+ "`ReadOptions::io_activity` set to `Env::IOActivity::kUnknown` or "
939
+ "`Env::IOActivity::kMultiGetEntity`");
940
+ for (size_t i = 0; i < num_keys; ++i) {
941
+ if (statuses[i].ok()) {
942
+ statuses[i] = s;
943
+ }
944
+ }
945
+ return;
946
+ }
947
+
948
+ ReadOptions read_options(_read_options);
949
+ if (read_options.io_activity == Env::IOActivity::kUnknown) {
950
+ read_options.io_activity = Env::IOActivity::kMultiGetEntity;
951
+ }
952
+
953
+ if (!column_family) {
954
+ const Status s = Status::InvalidArgument(
955
+ "Cannot call MultiGetEntityFromBatchAndDB without a column family "
956
+ "handle");
957
+ for (size_t i = 0; i < num_keys; ++i) {
958
+ statuses[i] = s;
959
+ }
960
+ return;
961
+ }
962
+
963
+ const Comparator* const ucmp = rep->comparator.GetComparator(column_family);
964
+ const size_t ts_sz = ucmp ? ucmp->timestamp_size() : 0;
965
+ if (ts_sz > 0) {
966
+ if (!read_options.timestamp) {
967
+ const Status s = Status::InvalidArgument("Must specify timestamp");
968
+ for (size_t i = 0; i < num_keys; ++i) {
969
+ statuses[i] = s;
970
+ }
971
+ return;
972
+ }
973
+
974
+ if (read_options.timestamp->size() != ts_sz) {
975
+ const Status s = Status::InvalidArgument(
976
+ "Timestamp size does not match the timestamp size of the "
977
+ "column family");
978
+ for (size_t i = 0; i < num_keys; ++i) {
979
+ statuses[i] = s;
980
+ }
981
+ return;
982
+ }
983
+ } else {
984
+ if (read_options.timestamp) {
985
+ const Status s = Status::InvalidArgument(
986
+ "Cannot specify timestamp since the column family does not have "
987
+ "timestamps enabled");
988
+ for (size_t i = 0; i < num_keys; ++i) {
989
+ statuses[i] = s;
990
+ }
991
+ return;
992
+ }
993
+ }
994
+
995
+ if (!keys) {
996
+ const Status s = Status::InvalidArgument(
997
+ "Cannot call MultiGetEntityFromBatchAndDB without keys");
998
+ for (size_t i = 0; i < num_keys; ++i) {
999
+ statuses[i] = s;
1000
+ }
1001
+ return;
1002
+ }
1003
+
1004
+ if (!results) {
1005
+ const Status s = Status::InvalidArgument(
1006
+ "Cannot call MultiGetEntityFromBatchAndDB without "
1007
+ "PinnableWideColumns objects");
1008
+ for (size_t i = 0; i < num_keys; ++i) {
1009
+ statuses[i] = s;
1010
+ }
1011
+ return;
1012
+ }
1013
+
1014
+ struct MergeTuple {
1015
+ MergeTuple(const Slice& _key, Status* _s, MergeContext&& _merge_context,
1016
+ PinnableWideColumns* _columns)
1017
+ : key(_key),
1018
+ s(_s),
1019
+ merge_context(std::move(_merge_context)),
1020
+ columns(_columns) {
1021
+ assert(s);
1022
+ assert(columns);
1023
+ }
1024
+
1025
+ Slice key;
1026
+ Status* s;
1027
+ PinnableWideColumns existing;
1028
+ MergeContext merge_context;
1029
+ PinnableWideColumns* columns;
1030
+ };
1031
+
1032
+ autovector<MergeTuple, MultiGetContext::MAX_BATCH_SIZE> merges;
1033
+
1034
+ autovector<KeyContext, MultiGetContext::MAX_BATCH_SIZE> key_contexts;
1035
+
1036
+ for (size_t i = 0; i < num_keys; ++i) {
1037
+ const Slice& key = keys[i];
1038
+ MergeContext merge_context;
1039
+ PinnableWideColumns* const columns = &results[i];
1040
+ Status* const s = &statuses[i];
1041
+
1042
+ columns->Reset();
1043
+
1044
+ auto result = WriteBatchWithIndexInternal::GetEntityFromBatch(
1045
+ this, column_family, key, &merge_context, columns, s);
1046
+
1047
+ if (result == WBWIIteratorImpl::kFound ||
1048
+ result == WBWIIteratorImpl::kError) {
1049
+ continue;
1050
+ }
1051
+
1052
+ if (result == WBWIIteratorImpl::kDeleted) {
1053
+ *s = Status::NotFound();
1054
+ continue;
1055
+ }
1056
+
1057
+ if (result == WBWIIteratorImpl::kMergeInProgress) {
1058
+ merges.emplace_back(key, s, std::move(merge_context), columns);
1059
+
1060
+ // The columns field will be populated by the loop below to prevent issues
1061
+ // with dangling pointers.
1062
+ key_contexts.emplace_back(column_family, key, /* value */ nullptr,
1063
+ /* columns */ nullptr, /* timestamp */ nullptr,
1064
+ s);
1065
+ continue;
1066
+ }
1067
+
1068
+ assert(result == WBWIIteratorImpl::kNotFound);
1069
+ key_contexts.emplace_back(column_family, key, /* value */ nullptr, columns,
1070
+ /* timestamp */ nullptr, s);
1071
+ }
1072
+
1073
+ autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE> sorted_keys;
1074
+ sorted_keys.reserve(key_contexts.size());
1075
+
1076
+ size_t merges_idx = 0;
1077
+ for (KeyContext& key_context : key_contexts) {
1078
+ if (!key_context.columns) {
1079
+ assert(*key_context.key == merges[merges_idx].key);
1080
+
1081
+ key_context.columns = &merges[merges_idx].existing;
1082
+ ++merges_idx;
1083
+ }
1084
+
1085
+ sorted_keys.emplace_back(&key_context);
1086
+ }
1087
+
1088
+ static_cast_with_check<DBImpl>(db->GetRootDB())
1089
+ ->PrepareMultiGetKeys(sorted_keys.size(), sorted_input, &sorted_keys);
1090
+ static_cast_with_check<DBImpl>(db->GetRootDB())
1091
+ ->MultiGetEntityWithCallback(read_options, column_family, callback,
1092
+ &sorted_keys);
1093
+
1094
+ for (const auto& merge : merges) {
1095
+ if (merge.s->ok() || merge.s->IsNotFound()) { // DB lookup succeeded
1096
+ MergeAcrossBatchAndDB(column_family, merge.key, merge.existing,
1097
+ merge.merge_context, merge.columns, merge.s);
1098
+ }
1099
+ }
1100
+ }
1101
+
803
1102
  void WriteBatchWithIndex::SetSavePoint() { rep->write_batch.SetSavePoint(); }
804
1103
 
805
1104
  Status WriteBatchWithIndex::RollbackToSavePoint() {
@@ -36,6 +36,8 @@ BaseDeltaIterator::BaseDeltaIterator(ColumnFamilyHandle* column_family,
36
36
  assert(comparator_);
37
37
  }
38
38
 
39
+ BaseDeltaIterator::~BaseDeltaIterator() = default;
40
+
39
41
  bool BaseDeltaIterator::Valid() const {
40
42
  return status_.ok() ? (current_at_base_ ? BaseValid() : DeltaValid()) : false;
41
43
  }
@@ -281,6 +283,7 @@ void BaseDeltaIterator::SetValueAndColumnsFromDelta() {
281
283
 
282
284
  status_ = WideColumnSerialization::Deserialize(value_copy, columns_);
283
285
  if (!status_.ok()) {
286
+ columns_.clear();
284
287
  return;
285
288
  }
286
289
 
@@ -340,6 +343,7 @@ void BaseDeltaIterator::SetValueAndColumnsFromDelta() {
340
343
 
341
344
  status_ = WideColumnSerialization::Deserialize(entity, columns_);
342
345
  if (!status_.ok()) {
346
+ columns_.clear();
343
347
  return;
344
348
  }
345
349
 
@@ -838,6 +842,9 @@ WBWIIteratorImpl::Result WriteBatchWithIndexInternal::GetFromBatchImpl(
838
842
  Traits::ClearOutput(output);
839
843
  result = WBWIIteratorImpl::Result::kError;
840
844
  }
845
+ } else {
846
+ Traits::ClearOutput(output);
847
+ *s = Status::OK();
841
848
  }
842
849
 
843
850
  return result;
@@ -38,7 +38,7 @@ class BaseDeltaIterator : public Iterator {
38
38
  WBWIIteratorImpl* delta_iterator,
39
39
  const Comparator* comparator);
40
40
 
41
- ~BaseDeltaIterator() override {}
41
+ ~BaseDeltaIterator() override;
42
42
 
43
43
  bool Valid() const override;
44
44
  void SeekToFirst() override;
@@ -1,102 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
- // This source code is licensed under both the GPLv2 (found in the
3
- // COPYING file in the root directory) and Apache 2.0 License
4
- // (found in the LICENSE.Apache file in the root directory).
5
-
6
- #include "db/multi_cf_iterator.h"
7
-
8
- #include <cassert>
9
-
10
- namespace ROCKSDB_NAMESPACE {
11
-
12
- template <typename BinaryHeap, typename ChildSeekFuncType>
13
- void MultiCfIterator::SeekCommon(BinaryHeap& heap,
14
- ChildSeekFuncType child_seek_func) {
15
- heap.clear();
16
- int i = 0;
17
- for (auto& cfh_iter_pair : cfh_iter_pairs_) {
18
- auto& cfh = cfh_iter_pair.first;
19
- auto& iter = cfh_iter_pair.second;
20
- child_seek_func(iter.get());
21
- if (iter->Valid()) {
22
- assert(iter->status().ok());
23
- heap.push(MultiCfIteratorInfo{iter.get(), cfh, i});
24
- } else {
25
- considerStatus(iter->status());
26
- }
27
- ++i;
28
- }
29
- }
30
-
31
- template <typename BinaryHeap, typename AdvanceFuncType>
32
- void MultiCfIterator::AdvanceIterator(BinaryHeap& heap,
33
- AdvanceFuncType advance_func) {
34
- // 1. Keep the top iterator (by popping it from the heap)
35
- // 2. Make sure all others have iterated past the top iterator key slice
36
- // 3. Advance the top iterator, and add it back to the heap if valid
37
- auto top = heap.top();
38
- heap.pop();
39
- if (!heap.empty()) {
40
- auto* current = heap.top().iterator;
41
- while (current->Valid() &&
42
- comparator_->Compare(top.iterator->key(), current->key()) == 0) {
43
- assert(current->status().ok());
44
- advance_func(current);
45
- if (current->Valid()) {
46
- heap.replace_top(heap.top());
47
- } else {
48
- considerStatus(current->status());
49
- heap.pop();
50
- }
51
- if (!heap.empty()) {
52
- current = heap.top().iterator;
53
- }
54
- }
55
- }
56
- advance_func(top.iterator);
57
- if (top.iterator->Valid()) {
58
- assert(top.iterator->status().ok());
59
- heap.push(top);
60
- } else {
61
- considerStatus(top.iterator->status());
62
- }
63
- }
64
-
65
- void MultiCfIterator::SeekToFirst() {
66
- auto& min_heap = GetHeap<MultiCfMinHeap>([this]() { InitMinHeap(); });
67
- SeekCommon(min_heap, [](Iterator* iter) { iter->SeekToFirst(); });
68
- }
69
- void MultiCfIterator::Seek(const Slice& target) {
70
- auto& min_heap = GetHeap<MultiCfMinHeap>([this]() { InitMinHeap(); });
71
- SeekCommon(min_heap, [&target](Iterator* iter) { iter->Seek(target); });
72
- }
73
- void MultiCfIterator::SeekToLast() {
74
- auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() { InitMaxHeap(); });
75
- SeekCommon(max_heap, [](Iterator* iter) { iter->SeekToLast(); });
76
- }
77
- void MultiCfIterator::SeekForPrev(const Slice& target) {
78
- auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() { InitMaxHeap(); });
79
- SeekCommon(max_heap,
80
- [&target](Iterator* iter) { iter->SeekForPrev(target); });
81
- }
82
-
83
- void MultiCfIterator::Next() {
84
- assert(Valid());
85
- auto& min_heap = GetHeap<MultiCfMinHeap>([this]() {
86
- Slice target = key();
87
- InitMinHeap();
88
- Seek(target);
89
- });
90
- AdvanceIterator(min_heap, [](Iterator* iter) { iter->Next(); });
91
- }
92
- void MultiCfIterator::Prev() {
93
- assert(Valid());
94
- auto& max_heap = GetHeap<MultiCfMaxHeap>([this]() {
95
- Slice target = key();
96
- InitMaxHeap();
97
- SeekForPrev(target);
98
- });
99
- AdvanceIterator(max_heap, [](Iterator* iter) { iter->Prev(); });
100
- }
101
-
102
- } // namespace ROCKSDB_NAMESPACE
@@ -1,159 +0,0 @@
1
- // Copyright (c) Meta Platforms, Inc. and affiliates.
2
- // This source code is licensed under both the GPLv2 (found in the
3
- // COPYING file in the root directory) and Apache 2.0 License
4
- // (found in the LICENSE.Apache file in the root directory).
5
-
6
- #pragma once
7
-
8
- #include <variant>
9
-
10
- #include "rocksdb/comparator.h"
11
- #include "rocksdb/iterator.h"
12
- #include "rocksdb/options.h"
13
- #include "util/heap.h"
14
- #include "util/overload.h"
15
-
16
- namespace ROCKSDB_NAMESPACE {
17
-
18
- // UNDER CONSTRUCTION - DO NOT USE
19
- // A cross-column-family iterator from a consistent database state.
20
- // When the same key exists in more than one column families, the iterator
21
- // selects the value from the first column family containing the key, in the
22
- // order provided in the `column_families` parameter.
23
- class MultiCfIterator : public Iterator {
24
- public:
25
- MultiCfIterator(const Comparator* comparator,
26
- const std::vector<ColumnFamilyHandle*>& column_families,
27
- const std::vector<Iterator*>& child_iterators)
28
- : comparator_(comparator),
29
- heap_(MultiCfMinHeap(
30
- MultiCfHeapItemComparator<std::greater<int>>(comparator_))) {
31
- assert(column_families.size() > 0 &&
32
- column_families.size() == child_iterators.size());
33
- cfh_iter_pairs_.reserve(column_families.size());
34
- for (size_t i = 0; i < column_families.size(); ++i) {
35
- cfh_iter_pairs_.emplace_back(
36
- column_families[i], std::unique_ptr<Iterator>(child_iterators[i]));
37
- }
38
- }
39
- ~MultiCfIterator() override { status_.PermitUncheckedError(); }
40
-
41
- // No copy allowed
42
- MultiCfIterator(const MultiCfIterator&) = delete;
43
- MultiCfIterator& operator=(const MultiCfIterator&) = delete;
44
-
45
- private:
46
- std::vector<std::pair<ColumnFamilyHandle*, std::unique_ptr<Iterator>>>
47
- cfh_iter_pairs_;
48
- ReadOptions read_options_;
49
- Status status_;
50
-
51
- AttributeGroups attribute_groups_;
52
-
53
- struct MultiCfIteratorInfo {
54
- Iterator* iterator;
55
- ColumnFamilyHandle* cfh;
56
- int order;
57
- };
58
-
59
- template <typename CompareOp>
60
- class MultiCfHeapItemComparator {
61
- public:
62
- explicit MultiCfHeapItemComparator(const Comparator* comparator)
63
- : comparator_(comparator) {}
64
- bool operator()(const MultiCfIteratorInfo& a,
65
- const MultiCfIteratorInfo& b) const {
66
- assert(a.iterator);
67
- assert(b.iterator);
68
- assert(a.iterator->Valid());
69
- assert(b.iterator->Valid());
70
- int c = comparator_->Compare(a.iterator->key(), b.iterator->key());
71
- assert(c != 0 || a.order != b.order);
72
- return c == 0 ? a.order - b.order > 0 : CompareOp()(c, 0);
73
- }
74
-
75
- private:
76
- const Comparator* comparator_;
77
- };
78
- const Comparator* comparator_;
79
- using MultiCfMinHeap =
80
- BinaryHeap<MultiCfIteratorInfo,
81
- MultiCfHeapItemComparator<std::greater<int>>>;
82
- using MultiCfMaxHeap = BinaryHeap<MultiCfIteratorInfo,
83
- MultiCfHeapItemComparator<std::less<int>>>;
84
-
85
- using MultiCfIterHeap = std::variant<MultiCfMinHeap, MultiCfMaxHeap>;
86
-
87
- MultiCfIterHeap heap_;
88
-
89
- // TODO: Lower and Upper bounds
90
-
91
- Iterator* current() const {
92
- if (std::holds_alternative<MultiCfMaxHeap>(heap_)) {
93
- auto& max_heap = std::get<MultiCfMaxHeap>(heap_);
94
- return max_heap.top().iterator;
95
- }
96
- auto& min_heap = std::get<MultiCfMinHeap>(heap_);
97
- return min_heap.top().iterator;
98
- }
99
-
100
- Slice key() const override {
101
- assert(Valid());
102
- return current()->key();
103
- }
104
- Slice value() const override {
105
- assert(Valid());
106
- return current()->value();
107
- }
108
- const WideColumns& columns() const override {
109
- assert(Valid());
110
- return current()->columns();
111
- }
112
-
113
- bool Valid() const override {
114
- if (std::holds_alternative<MultiCfMaxHeap>(heap_)) {
115
- auto& max_heap = std::get<MultiCfMaxHeap>(heap_);
116
- return !max_heap.empty() && status_.ok();
117
- }
118
- auto& min_heap = std::get<MultiCfMinHeap>(heap_);
119
- return !min_heap.empty() && status_.ok();
120
- }
121
-
122
- Status status() const override { return status_; }
123
- void considerStatus(Status s) {
124
- if (!s.ok() && status_.ok()) {
125
- status_ = std::move(s);
126
- }
127
- }
128
-
129
- template <typename HeapType, typename InitFunc>
130
- HeapType& GetHeap(InitFunc initFunc) {
131
- if (!std::holds_alternative<HeapType>(heap_)) {
132
- initFunc();
133
- }
134
- return std::get<HeapType>(heap_);
135
- }
136
-
137
- void InitMinHeap() {
138
- heap_.emplace<MultiCfMinHeap>(
139
- MultiCfHeapItemComparator<std::greater<int>>(comparator_));
140
- }
141
- void InitMaxHeap() {
142
- heap_.emplace<MultiCfMaxHeap>(
143
- MultiCfHeapItemComparator<std::less<int>>(comparator_));
144
- }
145
-
146
- template <typename BinaryHeap, typename ChildSeekFuncType>
147
- void SeekCommon(BinaryHeap& heap, ChildSeekFuncType child_seek_func);
148
- template <typename BinaryHeap, typename AdvanceFuncType>
149
- void AdvanceIterator(BinaryHeap& heap, AdvanceFuncType advance_func);
150
-
151
- void SeekToFirst() override;
152
- void SeekToLast() override;
153
- void Seek(const Slice& /*target*/) override;
154
- void SeekForPrev(const Slice& /*target*/) override;
155
- void Next() override;
156
- void Prev() override;
157
- };
158
-
159
- } // namespace ROCKSDB_NAMESPACE