@nxtedition/rocksdb 1.0.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 (1088) hide show
  1. package/CHANGELOG.md +294 -0
  2. package/LICENSE +21 -0
  3. package/README.md +102 -0
  4. package/UPGRADING.md +91 -0
  5. package/binding.cc +1276 -0
  6. package/binding.gyp +73 -0
  7. package/binding.js +1 -0
  8. package/chained-batch.js +44 -0
  9. package/deps/rocksdb/build_version.cc +4 -0
  10. package/deps/rocksdb/rocksdb/CMakeLists.txt +1356 -0
  11. package/deps/rocksdb/rocksdb/COPYING +339 -0
  12. package/deps/rocksdb/rocksdb/LICENSE.Apache +202 -0
  13. package/deps/rocksdb/rocksdb/LICENSE.leveldb +29 -0
  14. package/deps/rocksdb/rocksdb/Makefile +2521 -0
  15. package/deps/rocksdb/rocksdb/TARGETS +2100 -0
  16. package/deps/rocksdb/rocksdb/cache/cache.cc +63 -0
  17. package/deps/rocksdb/rocksdb/cache/cache_bench.cc +381 -0
  18. package/deps/rocksdb/rocksdb/cache/cache_helpers.h +114 -0
  19. package/deps/rocksdb/rocksdb/cache/cache_test.cc +775 -0
  20. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +769 -0
  21. package/deps/rocksdb/rocksdb/cache/clock_cache.h +16 -0
  22. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +574 -0
  23. package/deps/rocksdb/rocksdb/cache/lru_cache.h +339 -0
  24. package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +199 -0
  25. package/deps/rocksdb/rocksdb/cache/sharded_cache.cc +162 -0
  26. package/deps/rocksdb/rocksdb/cache/sharded_cache.h +111 -0
  27. package/deps/rocksdb/rocksdb/cmake/RocksDBConfig.cmake.in +54 -0
  28. package/deps/rocksdb/rocksdb/cmake/modules/CxxFlags.cmake +7 -0
  29. package/deps/rocksdb/rocksdb/cmake/modules/FindJeMalloc.cmake +29 -0
  30. package/deps/rocksdb/rocksdb/cmake/modules/FindNUMA.cmake +29 -0
  31. package/deps/rocksdb/rocksdb/cmake/modules/FindSnappy.cmake +29 -0
  32. package/deps/rocksdb/rocksdb/cmake/modules/FindTBB.cmake +33 -0
  33. package/deps/rocksdb/rocksdb/cmake/modules/Findgflags.cmake +29 -0
  34. package/deps/rocksdb/rocksdb/cmake/modules/Findlz4.cmake +29 -0
  35. package/deps/rocksdb/rocksdb/cmake/modules/Findzstd.cmake +29 -0
  36. package/deps/rocksdb/rocksdb/cmake/modules/ReadVersion.cmake +10 -0
  37. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +108 -0
  38. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +115 -0
  39. package/deps/rocksdb/rocksdb/db/blob/blob_constants.h +16 -0
  40. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition.cc +154 -0
  41. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition.h +67 -0
  42. package/deps/rocksdb/rocksdb/db/blob/blob_file_addition_test.cc +206 -0
  43. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.cc +316 -0
  44. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.h +91 -0
  45. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder_test.cc +660 -0
  46. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.cc +99 -0
  47. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.h +49 -0
  48. package/deps/rocksdb/rocksdb/db/blob/blob_file_cache_test.cc +268 -0
  49. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage.cc +134 -0
  50. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage.h +57 -0
  51. package/deps/rocksdb/rocksdb/db/blob/blob_file_garbage_test.cc +173 -0
  52. package/deps/rocksdb/rocksdb/db/blob/blob_file_meta.cc +55 -0
  53. package/deps/rocksdb/rocksdb/db/blob/blob_file_meta.h +164 -0
  54. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.cc +423 -0
  55. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.h +81 -0
  56. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader_test.cc +771 -0
  57. package/deps/rocksdb/rocksdb/db/blob/blob_index.h +184 -0
  58. package/deps/rocksdb/rocksdb/db/blob/blob_log_format.cc +145 -0
  59. package/deps/rocksdb/rocksdb/db/blob/blob_log_format.h +148 -0
  60. package/deps/rocksdb/rocksdb/db/blob/blob_log_sequential_reader.cc +132 -0
  61. package/deps/rocksdb/rocksdb/db/blob/blob_log_sequential_reader.h +76 -0
  62. package/deps/rocksdb/rocksdb/db/blob/blob_log_writer.cc +168 -0
  63. package/deps/rocksdb/rocksdb/db/blob/blob_log_writer.h +83 -0
  64. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +307 -0
  65. package/deps/rocksdb/rocksdb/db/blob/db_blob_index_test.cc +464 -0
  66. package/deps/rocksdb/rocksdb/db/builder.cc +358 -0
  67. package/deps/rocksdb/rocksdb/db/builder.h +95 -0
  68. package/deps/rocksdb/rocksdb/db/c.cc +5281 -0
  69. package/deps/rocksdb/rocksdb/db/c_test.c +2883 -0
  70. package/deps/rocksdb/rocksdb/db/column_family.cc +1602 -0
  71. package/deps/rocksdb/rocksdb/db/column_family.h +787 -0
  72. package/deps/rocksdb/rocksdb/db/column_family_test.cc +3427 -0
  73. package/deps/rocksdb/rocksdb/db/compact_files_test.cc +425 -0
  74. package/deps/rocksdb/rocksdb/db/compacted_db_impl.cc +169 -0
  75. package/deps/rocksdb/rocksdb/db/compacted_db_impl.h +118 -0
  76. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +591 -0
  77. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +389 -0
  78. package/deps/rocksdb/rocksdb/db/compaction/compaction_iteration_stats.h +37 -0
  79. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +1023 -0
  80. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +353 -0
  81. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +1254 -0
  82. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +1917 -0
  83. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +208 -0
  84. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_stats_test.cc +1037 -0
  85. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +1224 -0
  86. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +1135 -0
  87. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +318 -0
  88. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +255 -0
  89. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +57 -0
  90. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +510 -0
  91. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +33 -0
  92. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +2190 -0
  93. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +1103 -0
  94. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +32 -0
  95. package/deps/rocksdb/rocksdb/db/compaction/sst_partitioner.cc +44 -0
  96. package/deps/rocksdb/rocksdb/db/comparator_db_test.cc +660 -0
  97. package/deps/rocksdb/rocksdb/db/convenience.cc +78 -0
  98. package/deps/rocksdb/rocksdb/db/corruption_test.cc +921 -0
  99. package/deps/rocksdb/rocksdb/db/cuckoo_table_db_test.cc +359 -0
  100. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +3820 -0
  101. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +1058 -0
  102. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +2128 -0
  103. package/deps/rocksdb/rocksdb/db/db_compaction_filter_test.cc +851 -0
  104. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +6292 -0
  105. package/deps/rocksdb/rocksdb/db/db_dynamic_level_test.cc +509 -0
  106. package/deps/rocksdb/rocksdb/db/db_encryption_test.cc +130 -0
  107. package/deps/rocksdb/rocksdb/db/db_filesnapshot.cc +137 -0
  108. package/deps/rocksdb/rocksdb/db/db_flush_test.cc +1119 -0
  109. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +5057 -0
  110. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +2274 -0
  111. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +3421 -0
  112. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +298 -0
  113. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +151 -0
  114. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +967 -0
  115. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +1806 -0
  116. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +270 -0
  117. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +146 -0
  118. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +683 -0
  119. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +333 -0
  120. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +2024 -0
  121. package/deps/rocksdb/rocksdb/db/db_impl/db_secondary_test.cc +932 -0
  122. package/deps/rocksdb/rocksdb/db/db_info_dumper.cc +137 -0
  123. package/deps/rocksdb/rocksdb/db/db_info_dumper.h +15 -0
  124. package/deps/rocksdb/rocksdb/db/db_inplace_update_test.cc +178 -0
  125. package/deps/rocksdb/rocksdb/db/db_io_failure_test.cc +592 -0
  126. package/deps/rocksdb/rocksdb/db/db_iter.cc +1493 -0
  127. package/deps/rocksdb/rocksdb/db/db_iter.h +390 -0
  128. package/deps/rocksdb/rocksdb/db/db_iter_stress_test.cc +657 -0
  129. package/deps/rocksdb/rocksdb/db/db_iter_test.cc +3268 -0
  130. package/deps/rocksdb/rocksdb/db/db_iterator_test.cc +3197 -0
  131. package/deps/rocksdb/rocksdb/db/db_log_iter_test.cc +299 -0
  132. package/deps/rocksdb/rocksdb/db/db_logical_block_size_cache_test.cc +513 -0
  133. package/deps/rocksdb/rocksdb/db/db_memtable_test.cc +329 -0
  134. package/deps/rocksdb/rocksdb/db/db_merge_operand_test.cc +241 -0
  135. package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +671 -0
  136. package/deps/rocksdb/rocksdb/db/db_options_test.cc +1022 -0
  137. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +1723 -0
  138. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +1694 -0
  139. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +1261 -0
  140. package/deps/rocksdb/rocksdb/db/db_statistics_test.cc +164 -0
  141. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +488 -0
  142. package/deps/rocksdb/rocksdb/db/db_tailing_iter_test.cc +567 -0
  143. package/deps/rocksdb/rocksdb/db/db_test.cc +6736 -0
  144. package/deps/rocksdb/rocksdb/db/db_test2.cc +5408 -0
  145. package/deps/rocksdb/rocksdb/db/db_test_util.cc +1633 -0
  146. package/deps/rocksdb/rocksdb/db/db_test_util.h +1194 -0
  147. package/deps/rocksdb/rocksdb/db/db_universal_compaction_test.cc +2235 -0
  148. package/deps/rocksdb/rocksdb/db/db_wal_test.cc +1780 -0
  149. package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +2520 -0
  150. package/deps/rocksdb/rocksdb/db/db_with_timestamp_compaction_test.cc +119 -0
  151. package/deps/rocksdb/rocksdb/db/db_write_test.cc +465 -0
  152. package/deps/rocksdb/rocksdb/db/dbformat.cc +222 -0
  153. package/deps/rocksdb/rocksdb/db/dbformat.h +786 -0
  154. package/deps/rocksdb/rocksdb/db/dbformat_test.cc +206 -0
  155. package/deps/rocksdb/rocksdb/db/deletefile_test.cc +580 -0
  156. package/deps/rocksdb/rocksdb/db/error_handler.cc +726 -0
  157. package/deps/rocksdb/rocksdb/db/error_handler.h +117 -0
  158. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +2598 -0
  159. package/deps/rocksdb/rocksdb/db/event_helpers.cc +233 -0
  160. package/deps/rocksdb/rocksdb/db/event_helpers.h +57 -0
  161. package/deps/rocksdb/rocksdb/db/experimental.cc +50 -0
  162. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +1559 -0
  163. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +910 -0
  164. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +195 -0
  165. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +2936 -0
  166. package/deps/rocksdb/rocksdb/db/fault_injection_test.cc +556 -0
  167. package/deps/rocksdb/rocksdb/db/file_indexer.cc +216 -0
  168. package/deps/rocksdb/rocksdb/db/file_indexer.h +142 -0
  169. package/deps/rocksdb/rocksdb/db/file_indexer_test.cc +350 -0
  170. package/deps/rocksdb/rocksdb/db/filename_test.cc +179 -0
  171. package/deps/rocksdb/rocksdb/db/flush_job.cc +514 -0
  172. package/deps/rocksdb/rocksdb/db/flush_job.h +169 -0
  173. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +647 -0
  174. package/deps/rocksdb/rocksdb/db/flush_scheduler.cc +86 -0
  175. package/deps/rocksdb/rocksdb/db/flush_scheduler.h +54 -0
  176. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +1023 -0
  177. package/deps/rocksdb/rocksdb/db/forward_iterator.h +163 -0
  178. package/deps/rocksdb/rocksdb/db/forward_iterator_bench.cc +377 -0
  179. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +282 -0
  180. package/deps/rocksdb/rocksdb/db/import_column_family_job.h +75 -0
  181. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +632 -0
  182. package/deps/rocksdb/rocksdb/db/internal_stats.cc +1461 -0
  183. package/deps/rocksdb/rocksdb/db/internal_stats.h +712 -0
  184. package/deps/rocksdb/rocksdb/db/job_context.h +226 -0
  185. package/deps/rocksdb/rocksdb/db/listener_test.cc +1118 -0
  186. package/deps/rocksdb/rocksdb/db/log_format.h +48 -0
  187. package/deps/rocksdb/rocksdb/db/log_reader.cc +654 -0
  188. package/deps/rocksdb/rocksdb/db/log_reader.h +192 -0
  189. package/deps/rocksdb/rocksdb/db/log_test.cc +901 -0
  190. package/deps/rocksdb/rocksdb/db/log_writer.cc +164 -0
  191. package/deps/rocksdb/rocksdb/db/log_writer.h +115 -0
  192. package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.cc +67 -0
  193. package/deps/rocksdb/rocksdb/db/logs_with_prep_tracker.h +63 -0
  194. package/deps/rocksdb/rocksdb/db/lookup_key.h +66 -0
  195. package/deps/rocksdb/rocksdb/db/malloc_stats.cc +54 -0
  196. package/deps/rocksdb/rocksdb/db/malloc_stats.h +24 -0
  197. package/deps/rocksdb/rocksdb/db/manual_compaction_test.cc +296 -0
  198. package/deps/rocksdb/rocksdb/db/memtable.cc +1169 -0
  199. package/deps/rocksdb/rocksdb/db/memtable.h +554 -0
  200. package/deps/rocksdb/rocksdb/db/memtable_list.cc +888 -0
  201. package/deps/rocksdb/rocksdb/db/memtable_list.h +438 -0
  202. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +935 -0
  203. package/deps/rocksdb/rocksdb/db/merge_context.h +134 -0
  204. package/deps/rocksdb/rocksdb/db/merge_helper.cc +421 -0
  205. package/deps/rocksdb/rocksdb/db/merge_helper.h +197 -0
  206. package/deps/rocksdb/rocksdb/db/merge_helper_test.cc +290 -0
  207. package/deps/rocksdb/rocksdb/db/merge_operator.cc +86 -0
  208. package/deps/rocksdb/rocksdb/db/merge_test.cc +608 -0
  209. package/deps/rocksdb/rocksdb/db/obsolete_files_test.cc +338 -0
  210. package/deps/rocksdb/rocksdb/db/options_file_test.cc +119 -0
  211. package/deps/rocksdb/rocksdb/db/output_validator.cc +30 -0
  212. package/deps/rocksdb/rocksdb/db/output_validator.h +47 -0
  213. package/deps/rocksdb/rocksdb/db/perf_context_test.cc +993 -0
  214. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.cc +113 -0
  215. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.h +76 -0
  216. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler_test.cc +231 -0
  217. package/deps/rocksdb/rocksdb/db/pinned_iterators_manager.h +87 -0
  218. package/deps/rocksdb/rocksdb/db/plain_table_db_test.cc +1374 -0
  219. package/deps/rocksdb/rocksdb/db/pre_release_callback.h +38 -0
  220. package/deps/rocksdb/rocksdb/db/prefix_test.cc +910 -0
  221. package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +489 -0
  222. package/deps/rocksdb/rocksdb/db/range_del_aggregator.h +446 -0
  223. package/deps/rocksdb/rocksdb/db/range_del_aggregator_bench.cc +260 -0
  224. package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +709 -0
  225. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.cc +439 -0
  226. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +256 -0
  227. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter_test.cc +552 -0
  228. package/deps/rocksdb/rocksdb/db/read_callback.h +53 -0
  229. package/deps/rocksdb/rocksdb/db/repair.cc +722 -0
  230. package/deps/rocksdb/rocksdb/db/repair_test.cc +390 -0
  231. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +61 -0
  232. package/deps/rocksdb/rocksdb/db/snapshot_impl.cc +26 -0
  233. package/deps/rocksdb/rocksdb/db/snapshot_impl.h +167 -0
  234. package/deps/rocksdb/rocksdb/db/table_cache.cc +704 -0
  235. package/deps/rocksdb/rocksdb/db/table_cache.h +233 -0
  236. package/deps/rocksdb/rocksdb/db/table_properties_collector.cc +75 -0
  237. package/deps/rocksdb/rocksdb/db/table_properties_collector.h +107 -0
  238. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +517 -0
  239. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +318 -0
  240. package/deps/rocksdb/rocksdb/db/transaction_log_impl.h +128 -0
  241. package/deps/rocksdb/rocksdb/db/trim_history_scheduler.cc +54 -0
  242. package/deps/rocksdb/rocksdb/db/trim_history_scheduler.h +44 -0
  243. package/deps/rocksdb/rocksdb/db/version_builder.cc +1078 -0
  244. package/deps/rocksdb/rocksdb/db/version_builder.h +69 -0
  245. package/deps/rocksdb/rocksdb/db/version_builder_test.cc +1551 -0
  246. package/deps/rocksdb/rocksdb/db/version_edit.cc +955 -0
  247. package/deps/rocksdb/rocksdb/db/version_edit.h +609 -0
  248. package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +699 -0
  249. package/deps/rocksdb/rocksdb/db/version_edit_handler.h +252 -0
  250. package/deps/rocksdb/rocksdb/db/version_edit_test.cc +597 -0
  251. package/deps/rocksdb/rocksdb/db/version_set.cc +6333 -0
  252. package/deps/rocksdb/rocksdb/db/version_set.h +1485 -0
  253. package/deps/rocksdb/rocksdb/db/version_set_test.cc +3035 -0
  254. package/deps/rocksdb/rocksdb/db/wal_edit.cc +204 -0
  255. package/deps/rocksdb/rocksdb/db/wal_edit.h +166 -0
  256. package/deps/rocksdb/rocksdb/db/wal_edit_test.cc +214 -0
  257. package/deps/rocksdb/rocksdb/db/wal_manager.cc +517 -0
  258. package/deps/rocksdb/rocksdb/db/wal_manager.h +119 -0
  259. package/deps/rocksdb/rocksdb/db/wal_manager_test.cc +340 -0
  260. package/deps/rocksdb/rocksdb/db/write_batch.cc +2174 -0
  261. package/deps/rocksdb/rocksdb/db/write_batch_base.cc +94 -0
  262. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +250 -0
  263. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +907 -0
  264. package/deps/rocksdb/rocksdb/db/write_callback.h +27 -0
  265. package/deps/rocksdb/rocksdb/db/write_callback_test.cc +457 -0
  266. package/deps/rocksdb/rocksdb/db/write_controller.cc +128 -0
  267. package/deps/rocksdb/rocksdb/db/write_controller.h +144 -0
  268. package/deps/rocksdb/rocksdb/db/write_controller_test.cc +135 -0
  269. package/deps/rocksdb/rocksdb/db/write_thread.cc +796 -0
  270. package/deps/rocksdb/rocksdb/db/write_thread.h +433 -0
  271. package/deps/rocksdb/rocksdb/db_stress_tool/CMakeLists.txt +14 -0
  272. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +341 -0
  273. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +520 -0
  274. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress.cc +23 -0
  275. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +337 -0
  276. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +554 -0
  277. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_compaction_filter.h +79 -0
  278. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +173 -0
  279. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.h +17 -0
  280. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +38 -0
  281. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +763 -0
  282. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_listener.h +222 -0
  283. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.cc +27 -0
  284. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_shared_state.h +428 -0
  285. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_stat.h +218 -0
  286. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_table_properties_collector.h +64 -0
  287. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +2430 -0
  288. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +237 -0
  289. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +343 -0
  290. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +800 -0
  291. package/deps/rocksdb/rocksdb/env/composite_env_wrapper.h +920 -0
  292. package/deps/rocksdb/rocksdb/env/env.cc +733 -0
  293. package/deps/rocksdb/rocksdb/env/env_basic_test.cc +352 -0
  294. package/deps/rocksdb/rocksdb/env/env_chroot.cc +346 -0
  295. package/deps/rocksdb/rocksdb/env/env_chroot.h +22 -0
  296. package/deps/rocksdb/rocksdb/env/env_encryption.cc +1148 -0
  297. package/deps/rocksdb/rocksdb/env/env_encryption_ctr.h +137 -0
  298. package/deps/rocksdb/rocksdb/env/env_hdfs.cc +648 -0
  299. package/deps/rocksdb/rocksdb/env/env_posix.cc +514 -0
  300. package/deps/rocksdb/rocksdb/env/env_test.cc +2230 -0
  301. package/deps/rocksdb/rocksdb/env/file_system.cc +132 -0
  302. package/deps/rocksdb/rocksdb/env/file_system_tracer.cc +448 -0
  303. package/deps/rocksdb/rocksdb/env/file_system_tracer.h +415 -0
  304. package/deps/rocksdb/rocksdb/env/fs_posix.cc +1086 -0
  305. package/deps/rocksdb/rocksdb/env/io_posix.cc +1499 -0
  306. package/deps/rocksdb/rocksdb/env/io_posix.h +402 -0
  307. package/deps/rocksdb/rocksdb/env/io_posix_test.cc +140 -0
  308. package/deps/rocksdb/rocksdb/env/mock_env.cc +1066 -0
  309. package/deps/rocksdb/rocksdb/env/mock_env.h +41 -0
  310. package/deps/rocksdb/rocksdb/env/mock_env_test.cc +85 -0
  311. package/deps/rocksdb/rocksdb/file/delete_scheduler.cc +402 -0
  312. package/deps/rocksdb/rocksdb/file/delete_scheduler.h +150 -0
  313. package/deps/rocksdb/rocksdb/file/delete_scheduler_test.cc +717 -0
  314. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +156 -0
  315. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +99 -0
  316. package/deps/rocksdb/rocksdb/file/file_util.cc +268 -0
  317. package/deps/rocksdb/rocksdb/file/file_util.h +96 -0
  318. package/deps/rocksdb/rocksdb/file/filename.cc +473 -0
  319. package/deps/rocksdb/rocksdb/file/filename.h +182 -0
  320. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +188 -0
  321. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +315 -0
  322. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +142 -0
  323. package/deps/rocksdb/rocksdb/file/random_access_file_reader_test.cc +482 -0
  324. package/deps/rocksdb/rocksdb/file/read_write_util.cc +67 -0
  325. package/deps/rocksdb/rocksdb/file/read_write_util.h +34 -0
  326. package/deps/rocksdb/rocksdb/file/readahead_raf.cc +169 -0
  327. package/deps/rocksdb/rocksdb/file/readahead_raf.h +29 -0
  328. package/deps/rocksdb/rocksdb/file/sequence_file_reader.cc +237 -0
  329. package/deps/rocksdb/rocksdb/file/sequence_file_reader.h +63 -0
  330. package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.cc +552 -0
  331. package/deps/rocksdb/rocksdb/file/sst_file_manager_impl.h +203 -0
  332. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +523 -0
  333. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +251 -0
  334. package/deps/rocksdb/rocksdb/hdfs/env_hdfs.h +386 -0
  335. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +839 -0
  336. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +2218 -0
  337. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +294 -0
  338. package/deps/rocksdb/rocksdb/include/rocksdb/cleanable.h +71 -0
  339. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_filter.h +214 -0
  340. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_job_stats.h +98 -0
  341. package/deps/rocksdb/rocksdb/include/rocksdb/comparator.h +137 -0
  342. package/deps/rocksdb/rocksdb/include/rocksdb/compression_type.h +40 -0
  343. package/deps/rocksdb/rocksdb/include/rocksdb/concurrent_task_limiter.h +46 -0
  344. package/deps/rocksdb/rocksdb/include/rocksdb/configurable.h +359 -0
  345. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +499 -0
  346. package/deps/rocksdb/rocksdb/include/rocksdb/customizable.h +138 -0
  347. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +1697 -0
  348. package/deps/rocksdb/rocksdb/include/rocksdb/db_bench_tool.h +11 -0
  349. package/deps/rocksdb/rocksdb/include/rocksdb/db_dump_tool.h +45 -0
  350. package/deps/rocksdb/rocksdb/include/rocksdb/db_stress_tool.h +11 -0
  351. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1671 -0
  352. package/deps/rocksdb/rocksdb/include/rocksdb/env_encryption.h +405 -0
  353. package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +29 -0
  354. package/deps/rocksdb/rocksdb/include/rocksdb/file_checksum.h +129 -0
  355. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +1472 -0
  356. package/deps/rocksdb/rocksdb/include/rocksdb/filter_policy.h +238 -0
  357. package/deps/rocksdb/rocksdb/include/rocksdb/flush_block_policy.h +61 -0
  358. package/deps/rocksdb/rocksdb/include/rocksdb/io_status.h +269 -0
  359. package/deps/rocksdb/rocksdb/include/rocksdb/iostats_context.h +56 -0
  360. package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +128 -0
  361. package/deps/rocksdb/rocksdb/include/rocksdb/ldb_tool.h +43 -0
  362. package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +556 -0
  363. package/deps/rocksdb/rocksdb/include/rocksdb/memory_allocator.h +77 -0
  364. package/deps/rocksdb/rocksdb/include/rocksdb/memtablerep.h +385 -0
  365. package/deps/rocksdb/rocksdb/include/rocksdb/merge_operator.h +257 -0
  366. package/deps/rocksdb/rocksdb/include/rocksdb/metadata.h +155 -0
  367. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +1702 -0
  368. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +237 -0
  369. package/deps/rocksdb/rocksdb/include/rocksdb/perf_level.h +35 -0
  370. package/deps/rocksdb/rocksdb/include/rocksdb/persistent_cache.h +73 -0
  371. package/deps/rocksdb/rocksdb/include/rocksdb/rate_limiter.h +139 -0
  372. package/deps/rocksdb/rocksdb/include/rocksdb/rocksdb_namespace.h +10 -0
  373. package/deps/rocksdb/rocksdb/include/rocksdb/slice.h +269 -0
  374. package/deps/rocksdb/rocksdb/include/rocksdb/slice_transform.h +103 -0
  375. package/deps/rocksdb/rocksdb/include/rocksdb/snapshot.h +48 -0
  376. package/deps/rocksdb/rocksdb/include/rocksdb/sst_dump_tool.h +19 -0
  377. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_manager.h +136 -0
  378. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_reader.h +47 -0
  379. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +145 -0
  380. package/deps/rocksdb/rocksdb/include/rocksdb/sst_partitioner.h +135 -0
  381. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +592 -0
  382. package/deps/rocksdb/rocksdb/include/rocksdb/stats_history.h +69 -0
  383. package/deps/rocksdb/rocksdb/include/rocksdb/status.h +608 -0
  384. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +711 -0
  385. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +280 -0
  386. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +188 -0
  387. package/deps/rocksdb/rocksdb/include/rocksdb/threadpool.h +58 -0
  388. package/deps/rocksdb/rocksdb/include/rocksdb/trace_reader_writer.h +48 -0
  389. package/deps/rocksdb/rocksdb/include/rocksdb/transaction_log.h +121 -0
  390. package/deps/rocksdb/rocksdb/include/rocksdb/types.h +74 -0
  391. package/deps/rocksdb/rocksdb/include/rocksdb/universal_compaction.h +86 -0
  392. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/backupable_db.h +535 -0
  393. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/checkpoint.h +61 -0
  394. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/convenience.h +10 -0
  395. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/db_ttl.h +72 -0
  396. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/debug.h +49 -0
  397. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/env_librados.h +175 -0
  398. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/env_mirror.h +180 -0
  399. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/info_log_finder.h +19 -0
  400. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd.h +288 -0
  401. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/ldb_cmd_execute_result.h +71 -0
  402. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/leveldb_options.h +145 -0
  403. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_custom_library.h +43 -0
  404. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/lua/rocks_lua_util.h +55 -0
  405. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/memory_util.h +50 -0
  406. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/object_registry.h +205 -0
  407. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/optimistic_transaction_db.h +100 -0
  408. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/option_change_migration.h +19 -0
  409. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +876 -0
  410. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_util.h +128 -0
  411. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/sim_cache.h +94 -0
  412. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/stackable_db.h +504 -0
  413. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +95 -0
  414. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +626 -0
  415. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +432 -0
  416. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db_mutex.h +92 -0
  417. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/utility_db.h +34 -0
  418. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +279 -0
  419. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +16 -0
  420. package/deps/rocksdb/rocksdb/include/rocksdb/wal_filter.h +102 -0
  421. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +377 -0
  422. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch_base.h +127 -0
  423. package/deps/rocksdb/rocksdb/include/rocksdb/write_buffer_manager.h +106 -0
  424. package/deps/rocksdb/rocksdb/logging/auto_roll_logger.cc +300 -0
  425. package/deps/rocksdb/rocksdb/logging/auto_roll_logger.h +165 -0
  426. package/deps/rocksdb/rocksdb/logging/auto_roll_logger_test.cc +684 -0
  427. package/deps/rocksdb/rocksdb/logging/env_logger.h +165 -0
  428. package/deps/rocksdb/rocksdb/logging/env_logger_test.cc +162 -0
  429. package/deps/rocksdb/rocksdb/logging/event_logger.cc +70 -0
  430. package/deps/rocksdb/rocksdb/logging/event_logger.h +203 -0
  431. package/deps/rocksdb/rocksdb/logging/event_logger_test.cc +43 -0
  432. package/deps/rocksdb/rocksdb/logging/log_buffer.cc +92 -0
  433. package/deps/rocksdb/rocksdb/logging/log_buffer.h +56 -0
  434. package/deps/rocksdb/rocksdb/logging/logging.h +68 -0
  435. package/deps/rocksdb/rocksdb/logging/posix_logger.h +185 -0
  436. package/deps/rocksdb/rocksdb/memory/allocator.h +57 -0
  437. package/deps/rocksdb/rocksdb/memory/arena.cc +233 -0
  438. package/deps/rocksdb/rocksdb/memory/arena.h +141 -0
  439. package/deps/rocksdb/rocksdb/memory/arena_test.cc +204 -0
  440. package/deps/rocksdb/rocksdb/memory/concurrent_arena.cc +47 -0
  441. package/deps/rocksdb/rocksdb/memory/concurrent_arena.h +218 -0
  442. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.cc +206 -0
  443. package/deps/rocksdb/rocksdb/memory/jemalloc_nodump_allocator.h +78 -0
  444. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator.cc +33 -0
  445. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator.h +27 -0
  446. package/deps/rocksdb/rocksdb/memory/memkind_kmem_allocator_test.cc +102 -0
  447. package/deps/rocksdb/rocksdb/memory/memory_allocator.h +38 -0
  448. package/deps/rocksdb/rocksdb/memory/memory_usage.h +25 -0
  449. package/deps/rocksdb/rocksdb/memtable/alloc_tracker.cc +62 -0
  450. package/deps/rocksdb/rocksdb/memtable/hash_linklist_rep.cc +844 -0
  451. package/deps/rocksdb/rocksdb/memtable/hash_linklist_rep.h +49 -0
  452. package/deps/rocksdb/rocksdb/memtable/hash_skiplist_rep.cc +349 -0
  453. package/deps/rocksdb/rocksdb/memtable/hash_skiplist_rep.h +44 -0
  454. package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +997 -0
  455. package/deps/rocksdb/rocksdb/memtable/inlineskiplist_test.cc +663 -0
  456. package/deps/rocksdb/rocksdb/memtable/memtablerep_bench.cc +677 -0
  457. package/deps/rocksdb/rocksdb/memtable/skiplist.h +496 -0
  458. package/deps/rocksdb/rocksdb/memtable/skiplist_test.cc +388 -0
  459. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +280 -0
  460. package/deps/rocksdb/rocksdb/memtable/stl_wrappers.h +33 -0
  461. package/deps/rocksdb/rocksdb/memtable/vectorrep.cc +301 -0
  462. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager.cc +148 -0
  463. package/deps/rocksdb/rocksdb/memtable/write_buffer_manager_test.cc +203 -0
  464. package/deps/rocksdb/rocksdb/monitoring/file_read_sample.h +23 -0
  465. package/deps/rocksdb/rocksdb/monitoring/histogram.cc +287 -0
  466. package/deps/rocksdb/rocksdb/monitoring/histogram.h +149 -0
  467. package/deps/rocksdb/rocksdb/monitoring/histogram_test.cc +231 -0
  468. package/deps/rocksdb/rocksdb/monitoring/histogram_windowing.cc +200 -0
  469. package/deps/rocksdb/rocksdb/monitoring/histogram_windowing.h +84 -0
  470. package/deps/rocksdb/rocksdb/monitoring/in_memory_stats_history.cc +49 -0
  471. package/deps/rocksdb/rocksdb/monitoring/in_memory_stats_history.h +74 -0
  472. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.cc +71 -0
  473. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.h +98 -0
  474. package/deps/rocksdb/rocksdb/monitoring/iostats_context.cc +62 -0
  475. package/deps/rocksdb/rocksdb/monitoring/iostats_context_imp.h +60 -0
  476. package/deps/rocksdb/rocksdb/monitoring/iostats_context_test.cc +29 -0
  477. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +566 -0
  478. package/deps/rocksdb/rocksdb/monitoring/perf_context_imp.h +97 -0
  479. package/deps/rocksdb/rocksdb/monitoring/perf_level.cc +28 -0
  480. package/deps/rocksdb/rocksdb/monitoring/perf_level_imp.h +18 -0
  481. package/deps/rocksdb/rocksdb/monitoring/perf_step_timer.h +79 -0
  482. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.cc +169 -0
  483. package/deps/rocksdb/rocksdb/monitoring/persistent_stats_history.h +83 -0
  484. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +431 -0
  485. package/deps/rocksdb/rocksdb/monitoring/statistics.h +138 -0
  486. package/deps/rocksdb/rocksdb/monitoring/statistics_test.cc +47 -0
  487. package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +652 -0
  488. package/deps/rocksdb/rocksdb/monitoring/thread_status_impl.cc +163 -0
  489. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.cc +314 -0
  490. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater.h +233 -0
  491. package/deps/rocksdb/rocksdb/monitoring/thread_status_updater_debug.cc +43 -0
  492. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.cc +206 -0
  493. package/deps/rocksdb/rocksdb/monitoring/thread_status_util.h +134 -0
  494. package/deps/rocksdb/rocksdb/monitoring/thread_status_util_debug.cc +32 -0
  495. package/deps/rocksdb/rocksdb/options/cf_options.cc +1026 -0
  496. package/deps/rocksdb/rocksdb/options/cf_options.h +308 -0
  497. package/deps/rocksdb/rocksdb/options/configurable.cc +681 -0
  498. package/deps/rocksdb/rocksdb/options/configurable_helper.h +251 -0
  499. package/deps/rocksdb/rocksdb/options/configurable_test.cc +757 -0
  500. package/deps/rocksdb/rocksdb/options/configurable_test.h +127 -0
  501. package/deps/rocksdb/rocksdb/options/customizable.cc +77 -0
  502. package/deps/rocksdb/rocksdb/options/customizable_helper.h +216 -0
  503. package/deps/rocksdb/rocksdb/options/customizable_test.cc +625 -0
  504. package/deps/rocksdb/rocksdb/options/db_options.cc +835 -0
  505. package/deps/rocksdb/rocksdb/options/db_options.h +126 -0
  506. package/deps/rocksdb/rocksdb/options/options.cc +664 -0
  507. package/deps/rocksdb/rocksdb/options/options_helper.cc +1391 -0
  508. package/deps/rocksdb/rocksdb/options/options_helper.h +118 -0
  509. package/deps/rocksdb/rocksdb/options/options_parser.cc +721 -0
  510. package/deps/rocksdb/rocksdb/options/options_parser.h +151 -0
  511. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +583 -0
  512. package/deps/rocksdb/rocksdb/options/options_test.cc +3794 -0
  513. package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +106 -0
  514. package/deps/rocksdb/rocksdb/port/lang.h +16 -0
  515. package/deps/rocksdb/rocksdb/port/likely.h +18 -0
  516. package/deps/rocksdb/rocksdb/port/malloc.h +17 -0
  517. package/deps/rocksdb/rocksdb/port/port.h +21 -0
  518. package/deps/rocksdb/rocksdb/port/port_dirent.h +44 -0
  519. package/deps/rocksdb/rocksdb/port/port_example.h +101 -0
  520. package/deps/rocksdb/rocksdb/port/port_posix.cc +266 -0
  521. package/deps/rocksdb/rocksdb/port/port_posix.h +223 -0
  522. package/deps/rocksdb/rocksdb/port/stack_trace.cc +179 -0
  523. package/deps/rocksdb/rocksdb/port/stack_trace.h +28 -0
  524. package/deps/rocksdb/rocksdb/port/sys_time.h +47 -0
  525. package/deps/rocksdb/rocksdb/port/util_logger.h +20 -0
  526. package/deps/rocksdb/rocksdb/port/win/env_default.cc +45 -0
  527. package/deps/rocksdb/rocksdb/port/win/env_win.cc +1449 -0
  528. package/deps/rocksdb/rocksdb/port/win/env_win.h +294 -0
  529. package/deps/rocksdb/rocksdb/port/win/io_win.cc +1084 -0
  530. package/deps/rocksdb/rocksdb/port/win/io_win.h +494 -0
  531. package/deps/rocksdb/rocksdb/port/win/port_win.cc +283 -0
  532. package/deps/rocksdb/rocksdb/port/win/port_win.h +411 -0
  533. package/deps/rocksdb/rocksdb/port/win/win_jemalloc.cc +79 -0
  534. package/deps/rocksdb/rocksdb/port/win/win_logger.cc +194 -0
  535. package/deps/rocksdb/rocksdb/port/win/win_logger.h +67 -0
  536. package/deps/rocksdb/rocksdb/port/win/win_thread.cc +183 -0
  537. package/deps/rocksdb/rocksdb/port/win/win_thread.h +122 -0
  538. package/deps/rocksdb/rocksdb/port/win/xpress_win.cc +221 -0
  539. package/deps/rocksdb/rocksdb/port/win/xpress_win.h +26 -0
  540. package/deps/rocksdb/rocksdb/port/xpress.h +17 -0
  541. package/deps/rocksdb/rocksdb/src.mk +631 -0
  542. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.cc +126 -0
  543. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.h +57 -0
  544. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.cc +73 -0
  545. package/deps/rocksdb/rocksdb/table/block_based/binary_search_index_reader.h +48 -0
  546. package/deps/rocksdb/rocksdb/table/block_based/block.cc +1049 -0
  547. package/deps/rocksdb/rocksdb/table/block_based/block.h +720 -0
  548. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.cc +348 -0
  549. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block.h +119 -0
  550. package/deps/rocksdb/rocksdb/table/block_based/block_based_filter_block_test.cc +434 -0
  551. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +1835 -0
  552. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +193 -0
  553. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +839 -0
  554. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.h +95 -0
  555. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +383 -0
  556. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +251 -0
  557. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +3563 -0
  558. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +681 -0
  559. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +190 -0
  560. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +347 -0
  561. package/deps/rocksdb/rocksdb/table/block_based/block_builder.cc +201 -0
  562. package/deps/rocksdb/rocksdb/table/block_based/block_builder.h +78 -0
  563. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +66 -0
  564. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.h +32 -0
  565. package/deps/rocksdb/rocksdb/table/block_based/block_prefix_index.cc +232 -0
  566. package/deps/rocksdb/rocksdb/table/block_based/block_prefix_index.h +66 -0
  567. package/deps/rocksdb/rocksdb/table/block_based/block_test.cc +623 -0
  568. package/deps/rocksdb/rocksdb/table/block_based/block_type.h +30 -0
  569. package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +220 -0
  570. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.cc +59 -0
  571. package/deps/rocksdb/rocksdb/table/block_based/data_block_footer.h +25 -0
  572. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index.cc +93 -0
  573. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index.h +136 -0
  574. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index_test.cc +717 -0
  575. package/deps/rocksdb/rocksdb/table/block_based/filter_block.h +180 -0
  576. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +102 -0
  577. package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +55 -0
  578. package/deps/rocksdb/rocksdb/table/block_based/filter_policy.cc +1407 -0
  579. package/deps/rocksdb/rocksdb/table/block_based/filter_policy_internal.h +168 -0
  580. package/deps/rocksdb/rocksdb/table/block_based/flush_block_policy.cc +88 -0
  581. package/deps/rocksdb/rocksdb/table/block_based/flush_block_policy.h +41 -0
  582. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +344 -0
  583. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.h +139 -0
  584. package/deps/rocksdb/rocksdb/table/block_based/full_filter_block_test.cc +333 -0
  585. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.cc +147 -0
  586. package/deps/rocksdb/rocksdb/table/block_based/hash_index_reader.h +49 -0
  587. package/deps/rocksdb/rocksdb/table/block_based/index_builder.cc +248 -0
  588. package/deps/rocksdb/rocksdb/table/block_based/index_builder.h +444 -0
  589. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +54 -0
  590. package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.h +85 -0
  591. package/deps/rocksdb/rocksdb/table/block_based/mock_block_based_table.h +56 -0
  592. package/deps/rocksdb/rocksdb/table/block_based/parsed_full_filter_block.cc +22 -0
  593. package/deps/rocksdb/rocksdb/table/block_based/parsed_full_filter_block.h +40 -0
  594. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +521 -0
  595. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +144 -0
  596. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +424 -0
  597. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.cc +163 -0
  598. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_iterator.h +142 -0
  599. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +186 -0
  600. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.h +51 -0
  601. package/deps/rocksdb/rocksdb/table/block_based/reader_common.cc +64 -0
  602. package/deps/rocksdb/rocksdb/table/block_based/reader_common.h +38 -0
  603. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +120 -0
  604. package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.h +59 -0
  605. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +324 -0
  606. package/deps/rocksdb/rocksdb/table/block_fetcher.h +129 -0
  607. package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +534 -0
  608. package/deps/rocksdb/rocksdb/table/cleanable_test.cc +277 -0
  609. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.cc +543 -0
  610. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder.h +136 -0
  611. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_builder_test.cc +663 -0
  612. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.cc +107 -0
  613. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.h +81 -0
  614. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader.cc +404 -0
  615. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader.h +101 -0
  616. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_reader_test.cc +585 -0
  617. package/deps/rocksdb/rocksdb/table/format.cc +422 -0
  618. package/deps/rocksdb/rocksdb/table/format.h +348 -0
  619. package/deps/rocksdb/rocksdb/table/get_context.cc +408 -0
  620. package/deps/rocksdb/rocksdb/table/get_context.h +212 -0
  621. package/deps/rocksdb/rocksdb/table/internal_iterator.h +205 -0
  622. package/deps/rocksdb/rocksdb/table/iter_heap.h +42 -0
  623. package/deps/rocksdb/rocksdb/table/iterator.cc +210 -0
  624. package/deps/rocksdb/rocksdb/table/iterator_wrapper.h +180 -0
  625. package/deps/rocksdb/rocksdb/table/merger_test.cc +180 -0
  626. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +481 -0
  627. package/deps/rocksdb/rocksdb/table/merging_iterator.h +64 -0
  628. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +541 -0
  629. package/deps/rocksdb/rocksdb/table/meta_blocks.h +154 -0
  630. package/deps/rocksdb/rocksdb/table/mock_table.cc +328 -0
  631. package/deps/rocksdb/rocksdb/table/mock_table.h +89 -0
  632. package/deps/rocksdb/rocksdb/table/multiget_context.h +282 -0
  633. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.cc +116 -0
  634. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.h +44 -0
  635. package/deps/rocksdb/rocksdb/table/persistent_cache_options.h +34 -0
  636. package/deps/rocksdb/rocksdb/table/plain/plain_table_bloom.cc +78 -0
  637. package/deps/rocksdb/rocksdb/table/plain/plain_table_bloom.h +135 -0
  638. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.cc +332 -0
  639. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.h +153 -0
  640. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.cc +263 -0
  641. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.h +182 -0
  642. package/deps/rocksdb/rocksdb/table/plain/plain_table_index.cc +211 -0
  643. package/deps/rocksdb/rocksdb/table/plain/plain_table_index.h +249 -0
  644. package/deps/rocksdb/rocksdb/table/plain/plain_table_key_coding.cc +506 -0
  645. package/deps/rocksdb/rocksdb/table/plain/plain_table_key_coding.h +201 -0
  646. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.cc +781 -0
  647. package/deps/rocksdb/rocksdb/table/plain/plain_table_reader.h +247 -0
  648. package/deps/rocksdb/rocksdb/table/scoped_arena_iterator.h +61 -0
  649. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +502 -0
  650. package/deps/rocksdb/rocksdb/table/sst_file_dumper.h +96 -0
  651. package/deps/rocksdb/rocksdb/table/sst_file_reader.cc +98 -0
  652. package/deps/rocksdb/rocksdb/table/sst_file_reader_test.cc +228 -0
  653. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +340 -0
  654. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +94 -0
  655. package/deps/rocksdb/rocksdb/table/table_builder.h +203 -0
  656. package/deps/rocksdb/rocksdb/table/table_factory.cc +38 -0
  657. package/deps/rocksdb/rocksdb/table/table_properties.cc +300 -0
  658. package/deps/rocksdb/rocksdb/table/table_properties_internal.h +30 -0
  659. package/deps/rocksdb/rocksdb/table/table_reader.h +147 -0
  660. package/deps/rocksdb/rocksdb/table/table_reader_bench.cc +347 -0
  661. package/deps/rocksdb/rocksdb/table/table_reader_caller.h +39 -0
  662. package/deps/rocksdb/rocksdb/table/table_test.cc +4769 -0
  663. package/deps/rocksdb/rocksdb/table/two_level_iterator.cc +215 -0
  664. package/deps/rocksdb/rocksdb/table/two_level_iterator.h +43 -0
  665. package/deps/rocksdb/rocksdb/test_util/mock_time_env.cc +38 -0
  666. package/deps/rocksdb/rocksdb/test_util/mock_time_env.h +74 -0
  667. package/deps/rocksdb/rocksdb/test_util/sync_point.cc +93 -0
  668. package/deps/rocksdb/rocksdb/test_util/sync_point.h +161 -0
  669. package/deps/rocksdb/rocksdb/test_util/sync_point_impl.cc +129 -0
  670. package/deps/rocksdb/rocksdb/test_util/sync_point_impl.h +74 -0
  671. package/deps/rocksdb/rocksdb/test_util/testharness.cc +56 -0
  672. package/deps/rocksdb/rocksdb/test_util/testharness.h +53 -0
  673. package/deps/rocksdb/rocksdb/test_util/testutil.cc +566 -0
  674. package/deps/rocksdb/rocksdb/test_util/testutil.h +887 -0
  675. package/deps/rocksdb/rocksdb/test_util/testutil_test.cc +43 -0
  676. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.cc +388 -0
  677. package/deps/rocksdb/rocksdb/test_util/transaction_test_util.h +132 -0
  678. package/deps/rocksdb/rocksdb/third-party/folly/folly/CPortability.h +27 -0
  679. package/deps/rocksdb/rocksdb/third-party/folly/folly/ConstexprMath.h +45 -0
  680. package/deps/rocksdb/rocksdb/third-party/folly/folly/Indestructible.h +166 -0
  681. package/deps/rocksdb/rocksdb/third-party/folly/folly/Optional.h +570 -0
  682. package/deps/rocksdb/rocksdb/third-party/folly/folly/Portability.h +92 -0
  683. package/deps/rocksdb/rocksdb/third-party/folly/folly/ScopeGuard.h +54 -0
  684. package/deps/rocksdb/rocksdb/third-party/folly/folly/Traits.h +152 -0
  685. package/deps/rocksdb/rocksdb/third-party/folly/folly/Unit.h +59 -0
  686. package/deps/rocksdb/rocksdb/third-party/folly/folly/Utility.h +141 -0
  687. package/deps/rocksdb/rocksdb/third-party/folly/folly/chrono/Hardware.h +33 -0
  688. package/deps/rocksdb/rocksdb/third-party/folly/folly/container/Array.h +74 -0
  689. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex-inl.h +117 -0
  690. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex.cpp +263 -0
  691. package/deps/rocksdb/rocksdb/third-party/folly/folly/detail/Futex.h +96 -0
  692. package/deps/rocksdb/rocksdb/third-party/folly/folly/functional/Invoke.h +40 -0
  693. package/deps/rocksdb/rocksdb/third-party/folly/folly/hash/Hash.h +29 -0
  694. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Align.h +144 -0
  695. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Bits.h +30 -0
  696. package/deps/rocksdb/rocksdb/third-party/folly/folly/lang/Launder.h +51 -0
  697. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/Asm.h +28 -0
  698. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/SysSyscall.h +10 -0
  699. package/deps/rocksdb/rocksdb/third-party/folly/folly/portability/SysTypes.h +26 -0
  700. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification-inl.h +138 -0
  701. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification.cpp +23 -0
  702. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicNotification.h +57 -0
  703. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicUtil-inl.h +260 -0
  704. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/AtomicUtil.h +52 -0
  705. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/Baton.h +328 -0
  706. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex-inl.h +1703 -0
  707. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex.cpp +16 -0
  708. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutex.h +304 -0
  709. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/DistributedMutexSpecializations.h +39 -0
  710. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/ParkingLot.cpp +26 -0
  711. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/ParkingLot.h +318 -0
  712. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/WaitOptions.cpp +12 -0
  713. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/WaitOptions.h +57 -0
  714. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/InlineFunctionRef.h +219 -0
  715. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/ProxyLockable-inl.h +207 -0
  716. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/ProxyLockable.h +164 -0
  717. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/Sleeper.h +57 -0
  718. package/deps/rocksdb/rocksdb/third-party/folly/folly/synchronization/detail/Spin.h +77 -0
  719. package/deps/rocksdb/rocksdb/third-party/gcc/ppc-asm.h +390 -0
  720. package/deps/rocksdb/rocksdb/thirdparty.inc +268 -0
  721. package/deps/rocksdb/rocksdb/tools/CMakeLists.txt +30 -0
  722. package/deps/rocksdb/rocksdb/tools/blob_dump.cc +110 -0
  723. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/__init__.py +2 -0
  724. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.py +2000 -0
  725. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.sh +156 -0
  726. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim_test.py +734 -0
  727. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.cc +2307 -0
  728. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer.h +395 -0
  729. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_plot.py +721 -0
  730. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +719 -0
  731. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_tool.cc +25 -0
  732. package/deps/rocksdb/rocksdb/tools/db_bench.cc +21 -0
  733. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +7416 -0
  734. package/deps/rocksdb/rocksdb/tools/db_bench_tool_test.cc +328 -0
  735. package/deps/rocksdb/rocksdb/tools/db_repl_stress.cc +130 -0
  736. package/deps/rocksdb/rocksdb/tools/db_sanity_test.cc +297 -0
  737. package/deps/rocksdb/rocksdb/tools/dump/db_dump_tool.cc +259 -0
  738. package/deps/rocksdb/rocksdb/tools/dump/rocksdb_dump.cc +63 -0
  739. package/deps/rocksdb/rocksdb/tools/dump/rocksdb_undump.cc +62 -0
  740. package/deps/rocksdb/rocksdb/tools/io_tracer_parser.cc +25 -0
  741. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_test.cc +187 -0
  742. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_tool.cc +120 -0
  743. package/deps/rocksdb/rocksdb/tools/io_tracer_parser_tool.h +40 -0
  744. package/deps/rocksdb/rocksdb/tools/ldb.cc +21 -0
  745. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +3609 -0
  746. package/deps/rocksdb/rocksdb/tools/ldb_cmd_impl.h +665 -0
  747. package/deps/rocksdb/rocksdb/tools/ldb_cmd_test.cc +746 -0
  748. package/deps/rocksdb/rocksdb/tools/ldb_tool.cc +159 -0
  749. package/deps/rocksdb/rocksdb/tools/reduce_levels_test.cc +221 -0
  750. package/deps/rocksdb/rocksdb/tools/sst_dump.cc +20 -0
  751. package/deps/rocksdb/rocksdb/tools/sst_dump_test.cc +427 -0
  752. package/deps/rocksdb/rocksdb/tools/sst_dump_tool.cc +541 -0
  753. package/deps/rocksdb/rocksdb/tools/trace_analyzer.cc +25 -0
  754. package/deps/rocksdb/rocksdb/tools/trace_analyzer_test.cc +752 -0
  755. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.cc +2001 -0
  756. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.h +292 -0
  757. package/deps/rocksdb/rocksdb/tools/write_stress.cc +305 -0
  758. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.cc +496 -0
  759. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.h +294 -0
  760. package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer_test.cc +379 -0
  761. package/deps/rocksdb/rocksdb/trace_replay/io_tracer.cc +229 -0
  762. package/deps/rocksdb/rocksdb/trace_replay/io_tracer.h +174 -0
  763. package/deps/rocksdb/rocksdb/trace_replay/io_tracer_test.cc +215 -0
  764. package/deps/rocksdb/rocksdb/trace_replay/trace_replay.cc +491 -0
  765. package/deps/rocksdb/rocksdb/trace_replay/trace_replay.h +195 -0
  766. package/deps/rocksdb/rocksdb/util/aligned_buffer.h +255 -0
  767. package/deps/rocksdb/rocksdb/util/autovector.h +367 -0
  768. package/deps/rocksdb/rocksdb/util/autovector_test.cc +330 -0
  769. package/deps/rocksdb/rocksdb/util/bloom_impl.h +485 -0
  770. package/deps/rocksdb/rocksdb/util/bloom_test.cc +1191 -0
  771. package/deps/rocksdb/rocksdb/util/build_version.cc.in +5 -0
  772. package/deps/rocksdb/rocksdb/util/build_version.h +15 -0
  773. package/deps/rocksdb/rocksdb/util/cast_util.h +20 -0
  774. package/deps/rocksdb/rocksdb/util/channel.h +67 -0
  775. package/deps/rocksdb/rocksdb/util/coding.cc +89 -0
  776. package/deps/rocksdb/rocksdb/util/coding.h +419 -0
  777. package/deps/rocksdb/rocksdb/util/coding_lean.h +101 -0
  778. package/deps/rocksdb/rocksdb/util/coding_test.cc +217 -0
  779. package/deps/rocksdb/rocksdb/util/compaction_job_stats_impl.cc +92 -0
  780. package/deps/rocksdb/rocksdb/util/comparator.cc +219 -0
  781. package/deps/rocksdb/rocksdb/util/compression.h +1529 -0
  782. package/deps/rocksdb/rocksdb/util/compression_context_cache.cc +108 -0
  783. package/deps/rocksdb/rocksdb/util/compression_context_cache.h +47 -0
  784. package/deps/rocksdb/rocksdb/util/concurrent_task_limiter_impl.cc +67 -0
  785. package/deps/rocksdb/rocksdb/util/concurrent_task_limiter_impl.h +67 -0
  786. package/deps/rocksdb/rocksdb/util/core_local.h +83 -0
  787. package/deps/rocksdb/rocksdb/util/crc32c.cc +1283 -0
  788. package/deps/rocksdb/rocksdb/util/crc32c.h +51 -0
  789. package/deps/rocksdb/rocksdb/util/crc32c_arm64.cc +169 -0
  790. package/deps/rocksdb/rocksdb/util/crc32c_arm64.h +50 -0
  791. package/deps/rocksdb/rocksdb/util/crc32c_ppc.c +94 -0
  792. package/deps/rocksdb/rocksdb/util/crc32c_ppc.h +19 -0
  793. package/deps/rocksdb/rocksdb/util/crc32c_ppc_asm.S +756 -0
  794. package/deps/rocksdb/rocksdb/util/crc32c_ppc_constants.h +900 -0
  795. package/deps/rocksdb/rocksdb/util/crc32c_test.cc +180 -0
  796. package/deps/rocksdb/rocksdb/util/defer.h +52 -0
  797. package/deps/rocksdb/rocksdb/util/defer_test.cc +39 -0
  798. package/deps/rocksdb/rocksdb/util/duplicate_detector.h +68 -0
  799. package/deps/rocksdb/rocksdb/util/dynamic_bloom.cc +70 -0
  800. package/deps/rocksdb/rocksdb/util/dynamic_bloom.h +214 -0
  801. package/deps/rocksdb/rocksdb/util/dynamic_bloom_test.cc +323 -0
  802. package/deps/rocksdb/rocksdb/util/fastrange.h +112 -0
  803. package/deps/rocksdb/rocksdb/util/file_checksum_helper.cc +136 -0
  804. package/deps/rocksdb/rocksdb/util/file_checksum_helper.h +98 -0
  805. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +449 -0
  806. package/deps/rocksdb/rocksdb/util/filelock_test.cc +152 -0
  807. package/deps/rocksdb/rocksdb/util/filter_bench.cc +781 -0
  808. package/deps/rocksdb/rocksdb/util/gflags_compat.h +20 -0
  809. package/deps/rocksdb/rocksdb/util/hash.cc +83 -0
  810. package/deps/rocksdb/rocksdb/util/hash.h +107 -0
  811. package/deps/rocksdb/rocksdb/util/hash_map.h +67 -0
  812. package/deps/rocksdb/rocksdb/util/hash_test.cc +593 -0
  813. package/deps/rocksdb/rocksdb/util/heap.h +166 -0
  814. package/deps/rocksdb/rocksdb/util/heap_test.cc +139 -0
  815. package/deps/rocksdb/rocksdb/util/kv_map.h +33 -0
  816. package/deps/rocksdb/rocksdb/util/log_write_bench.cc +86 -0
  817. package/deps/rocksdb/rocksdb/util/math.h +186 -0
  818. package/deps/rocksdb/rocksdb/util/math128.h +298 -0
  819. package/deps/rocksdb/rocksdb/util/murmurhash.cc +191 -0
  820. package/deps/rocksdb/rocksdb/util/murmurhash.h +42 -0
  821. package/deps/rocksdb/rocksdb/util/mutexlock.h +186 -0
  822. package/deps/rocksdb/rocksdb/util/ppc-opcode.h +27 -0
  823. package/deps/rocksdb/rocksdb/util/random.cc +56 -0
  824. package/deps/rocksdb/rocksdb/util/random.h +186 -0
  825. package/deps/rocksdb/rocksdb/util/random_test.cc +105 -0
  826. package/deps/rocksdb/rocksdb/util/rate_limiter.cc +340 -0
  827. package/deps/rocksdb/rocksdb/util/rate_limiter.h +113 -0
  828. package/deps/rocksdb/rocksdb/util/rate_limiter_test.cc +251 -0
  829. package/deps/rocksdb/rocksdb/util/repeatable_thread.h +151 -0
  830. package/deps/rocksdb/rocksdb/util/repeatable_thread_test.cc +107 -0
  831. package/deps/rocksdb/rocksdb/util/ribbon_alg.h +1201 -0
  832. package/deps/rocksdb/rocksdb/util/ribbon_impl.h +1062 -0
  833. package/deps/rocksdb/rocksdb/util/ribbon_test.cc +931 -0
  834. package/deps/rocksdb/rocksdb/util/set_comparator.h +22 -0
  835. package/deps/rocksdb/rocksdb/util/slice.cc +243 -0
  836. package/deps/rocksdb/rocksdb/util/slice_test.cc +163 -0
  837. package/deps/rocksdb/rocksdb/util/slice_transform_test.cc +153 -0
  838. package/deps/rocksdb/rocksdb/util/status.cc +149 -0
  839. package/deps/rocksdb/rocksdb/util/stderr_logger.h +31 -0
  840. package/deps/rocksdb/rocksdb/util/stop_watch.h +118 -0
  841. package/deps/rocksdb/rocksdb/util/string_util.cc +422 -0
  842. package/deps/rocksdb/rocksdb/util/string_util.h +144 -0
  843. package/deps/rocksdb/rocksdb/util/thread_list_test.cc +354 -0
  844. package/deps/rocksdb/rocksdb/util/thread_local.cc +554 -0
  845. package/deps/rocksdb/rocksdb/util/thread_local.h +101 -0
  846. package/deps/rocksdb/rocksdb/util/thread_local_test.cc +583 -0
  847. package/deps/rocksdb/rocksdb/util/thread_operation.h +121 -0
  848. package/deps/rocksdb/rocksdb/util/threadpool_imp.cc +506 -0
  849. package/deps/rocksdb/rocksdb/util/threadpool_imp.h +112 -0
  850. package/deps/rocksdb/rocksdb/util/timer.h +331 -0
  851. package/deps/rocksdb/rocksdb/util/timer_queue.h +230 -0
  852. package/deps/rocksdb/rocksdb/util/timer_queue_test.cc +72 -0
  853. package/deps/rocksdb/rocksdb/util/timer_test.cc +399 -0
  854. package/deps/rocksdb/rocksdb/util/user_comparator_wrapper.h +80 -0
  855. package/deps/rocksdb/rocksdb/util/vector_iterator.h +101 -0
  856. package/deps/rocksdb/rocksdb/util/work_queue.h +148 -0
  857. package/deps/rocksdb/rocksdb/util/work_queue_test.cc +268 -0
  858. package/deps/rocksdb/rocksdb/util/xxh3p.h +1392 -0
  859. package/deps/rocksdb/rocksdb/util/xxhash.cc +1158 -0
  860. package/deps/rocksdb/rocksdb/util/xxhash.h +598 -0
  861. package/deps/rocksdb/rocksdb/utilities/backupable/backupable_db.cc +2354 -0
  862. package/deps/rocksdb/rocksdb/utilities/backupable/backupable_db_test.cc +2955 -0
  863. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.cc +488 -0
  864. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_compaction_filter.h +199 -0
  865. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.cc +112 -0
  866. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db.h +266 -0
  867. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_gc_stats.h +52 -0
  868. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.cc +2167 -0
  869. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.h +500 -0
  870. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +113 -0
  871. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_iterator.h +147 -0
  872. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_listener.h +66 -0
  873. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_test.cc +2386 -0
  874. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +281 -0
  875. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.h +58 -0
  876. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.cc +314 -0
  877. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_file.h +244 -0
  878. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_compaction_filter.cc +47 -0
  879. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_compaction_filter.h +42 -0
  880. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_format_test.cc +375 -0
  881. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_functional_test.cc +327 -0
  882. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_row_merge_test.cc +114 -0
  883. package/deps/rocksdb/rocksdb/utilities/cassandra/cassandra_serialize_test.cc +187 -0
  884. package/deps/rocksdb/rocksdb/utilities/cassandra/format.cc +390 -0
  885. package/deps/rocksdb/rocksdb/utilities/cassandra/format.h +184 -0
  886. package/deps/rocksdb/rocksdb/utilities/cassandra/merge_operator.cc +67 -0
  887. package/deps/rocksdb/rocksdb/utilities/cassandra/merge_operator.h +44 -0
  888. package/deps/rocksdb/rocksdb/utilities/cassandra/serialize.h +75 -0
  889. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.cc +72 -0
  890. package/deps/rocksdb/rocksdb/utilities/cassandra/test_utils.h +43 -0
  891. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.cc +588 -0
  892. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.h +82 -0
  893. package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_test.cc +821 -0
  894. package/deps/rocksdb/rocksdb/utilities/compaction_filters/layered_compaction_filter_base.h +37 -0
  895. package/deps/rocksdb/rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.cc +29 -0
  896. package/deps/rocksdb/rocksdb/utilities/compaction_filters/remove_emptyvalue_compactionfilter.h +27 -0
  897. package/deps/rocksdb/rocksdb/utilities/convenience/info_log_finder.cc +25 -0
  898. package/deps/rocksdb/rocksdb/utilities/debug.cc +82 -0
  899. package/deps/rocksdb/rocksdb/utilities/env_librados.cc +1497 -0
  900. package/deps/rocksdb/rocksdb/utilities/env_librados_test.cc +1146 -0
  901. package/deps/rocksdb/rocksdb/utilities/env_mirror.cc +262 -0
  902. package/deps/rocksdb/rocksdb/utilities/env_mirror_test.cc +223 -0
  903. package/deps/rocksdb/rocksdb/utilities/env_timed.cc +145 -0
  904. package/deps/rocksdb/rocksdb/utilities/env_timed_test.cc +44 -0
  905. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.cc +490 -0
  906. package/deps/rocksdb/rocksdb/utilities/fault_injection_env.h +242 -0
  907. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +581 -0
  908. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +437 -0
  909. package/deps/rocksdb/rocksdb/utilities/leveldb_options/leveldb_options.cc +56 -0
  910. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +275 -0
  911. package/deps/rocksdb/rocksdb/utilities/memory/memory_util.cc +52 -0
  912. package/deps/rocksdb/rocksdb/utilities/merge_operators/bytesxor.cc +59 -0
  913. package/deps/rocksdb/rocksdb/utilities/merge_operators/bytesxor.h +39 -0
  914. package/deps/rocksdb/rocksdb/utilities/merge_operators/max.cc +77 -0
  915. package/deps/rocksdb/rocksdb/utilities/merge_operators/put.cc +83 -0
  916. package/deps/rocksdb/rocksdb/utilities/merge_operators/sortlist.cc +97 -0
  917. package/deps/rocksdb/rocksdb/utilities/merge_operators/sortlist.h +38 -0
  918. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend.cc +59 -0
  919. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend.h +31 -0
  920. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend2.cc +117 -0
  921. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend2.h +49 -0
  922. package/deps/rocksdb/rocksdb/utilities/merge_operators/string_append/stringappend_test.cc +598 -0
  923. package/deps/rocksdb/rocksdb/utilities/merge_operators/uint64add.cc +69 -0
  924. package/deps/rocksdb/rocksdb/utilities/merge_operators.h +55 -0
  925. package/deps/rocksdb/rocksdb/utilities/object_registry.cc +87 -0
  926. package/deps/rocksdb/rocksdb/utilities/object_registry_test.cc +174 -0
  927. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration.cc +168 -0
  928. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration_test.cc +431 -0
  929. package/deps/rocksdb/rocksdb/utilities/options/options_util.cc +159 -0
  930. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +655 -0
  931. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier.cc +425 -0
  932. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier.h +156 -0
  933. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.cc +609 -0
  934. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file.h +296 -0
  935. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_file_buffer.h +127 -0
  936. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_metadata.cc +86 -0
  937. package/deps/rocksdb/rocksdb/utilities/persistent_cache/block_cache_tier_metadata.h +125 -0
  938. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table.h +238 -0
  939. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_bench.cc +308 -0
  940. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_evictable.h +168 -0
  941. package/deps/rocksdb/rocksdb/utilities/persistent_cache/hash_table_test.cc +160 -0
  942. package/deps/rocksdb/rocksdb/utilities/persistent_cache/lrulist.h +174 -0
  943. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_bench.cc +360 -0
  944. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_test.cc +456 -0
  945. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_test.h +286 -0
  946. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_tier.cc +167 -0
  947. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_tier.h +339 -0
  948. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_util.h +67 -0
  949. package/deps/rocksdb/rocksdb/utilities/persistent_cache/volatile_tier_impl.cc +140 -0
  950. package/deps/rocksdb/rocksdb/utilities/persistent_cache/volatile_tier_impl.h +142 -0
  951. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator.cc +285 -0
  952. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator.h +231 -0
  953. package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator_test.cc +494 -0
  954. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache.cc +356 -0
  955. package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache_test.cc +224 -0
  956. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +122 -0
  957. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.h +72 -0
  958. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector_test.cc +244 -0
  959. package/deps/rocksdb/rocksdb/utilities/trace/file_trace_reader_writer.cc +125 -0
  960. package/deps/rocksdb/rocksdb/utilities/trace/file_trace_reader_writer.h +48 -0
  961. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_manager.cc +29 -0
  962. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_manager.h +82 -0
  963. package/deps/rocksdb/rocksdb/utilities/transactions/lock/lock_tracker.h +209 -0
  964. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager.cc +720 -0
  965. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager.h +223 -0
  966. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager_test.cc +181 -0
  967. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_manager_test.h +319 -0
  968. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.cc +270 -0
  969. package/deps/rocksdb/rocksdb/utilities/transactions/lock/point/point_lock_tracker.h +99 -0
  970. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_lock_manager.h +30 -0
  971. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_locking_test.cc +306 -0
  972. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.AGPLv3 +661 -0
  973. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.APACHEv2 +174 -0
  974. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/COPYING.GPLv2 +339 -0
  975. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/db.h +76 -0
  976. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/ft/comparator.h +138 -0
  977. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/ft/ft-status.h +102 -0
  978. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.cc +139 -0
  979. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/concurrent_tree.h +174 -0
  980. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.cc +222 -0
  981. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/keyrange.h +141 -0
  982. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.cc +525 -0
  983. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/lock_request.h +253 -0
  984. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.cc +1007 -0
  985. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/locktree.h +560 -0
  986. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/manager.cc +527 -0
  987. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.cc +265 -0
  988. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/range_buffer.h +178 -0
  989. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/treenode.cc +520 -0
  990. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/treenode.h +302 -0
  991. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.cc +120 -0
  992. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/txnid_set.h +92 -0
  993. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/wfg.cc +213 -0
  994. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/locktree/wfg.h +124 -0
  995. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/memory.h +215 -0
  996. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_assert_subst.h +39 -0
  997. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_atomic.h +130 -0
  998. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_external_pthread.h +82 -0
  999. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_instrumentation.h +286 -0
  1000. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_portability.h +87 -0
  1001. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_pthread.h +520 -0
  1002. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_race_tools.h +179 -0
  1003. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +172 -0
  1004. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/txn_subst.h +27 -0
  1005. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/standalone_port.cc +132 -0
  1006. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/dbt.cc +153 -0
  1007. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/dbt.h +98 -0
  1008. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +144 -0
  1009. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/memarena.cc +201 -0
  1010. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/memarena.h +141 -0
  1011. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/omt.h +794 -0
  1012. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/omt_impl.h +1295 -0
  1013. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/partitioned_counter.h +165 -0
  1014. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/status.h +76 -0
  1015. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.cc +479 -0
  1016. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_manager.h +130 -0
  1017. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.cc +156 -0
  1018. package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/range_tree_lock_tracker.h +146 -0
  1019. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction.cc +196 -0
  1020. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction.h +101 -0
  1021. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.cc +111 -0
  1022. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_db_impl.h +87 -0
  1023. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +1418 -0
  1024. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +752 -0
  1025. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +232 -0
  1026. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +628 -0
  1027. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.h +228 -0
  1028. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +49 -0
  1029. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +678 -0
  1030. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +373 -0
  1031. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_db_mutex_impl.cc +135 -0
  1032. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_db_mutex_impl.h +26 -0
  1033. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +6350 -0
  1034. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.h +522 -0
  1035. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.cc +188 -0
  1036. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_util.h +80 -0
  1037. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_transaction_test.cc +3531 -0
  1038. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +483 -0
  1039. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.h +119 -0
  1040. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.cc +999 -0
  1041. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn_db.h +1109 -0
  1042. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_transaction_test.cc +786 -0
  1043. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.cc +1039 -0
  1044. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn.h +341 -0
  1045. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +470 -0
  1046. package/deps/rocksdb/rocksdb/utilities/transactions/write_unprepared_txn_db.h +108 -0
  1047. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +332 -0
  1048. package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.h +353 -0
  1049. package/deps/rocksdb/rocksdb/utilities/ttl/ttl_test.cc +703 -0
  1050. package/deps/rocksdb/rocksdb/utilities/util_merge_operators_test.cc +99 -0
  1051. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +617 -0
  1052. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +345 -0
  1053. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +569 -0
  1054. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +1867 -0
  1055. package/deps/rocksdb/rocksdb.gyp +475 -0
  1056. package/deps/snappy/freebsd/config.h +135 -0
  1057. package/deps/snappy/freebsd/snappy-stubs-public.h +100 -0
  1058. package/deps/snappy/linux/config.h +135 -0
  1059. package/deps/snappy/linux/snappy-stubs-public.h +100 -0
  1060. package/deps/snappy/mac/config.h +137 -0
  1061. package/deps/snappy/mac/snappy-stubs-public.h +100 -0
  1062. package/deps/snappy/openbsd/config.h +135 -0
  1063. package/deps/snappy/openbsd/snappy-stubs-public.h +100 -0
  1064. package/deps/snappy/snappy-1.1.7/COPYING +54 -0
  1065. package/deps/snappy/snappy-1.1.7/cmake/SnappyConfig.cmake +1 -0
  1066. package/deps/snappy/snappy-1.1.7/cmake/config.h.in +62 -0
  1067. package/deps/snappy/snappy-1.1.7/snappy-c.cc +90 -0
  1068. package/deps/snappy/snappy-1.1.7/snappy-c.h +138 -0
  1069. package/deps/snappy/snappy-1.1.7/snappy-internal.h +224 -0
  1070. package/deps/snappy/snappy-1.1.7/snappy-sinksource.cc +104 -0
  1071. package/deps/snappy/snappy-1.1.7/snappy-sinksource.h +182 -0
  1072. package/deps/snappy/snappy-1.1.7/snappy-stubs-internal.cc +42 -0
  1073. package/deps/snappy/snappy-1.1.7/snappy-stubs-internal.h +561 -0
  1074. package/deps/snappy/snappy-1.1.7/snappy-stubs-public.h.in +94 -0
  1075. package/deps/snappy/snappy-1.1.7/snappy-test.cc +612 -0
  1076. package/deps/snappy/snappy-1.1.7/snappy-test.h +573 -0
  1077. package/deps/snappy/snappy-1.1.7/snappy.cc +1515 -0
  1078. package/deps/snappy/snappy-1.1.7/snappy.h +203 -0
  1079. package/deps/snappy/snappy-1.1.7/snappy_unittest.cc +1410 -0
  1080. package/deps/snappy/snappy.gyp +90 -0
  1081. package/deps/snappy/solaris/config.h +135 -0
  1082. package/deps/snappy/solaris/snappy-stubs-public.h +100 -0
  1083. package/deps/snappy/win32/config.h +29 -0
  1084. package/deps/snappy/win32/snappy-stubs-public.h +100 -0
  1085. package/iterator.js +55 -0
  1086. package/leveldown.js +113 -0
  1087. package/package-lock.json +23687 -0
  1088. package/package.json +70 -0
@@ -0,0 +1,2174 @@
1
+ // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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
+ // Copyright (c) 2011 The LevelDB Authors. All rights reserved.
7
+ // Use of this source code is governed by a BSD-style license that can be
8
+ // found in the LICENSE file. See the AUTHORS file for names of contributors.
9
+ //
10
+ // WriteBatch::rep_ :=
11
+ // sequence: fixed64
12
+ // count: fixed32
13
+ // data: record[count]
14
+ // record :=
15
+ // kTypeValue varstring varstring
16
+ // kTypeDeletion varstring
17
+ // kTypeSingleDeletion varstring
18
+ // kTypeRangeDeletion varstring varstring
19
+ // kTypeMerge varstring varstring
20
+ // kTypeColumnFamilyValue varint32 varstring varstring
21
+ // kTypeColumnFamilyDeletion varint32 varstring
22
+ // kTypeColumnFamilySingleDeletion varint32 varstring
23
+ // kTypeColumnFamilyRangeDeletion varint32 varstring varstring
24
+ // kTypeColumnFamilyMerge varint32 varstring varstring
25
+ // kTypeBeginPrepareXID varstring
26
+ // kTypeEndPrepareXID
27
+ // kTypeCommitXID varstring
28
+ // kTypeRollbackXID varstring
29
+ // kTypeBeginPersistedPrepareXID varstring
30
+ // kTypeBeginUnprepareXID varstring
31
+ // kTypeNoop
32
+ // varstring :=
33
+ // len: varint32
34
+ // data: uint8[len]
35
+
36
+ #include "rocksdb/write_batch.h"
37
+
38
+ #include <map>
39
+ #include <stack>
40
+ #include <stdexcept>
41
+ #include <type_traits>
42
+ #include <unordered_map>
43
+ #include <vector>
44
+
45
+ #include "db/column_family.h"
46
+ #include "db/db_impl/db_impl.h"
47
+ #include "db/dbformat.h"
48
+ #include "db/flush_scheduler.h"
49
+ #include "db/memtable.h"
50
+ #include "db/merge_context.h"
51
+ #include "db/snapshot_impl.h"
52
+ #include "db/trim_history_scheduler.h"
53
+ #include "db/write_batch_internal.h"
54
+ #include "monitoring/perf_context_imp.h"
55
+ #include "monitoring/statistics.h"
56
+ #include "port/lang.h"
57
+ #include "rocksdb/merge_operator.h"
58
+ #include "util/autovector.h"
59
+ #include "util/cast_util.h"
60
+ #include "util/coding.h"
61
+ #include "util/duplicate_detector.h"
62
+ #include "util/string_util.h"
63
+
64
+ namespace ROCKSDB_NAMESPACE {
65
+
66
+ // anon namespace for file-local types
67
+ namespace {
68
+
69
+ enum ContentFlags : uint32_t {
70
+ DEFERRED = 1 << 0,
71
+ HAS_PUT = 1 << 1,
72
+ HAS_DELETE = 1 << 2,
73
+ HAS_SINGLE_DELETE = 1 << 3,
74
+ HAS_MERGE = 1 << 4,
75
+ HAS_BEGIN_PREPARE = 1 << 5,
76
+ HAS_END_PREPARE = 1 << 6,
77
+ HAS_COMMIT = 1 << 7,
78
+ HAS_ROLLBACK = 1 << 8,
79
+ HAS_DELETE_RANGE = 1 << 9,
80
+ HAS_BLOB_INDEX = 1 << 10,
81
+ HAS_BEGIN_UNPREPARE = 1 << 11,
82
+ };
83
+
84
+ struct BatchContentClassifier : public WriteBatch::Handler {
85
+ uint32_t content_flags = 0;
86
+
87
+ Status PutCF(uint32_t, const Slice&, const Slice&) override {
88
+ content_flags |= ContentFlags::HAS_PUT;
89
+ return Status::OK();
90
+ }
91
+
92
+ Status DeleteCF(uint32_t, const Slice&) override {
93
+ content_flags |= ContentFlags::HAS_DELETE;
94
+ return Status::OK();
95
+ }
96
+
97
+ Status SingleDeleteCF(uint32_t, const Slice&) override {
98
+ content_flags |= ContentFlags::HAS_SINGLE_DELETE;
99
+ return Status::OK();
100
+ }
101
+
102
+ Status DeleteRangeCF(uint32_t, const Slice&, const Slice&) override {
103
+ content_flags |= ContentFlags::HAS_DELETE_RANGE;
104
+ return Status::OK();
105
+ }
106
+
107
+ Status MergeCF(uint32_t, const Slice&, const Slice&) override {
108
+ content_flags |= ContentFlags::HAS_MERGE;
109
+ return Status::OK();
110
+ }
111
+
112
+ Status PutBlobIndexCF(uint32_t, const Slice&, const Slice&) override {
113
+ content_flags |= ContentFlags::HAS_BLOB_INDEX;
114
+ return Status::OK();
115
+ }
116
+
117
+ Status MarkBeginPrepare(bool unprepare) override {
118
+ content_flags |= ContentFlags::HAS_BEGIN_PREPARE;
119
+ if (unprepare) {
120
+ content_flags |= ContentFlags::HAS_BEGIN_UNPREPARE;
121
+ }
122
+ return Status::OK();
123
+ }
124
+
125
+ Status MarkEndPrepare(const Slice&) override {
126
+ content_flags |= ContentFlags::HAS_END_PREPARE;
127
+ return Status::OK();
128
+ }
129
+
130
+ Status MarkCommit(const Slice&) override {
131
+ content_flags |= ContentFlags::HAS_COMMIT;
132
+ return Status::OK();
133
+ }
134
+
135
+ Status MarkRollback(const Slice&) override {
136
+ content_flags |= ContentFlags::HAS_ROLLBACK;
137
+ return Status::OK();
138
+ }
139
+ };
140
+
141
+ class TimestampAssigner : public WriteBatch::Handler {
142
+ public:
143
+ explicit TimestampAssigner(const Slice& ts)
144
+ : timestamp_(ts), timestamps_(kEmptyTimestampList) {}
145
+ explicit TimestampAssigner(const std::vector<Slice>& ts_list)
146
+ : timestamps_(ts_list) {
147
+ SanityCheck();
148
+ }
149
+ ~TimestampAssigner() override {}
150
+
151
+ Status PutCF(uint32_t, const Slice& key, const Slice&) override {
152
+ AssignTimestamp(key);
153
+ ++idx_;
154
+ return Status::OK();
155
+ }
156
+
157
+ Status DeleteCF(uint32_t, const Slice& key) override {
158
+ AssignTimestamp(key);
159
+ ++idx_;
160
+ return Status::OK();
161
+ }
162
+
163
+ Status SingleDeleteCF(uint32_t, const Slice& key) override {
164
+ AssignTimestamp(key);
165
+ ++idx_;
166
+ return Status::OK();
167
+ }
168
+
169
+ Status DeleteRangeCF(uint32_t, const Slice& begin_key,
170
+ const Slice& end_key) override {
171
+ AssignTimestamp(begin_key);
172
+ AssignTimestamp(end_key);
173
+ ++idx_;
174
+ return Status::OK();
175
+ }
176
+
177
+ Status MergeCF(uint32_t, const Slice& key, const Slice&) override {
178
+ AssignTimestamp(key);
179
+ ++idx_;
180
+ return Status::OK();
181
+ }
182
+
183
+ Status PutBlobIndexCF(uint32_t, const Slice&, const Slice&) override {
184
+ // TODO (yanqin): support blob db in the future.
185
+ return Status::OK();
186
+ }
187
+
188
+ Status MarkBeginPrepare(bool) override {
189
+ // TODO (yanqin): support in the future.
190
+ return Status::OK();
191
+ }
192
+
193
+ Status MarkEndPrepare(const Slice&) override {
194
+ // TODO (yanqin): support in the future.
195
+ return Status::OK();
196
+ }
197
+
198
+ Status MarkCommit(const Slice&) override {
199
+ // TODO (yanqin): support in the future.
200
+ return Status::OK();
201
+ }
202
+
203
+ Status MarkRollback(const Slice&) override {
204
+ // TODO (yanqin): support in the future.
205
+ return Status::OK();
206
+ }
207
+
208
+ private:
209
+ void SanityCheck() const {
210
+ assert(!timestamps_.empty());
211
+ #ifndef NDEBUG
212
+ const size_t ts_sz = timestamps_[0].size();
213
+ for (size_t i = 1; i != timestamps_.size(); ++i) {
214
+ assert(ts_sz == timestamps_[i].size());
215
+ }
216
+ #endif // !NDEBUG
217
+ }
218
+
219
+ void AssignTimestamp(const Slice& key) {
220
+ assert(timestamps_.empty() || idx_ < timestamps_.size());
221
+ const Slice& ts = timestamps_.empty() ? timestamp_ : timestamps_[idx_];
222
+ size_t ts_sz = ts.size();
223
+ char* ptr = const_cast<char*>(key.data() + key.size() - ts_sz);
224
+ memcpy(ptr, ts.data(), ts_sz);
225
+ }
226
+
227
+ static const std::vector<Slice> kEmptyTimestampList;
228
+ const Slice timestamp_;
229
+ const std::vector<Slice>& timestamps_;
230
+ size_t idx_ = 0;
231
+
232
+ // No copy or move.
233
+ TimestampAssigner(const TimestampAssigner&) = delete;
234
+ TimestampAssigner(TimestampAssigner&&) = delete;
235
+ TimestampAssigner& operator=(const TimestampAssigner&) = delete;
236
+ TimestampAssigner&& operator=(TimestampAssigner&&) = delete;
237
+ };
238
+ const std::vector<Slice> TimestampAssigner::kEmptyTimestampList;
239
+
240
+ } // anon namespace
241
+
242
+ struct SavePoints {
243
+ std::stack<SavePoint, autovector<SavePoint>> stack;
244
+ };
245
+
246
+ WriteBatch::WriteBatch(size_t reserved_bytes, size_t max_bytes)
247
+ : content_flags_(0), max_bytes_(max_bytes), rep_(), timestamp_size_(0) {
248
+ rep_.reserve((reserved_bytes > WriteBatchInternal::kHeader)
249
+ ? reserved_bytes
250
+ : WriteBatchInternal::kHeader);
251
+ rep_.resize(WriteBatchInternal::kHeader);
252
+ }
253
+
254
+ WriteBatch::WriteBatch(size_t reserved_bytes, size_t max_bytes, size_t ts_sz)
255
+ : content_flags_(0), max_bytes_(max_bytes), rep_(), timestamp_size_(ts_sz) {
256
+ rep_.reserve((reserved_bytes > WriteBatchInternal::kHeader) ?
257
+ reserved_bytes : WriteBatchInternal::kHeader);
258
+ rep_.resize(WriteBatchInternal::kHeader);
259
+ }
260
+
261
+ WriteBatch::WriteBatch(const std::string& rep)
262
+ : content_flags_(ContentFlags::DEFERRED),
263
+ max_bytes_(0),
264
+ rep_(rep),
265
+ timestamp_size_(0) {}
266
+
267
+ WriteBatch::WriteBatch(std::string&& rep)
268
+ : content_flags_(ContentFlags::DEFERRED),
269
+ max_bytes_(0),
270
+ rep_(std::move(rep)),
271
+ timestamp_size_(0) {}
272
+
273
+ WriteBatch::WriteBatch(const WriteBatch& src)
274
+ : wal_term_point_(src.wal_term_point_),
275
+ content_flags_(src.content_flags_.load(std::memory_order_relaxed)),
276
+ max_bytes_(src.max_bytes_),
277
+ rep_(src.rep_),
278
+ timestamp_size_(src.timestamp_size_) {
279
+ if (src.save_points_ != nullptr) {
280
+ save_points_.reset(new SavePoints());
281
+ save_points_->stack = src.save_points_->stack;
282
+ }
283
+ }
284
+
285
+ WriteBatch::WriteBatch(WriteBatch&& src) noexcept
286
+ : save_points_(std::move(src.save_points_)),
287
+ wal_term_point_(std::move(src.wal_term_point_)),
288
+ content_flags_(src.content_flags_.load(std::memory_order_relaxed)),
289
+ max_bytes_(src.max_bytes_),
290
+ rep_(std::move(src.rep_)),
291
+ timestamp_size_(src.timestamp_size_) {}
292
+
293
+ WriteBatch& WriteBatch::operator=(const WriteBatch& src) {
294
+ if (&src != this) {
295
+ this->~WriteBatch();
296
+ new (this) WriteBatch(src);
297
+ }
298
+ return *this;
299
+ }
300
+
301
+ WriteBatch& WriteBatch::operator=(WriteBatch&& src) {
302
+ if (&src != this) {
303
+ this->~WriteBatch();
304
+ new (this) WriteBatch(std::move(src));
305
+ }
306
+ return *this;
307
+ }
308
+
309
+ WriteBatch::~WriteBatch() { }
310
+
311
+ WriteBatch::Handler::~Handler() { }
312
+
313
+ void WriteBatch::Handler::LogData(const Slice& /*blob*/) {
314
+ // If the user has not specified something to do with blobs, then we ignore
315
+ // them.
316
+ }
317
+
318
+ bool WriteBatch::Handler::Continue() {
319
+ return true;
320
+ }
321
+
322
+ void WriteBatch::Clear() {
323
+ rep_.clear();
324
+ rep_.resize(WriteBatchInternal::kHeader);
325
+
326
+ content_flags_.store(0, std::memory_order_relaxed);
327
+
328
+ if (save_points_ != nullptr) {
329
+ while (!save_points_->stack.empty()) {
330
+ save_points_->stack.pop();
331
+ }
332
+ }
333
+
334
+ wal_term_point_.clear();
335
+ }
336
+
337
+ uint32_t WriteBatch::Count() const { return WriteBatchInternal::Count(this); }
338
+
339
+ uint32_t WriteBatch::ComputeContentFlags() const {
340
+ auto rv = content_flags_.load(std::memory_order_relaxed);
341
+ if ((rv & ContentFlags::DEFERRED) != 0) {
342
+ BatchContentClassifier classifier;
343
+ // Should we handle status here?
344
+ Iterate(&classifier).PermitUncheckedError();
345
+ rv = classifier.content_flags;
346
+
347
+ // this method is conceptually const, because it is performing a lazy
348
+ // computation that doesn't affect the abstract state of the batch.
349
+ // content_flags_ is marked mutable so that we can perform the
350
+ // following assignment
351
+ content_flags_.store(rv, std::memory_order_relaxed);
352
+ }
353
+ return rv;
354
+ }
355
+
356
+ void WriteBatch::MarkWalTerminationPoint() {
357
+ wal_term_point_.size = GetDataSize();
358
+ wal_term_point_.count = Count();
359
+ wal_term_point_.content_flags = content_flags_;
360
+ }
361
+
362
+ bool WriteBatch::HasPut() const {
363
+ return (ComputeContentFlags() & ContentFlags::HAS_PUT) != 0;
364
+ }
365
+
366
+ bool WriteBatch::HasDelete() const {
367
+ return (ComputeContentFlags() & ContentFlags::HAS_DELETE) != 0;
368
+ }
369
+
370
+ bool WriteBatch::HasSingleDelete() const {
371
+ return (ComputeContentFlags() & ContentFlags::HAS_SINGLE_DELETE) != 0;
372
+ }
373
+
374
+ bool WriteBatch::HasDeleteRange() const {
375
+ return (ComputeContentFlags() & ContentFlags::HAS_DELETE_RANGE) != 0;
376
+ }
377
+
378
+ bool WriteBatch::HasMerge() const {
379
+ return (ComputeContentFlags() & ContentFlags::HAS_MERGE) != 0;
380
+ }
381
+
382
+ bool ReadKeyFromWriteBatchEntry(Slice* input, Slice* key, bool cf_record) {
383
+ assert(input != nullptr && key != nullptr);
384
+ // Skip tag byte
385
+ input->remove_prefix(1);
386
+
387
+ if (cf_record) {
388
+ // Skip column_family bytes
389
+ uint32_t cf;
390
+ if (!GetVarint32(input, &cf)) {
391
+ return false;
392
+ }
393
+ }
394
+
395
+ // Extract key
396
+ return GetLengthPrefixedSlice(input, key);
397
+ }
398
+
399
+ bool WriteBatch::HasBeginPrepare() const {
400
+ return (ComputeContentFlags() & ContentFlags::HAS_BEGIN_PREPARE) != 0;
401
+ }
402
+
403
+ bool WriteBatch::HasEndPrepare() const {
404
+ return (ComputeContentFlags() & ContentFlags::HAS_END_PREPARE) != 0;
405
+ }
406
+
407
+ bool WriteBatch::HasCommit() const {
408
+ return (ComputeContentFlags() & ContentFlags::HAS_COMMIT) != 0;
409
+ }
410
+
411
+ bool WriteBatch::HasRollback() const {
412
+ return (ComputeContentFlags() & ContentFlags::HAS_ROLLBACK) != 0;
413
+ }
414
+
415
+ Status ReadRecordFromWriteBatch(Slice* input, char* tag,
416
+ uint32_t* column_family, Slice* key,
417
+ Slice* value, Slice* blob, Slice* xid) {
418
+ assert(key != nullptr && value != nullptr);
419
+ *tag = (*input)[0];
420
+ input->remove_prefix(1);
421
+ *column_family = 0; // default
422
+ switch (*tag) {
423
+ case kTypeColumnFamilyValue:
424
+ if (!GetVarint32(input, column_family)) {
425
+ return Status::Corruption("bad WriteBatch Put");
426
+ }
427
+ FALLTHROUGH_INTENDED;
428
+ case kTypeValue:
429
+ if (!GetLengthPrefixedSlice(input, key) ||
430
+ !GetLengthPrefixedSlice(input, value)) {
431
+ return Status::Corruption("bad WriteBatch Put");
432
+ }
433
+ break;
434
+ case kTypeColumnFamilyDeletion:
435
+ case kTypeColumnFamilySingleDeletion:
436
+ if (!GetVarint32(input, column_family)) {
437
+ return Status::Corruption("bad WriteBatch Delete");
438
+ }
439
+ FALLTHROUGH_INTENDED;
440
+ case kTypeDeletion:
441
+ case kTypeSingleDeletion:
442
+ if (!GetLengthPrefixedSlice(input, key)) {
443
+ return Status::Corruption("bad WriteBatch Delete");
444
+ }
445
+ break;
446
+ case kTypeColumnFamilyRangeDeletion:
447
+ if (!GetVarint32(input, column_family)) {
448
+ return Status::Corruption("bad WriteBatch DeleteRange");
449
+ }
450
+ FALLTHROUGH_INTENDED;
451
+ case kTypeRangeDeletion:
452
+ // for range delete, "key" is begin_key, "value" is end_key
453
+ if (!GetLengthPrefixedSlice(input, key) ||
454
+ !GetLengthPrefixedSlice(input, value)) {
455
+ return Status::Corruption("bad WriteBatch DeleteRange");
456
+ }
457
+ break;
458
+ case kTypeColumnFamilyMerge:
459
+ if (!GetVarint32(input, column_family)) {
460
+ return Status::Corruption("bad WriteBatch Merge");
461
+ }
462
+ FALLTHROUGH_INTENDED;
463
+ case kTypeMerge:
464
+ if (!GetLengthPrefixedSlice(input, key) ||
465
+ !GetLengthPrefixedSlice(input, value)) {
466
+ return Status::Corruption("bad WriteBatch Merge");
467
+ }
468
+ break;
469
+ case kTypeColumnFamilyBlobIndex:
470
+ if (!GetVarint32(input, column_family)) {
471
+ return Status::Corruption("bad WriteBatch BlobIndex");
472
+ }
473
+ FALLTHROUGH_INTENDED;
474
+ case kTypeBlobIndex:
475
+ if (!GetLengthPrefixedSlice(input, key) ||
476
+ !GetLengthPrefixedSlice(input, value)) {
477
+ return Status::Corruption("bad WriteBatch BlobIndex");
478
+ }
479
+ break;
480
+ case kTypeLogData:
481
+ assert(blob != nullptr);
482
+ if (!GetLengthPrefixedSlice(input, blob)) {
483
+ return Status::Corruption("bad WriteBatch Blob");
484
+ }
485
+ break;
486
+ case kTypeNoop:
487
+ case kTypeBeginPrepareXID:
488
+ // This indicates that the prepared batch is also persisted in the db.
489
+ // This is used in WritePreparedTxn
490
+ case kTypeBeginPersistedPrepareXID:
491
+ // This is used in WriteUnpreparedTxn
492
+ case kTypeBeginUnprepareXID:
493
+ break;
494
+ case kTypeEndPrepareXID:
495
+ if (!GetLengthPrefixedSlice(input, xid)) {
496
+ return Status::Corruption("bad EndPrepare XID");
497
+ }
498
+ break;
499
+ case kTypeCommitXID:
500
+ if (!GetLengthPrefixedSlice(input, xid)) {
501
+ return Status::Corruption("bad Commit XID");
502
+ }
503
+ break;
504
+ case kTypeRollbackXID:
505
+ if (!GetLengthPrefixedSlice(input, xid)) {
506
+ return Status::Corruption("bad Rollback XID");
507
+ }
508
+ break;
509
+ default:
510
+ return Status::Corruption("unknown WriteBatch tag");
511
+ }
512
+ return Status::OK();
513
+ }
514
+
515
+ Status WriteBatch::Iterate(Handler* handler) const {
516
+ if (rep_.size() < WriteBatchInternal::kHeader) {
517
+ return Status::Corruption("malformed WriteBatch (too small)");
518
+ }
519
+
520
+ return WriteBatchInternal::Iterate(this, handler, WriteBatchInternal::kHeader,
521
+ rep_.size());
522
+ }
523
+
524
+ Status WriteBatchInternal::Iterate(const WriteBatch* wb,
525
+ WriteBatch::Handler* handler, size_t begin,
526
+ size_t end) {
527
+ if (begin > wb->rep_.size() || end > wb->rep_.size() || end < begin) {
528
+ return Status::Corruption("Invalid start/end bounds for Iterate");
529
+ }
530
+ assert(begin <= end);
531
+ Slice input(wb->rep_.data() + begin, static_cast<size_t>(end - begin));
532
+ bool whole_batch =
533
+ (begin == WriteBatchInternal::kHeader) && (end == wb->rep_.size());
534
+
535
+ Slice key, value, blob, xid;
536
+ // Sometimes a sub-batch starts with a Noop. We want to exclude such Noops as
537
+ // the batch boundary symbols otherwise we would mis-count the number of
538
+ // batches. We do that by checking whether the accumulated batch is empty
539
+ // before seeing the next Noop.
540
+ bool empty_batch = true;
541
+ uint32_t found = 0;
542
+ Status s;
543
+ char tag = 0;
544
+ uint32_t column_family = 0; // default
545
+ bool last_was_try_again = false;
546
+ bool handler_continue = true;
547
+ while (((s.ok() && !input.empty()) || UNLIKELY(s.IsTryAgain()))) {
548
+ handler_continue = handler->Continue();
549
+ if (!handler_continue) {
550
+ break;
551
+ }
552
+
553
+ if (LIKELY(!s.IsTryAgain())) {
554
+ last_was_try_again = false;
555
+ tag = 0;
556
+ column_family = 0; // default
557
+
558
+ s = ReadRecordFromWriteBatch(&input, &tag, &column_family, &key, &value,
559
+ &blob, &xid);
560
+ if (!s.ok()) {
561
+ return s;
562
+ }
563
+ } else {
564
+ assert(s.IsTryAgain());
565
+ assert(!last_was_try_again); // to detect infinite loop bugs
566
+ if (UNLIKELY(last_was_try_again)) {
567
+ return Status::Corruption(
568
+ "two consecutive TryAgain in WriteBatch handler; this is either a "
569
+ "software bug or data corruption.");
570
+ }
571
+ last_was_try_again = true;
572
+ s = Status::OK();
573
+ }
574
+
575
+ switch (tag) {
576
+ case kTypeColumnFamilyValue:
577
+ case kTypeValue:
578
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
579
+ (ContentFlags::DEFERRED | ContentFlags::HAS_PUT));
580
+ s = handler->PutCF(column_family, key, value);
581
+ if (LIKELY(s.ok())) {
582
+ empty_batch = false;
583
+ found++;
584
+ }
585
+ break;
586
+ case kTypeColumnFamilyDeletion:
587
+ case kTypeDeletion:
588
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
589
+ (ContentFlags::DEFERRED | ContentFlags::HAS_DELETE));
590
+ s = handler->DeleteCF(column_family, key);
591
+ if (LIKELY(s.ok())) {
592
+ empty_batch = false;
593
+ found++;
594
+ }
595
+ break;
596
+ case kTypeColumnFamilySingleDeletion:
597
+ case kTypeSingleDeletion:
598
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
599
+ (ContentFlags::DEFERRED | ContentFlags::HAS_SINGLE_DELETE));
600
+ s = handler->SingleDeleteCF(column_family, key);
601
+ if (LIKELY(s.ok())) {
602
+ empty_batch = false;
603
+ found++;
604
+ }
605
+ break;
606
+ case kTypeColumnFamilyRangeDeletion:
607
+ case kTypeRangeDeletion:
608
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
609
+ (ContentFlags::DEFERRED | ContentFlags::HAS_DELETE_RANGE));
610
+ s = handler->DeleteRangeCF(column_family, key, value);
611
+ if (LIKELY(s.ok())) {
612
+ empty_batch = false;
613
+ found++;
614
+ }
615
+ break;
616
+ case kTypeColumnFamilyMerge:
617
+ case kTypeMerge:
618
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
619
+ (ContentFlags::DEFERRED | ContentFlags::HAS_MERGE));
620
+ s = handler->MergeCF(column_family, key, value);
621
+ if (LIKELY(s.ok())) {
622
+ empty_batch = false;
623
+ found++;
624
+ }
625
+ break;
626
+ case kTypeColumnFamilyBlobIndex:
627
+ case kTypeBlobIndex:
628
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
629
+ (ContentFlags::DEFERRED | ContentFlags::HAS_BLOB_INDEX));
630
+ s = handler->PutBlobIndexCF(column_family, key, value);
631
+ if (LIKELY(s.ok())) {
632
+ found++;
633
+ }
634
+ break;
635
+ case kTypeLogData:
636
+ handler->LogData(blob);
637
+ // A batch might have nothing but LogData. It is still a batch.
638
+ empty_batch = false;
639
+ break;
640
+ case kTypeBeginPrepareXID:
641
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
642
+ (ContentFlags::DEFERRED | ContentFlags::HAS_BEGIN_PREPARE));
643
+ s = handler->MarkBeginPrepare();
644
+ assert(s.ok());
645
+ empty_batch = false;
646
+ if (!handler->WriteAfterCommit()) {
647
+ s = Status::NotSupported(
648
+ "WriteCommitted txn tag when write_after_commit_ is disabled (in "
649
+ "WritePrepared/WriteUnprepared mode). If it is not due to "
650
+ "corruption, the WAL must be emptied before changing the "
651
+ "WritePolicy.");
652
+ }
653
+ if (handler->WriteBeforePrepare()) {
654
+ s = Status::NotSupported(
655
+ "WriteCommitted txn tag when write_before_prepare_ is enabled "
656
+ "(in WriteUnprepared mode). If it is not due to corruption, the "
657
+ "WAL must be emptied before changing the WritePolicy.");
658
+ }
659
+ break;
660
+ case kTypeBeginPersistedPrepareXID:
661
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
662
+ (ContentFlags::DEFERRED | ContentFlags::HAS_BEGIN_PREPARE));
663
+ s = handler->MarkBeginPrepare();
664
+ assert(s.ok());
665
+ empty_batch = false;
666
+ if (handler->WriteAfterCommit()) {
667
+ s = Status::NotSupported(
668
+ "WritePrepared/WriteUnprepared txn tag when write_after_commit_ "
669
+ "is enabled (in default WriteCommitted mode). If it is not due "
670
+ "to corruption, the WAL must be emptied before changing the "
671
+ "WritePolicy.");
672
+ }
673
+ break;
674
+ case kTypeBeginUnprepareXID:
675
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
676
+ (ContentFlags::DEFERRED | ContentFlags::HAS_BEGIN_UNPREPARE));
677
+ s = handler->MarkBeginPrepare(true /* unprepared */);
678
+ assert(s.ok());
679
+ empty_batch = false;
680
+ if (handler->WriteAfterCommit()) {
681
+ s = Status::NotSupported(
682
+ "WriteUnprepared txn tag when write_after_commit_ is enabled (in "
683
+ "default WriteCommitted mode). If it is not due to corruption, "
684
+ "the WAL must be emptied before changing the WritePolicy.");
685
+ }
686
+ if (!handler->WriteBeforePrepare()) {
687
+ s = Status::NotSupported(
688
+ "WriteUnprepared txn tag when write_before_prepare_ is disabled "
689
+ "(in WriteCommitted/WritePrepared mode). If it is not due to "
690
+ "corruption, the WAL must be emptied before changing the "
691
+ "WritePolicy.");
692
+ }
693
+ break;
694
+ case kTypeEndPrepareXID:
695
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
696
+ (ContentFlags::DEFERRED | ContentFlags::HAS_END_PREPARE));
697
+ s = handler->MarkEndPrepare(xid);
698
+ assert(s.ok());
699
+ empty_batch = true;
700
+ break;
701
+ case kTypeCommitXID:
702
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
703
+ (ContentFlags::DEFERRED | ContentFlags::HAS_COMMIT));
704
+ s = handler->MarkCommit(xid);
705
+ assert(s.ok());
706
+ empty_batch = true;
707
+ break;
708
+ case kTypeRollbackXID:
709
+ assert(wb->content_flags_.load(std::memory_order_relaxed) &
710
+ (ContentFlags::DEFERRED | ContentFlags::HAS_ROLLBACK));
711
+ s = handler->MarkRollback(xid);
712
+ assert(s.ok());
713
+ empty_batch = true;
714
+ break;
715
+ case kTypeNoop:
716
+ s = handler->MarkNoop(empty_batch);
717
+ assert(s.ok());
718
+ empty_batch = true;
719
+ break;
720
+ default:
721
+ return Status::Corruption("unknown WriteBatch tag");
722
+ }
723
+ }
724
+ if (!s.ok()) {
725
+ return s;
726
+ }
727
+ if (handler_continue && whole_batch &&
728
+ found != WriteBatchInternal::Count(wb)) {
729
+ return Status::Corruption("WriteBatch has wrong count");
730
+ } else {
731
+ return Status::OK();
732
+ }
733
+ }
734
+
735
+ bool WriteBatchInternal::IsLatestPersistentState(const WriteBatch* b) {
736
+ return b->is_latest_persistent_state_;
737
+ }
738
+
739
+ void WriteBatchInternal::SetAsLastestPersistentState(WriteBatch* b) {
740
+ b->is_latest_persistent_state_ = true;
741
+ }
742
+
743
+ uint32_t WriteBatchInternal::Count(const WriteBatch* b) {
744
+ return DecodeFixed32(b->rep_.data() + 8);
745
+ }
746
+
747
+ void WriteBatchInternal::SetCount(WriteBatch* b, uint32_t n) {
748
+ EncodeFixed32(&b->rep_[8], n);
749
+ }
750
+
751
+ SequenceNumber WriteBatchInternal::Sequence(const WriteBatch* b) {
752
+ return SequenceNumber(DecodeFixed64(b->rep_.data()));
753
+ }
754
+
755
+ void WriteBatchInternal::SetSequence(WriteBatch* b, SequenceNumber seq) {
756
+ EncodeFixed64(&b->rep_[0], seq);
757
+ }
758
+
759
+ size_t WriteBatchInternal::GetFirstOffset(WriteBatch* /*b*/) {
760
+ return WriteBatchInternal::kHeader;
761
+ }
762
+
763
+ Status WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
764
+ const Slice& key, const Slice& value) {
765
+ if (key.size() > size_t{port::kMaxUint32}) {
766
+ return Status::InvalidArgument("key is too large");
767
+ }
768
+ if (value.size() > size_t{port::kMaxUint32}) {
769
+ return Status::InvalidArgument("value is too large");
770
+ }
771
+
772
+ LocalSavePoint save(b);
773
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
774
+ if (column_family_id == 0) {
775
+ b->rep_.push_back(static_cast<char>(kTypeValue));
776
+ } else {
777
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyValue));
778
+ PutVarint32(&b->rep_, column_family_id);
779
+ }
780
+ if (0 == b->timestamp_size_) {
781
+ PutLengthPrefixedSlice(&b->rep_, key);
782
+ } else {
783
+ PutVarint32(&b->rep_,
784
+ static_cast<uint32_t>(key.size() + b->timestamp_size_));
785
+ b->rep_.append(key.data(), key.size());
786
+ b->rep_.append(b->timestamp_size_, '\0');
787
+ }
788
+ PutLengthPrefixedSlice(&b->rep_, value);
789
+ b->content_flags_.store(
790
+ b->content_flags_.load(std::memory_order_relaxed) | ContentFlags::HAS_PUT,
791
+ std::memory_order_relaxed);
792
+ return save.commit();
793
+ }
794
+
795
+ Status WriteBatch::Put(ColumnFamilyHandle* column_family, const Slice& key,
796
+ const Slice& value) {
797
+ return WriteBatchInternal::Put(this, GetColumnFamilyID(column_family), key,
798
+ value);
799
+ }
800
+
801
+ Status WriteBatchInternal::CheckSlicePartsLength(const SliceParts& key,
802
+ const SliceParts& value) {
803
+ size_t total_key_bytes = 0;
804
+ for (int i = 0; i < key.num_parts; ++i) {
805
+ total_key_bytes += key.parts[i].size();
806
+ }
807
+ if (total_key_bytes >= size_t{port::kMaxUint32}) {
808
+ return Status::InvalidArgument("key is too large");
809
+ }
810
+
811
+ size_t total_value_bytes = 0;
812
+ for (int i = 0; i < value.num_parts; ++i) {
813
+ total_value_bytes += value.parts[i].size();
814
+ }
815
+ if (total_value_bytes >= size_t{port::kMaxUint32}) {
816
+ return Status::InvalidArgument("value is too large");
817
+ }
818
+ return Status::OK();
819
+ }
820
+
821
+ Status WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
822
+ const SliceParts& key, const SliceParts& value) {
823
+ Status s = CheckSlicePartsLength(key, value);
824
+ if (!s.ok()) {
825
+ return s;
826
+ }
827
+
828
+ LocalSavePoint save(b);
829
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
830
+ if (column_family_id == 0) {
831
+ b->rep_.push_back(static_cast<char>(kTypeValue));
832
+ } else {
833
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyValue));
834
+ PutVarint32(&b->rep_, column_family_id);
835
+ }
836
+ if (0 == b->timestamp_size_) {
837
+ PutLengthPrefixedSliceParts(&b->rep_, key);
838
+ } else {
839
+ PutLengthPrefixedSlicePartsWithPadding(&b->rep_, key, b->timestamp_size_);
840
+ }
841
+ PutLengthPrefixedSliceParts(&b->rep_, value);
842
+ b->content_flags_.store(
843
+ b->content_flags_.load(std::memory_order_relaxed) | ContentFlags::HAS_PUT,
844
+ std::memory_order_relaxed);
845
+ return save.commit();
846
+ }
847
+
848
+ Status WriteBatch::Put(ColumnFamilyHandle* column_family, const SliceParts& key,
849
+ const SliceParts& value) {
850
+ return WriteBatchInternal::Put(this, GetColumnFamilyID(column_family), key,
851
+ value);
852
+ }
853
+
854
+ Status WriteBatchInternal::InsertNoop(WriteBatch* b) {
855
+ b->rep_.push_back(static_cast<char>(kTypeNoop));
856
+ return Status::OK();
857
+ }
858
+
859
+ Status WriteBatchInternal::MarkEndPrepare(WriteBatch* b, const Slice& xid,
860
+ bool write_after_commit,
861
+ bool unprepared_batch) {
862
+ // a manually constructed batch can only contain one prepare section
863
+ assert(b->rep_[12] == static_cast<char>(kTypeNoop));
864
+
865
+ // all savepoints up to this point are cleared
866
+ if (b->save_points_ != nullptr) {
867
+ while (!b->save_points_->stack.empty()) {
868
+ b->save_points_->stack.pop();
869
+ }
870
+ }
871
+
872
+ // rewrite noop as begin marker
873
+ b->rep_[12] = static_cast<char>(
874
+ write_after_commit ? kTypeBeginPrepareXID
875
+ : (unprepared_batch ? kTypeBeginUnprepareXID
876
+ : kTypeBeginPersistedPrepareXID));
877
+ b->rep_.push_back(static_cast<char>(kTypeEndPrepareXID));
878
+ PutLengthPrefixedSlice(&b->rep_, xid);
879
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
880
+ ContentFlags::HAS_END_PREPARE |
881
+ ContentFlags::HAS_BEGIN_PREPARE,
882
+ std::memory_order_relaxed);
883
+ if (unprepared_batch) {
884
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
885
+ ContentFlags::HAS_BEGIN_UNPREPARE,
886
+ std::memory_order_relaxed);
887
+ }
888
+ return Status::OK();
889
+ }
890
+
891
+ Status WriteBatchInternal::MarkCommit(WriteBatch* b, const Slice& xid) {
892
+ b->rep_.push_back(static_cast<char>(kTypeCommitXID));
893
+ PutLengthPrefixedSlice(&b->rep_, xid);
894
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
895
+ ContentFlags::HAS_COMMIT,
896
+ std::memory_order_relaxed);
897
+ return Status::OK();
898
+ }
899
+
900
+ Status WriteBatchInternal::MarkRollback(WriteBatch* b, const Slice& xid) {
901
+ b->rep_.push_back(static_cast<char>(kTypeRollbackXID));
902
+ PutLengthPrefixedSlice(&b->rep_, xid);
903
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
904
+ ContentFlags::HAS_ROLLBACK,
905
+ std::memory_order_relaxed);
906
+ return Status::OK();
907
+ }
908
+
909
+ Status WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
910
+ const Slice& key) {
911
+ LocalSavePoint save(b);
912
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
913
+ if (column_family_id == 0) {
914
+ b->rep_.push_back(static_cast<char>(kTypeDeletion));
915
+ } else {
916
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyDeletion));
917
+ PutVarint32(&b->rep_, column_family_id);
918
+ }
919
+ if (0 == b->timestamp_size_) {
920
+ PutLengthPrefixedSlice(&b->rep_, key);
921
+ } else {
922
+ PutVarint32(&b->rep_,
923
+ static_cast<uint32_t>(key.size() + b->timestamp_size_));
924
+ b->rep_.append(key.data(), key.size());
925
+ b->rep_.append(b->timestamp_size_, '\0');
926
+ }
927
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
928
+ ContentFlags::HAS_DELETE,
929
+ std::memory_order_relaxed);
930
+ return save.commit();
931
+ }
932
+
933
+ Status WriteBatch::Delete(ColumnFamilyHandle* column_family, const Slice& key) {
934
+ return WriteBatchInternal::Delete(this, GetColumnFamilyID(column_family),
935
+ key);
936
+ }
937
+
938
+ Status WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
939
+ const SliceParts& key) {
940
+ LocalSavePoint save(b);
941
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
942
+ if (column_family_id == 0) {
943
+ b->rep_.push_back(static_cast<char>(kTypeDeletion));
944
+ } else {
945
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyDeletion));
946
+ PutVarint32(&b->rep_, column_family_id);
947
+ }
948
+ if (0 == b->timestamp_size_) {
949
+ PutLengthPrefixedSliceParts(&b->rep_, key);
950
+ } else {
951
+ PutLengthPrefixedSlicePartsWithPadding(&b->rep_, key, b->timestamp_size_);
952
+ }
953
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
954
+ ContentFlags::HAS_DELETE,
955
+ std::memory_order_relaxed);
956
+ return save.commit();
957
+ }
958
+
959
+ Status WriteBatch::Delete(ColumnFamilyHandle* column_family,
960
+ const SliceParts& key) {
961
+ return WriteBatchInternal::Delete(this, GetColumnFamilyID(column_family),
962
+ key);
963
+ }
964
+
965
+ Status WriteBatchInternal::SingleDelete(WriteBatch* b,
966
+ uint32_t column_family_id,
967
+ const Slice& key) {
968
+ LocalSavePoint save(b);
969
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
970
+ if (column_family_id == 0) {
971
+ b->rep_.push_back(static_cast<char>(kTypeSingleDeletion));
972
+ } else {
973
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilySingleDeletion));
974
+ PutVarint32(&b->rep_, column_family_id);
975
+ }
976
+ PutLengthPrefixedSlice(&b->rep_, key);
977
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
978
+ ContentFlags::HAS_SINGLE_DELETE,
979
+ std::memory_order_relaxed);
980
+ return save.commit();
981
+ }
982
+
983
+ Status WriteBatch::SingleDelete(ColumnFamilyHandle* column_family,
984
+ const Slice& key) {
985
+ return WriteBatchInternal::SingleDelete(
986
+ this, GetColumnFamilyID(column_family), key);
987
+ }
988
+
989
+ Status WriteBatchInternal::SingleDelete(WriteBatch* b,
990
+ uint32_t column_family_id,
991
+ const SliceParts& key) {
992
+ LocalSavePoint save(b);
993
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
994
+ if (column_family_id == 0) {
995
+ b->rep_.push_back(static_cast<char>(kTypeSingleDeletion));
996
+ } else {
997
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilySingleDeletion));
998
+ PutVarint32(&b->rep_, column_family_id);
999
+ }
1000
+ PutLengthPrefixedSliceParts(&b->rep_, key);
1001
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1002
+ ContentFlags::HAS_SINGLE_DELETE,
1003
+ std::memory_order_relaxed);
1004
+ return save.commit();
1005
+ }
1006
+
1007
+ Status WriteBatch::SingleDelete(ColumnFamilyHandle* column_family,
1008
+ const SliceParts& key) {
1009
+ return WriteBatchInternal::SingleDelete(
1010
+ this, GetColumnFamilyID(column_family), key);
1011
+ }
1012
+
1013
+ Status WriteBatchInternal::DeleteRange(WriteBatch* b, uint32_t column_family_id,
1014
+ const Slice& begin_key,
1015
+ const Slice& end_key) {
1016
+ LocalSavePoint save(b);
1017
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
1018
+ if (column_family_id == 0) {
1019
+ b->rep_.push_back(static_cast<char>(kTypeRangeDeletion));
1020
+ } else {
1021
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyRangeDeletion));
1022
+ PutVarint32(&b->rep_, column_family_id);
1023
+ }
1024
+ PutLengthPrefixedSlice(&b->rep_, begin_key);
1025
+ PutLengthPrefixedSlice(&b->rep_, end_key);
1026
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1027
+ ContentFlags::HAS_DELETE_RANGE,
1028
+ std::memory_order_relaxed);
1029
+ return save.commit();
1030
+ }
1031
+
1032
+ Status WriteBatch::DeleteRange(ColumnFamilyHandle* column_family,
1033
+ const Slice& begin_key, const Slice& end_key) {
1034
+ return WriteBatchInternal::DeleteRange(this, GetColumnFamilyID(column_family),
1035
+ begin_key, end_key);
1036
+ }
1037
+
1038
+ Status WriteBatchInternal::DeleteRange(WriteBatch* b, uint32_t column_family_id,
1039
+ const SliceParts& begin_key,
1040
+ const SliceParts& end_key) {
1041
+ LocalSavePoint save(b);
1042
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
1043
+ if (column_family_id == 0) {
1044
+ b->rep_.push_back(static_cast<char>(kTypeRangeDeletion));
1045
+ } else {
1046
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyRangeDeletion));
1047
+ PutVarint32(&b->rep_, column_family_id);
1048
+ }
1049
+ PutLengthPrefixedSliceParts(&b->rep_, begin_key);
1050
+ PutLengthPrefixedSliceParts(&b->rep_, end_key);
1051
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1052
+ ContentFlags::HAS_DELETE_RANGE,
1053
+ std::memory_order_relaxed);
1054
+ return save.commit();
1055
+ }
1056
+
1057
+ Status WriteBatch::DeleteRange(ColumnFamilyHandle* column_family,
1058
+ const SliceParts& begin_key,
1059
+ const SliceParts& end_key) {
1060
+ return WriteBatchInternal::DeleteRange(this, GetColumnFamilyID(column_family),
1061
+ begin_key, end_key);
1062
+ }
1063
+
1064
+ Status WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
1065
+ const Slice& key, const Slice& value) {
1066
+ if (key.size() > size_t{port::kMaxUint32}) {
1067
+ return Status::InvalidArgument("key is too large");
1068
+ }
1069
+ if (value.size() > size_t{port::kMaxUint32}) {
1070
+ return Status::InvalidArgument("value is too large");
1071
+ }
1072
+
1073
+ LocalSavePoint save(b);
1074
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
1075
+ if (column_family_id == 0) {
1076
+ b->rep_.push_back(static_cast<char>(kTypeMerge));
1077
+ } else {
1078
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyMerge));
1079
+ PutVarint32(&b->rep_, column_family_id);
1080
+ }
1081
+ PutLengthPrefixedSlice(&b->rep_, key);
1082
+ PutLengthPrefixedSlice(&b->rep_, value);
1083
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1084
+ ContentFlags::HAS_MERGE,
1085
+ std::memory_order_relaxed);
1086
+ return save.commit();
1087
+ }
1088
+
1089
+ Status WriteBatch::Merge(ColumnFamilyHandle* column_family, const Slice& key,
1090
+ const Slice& value) {
1091
+ return WriteBatchInternal::Merge(this, GetColumnFamilyID(column_family), key,
1092
+ value);
1093
+ }
1094
+
1095
+ Status WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
1096
+ const SliceParts& key,
1097
+ const SliceParts& value) {
1098
+ Status s = CheckSlicePartsLength(key, value);
1099
+ if (!s.ok()) {
1100
+ return s;
1101
+ }
1102
+
1103
+ LocalSavePoint save(b);
1104
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
1105
+ if (column_family_id == 0) {
1106
+ b->rep_.push_back(static_cast<char>(kTypeMerge));
1107
+ } else {
1108
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyMerge));
1109
+ PutVarint32(&b->rep_, column_family_id);
1110
+ }
1111
+ PutLengthPrefixedSliceParts(&b->rep_, key);
1112
+ PutLengthPrefixedSliceParts(&b->rep_, value);
1113
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1114
+ ContentFlags::HAS_MERGE,
1115
+ std::memory_order_relaxed);
1116
+ return save.commit();
1117
+ }
1118
+
1119
+ Status WriteBatch::Merge(ColumnFamilyHandle* column_family,
1120
+ const SliceParts& key, const SliceParts& value) {
1121
+ return WriteBatchInternal::Merge(this, GetColumnFamilyID(column_family), key,
1122
+ value);
1123
+ }
1124
+
1125
+ Status WriteBatchInternal::PutBlobIndex(WriteBatch* b,
1126
+ uint32_t column_family_id,
1127
+ const Slice& key, const Slice& value) {
1128
+ LocalSavePoint save(b);
1129
+ WriteBatchInternal::SetCount(b, WriteBatchInternal::Count(b) + 1);
1130
+ if (column_family_id == 0) {
1131
+ b->rep_.push_back(static_cast<char>(kTypeBlobIndex));
1132
+ } else {
1133
+ b->rep_.push_back(static_cast<char>(kTypeColumnFamilyBlobIndex));
1134
+ PutVarint32(&b->rep_, column_family_id);
1135
+ }
1136
+ PutLengthPrefixedSlice(&b->rep_, key);
1137
+ PutLengthPrefixedSlice(&b->rep_, value);
1138
+ b->content_flags_.store(b->content_flags_.load(std::memory_order_relaxed) |
1139
+ ContentFlags::HAS_BLOB_INDEX,
1140
+ std::memory_order_relaxed);
1141
+ return save.commit();
1142
+ }
1143
+
1144
+ Status WriteBatch::PutLogData(const Slice& blob) {
1145
+ LocalSavePoint save(this);
1146
+ rep_.push_back(static_cast<char>(kTypeLogData));
1147
+ PutLengthPrefixedSlice(&rep_, blob);
1148
+ return save.commit();
1149
+ }
1150
+
1151
+ void WriteBatch::SetSavePoint() {
1152
+ if (save_points_ == nullptr) {
1153
+ save_points_.reset(new SavePoints());
1154
+ }
1155
+ // Record length and count of current batch of writes.
1156
+ save_points_->stack.push(SavePoint(
1157
+ GetDataSize(), Count(), content_flags_.load(std::memory_order_relaxed)));
1158
+ }
1159
+
1160
+ Status WriteBatch::RollbackToSavePoint() {
1161
+ if (save_points_ == nullptr || save_points_->stack.size() == 0) {
1162
+ return Status::NotFound();
1163
+ }
1164
+
1165
+ // Pop the most recent savepoint off the stack
1166
+ SavePoint savepoint = save_points_->stack.top();
1167
+ save_points_->stack.pop();
1168
+
1169
+ assert(savepoint.size <= rep_.size());
1170
+ assert(static_cast<uint32_t>(savepoint.count) <= Count());
1171
+
1172
+ if (savepoint.size == rep_.size()) {
1173
+ // No changes to rollback
1174
+ } else if (savepoint.size == 0) {
1175
+ // Rollback everything
1176
+ Clear();
1177
+ } else {
1178
+ rep_.resize(savepoint.size);
1179
+ WriteBatchInternal::SetCount(this, savepoint.count);
1180
+ content_flags_.store(savepoint.content_flags, std::memory_order_relaxed);
1181
+ }
1182
+
1183
+ return Status::OK();
1184
+ }
1185
+
1186
+ Status WriteBatch::PopSavePoint() {
1187
+ if (save_points_ == nullptr || save_points_->stack.size() == 0) {
1188
+ return Status::NotFound();
1189
+ }
1190
+
1191
+ // Pop the most recent savepoint off the stack
1192
+ save_points_->stack.pop();
1193
+
1194
+ return Status::OK();
1195
+ }
1196
+
1197
+ Status WriteBatch::AssignTimestamp(const Slice& ts) {
1198
+ TimestampAssigner ts_assigner(ts);
1199
+ return Iterate(&ts_assigner);
1200
+ }
1201
+
1202
+ Status WriteBatch::AssignTimestamps(const std::vector<Slice>& ts_list) {
1203
+ TimestampAssigner ts_assigner(ts_list);
1204
+ return Iterate(&ts_assigner);
1205
+ }
1206
+
1207
+ class MemTableInserter : public WriteBatch::Handler {
1208
+
1209
+ SequenceNumber sequence_;
1210
+ ColumnFamilyMemTables* const cf_mems_;
1211
+ FlushScheduler* const flush_scheduler_;
1212
+ TrimHistoryScheduler* const trim_history_scheduler_;
1213
+ const bool ignore_missing_column_families_;
1214
+ const uint64_t recovering_log_number_;
1215
+ // log number that all Memtables inserted into should reference
1216
+ uint64_t log_number_ref_;
1217
+ DBImpl* db_;
1218
+ const bool concurrent_memtable_writes_;
1219
+ bool post_info_created_;
1220
+
1221
+ bool* has_valid_writes_;
1222
+ // On some (!) platforms just default creating
1223
+ // a map is too expensive in the Write() path as they
1224
+ // cause memory allocations though unused.
1225
+ // Make creation optional but do not incur
1226
+ // std::unique_ptr additional allocation
1227
+ using MemPostInfoMap = std::map<MemTable*, MemTablePostProcessInfo>;
1228
+ using PostMapType = std::aligned_storage<sizeof(MemPostInfoMap)>::type;
1229
+ PostMapType mem_post_info_map_;
1230
+ // current recovered transaction we are rebuilding (recovery)
1231
+ WriteBatch* rebuilding_trx_;
1232
+ SequenceNumber rebuilding_trx_seq_;
1233
+ // Increase seq number once per each write batch. Otherwise increase it once
1234
+ // per key.
1235
+ bool seq_per_batch_;
1236
+ // Whether the memtable write will be done only after the commit
1237
+ bool write_after_commit_;
1238
+ // Whether memtable write can be done before prepare
1239
+ bool write_before_prepare_;
1240
+ // Whether this batch was unprepared or not
1241
+ bool unprepared_batch_;
1242
+ using DupDetector = std::aligned_storage<sizeof(DuplicateDetector)>::type;
1243
+ DupDetector duplicate_detector_;
1244
+ bool dup_dectector_on_;
1245
+
1246
+ bool hint_per_batch_;
1247
+ bool hint_created_;
1248
+ // Hints for this batch
1249
+ using HintMap = std::unordered_map<MemTable*, void*>;
1250
+ using HintMapType = std::aligned_storage<sizeof(HintMap)>::type;
1251
+ HintMapType hint_;
1252
+
1253
+ HintMap& GetHintMap() {
1254
+ assert(hint_per_batch_);
1255
+ if (!hint_created_) {
1256
+ new (&hint_) HintMap();
1257
+ hint_created_ = true;
1258
+ }
1259
+ return *reinterpret_cast<HintMap*>(&hint_);
1260
+ }
1261
+
1262
+ MemPostInfoMap& GetPostMap() {
1263
+ assert(concurrent_memtable_writes_);
1264
+ if(!post_info_created_) {
1265
+ new (&mem_post_info_map_) MemPostInfoMap();
1266
+ post_info_created_ = true;
1267
+ }
1268
+ return *reinterpret_cast<MemPostInfoMap*>(&mem_post_info_map_);
1269
+ }
1270
+
1271
+ bool IsDuplicateKeySeq(uint32_t column_family_id, const Slice& key) {
1272
+ assert(!write_after_commit_);
1273
+ assert(rebuilding_trx_ != nullptr);
1274
+ if (!dup_dectector_on_) {
1275
+ new (&duplicate_detector_) DuplicateDetector(db_);
1276
+ dup_dectector_on_ = true;
1277
+ }
1278
+ return reinterpret_cast<DuplicateDetector*>
1279
+ (&duplicate_detector_)->IsDuplicateKeySeq(column_family_id, key, sequence_);
1280
+ }
1281
+
1282
+ protected:
1283
+ bool WriteBeforePrepare() const override { return write_before_prepare_; }
1284
+ bool WriteAfterCommit() const override { return write_after_commit_; }
1285
+
1286
+ public:
1287
+ // cf_mems should not be shared with concurrent inserters
1288
+ MemTableInserter(SequenceNumber _sequence, ColumnFamilyMemTables* cf_mems,
1289
+ FlushScheduler* flush_scheduler,
1290
+ TrimHistoryScheduler* trim_history_scheduler,
1291
+ bool ignore_missing_column_families,
1292
+ uint64_t recovering_log_number, DB* db,
1293
+ bool concurrent_memtable_writes,
1294
+ bool* has_valid_writes = nullptr, bool seq_per_batch = false,
1295
+ bool batch_per_txn = true, bool hint_per_batch = false)
1296
+ : sequence_(_sequence),
1297
+ cf_mems_(cf_mems),
1298
+ flush_scheduler_(flush_scheduler),
1299
+ trim_history_scheduler_(trim_history_scheduler),
1300
+ ignore_missing_column_families_(ignore_missing_column_families),
1301
+ recovering_log_number_(recovering_log_number),
1302
+ log_number_ref_(0),
1303
+ db_(static_cast_with_check<DBImpl>(db)),
1304
+ concurrent_memtable_writes_(concurrent_memtable_writes),
1305
+ post_info_created_(false),
1306
+ has_valid_writes_(has_valid_writes),
1307
+ rebuilding_trx_(nullptr),
1308
+ rebuilding_trx_seq_(0),
1309
+ seq_per_batch_(seq_per_batch),
1310
+ // Write after commit currently uses one seq per key (instead of per
1311
+ // batch). So seq_per_batch being false indicates write_after_commit
1312
+ // approach.
1313
+ write_after_commit_(!seq_per_batch),
1314
+ // WriteUnprepared can write WriteBatches per transaction, so
1315
+ // batch_per_txn being false indicates write_before_prepare.
1316
+ write_before_prepare_(!batch_per_txn),
1317
+ unprepared_batch_(false),
1318
+ duplicate_detector_(),
1319
+ dup_dectector_on_(false),
1320
+ hint_per_batch_(hint_per_batch),
1321
+ hint_created_(false) {
1322
+ assert(cf_mems_);
1323
+ }
1324
+
1325
+ ~MemTableInserter() override {
1326
+ if (dup_dectector_on_) {
1327
+ reinterpret_cast<DuplicateDetector*>
1328
+ (&duplicate_detector_)->~DuplicateDetector();
1329
+ }
1330
+ if (post_info_created_) {
1331
+ reinterpret_cast<MemPostInfoMap*>
1332
+ (&mem_post_info_map_)->~MemPostInfoMap();
1333
+ }
1334
+ if (hint_created_) {
1335
+ for (auto iter : GetHintMap()) {
1336
+ delete[] reinterpret_cast<char*>(iter.second);
1337
+ }
1338
+ reinterpret_cast<HintMap*>(&hint_)->~HintMap();
1339
+ }
1340
+ delete rebuilding_trx_;
1341
+ }
1342
+
1343
+ MemTableInserter(const MemTableInserter&) = delete;
1344
+ MemTableInserter& operator=(const MemTableInserter&) = delete;
1345
+
1346
+ // The batch seq is regularly restarted; In normal mode it is set when
1347
+ // MemTableInserter is constructed in the write thread and in recovery mode it
1348
+ // is set when a batch, which is tagged with seq, is read from the WAL.
1349
+ // Within a sequenced batch, which could be a merge of multiple batches, we
1350
+ // have two policies to advance the seq: i) seq_per_key (default) and ii)
1351
+ // seq_per_batch. To implement the latter we need to mark the boundary between
1352
+ // the individual batches. The approach is this: 1) Use the terminating
1353
+ // markers to indicate the boundary (kTypeEndPrepareXID, kTypeCommitXID,
1354
+ // kTypeRollbackXID) 2) Terminate a batch with kTypeNoop in the absence of a
1355
+ // natural boundary marker.
1356
+ void MaybeAdvanceSeq(bool batch_boundry = false) {
1357
+ if (batch_boundry == seq_per_batch_) {
1358
+ sequence_++;
1359
+ }
1360
+ }
1361
+
1362
+ void set_log_number_ref(uint64_t log) { log_number_ref_ = log; }
1363
+
1364
+ SequenceNumber sequence() const { return sequence_; }
1365
+
1366
+ void PostProcess() {
1367
+ assert(concurrent_memtable_writes_);
1368
+ // If post info was not created there is nothing
1369
+ // to process and no need to create on demand
1370
+ if(post_info_created_) {
1371
+ for (auto& pair : GetPostMap()) {
1372
+ pair.first->BatchPostProcess(pair.second);
1373
+ }
1374
+ }
1375
+ }
1376
+
1377
+ bool SeekToColumnFamily(uint32_t column_family_id, Status* s) {
1378
+ // If we are in a concurrent mode, it is the caller's responsibility
1379
+ // to clone the original ColumnFamilyMemTables so that each thread
1380
+ // has its own instance. Otherwise, it must be guaranteed that there
1381
+ // is no concurrent access
1382
+ bool found = cf_mems_->Seek(column_family_id);
1383
+ if (!found) {
1384
+ if (ignore_missing_column_families_) {
1385
+ *s = Status::OK();
1386
+ } else {
1387
+ *s = Status::InvalidArgument(
1388
+ "Invalid column family specified in write batch");
1389
+ }
1390
+ return false;
1391
+ }
1392
+ if (recovering_log_number_ != 0 &&
1393
+ recovering_log_number_ < cf_mems_->GetLogNumber()) {
1394
+ // This is true only in recovery environment (recovering_log_number_ is
1395
+ // always 0 in
1396
+ // non-recovery, regular write code-path)
1397
+ // * If recovering_log_number_ < cf_mems_->GetLogNumber(), this means that
1398
+ // column
1399
+ // family already contains updates from this log. We can't apply updates
1400
+ // twice because of update-in-place or merge workloads -- ignore the
1401
+ // update
1402
+ *s = Status::OK();
1403
+ return false;
1404
+ }
1405
+
1406
+ if (has_valid_writes_ != nullptr) {
1407
+ *has_valid_writes_ = true;
1408
+ }
1409
+
1410
+ if (log_number_ref_ > 0) {
1411
+ cf_mems_->GetMemTable()->RefLogContainingPrepSection(log_number_ref_);
1412
+ }
1413
+
1414
+ return true;
1415
+ }
1416
+
1417
+ Status PutCFImpl(uint32_t column_family_id, const Slice& key,
1418
+ const Slice& value, ValueType value_type) {
1419
+ // optimize for non-recovery mode
1420
+ if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
1421
+ return WriteBatchInternal::Put(rebuilding_trx_, column_family_id, key,
1422
+ value);
1423
+ // else insert the values to the memtable right away
1424
+ }
1425
+
1426
+ Status ret_status;
1427
+ if (UNLIKELY(!SeekToColumnFamily(column_family_id, &ret_status))) {
1428
+ if (ret_status.ok() && rebuilding_trx_ != nullptr) {
1429
+ assert(!write_after_commit_);
1430
+ // The CF is probably flushed and hence no need for insert but we still
1431
+ // need to keep track of the keys for upcoming rollback/commit.
1432
+ ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
1433
+ key, value);
1434
+ if (ret_status.ok()) {
1435
+ MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, key));
1436
+ }
1437
+ } else if (ret_status.ok()) {
1438
+ MaybeAdvanceSeq(false /* batch_boundary */);
1439
+ }
1440
+ return ret_status;
1441
+ }
1442
+ assert(ret_status.ok());
1443
+
1444
+ MemTable* mem = cf_mems_->GetMemTable();
1445
+ auto* moptions = mem->GetImmutableMemTableOptions();
1446
+ // inplace_update_support is inconsistent with snapshots, and therefore with
1447
+ // any kind of transactions including the ones that use seq_per_batch
1448
+ assert(!seq_per_batch_ || !moptions->inplace_update_support);
1449
+ if (!moptions->inplace_update_support) {
1450
+ ret_status =
1451
+ mem->Add(sequence_, value_type, key, value,
1452
+ concurrent_memtable_writes_, get_post_process_info(mem),
1453
+ hint_per_batch_ ? &GetHintMap()[mem] : nullptr);
1454
+ } else if (moptions->inplace_callback == nullptr) {
1455
+ assert(!concurrent_memtable_writes_);
1456
+ ret_status = mem->Update(sequence_, key, value);
1457
+ } else {
1458
+ assert(!concurrent_memtable_writes_);
1459
+ ret_status = mem->UpdateCallback(sequence_, key, value);
1460
+ if (ret_status.IsNotFound()) {
1461
+ // key not found in memtable. Do sst get, update, add
1462
+ SnapshotImpl read_from_snapshot;
1463
+ read_from_snapshot.number_ = sequence_;
1464
+ ReadOptions ropts;
1465
+ // it's going to be overwritten for sure, so no point caching data block
1466
+ // containing the old version
1467
+ ropts.fill_cache = false;
1468
+ ropts.snapshot = &read_from_snapshot;
1469
+
1470
+ std::string prev_value;
1471
+ std::string merged_value;
1472
+
1473
+ auto cf_handle = cf_mems_->GetColumnFamilyHandle();
1474
+ Status get_status = Status::NotSupported();
1475
+ if (db_ != nullptr && recovering_log_number_ == 0) {
1476
+ if (cf_handle == nullptr) {
1477
+ cf_handle = db_->DefaultColumnFamily();
1478
+ }
1479
+ get_status = db_->Get(ropts, cf_handle, key, &prev_value);
1480
+ }
1481
+ // Intentionally overwrites the `NotFound` in `ret_status`.
1482
+ if (!get_status.ok() && !get_status.IsNotFound()) {
1483
+ ret_status = get_status;
1484
+ } else {
1485
+ ret_status = Status::OK();
1486
+ }
1487
+
1488
+ if (ret_status.ok()) {
1489
+ UpdateStatus update_status;
1490
+ char* prev_buffer = const_cast<char*>(prev_value.c_str());
1491
+ uint32_t prev_size = static_cast<uint32_t>(prev_value.size());
1492
+ if (get_status.ok()) {
1493
+ update_status = moptions->inplace_callback(prev_buffer, &prev_size,
1494
+ value, &merged_value);
1495
+ } else {
1496
+ update_status = moptions->inplace_callback(
1497
+ nullptr /* existing_value */, nullptr /* existing_value_size */,
1498
+ value, &merged_value);
1499
+ }
1500
+ if (update_status == UpdateStatus::UPDATED_INPLACE) {
1501
+ assert(get_status.ok());
1502
+ // prev_value is updated in-place with final value.
1503
+ ret_status = mem->Add(sequence_, value_type, key,
1504
+ Slice(prev_buffer, prev_size));
1505
+ if (ret_status.ok()) {
1506
+ RecordTick(moptions->statistics, NUMBER_KEYS_WRITTEN);
1507
+ }
1508
+ } else if (update_status == UpdateStatus::UPDATED) {
1509
+ // merged_value contains the final value.
1510
+ ret_status =
1511
+ mem->Add(sequence_, value_type, key, Slice(merged_value));
1512
+ if (ret_status.ok()) {
1513
+ RecordTick(moptions->statistics, NUMBER_KEYS_WRITTEN);
1514
+ }
1515
+ }
1516
+ }
1517
+ }
1518
+ }
1519
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1520
+ assert(seq_per_batch_);
1521
+ const bool kBatchBoundary = true;
1522
+ MaybeAdvanceSeq(kBatchBoundary);
1523
+ } else if (ret_status.ok()) {
1524
+ MaybeAdvanceSeq();
1525
+ CheckMemtableFull();
1526
+ }
1527
+ // optimize for non-recovery mode
1528
+ // If `ret_status` is `TryAgain` then the next (successful) try will add
1529
+ // the key to the rebuilding transaction object. If `ret_status` is
1530
+ // another non-OK `Status`, then the `rebuilding_trx_` will be thrown
1531
+ // away. So we only need to add to it when `ret_status.ok()`.
1532
+ if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
1533
+ assert(!write_after_commit_);
1534
+ ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
1535
+ key, value);
1536
+ }
1537
+ return ret_status;
1538
+ }
1539
+
1540
+ Status PutCF(uint32_t column_family_id, const Slice& key,
1541
+ const Slice& value) override {
1542
+ return PutCFImpl(column_family_id, key, value, kTypeValue);
1543
+ }
1544
+
1545
+ Status DeleteImpl(uint32_t /*column_family_id*/, const Slice& key,
1546
+ const Slice& value, ValueType delete_type) {
1547
+ Status ret_status;
1548
+ MemTable* mem = cf_mems_->GetMemTable();
1549
+ ret_status =
1550
+ mem->Add(sequence_, delete_type, key, value,
1551
+ concurrent_memtable_writes_, get_post_process_info(mem),
1552
+ hint_per_batch_ ? &GetHintMap()[mem] : nullptr);
1553
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1554
+ assert(seq_per_batch_);
1555
+ const bool kBatchBoundary = true;
1556
+ MaybeAdvanceSeq(kBatchBoundary);
1557
+ } else if (ret_status.ok()) {
1558
+ MaybeAdvanceSeq();
1559
+ CheckMemtableFull();
1560
+ }
1561
+ return ret_status;
1562
+ }
1563
+
1564
+ Status DeleteCF(uint32_t column_family_id, const Slice& key) override {
1565
+ // optimize for non-recovery mode
1566
+ if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
1567
+ return WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
1568
+ // else insert the values to the memtable right away
1569
+ }
1570
+
1571
+ Status ret_status;
1572
+ if (UNLIKELY(!SeekToColumnFamily(column_family_id, &ret_status))) {
1573
+ if (ret_status.ok() && rebuilding_trx_ != nullptr) {
1574
+ assert(!write_after_commit_);
1575
+ // The CF is probably flushed and hence no need for insert but we still
1576
+ // need to keep track of the keys for upcoming rollback/commit.
1577
+ ret_status =
1578
+ WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
1579
+ if (ret_status.ok()) {
1580
+ MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, key));
1581
+ }
1582
+ } else if (ret_status.ok()) {
1583
+ MaybeAdvanceSeq(false /* batch_boundary */);
1584
+ }
1585
+ return ret_status;
1586
+ }
1587
+
1588
+ ColumnFamilyData* cfd = cf_mems_->current();
1589
+ assert(!cfd || cfd->user_comparator());
1590
+ const size_t ts_sz = (cfd && cfd->user_comparator())
1591
+ ? cfd->user_comparator()->timestamp_size()
1592
+ : 0;
1593
+ const ValueType delete_type =
1594
+ (0 == ts_sz) ? kTypeDeletion : kTypeDeletionWithTimestamp;
1595
+ ret_status = DeleteImpl(column_family_id, key, Slice(), delete_type);
1596
+ // optimize for non-recovery mode
1597
+ // If `ret_status` is `TryAgain` then the next (successful) try will add
1598
+ // the key to the rebuilding transaction object. If `ret_status` is
1599
+ // another non-OK `Status`, then the `rebuilding_trx_` will be thrown
1600
+ // away. So we only need to add to it when `ret_status.ok()`.
1601
+ if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
1602
+ assert(!write_after_commit_);
1603
+ ret_status =
1604
+ WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
1605
+ }
1606
+ return ret_status;
1607
+ }
1608
+
1609
+ Status SingleDeleteCF(uint32_t column_family_id, const Slice& key) override {
1610
+ // optimize for non-recovery mode
1611
+ if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
1612
+ return WriteBatchInternal::SingleDelete(rebuilding_trx_, column_family_id,
1613
+ key);
1614
+ // else insert the values to the memtable right away
1615
+ }
1616
+
1617
+ Status ret_status;
1618
+ if (UNLIKELY(!SeekToColumnFamily(column_family_id, &ret_status))) {
1619
+ if (ret_status.ok() && rebuilding_trx_ != nullptr) {
1620
+ assert(!write_after_commit_);
1621
+ // The CF is probably flushed and hence no need for insert but we still
1622
+ // need to keep track of the keys for upcoming rollback/commit.
1623
+ ret_status = WriteBatchInternal::SingleDelete(rebuilding_trx_,
1624
+ column_family_id, key);
1625
+ if (ret_status.ok()) {
1626
+ MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, key));
1627
+ }
1628
+ } else if (ret_status.ok()) {
1629
+ MaybeAdvanceSeq(false /* batch_boundary */);
1630
+ }
1631
+ return ret_status;
1632
+ }
1633
+ assert(ret_status.ok());
1634
+
1635
+ ret_status =
1636
+ DeleteImpl(column_family_id, key, Slice(), kTypeSingleDeletion);
1637
+ // optimize for non-recovery mode
1638
+ // If `ret_status` is `TryAgain` then the next (successful) try will add
1639
+ // the key to the rebuilding transaction object. If `ret_status` is
1640
+ // another non-OK `Status`, then the `rebuilding_trx_` will be thrown
1641
+ // away. So we only need to add to it when `ret_status.ok()`.
1642
+ if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
1643
+ assert(!write_after_commit_);
1644
+ ret_status = WriteBatchInternal::SingleDelete(rebuilding_trx_,
1645
+ column_family_id, key);
1646
+ }
1647
+ return ret_status;
1648
+ }
1649
+
1650
+ Status DeleteRangeCF(uint32_t column_family_id, const Slice& begin_key,
1651
+ const Slice& end_key) override {
1652
+ // optimize for non-recovery mode
1653
+ if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
1654
+ return WriteBatchInternal::DeleteRange(rebuilding_trx_, column_family_id,
1655
+ begin_key, end_key);
1656
+ // else insert the values to the memtable right away
1657
+ }
1658
+
1659
+ Status ret_status;
1660
+ if (UNLIKELY(!SeekToColumnFamily(column_family_id, &ret_status))) {
1661
+ if (ret_status.ok() && rebuilding_trx_ != nullptr) {
1662
+ assert(!write_after_commit_);
1663
+ // The CF is probably flushed and hence no need for insert but we still
1664
+ // need to keep track of the keys for upcoming rollback/commit.
1665
+ ret_status = WriteBatchInternal::DeleteRange(
1666
+ rebuilding_trx_, column_family_id, begin_key, end_key);
1667
+ if (ret_status.ok()) {
1668
+ MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, begin_key));
1669
+ }
1670
+ } else if (ret_status.ok()) {
1671
+ MaybeAdvanceSeq(false /* batch_boundary */);
1672
+ }
1673
+ return ret_status;
1674
+ }
1675
+ assert(ret_status.ok());
1676
+
1677
+ if (db_ != nullptr) {
1678
+ auto cf_handle = cf_mems_->GetColumnFamilyHandle();
1679
+ if (cf_handle == nullptr) {
1680
+ cf_handle = db_->DefaultColumnFamily();
1681
+ }
1682
+ auto* cfd =
1683
+ static_cast_with_check<ColumnFamilyHandleImpl>(cf_handle)->cfd();
1684
+ if (!cfd->is_delete_range_supported()) {
1685
+ // TODO(ajkr): refactor `SeekToColumnFamily()` so it returns a `Status`.
1686
+ ret_status.PermitUncheckedError();
1687
+ return Status::NotSupported(
1688
+ std::string("DeleteRange not supported for table type ") +
1689
+ cfd->ioptions()->table_factory->Name() + " in CF " +
1690
+ cfd->GetName());
1691
+ }
1692
+ int cmp = cfd->user_comparator()->Compare(begin_key, end_key);
1693
+ if (cmp > 0) {
1694
+ // TODO(ajkr): refactor `SeekToColumnFamily()` so it returns a `Status`.
1695
+ ret_status.PermitUncheckedError();
1696
+ // It's an empty range where endpoints appear mistaken. Don't bother
1697
+ // applying it to the DB, and return an error to the user.
1698
+ return Status::InvalidArgument("end key comes before start key");
1699
+ } else if (cmp == 0) {
1700
+ // TODO(ajkr): refactor `SeekToColumnFamily()` so it returns a `Status`.
1701
+ ret_status.PermitUncheckedError();
1702
+ // It's an empty range. Don't bother applying it to the DB.
1703
+ return Status::OK();
1704
+ }
1705
+ }
1706
+
1707
+ ret_status =
1708
+ DeleteImpl(column_family_id, begin_key, end_key, kTypeRangeDeletion);
1709
+ // optimize for non-recovery mode
1710
+ // If `ret_status` is `TryAgain` then the next (successful) try will add
1711
+ // the key to the rebuilding transaction object. If `ret_status` is
1712
+ // another non-OK `Status`, then the `rebuilding_trx_` will be thrown
1713
+ // away. So we only need to add to it when `ret_status.ok()`.
1714
+ if (UNLIKELY(!ret_status.IsTryAgain() && rebuilding_trx_ != nullptr)) {
1715
+ assert(!write_after_commit_);
1716
+ ret_status = WriteBatchInternal::DeleteRange(
1717
+ rebuilding_trx_, column_family_id, begin_key, end_key);
1718
+ }
1719
+ return ret_status;
1720
+ }
1721
+
1722
+ Status MergeCF(uint32_t column_family_id, const Slice& key,
1723
+ const Slice& value) override {
1724
+ // optimize for non-recovery mode
1725
+ if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
1726
+ return WriteBatchInternal::Merge(rebuilding_trx_, column_family_id, key,
1727
+ value);
1728
+ // else insert the values to the memtable right away
1729
+ }
1730
+
1731
+ Status ret_status;
1732
+ if (UNLIKELY(!SeekToColumnFamily(column_family_id, &ret_status))) {
1733
+ if (ret_status.ok() && rebuilding_trx_ != nullptr) {
1734
+ assert(!write_after_commit_);
1735
+ // The CF is probably flushed and hence no need for insert but we still
1736
+ // need to keep track of the keys for upcoming rollback/commit.
1737
+ ret_status = WriteBatchInternal::Merge(rebuilding_trx_,
1738
+ column_family_id, key, value);
1739
+ if (ret_status.ok()) {
1740
+ MaybeAdvanceSeq(IsDuplicateKeySeq(column_family_id, key));
1741
+ }
1742
+ } else if (ret_status.ok()) {
1743
+ MaybeAdvanceSeq(false /* batch_boundary */);
1744
+ }
1745
+ return ret_status;
1746
+ }
1747
+ assert(ret_status.ok());
1748
+
1749
+ MemTable* mem = cf_mems_->GetMemTable();
1750
+ auto* moptions = mem->GetImmutableMemTableOptions();
1751
+ if (moptions->merge_operator == nullptr) {
1752
+ return Status::InvalidArgument(
1753
+ "Merge requires `ColumnFamilyOptions::merge_operator != nullptr`");
1754
+ }
1755
+ bool perform_merge = false;
1756
+ assert(!concurrent_memtable_writes_ ||
1757
+ moptions->max_successive_merges == 0);
1758
+
1759
+ // If we pass DB through and options.max_successive_merges is hit
1760
+ // during recovery, Get() will be issued which will try to acquire
1761
+ // DB mutex and cause deadlock, as DB mutex is already held.
1762
+ // So we disable merge in recovery
1763
+ if (moptions->max_successive_merges > 0 && db_ != nullptr &&
1764
+ recovering_log_number_ == 0) {
1765
+ assert(!concurrent_memtable_writes_);
1766
+ LookupKey lkey(key, sequence_);
1767
+
1768
+ // Count the number of successive merges at the head
1769
+ // of the key in the memtable
1770
+ size_t num_merges = mem->CountSuccessiveMergeEntries(lkey);
1771
+
1772
+ if (num_merges >= moptions->max_successive_merges) {
1773
+ perform_merge = true;
1774
+ }
1775
+ }
1776
+
1777
+ if (perform_merge) {
1778
+ // 1) Get the existing value
1779
+ std::string get_value;
1780
+
1781
+ // Pass in the sequence number so that we also include previous merge
1782
+ // operations in the same batch.
1783
+ SnapshotImpl read_from_snapshot;
1784
+ read_from_snapshot.number_ = sequence_;
1785
+ ReadOptions read_options;
1786
+ read_options.snapshot = &read_from_snapshot;
1787
+
1788
+ auto cf_handle = cf_mems_->GetColumnFamilyHandle();
1789
+ if (cf_handle == nullptr) {
1790
+ cf_handle = db_->DefaultColumnFamily();
1791
+ }
1792
+ Status get_status = db_->Get(read_options, cf_handle, key, &get_value);
1793
+ if (!get_status.ok()) {
1794
+ // Failed to read a key we know exists. Store the delta in memtable.
1795
+ perform_merge = false;
1796
+ } else {
1797
+ Slice get_value_slice = Slice(get_value);
1798
+
1799
+ // 2) Apply this merge
1800
+ auto merge_operator = moptions->merge_operator;
1801
+ assert(merge_operator);
1802
+
1803
+ std::string new_value;
1804
+
1805
+ Status merge_status = MergeHelper::TimedFullMerge(
1806
+ merge_operator, key, &get_value_slice, {value}, &new_value,
1807
+ moptions->info_log, moptions->statistics, Env::Default());
1808
+
1809
+ if (!merge_status.ok()) {
1810
+ // Failed to merge!
1811
+ // Store the delta in memtable
1812
+ perform_merge = false;
1813
+ } else {
1814
+ // 3) Add value to memtable
1815
+ assert(!concurrent_memtable_writes_);
1816
+ ret_status = mem->Add(sequence_, kTypeValue, key, new_value);
1817
+ }
1818
+ }
1819
+ }
1820
+
1821
+ if (!perform_merge) {
1822
+ // Add merge operand to memtable
1823
+ ret_status =
1824
+ mem->Add(sequence_, kTypeMerge, key, value,
1825
+ concurrent_memtable_writes_, get_post_process_info(mem));
1826
+ }
1827
+
1828
+ if (UNLIKELY(ret_status.IsTryAgain())) {
1829
+ assert(seq_per_batch_);
1830
+ const bool kBatchBoundary = true;
1831
+ MaybeAdvanceSeq(kBatchBoundary);
1832
+ } else if (ret_status.ok()) {
1833
+ MaybeAdvanceSeq();
1834
+ CheckMemtableFull();
1835
+ }
1836
+ // optimize for non-recovery mode
1837
+ // If `ret_status` is `TryAgain` then the next (successful) try will add
1838
+ // the key to the rebuilding transaction object. If `ret_status` is
1839
+ // another non-OK `Status`, then the `rebuilding_trx_` will be thrown
1840
+ // away. So we only need to add to it when `ret_status.ok()`.
1841
+ if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
1842
+ assert(!write_after_commit_);
1843
+ ret_status = WriteBatchInternal::Merge(rebuilding_trx_, column_family_id,
1844
+ key, value);
1845
+ }
1846
+ return ret_status;
1847
+ }
1848
+
1849
+ Status PutBlobIndexCF(uint32_t column_family_id, const Slice& key,
1850
+ const Slice& value) override {
1851
+ // Same as PutCF except for value type.
1852
+ return PutCFImpl(column_family_id, key, value, kTypeBlobIndex);
1853
+ }
1854
+
1855
+ void CheckMemtableFull() {
1856
+ if (flush_scheduler_ != nullptr) {
1857
+ auto* cfd = cf_mems_->current();
1858
+ assert(cfd != nullptr);
1859
+ if (cfd->mem()->ShouldScheduleFlush() &&
1860
+ cfd->mem()->MarkFlushScheduled()) {
1861
+ // MarkFlushScheduled only returns true if we are the one that
1862
+ // should take action, so no need to dedup further
1863
+ flush_scheduler_->ScheduleWork(cfd);
1864
+ }
1865
+ }
1866
+ // check if memtable_list size exceeds max_write_buffer_size_to_maintain
1867
+ if (trim_history_scheduler_ != nullptr) {
1868
+ auto* cfd = cf_mems_->current();
1869
+
1870
+ assert(cfd);
1871
+ assert(cfd->ioptions());
1872
+
1873
+ const size_t size_to_maintain = static_cast<size_t>(
1874
+ cfd->ioptions()->max_write_buffer_size_to_maintain);
1875
+
1876
+ if (size_to_maintain > 0) {
1877
+ MemTableList* const imm = cfd->imm();
1878
+ assert(imm);
1879
+
1880
+ if (imm->HasHistory()) {
1881
+ const MemTable* const mem = cfd->mem();
1882
+ assert(mem);
1883
+
1884
+ if (mem->ApproximateMemoryUsageFast() +
1885
+ imm->ApproximateMemoryUsageExcludingLast() >=
1886
+ size_to_maintain &&
1887
+ imm->MarkTrimHistoryNeeded()) {
1888
+ trim_history_scheduler_->ScheduleWork(cfd);
1889
+ }
1890
+ }
1891
+ }
1892
+ }
1893
+ }
1894
+
1895
+ // The write batch handler calls MarkBeginPrepare with unprepare set to true
1896
+ // if it encounters the kTypeBeginUnprepareXID marker.
1897
+ Status MarkBeginPrepare(bool unprepare) override {
1898
+ assert(rebuilding_trx_ == nullptr);
1899
+ assert(db_);
1900
+
1901
+ if (recovering_log_number_ != 0) {
1902
+ // during recovery we rebuild a hollow transaction
1903
+ // from all encountered prepare sections of the wal
1904
+ if (db_->allow_2pc() == false) {
1905
+ return Status::NotSupported(
1906
+ "WAL contains prepared transactions. Open with "
1907
+ "TransactionDB::Open().");
1908
+ }
1909
+
1910
+ // we are now iterating through a prepared section
1911
+ rebuilding_trx_ = new WriteBatch();
1912
+ rebuilding_trx_seq_ = sequence_;
1913
+ // Verify that we have matching MarkBeginPrepare/MarkEndPrepare markers.
1914
+ // unprepared_batch_ should be false because it is false by default, and
1915
+ // gets reset to false in MarkEndPrepare.
1916
+ assert(!unprepared_batch_);
1917
+ unprepared_batch_ = unprepare;
1918
+
1919
+ if (has_valid_writes_ != nullptr) {
1920
+ *has_valid_writes_ = true;
1921
+ }
1922
+ }
1923
+
1924
+ return Status::OK();
1925
+ }
1926
+
1927
+ Status MarkEndPrepare(const Slice& name) override {
1928
+ assert(db_);
1929
+ assert((rebuilding_trx_ != nullptr) == (recovering_log_number_ != 0));
1930
+
1931
+ if (recovering_log_number_ != 0) {
1932
+ assert(db_->allow_2pc());
1933
+ size_t batch_cnt =
1934
+ write_after_commit_
1935
+ ? 0 // 0 will disable further checks
1936
+ : static_cast<size_t>(sequence_ - rebuilding_trx_seq_ + 1);
1937
+ db_->InsertRecoveredTransaction(recovering_log_number_, name.ToString(),
1938
+ rebuilding_trx_, rebuilding_trx_seq_,
1939
+ batch_cnt, unprepared_batch_);
1940
+ unprepared_batch_ = false;
1941
+ rebuilding_trx_ = nullptr;
1942
+ } else {
1943
+ assert(rebuilding_trx_ == nullptr);
1944
+ }
1945
+ const bool batch_boundry = true;
1946
+ MaybeAdvanceSeq(batch_boundry);
1947
+
1948
+ return Status::OK();
1949
+ }
1950
+
1951
+ Status MarkNoop(bool empty_batch) override {
1952
+ // A hack in pessimistic transaction could result into a noop at the start
1953
+ // of the write batch, that should be ignored.
1954
+ if (!empty_batch) {
1955
+ // In the absence of Prepare markers, a kTypeNoop tag indicates the end of
1956
+ // a batch. This happens when write batch commits skipping the prepare
1957
+ // phase.
1958
+ const bool batch_boundry = true;
1959
+ MaybeAdvanceSeq(batch_boundry);
1960
+ }
1961
+ return Status::OK();
1962
+ }
1963
+
1964
+ Status MarkCommit(const Slice& name) override {
1965
+ assert(db_);
1966
+
1967
+ Status s;
1968
+
1969
+ if (recovering_log_number_ != 0) {
1970
+ // in recovery when we encounter a commit marker
1971
+ // we lookup this transaction in our set of rebuilt transactions
1972
+ // and commit.
1973
+ auto trx = db_->GetRecoveredTransaction(name.ToString());
1974
+
1975
+ // the log containing the prepared section may have
1976
+ // been released in the last incarnation because the
1977
+ // data was flushed to L0
1978
+ if (trx != nullptr) {
1979
+ // at this point individual CF lognumbers will prevent
1980
+ // duplicate re-insertion of values.
1981
+ assert(log_number_ref_ == 0);
1982
+ if (write_after_commit_) {
1983
+ // write_after_commit_ can only have one batch in trx.
1984
+ assert(trx->batches_.size() == 1);
1985
+ const auto& batch_info = trx->batches_.begin()->second;
1986
+ // all inserts must reference this trx log number
1987
+ log_number_ref_ = batch_info.log_number_;
1988
+ s = batch_info.batch_->Iterate(this);
1989
+ log_number_ref_ = 0;
1990
+ }
1991
+ // else the values are already inserted before the commit
1992
+
1993
+ if (s.ok()) {
1994
+ db_->DeleteRecoveredTransaction(name.ToString());
1995
+ }
1996
+ if (has_valid_writes_ != nullptr) {
1997
+ *has_valid_writes_ = true;
1998
+ }
1999
+ }
2000
+ } else {
2001
+ // When writes are not delayed until commit, there is no disconnect
2002
+ // between a memtable write and the WAL that supports it. So the commit
2003
+ // need not reference any log as the only log to which it depends.
2004
+ assert(!write_after_commit_ || log_number_ref_ > 0);
2005
+ }
2006
+ const bool batch_boundry = true;
2007
+ MaybeAdvanceSeq(batch_boundry);
2008
+
2009
+ return s;
2010
+ }
2011
+
2012
+ Status MarkRollback(const Slice& name) override {
2013
+ assert(db_);
2014
+
2015
+ if (recovering_log_number_ != 0) {
2016
+ auto trx = db_->GetRecoveredTransaction(name.ToString());
2017
+
2018
+ // the log containing the transactions prep section
2019
+ // may have been released in the previous incarnation
2020
+ // because we knew it had been rolled back
2021
+ if (trx != nullptr) {
2022
+ db_->DeleteRecoveredTransaction(name.ToString());
2023
+ }
2024
+ } else {
2025
+ // in non recovery we simply ignore this tag
2026
+ }
2027
+
2028
+ const bool batch_boundry = true;
2029
+ MaybeAdvanceSeq(batch_boundry);
2030
+
2031
+ return Status::OK();
2032
+ }
2033
+
2034
+ private:
2035
+ MemTablePostProcessInfo* get_post_process_info(MemTable* mem) {
2036
+ if (!concurrent_memtable_writes_) {
2037
+ // No need to batch counters locally if we don't use concurrent mode.
2038
+ return nullptr;
2039
+ }
2040
+ return &GetPostMap()[mem];
2041
+ }
2042
+ };
2043
+
2044
+ // This function can only be called in these conditions:
2045
+ // 1) During Recovery()
2046
+ // 2) During Write(), in a single-threaded write thread
2047
+ // 3) During Write(), in a concurrent context where memtables has been cloned
2048
+ // The reason is that it calls memtables->Seek(), which has a stateful cache
2049
+ Status WriteBatchInternal::InsertInto(
2050
+ WriteThread::WriteGroup& write_group, SequenceNumber sequence,
2051
+ ColumnFamilyMemTables* memtables, FlushScheduler* flush_scheduler,
2052
+ TrimHistoryScheduler* trim_history_scheduler,
2053
+ bool ignore_missing_column_families, uint64_t recovery_log_number, DB* db,
2054
+ bool concurrent_memtable_writes, bool seq_per_batch, bool batch_per_txn) {
2055
+ MemTableInserter inserter(
2056
+ sequence, memtables, flush_scheduler, trim_history_scheduler,
2057
+ ignore_missing_column_families, recovery_log_number, db,
2058
+ concurrent_memtable_writes, nullptr /*has_valid_writes*/, seq_per_batch,
2059
+ batch_per_txn);
2060
+ for (auto w : write_group) {
2061
+ if (w->CallbackFailed()) {
2062
+ continue;
2063
+ }
2064
+ w->sequence = inserter.sequence();
2065
+ if (!w->ShouldWriteToMemtable()) {
2066
+ // In seq_per_batch_ mode this advances the seq by one.
2067
+ inserter.MaybeAdvanceSeq(true);
2068
+ continue;
2069
+ }
2070
+ SetSequence(w->batch, inserter.sequence());
2071
+ inserter.set_log_number_ref(w->log_ref);
2072
+ w->status = w->batch->Iterate(&inserter);
2073
+ if (!w->status.ok()) {
2074
+ return w->status;
2075
+ }
2076
+ assert(!seq_per_batch || w->batch_cnt != 0);
2077
+ assert(!seq_per_batch || inserter.sequence() - w->sequence == w->batch_cnt);
2078
+ }
2079
+ return Status::OK();
2080
+ }
2081
+
2082
+ Status WriteBatchInternal::InsertInto(
2083
+ WriteThread::Writer* writer, SequenceNumber sequence,
2084
+ ColumnFamilyMemTables* memtables, FlushScheduler* flush_scheduler,
2085
+ TrimHistoryScheduler* trim_history_scheduler,
2086
+ bool ignore_missing_column_families, uint64_t log_number, DB* db,
2087
+ bool concurrent_memtable_writes, bool seq_per_batch, size_t batch_cnt,
2088
+ bool batch_per_txn, bool hint_per_batch) {
2089
+ #ifdef NDEBUG
2090
+ (void)batch_cnt;
2091
+ #endif
2092
+ assert(writer->ShouldWriteToMemtable());
2093
+ MemTableInserter inserter(
2094
+ sequence, memtables, flush_scheduler, trim_history_scheduler,
2095
+ ignore_missing_column_families, log_number, db,
2096
+ concurrent_memtable_writes, nullptr /*has_valid_writes*/, seq_per_batch,
2097
+ batch_per_txn, hint_per_batch);
2098
+ SetSequence(writer->batch, sequence);
2099
+ inserter.set_log_number_ref(writer->log_ref);
2100
+ Status s = writer->batch->Iterate(&inserter);
2101
+ assert(!seq_per_batch || batch_cnt != 0);
2102
+ assert(!seq_per_batch || inserter.sequence() - sequence == batch_cnt);
2103
+ if (concurrent_memtable_writes) {
2104
+ inserter.PostProcess();
2105
+ }
2106
+ return s;
2107
+ }
2108
+
2109
+ Status WriteBatchInternal::InsertInto(
2110
+ const WriteBatch* batch, ColumnFamilyMemTables* memtables,
2111
+ FlushScheduler* flush_scheduler,
2112
+ TrimHistoryScheduler* trim_history_scheduler,
2113
+ bool ignore_missing_column_families, uint64_t log_number, DB* db,
2114
+ bool concurrent_memtable_writes, SequenceNumber* next_seq,
2115
+ bool* has_valid_writes, bool seq_per_batch, bool batch_per_txn) {
2116
+ MemTableInserter inserter(Sequence(batch), memtables, flush_scheduler,
2117
+ trim_history_scheduler,
2118
+ ignore_missing_column_families, log_number, db,
2119
+ concurrent_memtable_writes, has_valid_writes,
2120
+ seq_per_batch, batch_per_txn);
2121
+ Status s = batch->Iterate(&inserter);
2122
+ if (next_seq != nullptr) {
2123
+ *next_seq = inserter.sequence();
2124
+ }
2125
+ if (concurrent_memtable_writes) {
2126
+ inserter.PostProcess();
2127
+ }
2128
+ return s;
2129
+ }
2130
+
2131
+ Status WriteBatchInternal::SetContents(WriteBatch* b, const Slice& contents) {
2132
+ assert(contents.size() >= WriteBatchInternal::kHeader);
2133
+ b->rep_.assign(contents.data(), contents.size());
2134
+ b->content_flags_.store(ContentFlags::DEFERRED, std::memory_order_relaxed);
2135
+ return Status::OK();
2136
+ }
2137
+
2138
+ Status WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src,
2139
+ const bool wal_only) {
2140
+ size_t src_len;
2141
+ int src_count;
2142
+ uint32_t src_flags;
2143
+
2144
+ const SavePoint& batch_end = src->GetWalTerminationPoint();
2145
+
2146
+ if (wal_only && !batch_end.is_cleared()) {
2147
+ src_len = batch_end.size - WriteBatchInternal::kHeader;
2148
+ src_count = batch_end.count;
2149
+ src_flags = batch_end.content_flags;
2150
+ } else {
2151
+ src_len = src->rep_.size() - WriteBatchInternal::kHeader;
2152
+ src_count = Count(src);
2153
+ src_flags = src->content_flags_.load(std::memory_order_relaxed);
2154
+ }
2155
+
2156
+ SetCount(dst, Count(dst) + src_count);
2157
+ assert(src->rep_.size() >= WriteBatchInternal::kHeader);
2158
+ dst->rep_.append(src->rep_.data() + WriteBatchInternal::kHeader, src_len);
2159
+ dst->content_flags_.store(
2160
+ dst->content_flags_.load(std::memory_order_relaxed) | src_flags,
2161
+ std::memory_order_relaxed);
2162
+ return Status::OK();
2163
+ }
2164
+
2165
+ size_t WriteBatchInternal::AppendedByteSize(size_t leftByteSize,
2166
+ size_t rightByteSize) {
2167
+ if (leftByteSize == 0 || rightByteSize == 0) {
2168
+ return leftByteSize + rightByteSize;
2169
+ } else {
2170
+ return leftByteSize + rightByteSize - WriteBatchInternal::kHeader;
2171
+ }
2172
+ }
2173
+
2174
+ } // namespace ROCKSDB_NAMESPACE