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
@@ -341,7 +341,15 @@ class VersionStorageInfo {
341
341
  EpochNumberRequirement epoch_number_requirement) {
342
342
  epoch_number_requirement_ = epoch_number_requirement;
343
343
  }
344
- void RecoverEpochNumbers(ColumnFamilyData* cfd);
344
+ // Ensure all files have epoch number set.
345
+ // If there is a file missing epoch number, all files' epoch number will be
346
+ // reset according to CF's epoch number. Otherwise, the CF will be updated
347
+ // with the max epoch number of the files.
348
+ //
349
+ // @param restart_epoch This CF's epoch number will be reset to start from 0.
350
+ // @param force Force resetting all files' epoch number.
351
+ void RecoverEpochNumbers(ColumnFamilyData* cfd, bool restart_epoch = true,
352
+ bool force = false);
345
353
 
346
354
  class FileLocation {
347
355
  public:
@@ -789,16 +797,20 @@ struct ObsoleteFileInfo {
789
797
  // the file, usually because the file is trivial moved so two FileMetadata
790
798
  // is managing the file.
791
799
  bool only_delete_metadata = false;
800
+ // To apply to this file
801
+ uint32_t uncache_aggressiveness = 0;
792
802
 
793
803
  ObsoleteFileInfo() noexcept
794
804
  : metadata(nullptr), only_delete_metadata(false) {}
795
805
  ObsoleteFileInfo(FileMetaData* f, const std::string& file_path,
806
+ uint32_t _uncache_aggressiveness,
796
807
  std::shared_ptr<CacheReservationManager>
797
808
  file_metadata_cache_res_mgr_arg = nullptr)
798
809
  : metadata(f),
799
810
  path(file_path),
800
- only_delete_metadata(false),
801
- file_metadata_cache_res_mgr(file_metadata_cache_res_mgr_arg) {}
811
+ uncache_aggressiveness(_uncache_aggressiveness),
812
+ file_metadata_cache_res_mgr(
813
+ std::move(file_metadata_cache_res_mgr_arg)) {}
802
814
 
803
815
  ObsoleteFileInfo(const ObsoleteFileInfo&) = delete;
804
816
  ObsoleteFileInfo& operator=(const ObsoleteFileInfo&) = delete;
@@ -808,9 +820,13 @@ struct ObsoleteFileInfo {
808
820
  }
809
821
 
810
822
  ObsoleteFileInfo& operator=(ObsoleteFileInfo&& rhs) noexcept {
811
- path = std::move(rhs.path);
812
823
  metadata = rhs.metadata;
813
824
  rhs.metadata = nullptr;
825
+ path = std::move(rhs.path);
826
+ only_delete_metadata = rhs.only_delete_metadata;
827
+ rhs.only_delete_metadata = false;
828
+ uncache_aggressiveness = rhs.uncache_aggressiveness;
829
+ rhs.uncache_aggressiveness = 0;
814
830
  file_metadata_cache_res_mgr = rhs.file_metadata_cache_res_mgr;
815
831
  rhs.file_metadata_cache_res_mgr = nullptr;
816
832
 
@@ -1258,7 +1274,8 @@ class VersionSet {
1258
1274
  // are not opened
1259
1275
  Status Recover(const std::vector<ColumnFamilyDescriptor>& column_families,
1260
1276
  bool read_only = false, std::string* db_id = nullptr,
1261
- bool no_error_if_files_missing = false);
1277
+ bool no_error_if_files_missing = false, bool is_retry = false,
1278
+ Status* log_status = nullptr);
1262
1279
 
1263
1280
  Status TryRecover(const std::vector<ColumnFamilyDescriptor>& column_families,
1264
1281
  bool read_only,
@@ -1486,10 +1503,7 @@ class VersionSet {
1486
1503
  void GetLiveFilesMetaData(std::vector<LiveFileMetaData>* metadata);
1487
1504
 
1488
1505
  void AddObsoleteBlobFile(uint64_t blob_file_number, std::string path) {
1489
- assert(table_cache_);
1490
-
1491
- table_cache_->Erase(GetSliceForKey(&blob_file_number));
1492
-
1506
+ // TODO: Erase file from BlobFileCache?
1493
1507
  obsolete_blob_files_.emplace_back(blob_file_number, std::move(path));
1494
1508
  }
1495
1509
 
@@ -1667,6 +1681,8 @@ class VersionSet {
1667
1681
  // Current size of manifest file
1668
1682
  uint64_t manifest_file_size_;
1669
1683
 
1684
+ // Obsolete files, or during DB shutdown any files not referenced by what's
1685
+ // left of the in-memory LSM state.
1670
1686
  std::vector<ObsoleteFileInfo> obsolete_files_;
1671
1687
  std::vector<ObsoleteBlobFileInfo> obsolete_blob_files_;
1672
1688
  std::vector<std::string> obsolete_manifests_;
@@ -1732,7 +1748,8 @@ class ReactiveVersionSet : public VersionSet {
1732
1748
  InstrumentedMutex* mu,
1733
1749
  std::unique_ptr<log::FragmentBufferedReader>* manifest_reader,
1734
1750
  Status* manifest_read_status,
1735
- std::unordered_set<ColumnFamilyData*>* cfds_changed);
1751
+ std::unordered_set<ColumnFamilyData*>* cfds_changed,
1752
+ std::vector<std::string>* files_to_delete);
1736
1753
 
1737
1754
  Status Recover(const std::vector<ColumnFamilyDescriptor>& column_families,
1738
1755
  std::unique_ptr<log::FragmentBufferedReader>* manifest_reader,
@@ -43,16 +43,17 @@ Status WalManager::DeleteFile(const std::string& fname, uint64_t number) {
43
43
  }
44
44
  return s;
45
45
  }
46
-
47
- Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
46
+ Status WalManager::GetSortedWalFiles(VectorWalPtr& files, bool need_seqnos,
47
+ bool include_archived) {
48
48
  // First get sorted files in db dir, then get sorted files from archived
49
49
  // dir, to avoid a race condition where a log file is moved to archived
50
50
  // dir in between.
51
51
  Status s;
52
52
  // list wal files in main db dir.
53
- VectorLogPtr logs;
54
- s = GetSortedWalsOfType(wal_dir_, logs, kAliveLogFile);
55
- if (!s.ok()) {
53
+ VectorWalPtr logs;
54
+ s = GetSortedWalsOfType(wal_dir_, logs, kAliveLogFile, need_seqnos);
55
+
56
+ if (!include_archived || !s.ok()) {
56
57
  return s;
57
58
  }
58
59
 
@@ -67,13 +68,13 @@ Status WalManager::GetSortedWalFiles(VectorLogPtr& files) {
67
68
  std::string archivedir = ArchivalDirectory(wal_dir_);
68
69
  Status exists = env_->FileExists(archivedir);
69
70
  if (exists.ok()) {
70
- s = GetSortedWalsOfType(archivedir, files, kArchivedLogFile);
71
+ s = GetSortedWalsOfType(archivedir, files, kArchivedLogFile, need_seqnos);
71
72
  if (!s.ok()) {
72
73
  return s;
73
74
  }
74
75
  } else if (!exists.IsNotFound()) {
75
- assert(s.IsIOError());
76
- return s;
76
+ assert(s.ok());
77
+ return exists;
77
78
  }
78
79
 
79
80
  uint64_t latest_archived_log_number = 0;
@@ -113,7 +114,7 @@ Status WalManager::GetUpdatesSince(
113
114
  // Get all sorted Wal Files.
114
115
  // Do binary search and open files and find the seq number.
115
116
 
116
- std::unique_ptr<VectorLogPtr> wal_files(new VectorLogPtr);
117
+ std::unique_ptr<VectorWalPtr> wal_files(new VectorWalPtr);
117
118
  Status s = GetSortedWalFiles(*wal_files);
118
119
  if (!s.ok()) {
119
120
  return s;
@@ -173,7 +174,6 @@ void WalManager::PurgeObsoleteWALFiles() {
173
174
  if (!s.ok()) {
174
175
  ROCKS_LOG_ERROR(db_options_.info_log, "Can't get archive files: %s",
175
176
  s.ToString().c_str());
176
- assert(false);
177
177
  return;
178
178
  }
179
179
 
@@ -249,8 +249,9 @@ void WalManager::PurgeObsoleteWALFiles() {
249
249
  }
250
250
 
251
251
  size_t files_del_num = log_files_num - files_keep_num;
252
- VectorLogPtr archived_logs;
253
- s = GetSortedWalsOfType(archival_dir, archived_logs, kArchivedLogFile);
252
+ VectorWalPtr archived_logs;
253
+ s = GetSortedWalsOfType(archival_dir, archived_logs, kArchivedLogFile,
254
+ /*need_seqno=*/false);
254
255
  if (!s.ok()) {
255
256
  ROCKS_LOG_WARN(db_options_.info_log,
256
257
  "Unable to get archived WALs from: %s: %s",
@@ -285,14 +286,17 @@ void WalManager::ArchiveWALFile(const std::string& fname, uint64_t number) {
285
286
  Status s = env_->RenameFile(fname, archived_log_name);
286
287
  // The sync point below is used in (DBTest,TransactionLogIteratorRace)
287
288
  TEST_SYNC_POINT("WalManager::PurgeObsoleteFiles:2");
289
+ // The sync point below is used in
290
+ // (CheckPointTest, CheckpointWithArchievedLog)
291
+ TEST_SYNC_POINT("WalManager::ArchiveWALFile");
288
292
  ROCKS_LOG_INFO(db_options_.info_log, "Move log file %s to %s -- %s\n",
289
293
  fname.c_str(), archived_log_name.c_str(),
290
294
  s.ToString().c_str());
291
295
  }
292
296
 
293
297
  Status WalManager::GetSortedWalsOfType(const std::string& path,
294
- VectorLogPtr& log_files,
295
- WalFileType log_type) {
298
+ VectorWalPtr& log_files,
299
+ WalFileType log_type, bool need_seqnos) {
296
300
  std::vector<std::string> all_files;
297
301
  const Status status = env_->GetChildren(path, &all_files);
298
302
  if (!status.ok()) {
@@ -304,13 +308,17 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
304
308
  FileType type;
305
309
  if (ParseFileName(f, &number, &type) && type == kWalFile) {
306
310
  SequenceNumber sequence;
307
- Status s = ReadFirstRecord(log_type, number, &sequence);
308
- if (!s.ok()) {
309
- return s;
310
- }
311
- if (sequence == 0) {
312
- // empty file
313
- continue;
311
+ if (need_seqnos) {
312
+ Status s = ReadFirstRecord(log_type, number, &sequence);
313
+ if (!s.ok()) {
314
+ return s;
315
+ }
316
+ if (sequence == 0) {
317
+ // empty file
318
+ continue;
319
+ }
320
+ } else {
321
+ sequence = 0;
314
322
  }
315
323
 
316
324
  // Reproduce the race condition where a log file is moved
@@ -320,7 +328,7 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
320
328
  TEST_SYNC_POINT("WalManager::GetSortedWalsOfType:2");
321
329
 
322
330
  uint64_t size_bytes;
323
- s = env_->GetFileSize(LogFileName(path, number), &size_bytes);
331
+ Status s = env_->GetFileSize(LogFileName(path, number), &size_bytes);
324
332
  // re-try in case the alive log file has been moved to archive.
325
333
  if (!s.ok() && log_type == kAliveLogFile) {
326
334
  std::string archived_file = ArchivedLogFileName(path, number);
@@ -338,20 +346,20 @@ Status WalManager::GetSortedWalsOfType(const std::string& path,
338
346
  }
339
347
 
340
348
  log_files.emplace_back(
341
- new LogFileImpl(number, log_type, sequence, size_bytes));
349
+ new WalFileImpl(number, log_type, sequence, size_bytes));
342
350
  }
343
351
  }
344
352
  std::sort(
345
353
  log_files.begin(), log_files.end(),
346
- [](const std::unique_ptr<LogFile>& a, const std::unique_ptr<LogFile>& b) {
347
- LogFileImpl* a_impl = static_cast_with_check<LogFileImpl>(a.get());
348
- LogFileImpl* b_impl = static_cast_with_check<LogFileImpl>(b.get());
354
+ [](const std::unique_ptr<WalFile>& a, const std::unique_ptr<WalFile>& b) {
355
+ WalFileImpl* a_impl = static_cast_with_check<WalFileImpl>(a.get());
356
+ WalFileImpl* b_impl = static_cast_with_check<WalFileImpl>(b.get());
349
357
  return *a_impl < *b_impl;
350
358
  });
351
359
  return status;
352
360
  }
353
361
 
354
- Status WalManager::RetainProbableWalFiles(VectorLogPtr& all_logs,
362
+ Status WalManager::RetainProbableWalFiles(VectorWalPtr& all_logs,
355
363
  const SequenceNumber target) {
356
364
  int64_t start = 0; // signed to avoid overflow when target is < first file.
357
365
  int64_t end = static_cast<int64_t>(all_logs.size()) - 1;
@@ -424,7 +432,7 @@ Status WalManager::ReadFirstRecord(const WalFileType type,
424
432
  }
425
433
 
426
434
  Status WalManager::GetLiveWalFile(uint64_t number,
427
- std::unique_ptr<LogFile>* log_file) {
435
+ std::unique_ptr<WalFile>* log_file) {
428
436
  if (!log_file) {
429
437
  return Status::InvalidArgument("log_file not preallocated.");
430
438
  }
@@ -442,7 +450,7 @@ Status WalManager::GetLiveWalFile(uint64_t number,
442
450
  return s;
443
451
  }
444
452
 
445
- log_file->reset(new LogFileImpl(number, kAliveLogFile,
453
+ log_file->reset(new WalFileImpl(number, kAliveLogFile,
446
454
  0, // SequenceNumber
447
455
  size_bytes));
448
456
 
@@ -49,7 +49,8 @@ class WalManager {
49
49
  wal_in_db_path_(db_options_.IsWalDirSameAsDBPath()),
50
50
  io_tracer_(io_tracer) {}
51
51
 
52
- Status GetSortedWalFiles(VectorLogPtr& files);
52
+ Status GetSortedWalFiles(VectorWalPtr& files, bool need_seqnos = true,
53
+ bool include_archived = true);
53
54
 
54
55
  // Allow user to tail transaction log to find all recent changes to the
55
56
  // database that are newer than `seq_number`.
@@ -64,7 +65,7 @@ class WalManager {
64
65
 
65
66
  Status DeleteFile(const std::string& fname, uint64_t number);
66
67
 
67
- Status GetLiveWalFile(uint64_t number, std::unique_ptr<LogFile>* log_file);
68
+ Status GetLiveWalFile(uint64_t number, std::unique_ptr<WalFile>* log_file);
68
69
 
69
70
  Status TEST_ReadFirstRecord(const WalFileType type, const uint64_t number,
70
71
  SequenceNumber* sequence) {
@@ -77,12 +78,12 @@ class WalManager {
77
78
  }
78
79
 
79
80
  private:
80
- Status GetSortedWalsOfType(const std::string& path, VectorLogPtr& log_files,
81
- WalFileType type);
81
+ Status GetSortedWalsOfType(const std::string& path, VectorWalPtr& log_files,
82
+ WalFileType type, bool need_seqnos);
82
83
  // Requires: all_logs should be sorted with earliest log file first
83
84
  // Retains all log files in all_logs which contain updates with seq no.
84
85
  // Greater Than or Equal to the requested SequenceNumber.
85
- Status RetainProbableWalFiles(VectorLogPtr& all_logs,
86
+ Status RetainProbableWalFiles(VectorWalPtr& all_logs,
86
87
  const SequenceNumber target);
87
88
 
88
89
  // ReadFirstRecord checks the read_first_record_cache_ to see if the entry
@@ -4,7 +4,6 @@
4
4
  // (found in the LICENSE.Apache file in the root directory).
5
5
 
6
6
  #include "rocksdb/wide_columns.h"
7
-
8
7
  #include "db/wide/wide_column_serialization.h"
9
8
 
10
9
  namespace ROCKSDB_NAMESPACE {
@@ -12,11 +11,11 @@ namespace ROCKSDB_NAMESPACE {
12
11
  const Slice kDefaultWideColumnName;
13
12
 
14
13
  const WideColumns kNoWideColumns;
15
- const AttributeGroups kNoAttributeGroups;
16
14
 
17
15
  Status PinnableWideColumns::CreateIndexForWideColumns() {
18
- Slice value_copy = value_;
16
+ columns_.clear();
19
17
 
18
+ Slice value_copy = value_;
20
19
  return WideColumnSerialization::Deserialize(value_copy, columns_);
21
20
  }
22
21
 
@@ -6,6 +6,7 @@
6
6
  #include "db/wide/wide_columns_helper.h"
7
7
 
8
8
  #include <algorithm>
9
+ #include <ios>
9
10
 
10
11
  #include "db/wide/wide_column_serialization.h"
11
12
 
@@ -15,6 +16,9 @@ void WideColumnsHelper::DumpWideColumns(const WideColumns& columns,
15
16
  if (columns.empty()) {
16
17
  return;
17
18
  }
19
+
20
+ const std::ios_base::fmtflags orig_flags = os.flags();
21
+
18
22
  if (hex) {
19
23
  os << std::hex;
20
24
  }
@@ -23,6 +27,8 @@ void WideColumnsHelper::DumpWideColumns(const WideColumns& columns,
23
27
  for (++it; it != columns.end(); ++it) {
24
28
  os << ' ' << *it;
25
29
  }
30
+
31
+ os.flags(orig_flags);
26
32
  }
27
33
 
28
34
  Status WideColumnsHelper::DumpSliceAsWideColumns(const Slice& value,
@@ -65,6 +65,7 @@
65
65
  #include "port/lang.h"
66
66
  #include "rocksdb/merge_operator.h"
67
67
  #include "rocksdb/system_clock.h"
68
+ #include "util/aligned_storage.h"
68
69
  #include "util/autovector.h"
69
70
  #include "util/cast_util.h"
70
71
  #include "util/coding.h"
@@ -484,13 +485,22 @@ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
484
485
  return Status::Corruption("bad WriteBatch TimedPut");
485
486
  }
486
487
  FALLTHROUGH_INTENDED;
487
- case kTypeValuePreferredSeqno:
488
+ case kTypeValuePreferredSeqno: {
489
+ Slice packed_value;
488
490
  if (!GetLengthPrefixedSlice(input, key) ||
489
- !GetLengthPrefixedSlice(input, value) ||
490
- !GetFixed64(input, write_unix_time)) {
491
+ !GetLengthPrefixedSlice(input, &packed_value)) {
491
492
  return Status::Corruption("bad WriteBatch TimedPut");
492
493
  }
494
+ if (write_unix_time) {
495
+ std::tie(*value, *write_unix_time) =
496
+ ParsePackedValueWithWriteTime(packed_value);
497
+ } else {
498
+ // Caller doesn't want to unpack write_unix_time, so keep it packed in
499
+ // the value.
500
+ *value = packed_value;
501
+ }
493
502
  break;
503
+ }
494
504
  default:
495
505
  return Status::Corruption("unknown WriteBatch tag");
496
506
  }
@@ -883,12 +893,11 @@ Status WriteBatchInternal::TimedPut(WriteBatch* b, uint32_t column_family_id,
883
893
  b->rep_.push_back(static_cast<char>(kTypeColumnFamilyValuePreferredSeqno));
884
894
  PutVarint32(&b->rep_, column_family_id);
885
895
  }
896
+ std::string value_buf;
897
+ Slice packed_value =
898
+ PackValueAndWriteTime(value, write_unix_time, &value_buf);
886
899
  PutLengthPrefixedSlice(&b->rep_, key);
887
- PutLengthPrefixedSlice(&b->rep_, value);
888
- // For a kTypeValuePreferredSeqno entry, its write time is encoded separately
889
- // from value in an encoded WriteBatch. They are packed into one value Slice
890
- // once it's written to the database.
891
- PutFixed64(&b->rep_, write_unix_time);
900
+ PutLengthPrefixedSlice(&b->rep_, packed_value);
892
901
 
893
902
  b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
894
903
  ContentFlags::HAS_TIMED_PUT,
@@ -899,7 +908,7 @@ Status WriteBatchInternal::TimedPut(WriteBatch* b, uint32_t column_family_id,
899
908
  // `kTypeColumnFamilyValuePreferredSeqno` here.
900
909
  b->prot_info_->entries_.emplace_back(
901
910
  ProtectionInfo64()
902
- .ProtectKVO(key, value, kTypeValuePreferredSeqno)
911
+ .ProtectKVO(key, packed_value, kTypeValuePreferredSeqno)
903
912
  .ProtectC(column_family_id));
904
913
  }
905
914
  return save.commit();
@@ -1779,7 +1788,6 @@ Status WriteBatch::VerifyChecksum() const {
1779
1788
  Slice input(rep_.data() + WriteBatchInternal::kHeader,
1780
1789
  rep_.size() - WriteBatchInternal::kHeader);
1781
1790
  Slice key, value, blob, xid;
1782
- uint64_t unix_write_time = 0;
1783
1791
  char tag = 0;
1784
1792
  uint32_t column_family = 0; // default
1785
1793
  Status s;
@@ -1792,7 +1800,7 @@ Status WriteBatch::VerifyChecksum() const {
1792
1800
  value.clear();
1793
1801
  column_family = 0;
1794
1802
  s = ReadRecordFromWriteBatch(&input, &tag, &column_family, &key, &value,
1795
- &blob, &xid, &unix_write_time);
1803
+ &blob, &xid, /*write_unix_time=*/nullptr);
1796
1804
  if (!s.ok()) {
1797
1805
  return s;
1798
1806
  }
@@ -1893,7 +1901,7 @@ class MemTableInserter : public WriteBatch::Handler {
1893
1901
  // Make creation optional but do not incur
1894
1902
  // std::unique_ptr additional allocation
1895
1903
  using MemPostInfoMap = std::map<MemTable*, MemTablePostProcessInfo>;
1896
- using PostMapType = std::aligned_storage<sizeof(MemPostInfoMap)>::type;
1904
+ using PostMapType = aligned_storage<MemPostInfoMap>::type;
1897
1905
  PostMapType mem_post_info_map_;
1898
1906
  // current recovered transaction we are rebuilding (recovery)
1899
1907
  WriteBatch* rebuilding_trx_;
@@ -1907,7 +1915,7 @@ class MemTableInserter : public WriteBatch::Handler {
1907
1915
  bool write_before_prepare_;
1908
1916
  // Whether this batch was unprepared or not
1909
1917
  bool unprepared_batch_;
1910
- using DupDetector = std::aligned_storage<sizeof(DuplicateDetector)>::type;
1918
+ using DupDetector = aligned_storage<DuplicateDetector>::type;
1911
1919
  DupDetector duplicate_detector_;
1912
1920
  bool dup_dectector_on_;
1913
1921
 
@@ -1915,7 +1923,7 @@ class MemTableInserter : public WriteBatch::Handler {
1915
1923
  bool hint_created_;
1916
1924
  // Hints for this batch
1917
1925
  using HintMap = std::unordered_map<MemTable*, void*>;
1918
- using HintMapType = std::aligned_storage<sizeof(HintMap)>::type;
1926
+ using HintMapType = aligned_storage<HintMap>::type;
1919
1927
  HintMapType hint_;
1920
1928
 
1921
1929
  HintMap& GetHintMap() {
@@ -2114,14 +2122,15 @@ class MemTableInserter : public WriteBatch::Handler {
2114
2122
  return true;
2115
2123
  }
2116
2124
 
2125
+ template <typename RebuildTxnOp>
2117
2126
  Status PutCFImpl(uint32_t column_family_id, const Slice& key,
2118
2127
  const Slice& value, ValueType value_type,
2128
+ RebuildTxnOp rebuild_txn_op,
2119
2129
  const ProtectionInfoKVOS64* kv_prot_info) {
2120
2130
  // optimize for non-recovery mode
2121
2131
  if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
2122
2132
  // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
2123
- return WriteBatchInternal::Put(rebuilding_trx_, column_family_id, key,
2124
- value);
2133
+ return rebuild_txn_op(rebuilding_trx_, column_family_id, key, value);
2125
2134
  // else insert the values to the memtable right away
2126
2135
  }
2127
2136
 
@@ -2132,8 +2141,8 @@ class MemTableInserter : public WriteBatch::Handler {
2132
2141
  // The CF is probably flushed and hence no need for insert but we still
2133
2142
  // need to keep track of the keys for upcoming rollback/commit.
2134
2143
  // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
2135
- ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
2136
- key, value);
2144
+ ret_status =
2145
+ rebuild_txn_op(rebuilding_trx_, column_family_id, key, value);
2137
2146
  if (ret_status.ok()) {
2138
2147
  MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, key));
2139
2148
  }
@@ -2257,8 +2266,8 @@ class MemTableInserter : public WriteBatch::Handler {
2257
2266
  if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
2258
2267
  assert(!write_after_commit_);
2259
2268
  // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
2260
- ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
2261
- key, value);
2269
+ ret_status =
2270
+ rebuild_txn_op(rebuilding_trx_, column_family_id, key, value);
2262
2271
  }
2263
2272
  return ret_status;
2264
2273
  }
@@ -2267,15 +2276,21 @@ class MemTableInserter : public WriteBatch::Handler {
2267
2276
  const Slice& value) override {
2268
2277
  const auto* kv_prot_info = NextProtectionInfo();
2269
2278
  Status ret_status;
2279
+
2280
+ auto rebuild_txn_op = [](WriteBatch* rebuilding_trx, uint32_t cf_id,
2281
+ const Slice& k, const Slice& v) -> Status {
2282
+ return WriteBatchInternal::Put(rebuilding_trx, cf_id, k, v);
2283
+ };
2284
+
2270
2285
  if (kv_prot_info != nullptr) {
2271
2286
  // Memtable needs seqno, doesn't need CF ID
2272
2287
  auto mem_kv_prot_info =
2273
2288
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
2274
2289
  ret_status = PutCFImpl(column_family_id, key, value, kTypeValue,
2275
- &mem_kv_prot_info);
2290
+ rebuild_txn_op, &mem_kv_prot_info);
2276
2291
  } else {
2277
2292
  ret_status = PutCFImpl(column_family_id, key, value, kTypeValue,
2278
- nullptr /* kv_prot_info */);
2293
+ rebuild_txn_op, nullptr /* kv_prot_info */);
2279
2294
  }
2280
2295
  // TODO: this assumes that if TryAgain status is returned to the caller,
2281
2296
  // the operation is actually tried again. The proper way to do this is to
@@ -2294,15 +2309,23 @@ class MemTableInserter : public WriteBatch::Handler {
2294
2309
  std::string value_buf;
2295
2310
  Slice packed_value =
2296
2311
  PackValueAndWriteTime(value, unix_write_time, &value_buf);
2312
+
2313
+ auto rebuild_txn_op = [](WriteBatch* /* rebuilding_trx */,
2314
+ uint32_t /* cf_id */, const Slice& /* k */,
2315
+ const Slice& /* v */) -> Status {
2316
+ return Status::NotSupported();
2317
+ };
2318
+
2297
2319
  if (kv_prot_info != nullptr) {
2298
2320
  auto mem_kv_prot_info =
2299
2321
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
2300
2322
  ret_status = PutCFImpl(column_family_id, key, packed_value,
2301
- kTypeValuePreferredSeqno, &mem_kv_prot_info);
2323
+ kTypeValuePreferredSeqno, rebuild_txn_op,
2324
+ &mem_kv_prot_info);
2302
2325
  } else {
2303
- ret_status =
2304
- PutCFImpl(column_family_id, key, packed_value,
2305
- kTypeValuePreferredSeqno, nullptr /* kv_prot_info */);
2326
+ ret_status = PutCFImpl(column_family_id, key, packed_value,
2327
+ kTypeValuePreferredSeqno, rebuild_txn_op,
2328
+ nullptr /* kv_prot_info */);
2306
2329
  }
2307
2330
 
2308
2331
  // TODO: this assumes that if TryAgain status is returned to the caller,
@@ -2320,14 +2343,27 @@ class MemTableInserter : public WriteBatch::Handler {
2320
2343
  const auto* kv_prot_info = NextProtectionInfo();
2321
2344
 
2322
2345
  Status s;
2346
+
2347
+ auto rebuild_txn_op = [](WriteBatch* rebuilding_trx, uint32_t cf_id,
2348
+ const Slice& k, Slice entity) -> Status {
2349
+ WideColumns columns;
2350
+ const Status st = WideColumnSerialization::Deserialize(entity, columns);
2351
+ if (!st.ok()) {
2352
+ return st;
2353
+ }
2354
+
2355
+ return WriteBatchInternal::PutEntity(rebuilding_trx, cf_id, k, columns);
2356
+ };
2357
+
2323
2358
  if (kv_prot_info) {
2324
2359
  // Memtable needs seqno, doesn't need CF ID
2325
2360
  auto mem_kv_prot_info =
2326
2361
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
2327
2362
  s = PutCFImpl(column_family_id, key, value, kTypeWideColumnEntity,
2328
- &mem_kv_prot_info);
2363
+ rebuild_txn_op, &mem_kv_prot_info);
2329
2364
  } else {
2330
2365
  s = PutCFImpl(column_family_id, key, value, kTypeWideColumnEntity,
2366
+ rebuild_txn_op,
2331
2367
  /* kv_prot_info */ nullptr);
2332
2368
  }
2333
2369
 
@@ -2766,16 +2802,23 @@ class MemTableInserter : public WriteBatch::Handler {
2766
2802
  const Slice& value) override {
2767
2803
  const auto* kv_prot_info = NextProtectionInfo();
2768
2804
  Status ret_status;
2805
+
2806
+ auto rebuild_txn_op = [](WriteBatch* /* rebuilding_trx */,
2807
+ uint32_t /* cf_id */, const Slice& /* k */,
2808
+ const Slice& /* v */) -> Status {
2809
+ return Status::NotSupported();
2810
+ };
2811
+
2769
2812
  if (kv_prot_info != nullptr) {
2770
2813
  // Memtable needs seqno, doesn't need CF ID
2771
2814
  auto mem_kv_prot_info =
2772
2815
  kv_prot_info->StripC(column_family_id).ProtectS(sequence_);
2773
2816
  // Same as PutCF except for value type.
2774
2817
  ret_status = PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2775
- &mem_kv_prot_info);
2818
+ rebuild_txn_op, &mem_kv_prot_info);
2776
2819
  } else {
2777
2820
  ret_status = PutCFImpl(column_family_id, key, value, kTypeBlobIndex,
2778
- nullptr /* kv_prot_info */);
2821
+ rebuild_txn_op, nullptr /* kv_prot_info */);
2779
2822
  }
2780
2823
  if (UNLIKELY(ret_status.IsTryAgain())) {
2781
2824
  DecrementProtectionInfoIdxForTryAgain();
@@ -3162,8 +3205,12 @@ class ProtectionInfoUpdater : public WriteBatch::Handler {
3162
3205
  }
3163
3206
 
3164
3207
  Status TimedPutCF(uint32_t cf, const Slice& key, const Slice& val,
3165
- uint64_t /*unix_write_time*/) override {
3166
- return UpdateProtInfo(cf, key, val, kTypeValuePreferredSeqno);
3208
+ uint64_t unix_write_time) override {
3209
+ std::string encoded_write_time;
3210
+ PutFixed64(&encoded_write_time, unix_write_time);
3211
+ std::array<Slice, 2> value_with_time{{val, encoded_write_time}};
3212
+ SliceParts packed_value(value_with_time.data(), 2);
3213
+ return UpdateProtInfo(cf, key, packed_value, kTypeValuePreferredSeqno);
3167
3214
  }
3168
3215
 
3169
3216
  Status PutEntityCF(uint32_t cf, const Slice& key,
@@ -3222,6 +3269,17 @@ class ProtectionInfoUpdater : public WriteBatch::Handler {
3222
3269
  return Status::OK();
3223
3270
  }
3224
3271
 
3272
+ Status UpdateProtInfo(uint32_t cf, const Slice& key, const SliceParts& val,
3273
+ const ValueType op_type) {
3274
+ if (prot_info_) {
3275
+ prot_info_->entries_.emplace_back(
3276
+ ProtectionInfo64()
3277
+ .ProtectKVO(SliceParts(&key, 1), val, op_type)
3278
+ .ProtectC(cf));
3279
+ }
3280
+ return Status::OK();
3281
+ }
3282
+
3225
3283
  // No copy or move.
3226
3284
  ProtectionInfoUpdater(const ProtectionInfoUpdater&) = delete;
3227
3285
  ProtectionInfoUpdater(ProtectionInfoUpdater&&) = delete;