@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,2274 @@
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
+ #pragma once
10
+
11
+ #include <atomic>
12
+ #include <deque>
13
+ #include <functional>
14
+ #include <limits>
15
+ #include <list>
16
+ #include <map>
17
+ #include <set>
18
+ #include <string>
19
+ #include <utility>
20
+ #include <vector>
21
+
22
+ #include "db/column_family.h"
23
+ #include "db/compaction/compaction_job.h"
24
+ #include "db/dbformat.h"
25
+ #include "db/error_handler.h"
26
+ #include "db/event_helpers.h"
27
+ #include "db/external_sst_file_ingestion_job.h"
28
+ #include "db/flush_job.h"
29
+ #include "db/flush_scheduler.h"
30
+ #include "db/import_column_family_job.h"
31
+ #include "db/internal_stats.h"
32
+ #include "db/log_writer.h"
33
+ #include "db/logs_with_prep_tracker.h"
34
+ #include "db/memtable_list.h"
35
+ #include "db/pre_release_callback.h"
36
+ #include "db/range_del_aggregator.h"
37
+ #include "db/read_callback.h"
38
+ #include "db/snapshot_checker.h"
39
+ #include "db/snapshot_impl.h"
40
+ #include "db/trim_history_scheduler.h"
41
+ #include "db/version_edit.h"
42
+ #include "db/wal_manager.h"
43
+ #include "db/write_controller.h"
44
+ #include "db/write_thread.h"
45
+ #include "logging/event_logger.h"
46
+ #include "monitoring/instrumented_mutex.h"
47
+ #include "options/db_options.h"
48
+ #include "port/port.h"
49
+ #include "rocksdb/db.h"
50
+ #include "rocksdb/env.h"
51
+ #include "rocksdb/memtablerep.h"
52
+ #include "rocksdb/status.h"
53
+ #include "rocksdb/trace_reader_writer.h"
54
+ #include "rocksdb/transaction_log.h"
55
+ #include "rocksdb/write_buffer_manager.h"
56
+ #include "table/scoped_arena_iterator.h"
57
+ #include "trace_replay/block_cache_tracer.h"
58
+ #include "trace_replay/io_tracer.h"
59
+ #include "trace_replay/trace_replay.h"
60
+ #include "util/autovector.h"
61
+ #include "util/hash.h"
62
+ #include "util/repeatable_thread.h"
63
+ #include "util/stop_watch.h"
64
+ #include "util/thread_local.h"
65
+
66
+ namespace ROCKSDB_NAMESPACE {
67
+
68
+ class Arena;
69
+ class ArenaWrappedDBIter;
70
+ class InMemoryStatsHistoryIterator;
71
+ class MemTable;
72
+ class PersistentStatsHistoryIterator;
73
+ class PeriodicWorkScheduler;
74
+ #ifndef NDEBUG
75
+ class PeriodicWorkTestScheduler;
76
+ #endif // !NDEBUG
77
+ class TableCache;
78
+ class TaskLimiterToken;
79
+ class Version;
80
+ class VersionEdit;
81
+ class VersionSet;
82
+ class WriteCallback;
83
+ struct JobContext;
84
+ struct ExternalSstFileInfo;
85
+ struct MemTableInfo;
86
+
87
+ // Class to maintain directories for all database paths other than main one.
88
+ class Directories {
89
+ public:
90
+ IOStatus SetDirectories(FileSystem* fs, const std::string& dbname,
91
+ const std::string& wal_dir,
92
+ const std::vector<DbPath>& data_paths);
93
+
94
+ FSDirectory* GetDataDir(size_t path_id) const {
95
+ assert(path_id < data_dirs_.size());
96
+ FSDirectory* ret_dir = data_dirs_[path_id].get();
97
+ if (ret_dir == nullptr) {
98
+ // Should use db_dir_
99
+ return db_dir_.get();
100
+ }
101
+ return ret_dir;
102
+ }
103
+
104
+ FSDirectory* GetWalDir() {
105
+ if (wal_dir_) {
106
+ return wal_dir_.get();
107
+ }
108
+ return db_dir_.get();
109
+ }
110
+
111
+ FSDirectory* GetDbDir() { return db_dir_.get(); }
112
+
113
+ private:
114
+ std::unique_ptr<FSDirectory> db_dir_;
115
+ std::vector<std::unique_ptr<FSDirectory>> data_dirs_;
116
+ std::unique_ptr<FSDirectory> wal_dir_;
117
+ };
118
+
119
+ // While DB is the public interface of RocksDB, and DBImpl is the actual
120
+ // class implementing it. It's the entrance of the core RocksdB engine.
121
+ // All other DB implementations, e.g. TransactionDB, BlobDB, etc, wrap a
122
+ // DBImpl internally.
123
+ // Other than functions implementing the DB interface, some public
124
+ // functions are there for other internal components to call. For
125
+ // example, TransactionDB directly calls DBImpl::WriteImpl() and
126
+ // BlobDB directly calls DBImpl::GetImpl(). Some other functions
127
+ // are for sub-components to call. For example, ColumnFamilyHandleImpl
128
+ // calls DBImpl::FindObsoleteFiles().
129
+ //
130
+ // Since it's a very large class, the definition of the functions is
131
+ // divided in several db_impl_*.cc files, besides db_impl.cc.
132
+ class DBImpl : public DB {
133
+ public:
134
+ DBImpl(const DBOptions& options, const std::string& dbname,
135
+ const bool seq_per_batch = false, const bool batch_per_txn = true);
136
+ // No copying allowed
137
+ DBImpl(const DBImpl&) = delete;
138
+ void operator=(const DBImpl&) = delete;
139
+
140
+ virtual ~DBImpl();
141
+
142
+ // ---- Implementations of the DB interface ----
143
+
144
+ using DB::Resume;
145
+ virtual Status Resume() override;
146
+
147
+ using DB::Put;
148
+ virtual Status Put(const WriteOptions& options,
149
+ ColumnFamilyHandle* column_family, const Slice& key,
150
+ const Slice& value) override;
151
+ using DB::Merge;
152
+ virtual Status Merge(const WriteOptions& options,
153
+ ColumnFamilyHandle* column_family, const Slice& key,
154
+ const Slice& value) override;
155
+ using DB::Delete;
156
+ virtual Status Delete(const WriteOptions& options,
157
+ ColumnFamilyHandle* column_family,
158
+ const Slice& key) override;
159
+ using DB::SingleDelete;
160
+ virtual Status SingleDelete(const WriteOptions& options,
161
+ ColumnFamilyHandle* column_family,
162
+ const Slice& key) override;
163
+ using DB::Write;
164
+ virtual Status Write(const WriteOptions& options,
165
+ WriteBatch* updates) override;
166
+
167
+ using DB::Get;
168
+ virtual Status Get(const ReadOptions& options,
169
+ ColumnFamilyHandle* column_family, const Slice& key,
170
+ PinnableSlice* value) override;
171
+ virtual Status Get(const ReadOptions& options,
172
+ ColumnFamilyHandle* column_family, const Slice& key,
173
+ PinnableSlice* value, std::string* timestamp) override;
174
+
175
+ using DB::GetMergeOperands;
176
+ Status GetMergeOperands(const ReadOptions& options,
177
+ ColumnFamilyHandle* column_family, const Slice& key,
178
+ PinnableSlice* merge_operands,
179
+ GetMergeOperandsOptions* get_merge_operands_options,
180
+ int* number_of_operands) override {
181
+ GetImplOptions get_impl_options;
182
+ get_impl_options.column_family = column_family;
183
+ get_impl_options.merge_operands = merge_operands;
184
+ get_impl_options.get_merge_operands_options = get_merge_operands_options;
185
+ get_impl_options.number_of_operands = number_of_operands;
186
+ get_impl_options.get_value = false;
187
+ return GetImpl(options, key, get_impl_options);
188
+ }
189
+
190
+ using DB::MultiGet;
191
+ virtual std::vector<Status> MultiGet(
192
+ const ReadOptions& options,
193
+ const std::vector<ColumnFamilyHandle*>& column_family,
194
+ const std::vector<Slice>& keys,
195
+ std::vector<std::string>* values) override;
196
+ virtual std::vector<Status> MultiGet(
197
+ const ReadOptions& options,
198
+ const std::vector<ColumnFamilyHandle*>& column_family,
199
+ const std::vector<Slice>& keys, std::vector<std::string>* values,
200
+ std::vector<std::string>* timestamps) override;
201
+
202
+ // This MultiGet is a batched version, which may be faster than calling Get
203
+ // multiple times, especially if the keys have some spatial locality that
204
+ // enables them to be queried in the same SST files/set of files. The larger
205
+ // the batch size, the more scope for batching and performance improvement
206
+ // The values and statuses parameters are arrays with number of elements
207
+ // equal to keys.size(). This allows the storage for those to be alloacted
208
+ // by the caller on the stack for small batches
209
+ virtual void MultiGet(const ReadOptions& options,
210
+ ColumnFamilyHandle* column_family,
211
+ const size_t num_keys, const Slice* keys,
212
+ PinnableSlice* values, Status* statuses,
213
+ const bool sorted_input = false) override;
214
+ virtual void MultiGet(const ReadOptions& options,
215
+ ColumnFamilyHandle* column_family,
216
+ const size_t num_keys, const Slice* keys,
217
+ PinnableSlice* values, std::string* timestamps,
218
+ Status* statuses,
219
+ const bool sorted_input = false) override;
220
+
221
+ virtual void MultiGet(const ReadOptions& options, const size_t num_keys,
222
+ ColumnFamilyHandle** column_families, const Slice* keys,
223
+ PinnableSlice* values, Status* statuses,
224
+ const bool sorted_input = false) override;
225
+ virtual void MultiGet(const ReadOptions& options, const size_t num_keys,
226
+ ColumnFamilyHandle** column_families, const Slice* keys,
227
+ PinnableSlice* values, std::string* timestamps,
228
+ Status* statuses,
229
+ const bool sorted_input = false) override;
230
+
231
+ virtual void MultiGetWithCallback(
232
+ const ReadOptions& options, ColumnFamilyHandle* column_family,
233
+ ReadCallback* callback,
234
+ autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE>* sorted_keys);
235
+
236
+ virtual Status CreateColumnFamily(const ColumnFamilyOptions& cf_options,
237
+ const std::string& column_family,
238
+ ColumnFamilyHandle** handle) override;
239
+ virtual Status CreateColumnFamilies(
240
+ const ColumnFamilyOptions& cf_options,
241
+ const std::vector<std::string>& column_family_names,
242
+ std::vector<ColumnFamilyHandle*>* handles) override;
243
+ virtual Status CreateColumnFamilies(
244
+ const std::vector<ColumnFamilyDescriptor>& column_families,
245
+ std::vector<ColumnFamilyHandle*>* handles) override;
246
+ virtual Status DropColumnFamily(ColumnFamilyHandle* column_family) override;
247
+ virtual Status DropColumnFamilies(
248
+ const std::vector<ColumnFamilyHandle*>& column_families) override;
249
+
250
+ // Returns false if key doesn't exist in the database and true if it may.
251
+ // If value_found is not passed in as null, then return the value if found in
252
+ // memory. On return, if value was found, then value_found will be set to true
253
+ // , otherwise false.
254
+ using DB::KeyMayExist;
255
+ virtual bool KeyMayExist(const ReadOptions& options,
256
+ ColumnFamilyHandle* column_family, const Slice& key,
257
+ std::string* value, std::string* timestamp,
258
+ bool* value_found = nullptr) override;
259
+
260
+ using DB::NewIterator;
261
+ virtual Iterator* NewIterator(const ReadOptions& options,
262
+ ColumnFamilyHandle* column_family) override;
263
+ virtual Status NewIterators(
264
+ const ReadOptions& options,
265
+ const std::vector<ColumnFamilyHandle*>& column_families,
266
+ std::vector<Iterator*>* iterators) override;
267
+
268
+ virtual const Snapshot* GetSnapshot() override;
269
+ virtual void ReleaseSnapshot(const Snapshot* snapshot) override;
270
+ using DB::GetProperty;
271
+ virtual bool GetProperty(ColumnFamilyHandle* column_family,
272
+ const Slice& property, std::string* value) override;
273
+ using DB::GetMapProperty;
274
+ virtual bool GetMapProperty(
275
+ ColumnFamilyHandle* column_family, const Slice& property,
276
+ std::map<std::string, std::string>* value) override;
277
+ using DB::GetIntProperty;
278
+ virtual bool GetIntProperty(ColumnFamilyHandle* column_family,
279
+ const Slice& property, uint64_t* value) override;
280
+ using DB::GetAggregatedIntProperty;
281
+ virtual bool GetAggregatedIntProperty(const Slice& property,
282
+ uint64_t* aggregated_value) override;
283
+ using DB::GetApproximateSizes;
284
+ virtual Status GetApproximateSizes(const SizeApproximationOptions& options,
285
+ ColumnFamilyHandle* column_family,
286
+ const Range* range, int n,
287
+ uint64_t* sizes) override;
288
+ using DB::GetApproximateMemTableStats;
289
+ virtual void GetApproximateMemTableStats(ColumnFamilyHandle* column_family,
290
+ const Range& range,
291
+ uint64_t* const count,
292
+ uint64_t* const size) override;
293
+ using DB::CompactRange;
294
+ virtual Status CompactRange(const CompactRangeOptions& options,
295
+ ColumnFamilyHandle* column_family,
296
+ const Slice* begin, const Slice* end) override;
297
+
298
+ using DB::CompactFiles;
299
+ virtual Status CompactFiles(
300
+ const CompactionOptions& compact_options,
301
+ ColumnFamilyHandle* column_family,
302
+ const std::vector<std::string>& input_file_names, const int output_level,
303
+ const int output_path_id = -1,
304
+ std::vector<std::string>* const output_file_names = nullptr,
305
+ CompactionJobInfo* compaction_job_info = nullptr) override;
306
+
307
+ virtual Status PauseBackgroundWork() override;
308
+ virtual Status ContinueBackgroundWork() override;
309
+
310
+ virtual Status EnableAutoCompaction(
311
+ const std::vector<ColumnFamilyHandle*>& column_family_handles) override;
312
+
313
+ virtual void EnableManualCompaction() override;
314
+ virtual void DisableManualCompaction() override;
315
+
316
+ using DB::SetOptions;
317
+ Status SetOptions(
318
+ ColumnFamilyHandle* column_family,
319
+ const std::unordered_map<std::string, std::string>& options_map) override;
320
+
321
+ virtual Status SetDBOptions(
322
+ const std::unordered_map<std::string, std::string>& options_map) override;
323
+
324
+ using DB::NumberLevels;
325
+ virtual int NumberLevels(ColumnFamilyHandle* column_family) override;
326
+ using DB::MaxMemCompactionLevel;
327
+ virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) override;
328
+ using DB::Level0StopWriteTrigger;
329
+ virtual int Level0StopWriteTrigger(
330
+ ColumnFamilyHandle* column_family) override;
331
+ virtual const std::string& GetName() const override;
332
+ virtual Env* GetEnv() const override;
333
+ virtual FileSystem* GetFileSystem() const override;
334
+ using DB::GetOptions;
335
+ virtual Options GetOptions(ColumnFamilyHandle* column_family) const override;
336
+ using DB::GetDBOptions;
337
+ virtual DBOptions GetDBOptions() const override;
338
+ using DB::Flush;
339
+ virtual Status Flush(const FlushOptions& options,
340
+ ColumnFamilyHandle* column_family) override;
341
+ virtual Status Flush(
342
+ const FlushOptions& options,
343
+ const std::vector<ColumnFamilyHandle*>& column_families) override;
344
+ virtual Status FlushWAL(bool sync) override;
345
+ bool TEST_WALBufferIsEmpty(bool lock = true);
346
+ virtual Status SyncWAL() override;
347
+ virtual Status LockWAL() override;
348
+ virtual Status UnlockWAL() override;
349
+
350
+ virtual SequenceNumber GetLatestSequenceNumber() const override;
351
+
352
+ virtual bool SetPreserveDeletesSequenceNumber(SequenceNumber seqnum) override;
353
+
354
+ virtual Status GetDbIdentity(std::string& identity) const override;
355
+
356
+ virtual Status GetDbIdentityFromIdentityFile(std::string* identity) const;
357
+
358
+ virtual Status GetDbSessionId(std::string& session_id) const override;
359
+
360
+ ColumnFamilyHandle* DefaultColumnFamily() const override;
361
+
362
+ ColumnFamilyHandle* PersistentStatsColumnFamily() const;
363
+
364
+ virtual Status Close() override;
365
+
366
+ virtual Status DisableFileDeletions() override;
367
+
368
+ virtual Status EnableFileDeletions(bool force) override;
369
+
370
+ virtual bool IsFileDeletionsEnabled() const;
371
+
372
+ Status GetStatsHistory(
373
+ uint64_t start_time, uint64_t end_time,
374
+ std::unique_ptr<StatsHistoryIterator>* stats_iterator) override;
375
+
376
+ #ifndef ROCKSDB_LITE
377
+ using DB::ResetStats;
378
+ virtual Status ResetStats() override;
379
+ // All the returned filenames start with "/"
380
+ virtual Status GetLiveFiles(std::vector<std::string>&,
381
+ uint64_t* manifest_file_size,
382
+ bool flush_memtable = true) override;
383
+ virtual Status GetSortedWalFiles(VectorLogPtr& files) override;
384
+ virtual Status GetCurrentWalFile(
385
+ std::unique_ptr<LogFile>* current_log_file) override;
386
+ virtual Status GetCreationTimeOfOldestFile(
387
+ uint64_t* creation_time) override;
388
+
389
+ virtual Status GetUpdatesSince(
390
+ SequenceNumber seq_number, std::unique_ptr<TransactionLogIterator>* iter,
391
+ const TransactionLogIterator::ReadOptions& read_options =
392
+ TransactionLogIterator::ReadOptions()) override;
393
+ virtual Status DeleteFile(std::string name) override;
394
+ Status DeleteFilesInRanges(ColumnFamilyHandle* column_family,
395
+ const RangePtr* ranges, size_t n,
396
+ bool include_end = true);
397
+
398
+ virtual void GetLiveFilesMetaData(
399
+ std::vector<LiveFileMetaData>* metadata) override;
400
+
401
+ virtual Status GetLiveFilesChecksumInfo(
402
+ FileChecksumList* checksum_list) override;
403
+
404
+ // Obtains the meta data of the specified column family of the DB.
405
+ // Status::NotFound() will be returned if the current DB does not have
406
+ // any column family match the specified name.
407
+ // TODO(yhchiang): output parameter is placed in the end in this codebase.
408
+ virtual void GetColumnFamilyMetaData(ColumnFamilyHandle* column_family,
409
+ ColumnFamilyMetaData* metadata) override;
410
+
411
+ Status SuggestCompactRange(ColumnFamilyHandle* column_family,
412
+ const Slice* begin, const Slice* end) override;
413
+
414
+ Status PromoteL0(ColumnFamilyHandle* column_family,
415
+ int target_level) override;
416
+
417
+ using DB::IngestExternalFile;
418
+ virtual Status IngestExternalFile(
419
+ ColumnFamilyHandle* column_family,
420
+ const std::vector<std::string>& external_files,
421
+ const IngestExternalFileOptions& ingestion_options) override;
422
+
423
+ using DB::IngestExternalFiles;
424
+ virtual Status IngestExternalFiles(
425
+ const std::vector<IngestExternalFileArg>& args) override;
426
+
427
+ using DB::CreateColumnFamilyWithImport;
428
+ virtual Status CreateColumnFamilyWithImport(
429
+ const ColumnFamilyOptions& options, const std::string& column_family_name,
430
+ const ImportColumnFamilyOptions& import_options,
431
+ const ExportImportFilesMetaData& metadata,
432
+ ColumnFamilyHandle** handle) override;
433
+
434
+ using DB::VerifyFileChecksums;
435
+ Status VerifyFileChecksums(const ReadOptions& read_options) override;
436
+
437
+ using DB::VerifyChecksum;
438
+ virtual Status VerifyChecksum(const ReadOptions& /*read_options*/) override;
439
+ // Verify the checksums of files in db. Currently only tables are checked.
440
+ //
441
+ // read_options: controls file I/O behavior, e.g. read ahead size while
442
+ // reading all the live table files.
443
+ //
444
+ // use_file_checksum: if false, verify the block checksums of all live table
445
+ // in db. Otherwise, obtain the file checksums and compare
446
+ // with the MANIFEST. Currently, file checksums are
447
+ // recomputed by reading all table files.
448
+ //
449
+ // Returns: OK if there is no file whose file or block checksum mismatches.
450
+ Status VerifyChecksumInternal(const ReadOptions& read_options,
451
+ bool use_file_checksum);
452
+
453
+ Status VerifySstFileChecksum(const FileMetaData& fmeta,
454
+ const std::string& fpath,
455
+ const ReadOptions& read_options);
456
+
457
+ using DB::StartTrace;
458
+ virtual Status StartTrace(
459
+ const TraceOptions& options,
460
+ std::unique_ptr<TraceWriter>&& trace_writer) override;
461
+
462
+ using DB::EndTrace;
463
+ virtual Status EndTrace() override;
464
+
465
+ using DB::StartBlockCacheTrace;
466
+ Status StartBlockCacheTrace(
467
+ const TraceOptions& options,
468
+ std::unique_ptr<TraceWriter>&& trace_writer) override;
469
+
470
+ using DB::EndBlockCacheTrace;
471
+ Status EndBlockCacheTrace() override;
472
+
473
+ using DB::StartIOTrace;
474
+ Status StartIOTrace(Env* env, const TraceOptions& options,
475
+ std::unique_ptr<TraceWriter>&& trace_writer) override;
476
+
477
+ using DB::EndIOTrace;
478
+ Status EndIOTrace() override;
479
+
480
+ using DB::GetPropertiesOfAllTables;
481
+ virtual Status GetPropertiesOfAllTables(
482
+ ColumnFamilyHandle* column_family,
483
+ TablePropertiesCollection* props) override;
484
+ virtual Status GetPropertiesOfTablesInRange(
485
+ ColumnFamilyHandle* column_family, const Range* range, std::size_t n,
486
+ TablePropertiesCollection* props) override;
487
+
488
+ #endif // ROCKSDB_LITE
489
+
490
+ // ---- End of implementations of the DB interface ----
491
+
492
+ struct GetImplOptions {
493
+ ColumnFamilyHandle* column_family = nullptr;
494
+ PinnableSlice* value = nullptr;
495
+ std::string* timestamp = nullptr;
496
+ bool* value_found = nullptr;
497
+ ReadCallback* callback = nullptr;
498
+ bool* is_blob_index = nullptr;
499
+ // If true return value associated with key via value pointer else return
500
+ // all merge operands for key via merge_operands pointer
501
+ bool get_value = true;
502
+ // Pointer to an array of size
503
+ // get_merge_operands_options.expected_max_number_of_operands allocated by
504
+ // user
505
+ PinnableSlice* merge_operands = nullptr;
506
+ GetMergeOperandsOptions* get_merge_operands_options = nullptr;
507
+ int* number_of_operands = nullptr;
508
+ };
509
+
510
+ // Function that Get and KeyMayExist call with no_io true or false
511
+ // Note: 'value_found' from KeyMayExist propagates here
512
+ // This function is also called by GetMergeOperands
513
+ // If get_impl_options.get_value = true get value associated with
514
+ // get_impl_options.key via get_impl_options.value
515
+ // If get_impl_options.get_value = false get merge operands associated with
516
+ // get_impl_options.key via get_impl_options.merge_operands
517
+ Status GetImpl(const ReadOptions& options, const Slice& key,
518
+ GetImplOptions& get_impl_options);
519
+
520
+ // If `snapshot` == kMaxSequenceNumber, set a recent one inside the file.
521
+ ArenaWrappedDBIter* NewIteratorImpl(const ReadOptions& options,
522
+ ColumnFamilyData* cfd,
523
+ SequenceNumber snapshot,
524
+ ReadCallback* read_callback,
525
+ bool expose_blob_index = false,
526
+ bool allow_refresh = true);
527
+
528
+ virtual SequenceNumber GetLastPublishedSequence() const {
529
+ if (last_seq_same_as_publish_seq_) {
530
+ return versions_->LastSequence();
531
+ } else {
532
+ return versions_->LastPublishedSequence();
533
+ }
534
+ }
535
+
536
+ // REQUIRES: joined the main write queue if two_write_queues is disabled, and
537
+ // the second write queue otherwise.
538
+ virtual void SetLastPublishedSequence(SequenceNumber seq);
539
+ // Returns LastSequence in last_seq_same_as_publish_seq_
540
+ // mode and LastAllocatedSequence otherwise. This is useful when visiblility
541
+ // depends also on data written to the WAL but not to the memtable.
542
+ SequenceNumber TEST_GetLastVisibleSequence() const;
543
+
544
+ #ifndef ROCKSDB_LITE
545
+ // Similar to Write() but will call the callback once on the single write
546
+ // thread to determine whether it is safe to perform the write.
547
+ virtual Status WriteWithCallback(const WriteOptions& write_options,
548
+ WriteBatch* my_batch,
549
+ WriteCallback* callback);
550
+
551
+ // Returns the sequence number that is guaranteed to be smaller than or equal
552
+ // to the sequence number of any key that could be inserted into the current
553
+ // memtables. It can then be assumed that any write with a larger(or equal)
554
+ // sequence number will be present in this memtable or a later memtable.
555
+ //
556
+ // If the earliest sequence number could not be determined,
557
+ // kMaxSequenceNumber will be returned.
558
+ //
559
+ // If include_history=true, will also search Memtables in MemTableList
560
+ // History.
561
+ SequenceNumber GetEarliestMemTableSequenceNumber(SuperVersion* sv,
562
+ bool include_history);
563
+
564
+ // For a given key, check to see if there are any records for this key
565
+ // in the memtables, including memtable history. If cache_only is false,
566
+ // SST files will also be checked.
567
+ //
568
+ // If a key is found, *found_record_for_key will be set to true and
569
+ // *seq will be set to the stored sequence number for the latest
570
+ // operation on this key or kMaxSequenceNumber if unknown.
571
+ // If no key is found, *found_record_for_key will be set to false.
572
+ //
573
+ // Note: If cache_only=false, it is possible for *seq to be set to 0 if
574
+ // the sequence number has been cleared from the record. If the caller is
575
+ // holding an active db snapshot, we know the missing sequence must be less
576
+ // than the snapshot's sequence number (sequence numbers are only cleared
577
+ // when there are no earlier active snapshots).
578
+ //
579
+ // If NotFound is returned and found_record_for_key is set to false, then no
580
+ // record for this key was found. If the caller is holding an active db
581
+ // snapshot, we know that no key could have existing after this snapshot
582
+ // (since we do not compact keys that have an earlier snapshot).
583
+ //
584
+ // Only records newer than or at `lower_bound_seq` are guaranteed to be
585
+ // returned. Memtables and files may not be checked if it only contains data
586
+ // older than `lower_bound_seq`.
587
+ //
588
+ // Returns OK or NotFound on success,
589
+ // other status on unexpected error.
590
+ // TODO(andrewkr): this API need to be aware of range deletion operations
591
+ Status GetLatestSequenceForKey(SuperVersion* sv, const Slice& key,
592
+ bool cache_only,
593
+ SequenceNumber lower_bound_seq,
594
+ SequenceNumber* seq,
595
+ bool* found_record_for_key,
596
+ bool* is_blob_index = nullptr);
597
+
598
+ Status TraceIteratorSeek(const uint32_t& cf_id, const Slice& key);
599
+ Status TraceIteratorSeekForPrev(const uint32_t& cf_id, const Slice& key);
600
+ #endif // ROCKSDB_LITE
601
+
602
+ // Similar to GetSnapshot(), but also lets the db know that this snapshot
603
+ // will be used for transaction write-conflict checking. The DB can then
604
+ // make sure not to compact any keys that would prevent a write-conflict from
605
+ // being detected.
606
+ const Snapshot* GetSnapshotForWriteConflictBoundary();
607
+
608
+ // checks if all live files exist on file system and that their file sizes
609
+ // match to our in-memory records
610
+ virtual Status CheckConsistency();
611
+
612
+ // max_file_num_to_ignore allows bottom level compaction to filter out newly
613
+ // compacted SST files. Setting max_file_num_to_ignore to kMaxUint64 will
614
+ // disable the filtering
615
+ Status RunManualCompaction(ColumnFamilyData* cfd, int input_level,
616
+ int output_level,
617
+ const CompactRangeOptions& compact_range_options,
618
+ const Slice* begin, const Slice* end,
619
+ bool exclusive, bool disallow_trivial_move,
620
+ uint64_t max_file_num_to_ignore);
621
+
622
+ // Return an internal iterator over the current state of the database.
623
+ // The keys of this iterator are internal keys (see format.h).
624
+ // The returned iterator should be deleted when no longer needed.
625
+ // If allow_unprepared_value is true, the returned iterator may defer reading
626
+ // the value and so will require PrepareValue() to be called before value();
627
+ // allow_unprepared_value = false is convenient when this optimization is not
628
+ // useful, e.g. when reading the whole column family.
629
+ // @param read_options Must outlive the returned iterator.
630
+ InternalIterator* NewInternalIterator(
631
+ const ReadOptions& read_options, Arena* arena,
632
+ RangeDelAggregator* range_del_agg, SequenceNumber sequence,
633
+ ColumnFamilyHandle* column_family = nullptr,
634
+ bool allow_unprepared_value = false);
635
+
636
+ LogsWithPrepTracker* logs_with_prep_tracker() {
637
+ return &logs_with_prep_tracker_;
638
+ }
639
+
640
+ struct BGJobLimits {
641
+ int max_flushes;
642
+ int max_compactions;
643
+ };
644
+ // Returns maximum background flushes and compactions allowed to be scheduled
645
+ BGJobLimits GetBGJobLimits() const;
646
+ // Need a static version that can be called during SanitizeOptions().
647
+ static BGJobLimits GetBGJobLimits(int max_background_flushes,
648
+ int max_background_compactions,
649
+ int max_background_jobs,
650
+ bool parallelize_compactions);
651
+
652
+ // move logs pending closing from job_context to the DB queue and
653
+ // schedule a purge
654
+ void ScheduleBgLogWriterClose(JobContext* job_context);
655
+
656
+ uint64_t MinLogNumberToKeep();
657
+
658
+ // Returns the lower bound file number for SSTs that won't be deleted, even if
659
+ // they're obsolete. This lower bound is used internally to prevent newly
660
+ // created flush/compaction output files from being deleted before they're
661
+ // installed. This technique avoids the need for tracking the exact numbers of
662
+ // files pending creation, although it prevents more files than necessary from
663
+ // being deleted.
664
+ uint64_t MinObsoleteSstNumberToKeep();
665
+
666
+ // Returns the list of live files in 'live' and the list
667
+ // of all files in the filesystem in 'candidate_files'.
668
+ // If force == false and the last call was less than
669
+ // db_options_.delete_obsolete_files_period_micros microseconds ago,
670
+ // it will not fill up the job_context
671
+ void FindObsoleteFiles(JobContext* job_context, bool force,
672
+ bool no_full_scan = false);
673
+
674
+ // Diffs the files listed in filenames and those that do not
675
+ // belong to live files are possibly removed. Also, removes all the
676
+ // files in sst_delete_files and log_delete_files.
677
+ // It is not necessary to hold the mutex when invoking this method.
678
+ // If FindObsoleteFiles() was run, we need to also run
679
+ // PurgeObsoleteFiles(), even if disable_delete_obsolete_files_ is true
680
+ void PurgeObsoleteFiles(JobContext& background_contet,
681
+ bool schedule_only = false);
682
+
683
+ // Schedule a background job to actually delete obsolete files.
684
+ void SchedulePurge();
685
+
686
+ const SnapshotList& snapshots() const { return snapshots_; }
687
+
688
+ // load list of snapshots to `snap_vector` that is no newer than `max_seq`
689
+ // in ascending order.
690
+ // `oldest_write_conflict_snapshot` is filled with the oldest snapshot
691
+ // which satisfies SnapshotImpl.is_write_conflict_boundary_ = true.
692
+ void LoadSnapshots(std::vector<SequenceNumber>* snap_vector,
693
+ SequenceNumber* oldest_write_conflict_snapshot,
694
+ const SequenceNumber& max_seq) const {
695
+ InstrumentedMutexLock l(mutex());
696
+ snapshots().GetAll(snap_vector, oldest_write_conflict_snapshot, max_seq);
697
+ }
698
+
699
+ const ImmutableDBOptions& immutable_db_options() const {
700
+ return immutable_db_options_;
701
+ }
702
+
703
+ // Cancel all background jobs, including flush, compaction, background
704
+ // purging, stats dumping threads, etc. If `wait` = true, wait for the
705
+ // running jobs to abort or finish before returning. Otherwise, only
706
+ // sends the signals.
707
+ void CancelAllBackgroundWork(bool wait);
708
+
709
+ // Find Super version and reference it. Based on options, it might return
710
+ // the thread local cached one.
711
+ // Call ReturnAndCleanupSuperVersion() when it is no longer needed.
712
+ SuperVersion* GetAndRefSuperVersion(ColumnFamilyData* cfd);
713
+
714
+ // Similar to the previous function but looks up based on a column family id.
715
+ // nullptr will be returned if this column family no longer exists.
716
+ // REQUIRED: this function should only be called on the write thread or if the
717
+ // mutex is held.
718
+ SuperVersion* GetAndRefSuperVersion(uint32_t column_family_id);
719
+
720
+ // Un-reference the super version and clean it up if it is the last reference.
721
+ void CleanupSuperVersion(SuperVersion* sv);
722
+
723
+ // Un-reference the super version and return it to thread local cache if
724
+ // needed. If it is the last reference of the super version. Clean it up
725
+ // after un-referencing it.
726
+ void ReturnAndCleanupSuperVersion(ColumnFamilyData* cfd, SuperVersion* sv);
727
+
728
+ // Similar to the previous function but looks up based on a column family id.
729
+ // nullptr will be returned if this column family no longer exists.
730
+ // REQUIRED: this function should only be called on the write thread.
731
+ void ReturnAndCleanupSuperVersion(uint32_t colun_family_id, SuperVersion* sv);
732
+
733
+ // REQUIRED: this function should only be called on the write thread or if the
734
+ // mutex is held. Return value only valid until next call to this function or
735
+ // mutex is released.
736
+ ColumnFamilyHandle* GetColumnFamilyHandle(uint32_t column_family_id);
737
+
738
+ // Same as above, should called without mutex held and not on write thread.
739
+ std::unique_ptr<ColumnFamilyHandle> GetColumnFamilyHandleUnlocked(
740
+ uint32_t column_family_id);
741
+
742
+ // Returns the number of currently running flushes.
743
+ // REQUIREMENT: mutex_ must be held when calling this function.
744
+ int num_running_flushes() {
745
+ mutex_.AssertHeld();
746
+ return num_running_flushes_;
747
+ }
748
+
749
+ // Returns the number of currently running compactions.
750
+ // REQUIREMENT: mutex_ must be held when calling this function.
751
+ int num_running_compactions() {
752
+ mutex_.AssertHeld();
753
+ return num_running_compactions_;
754
+ }
755
+
756
+ const WriteController& write_controller() { return write_controller_; }
757
+
758
+ // @param read_options Must outlive the returned iterator.
759
+ InternalIterator* NewInternalIterator(const ReadOptions& read_options,
760
+ ColumnFamilyData* cfd,
761
+ SuperVersion* super_version,
762
+ Arena* arena,
763
+ RangeDelAggregator* range_del_agg,
764
+ SequenceNumber sequence,
765
+ bool allow_unprepared_value);
766
+
767
+ // hollow transactions shell used for recovery.
768
+ // these will then be passed to TransactionDB so that
769
+ // locks can be reacquired before writing can resume.
770
+ struct RecoveredTransaction {
771
+ std::string name_;
772
+ bool unprepared_;
773
+
774
+ struct BatchInfo {
775
+ uint64_t log_number_;
776
+ // TODO(lth): For unprepared, the memory usage here can be big for
777
+ // unprepared transactions. This is only useful for rollbacks, and we
778
+ // can in theory just keep keyset for that.
779
+ WriteBatch* batch_;
780
+ // Number of sub-batches. A new sub-batch is created if txn attempts to
781
+ // insert a duplicate key,seq to memtable. This is currently used in
782
+ // WritePreparedTxn/WriteUnpreparedTxn.
783
+ size_t batch_cnt_;
784
+ };
785
+
786
+ // This maps the seq of the first key in the batch to BatchInfo, which
787
+ // contains WriteBatch and other information relevant to the batch.
788
+ //
789
+ // For WriteUnprepared, batches_ can have size greater than 1, but for
790
+ // other write policies, it must be of size 1.
791
+ std::map<SequenceNumber, BatchInfo> batches_;
792
+
793
+ explicit RecoveredTransaction(const uint64_t log, const std::string& name,
794
+ WriteBatch* batch, SequenceNumber seq,
795
+ size_t batch_cnt, bool unprepared)
796
+ : name_(name), unprepared_(unprepared) {
797
+ batches_[seq] = {log, batch, batch_cnt};
798
+ }
799
+
800
+ ~RecoveredTransaction() {
801
+ for (auto& it : batches_) {
802
+ delete it.second.batch_;
803
+ }
804
+ }
805
+
806
+ void AddBatch(SequenceNumber seq, uint64_t log_number, WriteBatch* batch,
807
+ size_t batch_cnt, bool unprepared) {
808
+ assert(batches_.count(seq) == 0);
809
+ batches_[seq] = {log_number, batch, batch_cnt};
810
+ // Prior state must be unprepared, since the prepare batch must be the
811
+ // last batch.
812
+ assert(unprepared_);
813
+ unprepared_ = unprepared;
814
+ }
815
+ };
816
+
817
+ bool allow_2pc() const { return immutable_db_options_.allow_2pc; }
818
+
819
+ std::unordered_map<std::string, RecoveredTransaction*>
820
+ recovered_transactions() {
821
+ return recovered_transactions_;
822
+ }
823
+
824
+ RecoveredTransaction* GetRecoveredTransaction(const std::string& name) {
825
+ auto it = recovered_transactions_.find(name);
826
+ if (it == recovered_transactions_.end()) {
827
+ return nullptr;
828
+ } else {
829
+ return it->second;
830
+ }
831
+ }
832
+
833
+ void InsertRecoveredTransaction(const uint64_t log, const std::string& name,
834
+ WriteBatch* batch, SequenceNumber seq,
835
+ size_t batch_cnt, bool unprepared_batch) {
836
+ // For WriteUnpreparedTxn, InsertRecoveredTransaction is called multiple
837
+ // times for every unprepared batch encountered during recovery.
838
+ //
839
+ // If the transaction is prepared, then the last call to
840
+ // InsertRecoveredTransaction will have unprepared_batch = false.
841
+ auto rtxn = recovered_transactions_.find(name);
842
+ if (rtxn == recovered_transactions_.end()) {
843
+ recovered_transactions_[name] = new RecoveredTransaction(
844
+ log, name, batch, seq, batch_cnt, unprepared_batch);
845
+ } else {
846
+ rtxn->second->AddBatch(seq, log, batch, batch_cnt, unprepared_batch);
847
+ }
848
+ logs_with_prep_tracker_.MarkLogAsContainingPrepSection(log);
849
+ }
850
+
851
+ void DeleteRecoveredTransaction(const std::string& name) {
852
+ auto it = recovered_transactions_.find(name);
853
+ assert(it != recovered_transactions_.end());
854
+ auto* trx = it->second;
855
+ recovered_transactions_.erase(it);
856
+ for (const auto& info : trx->batches_) {
857
+ logs_with_prep_tracker_.MarkLogAsHavingPrepSectionFlushed(
858
+ info.second.log_number_);
859
+ }
860
+ delete trx;
861
+ }
862
+
863
+ void DeleteAllRecoveredTransactions() {
864
+ for (auto it = recovered_transactions_.begin();
865
+ it != recovered_transactions_.end(); ++it) {
866
+ delete it->second;
867
+ }
868
+ recovered_transactions_.clear();
869
+ }
870
+
871
+ void AddToLogsToFreeQueue(log::Writer* log_writer) {
872
+ logs_to_free_queue_.push_back(log_writer);
873
+ }
874
+
875
+ void AddSuperVersionsToFreeQueue(SuperVersion* sv) {
876
+ superversions_to_free_queue_.push_back(sv);
877
+ }
878
+
879
+ void SetSnapshotChecker(SnapshotChecker* snapshot_checker);
880
+
881
+ // Fill JobContext with snapshot information needed by flush and compaction.
882
+ void GetSnapshotContext(JobContext* job_context,
883
+ std::vector<SequenceNumber>* snapshot_seqs,
884
+ SequenceNumber* earliest_write_conflict_snapshot,
885
+ SnapshotChecker** snapshot_checker);
886
+
887
+ // Not thread-safe.
888
+ void SetRecoverableStatePreReleaseCallback(PreReleaseCallback* callback);
889
+
890
+ InstrumentedMutex* mutex() const { return &mutex_; }
891
+
892
+ // Initialize a brand new DB. The DB directory is expected to be empty before
893
+ // calling it. Push new manifest file name into `new_filenames`.
894
+ Status NewDB(std::vector<std::string>* new_filenames);
895
+
896
+ // This is to be used only by internal rocksdb classes.
897
+ static Status Open(const DBOptions& db_options, const std::string& name,
898
+ const std::vector<ColumnFamilyDescriptor>& column_families,
899
+ std::vector<ColumnFamilyHandle*>* handles, DB** dbptr,
900
+ const bool seq_per_batch, const bool batch_per_txn);
901
+
902
+ static IOStatus CreateAndNewDirectory(
903
+ FileSystem* fs, const std::string& dirname,
904
+ std::unique_ptr<FSDirectory>* directory);
905
+
906
+ // find stats map from stats_history_ with smallest timestamp in
907
+ // the range of [start_time, end_time)
908
+ bool FindStatsByTime(uint64_t start_time, uint64_t end_time,
909
+ uint64_t* new_time,
910
+ std::map<std::string, uint64_t>* stats_map);
911
+
912
+ // Print information of all tombstones of all iterators to the std::string
913
+ // This is only used by ldb. The output might be capped. Tombstones
914
+ // printed out are not guaranteed to be in any order.
915
+ Status TablesRangeTombstoneSummary(ColumnFamilyHandle* column_family,
916
+ int max_entries_to_print,
917
+ std::string* out_str);
918
+
919
+ #ifndef NDEBUG
920
+ // Compact any files in the named level that overlap [*begin, *end]
921
+ Status TEST_CompactRange(int level, const Slice* begin, const Slice* end,
922
+ ColumnFamilyHandle* column_family = nullptr,
923
+ bool disallow_trivial_move = false);
924
+
925
+ Status TEST_SwitchWAL();
926
+
927
+ bool TEST_UnableToReleaseOldestLog() { return unable_to_release_oldest_log_; }
928
+
929
+ bool TEST_IsLogGettingFlushed() {
930
+ return alive_log_files_.begin()->getting_flushed;
931
+ }
932
+
933
+ Status TEST_SwitchMemtable(ColumnFamilyData* cfd = nullptr);
934
+
935
+ // Force current memtable contents to be flushed.
936
+ Status TEST_FlushMemTable(bool wait = true, bool allow_write_stall = false,
937
+ ColumnFamilyHandle* cfh = nullptr);
938
+
939
+ Status TEST_FlushMemTable(ColumnFamilyData* cfd,
940
+ const FlushOptions& flush_opts);
941
+
942
+ // Flush (multiple) ColumnFamilyData without using ColumnFamilyHandle. This
943
+ // is because in certain cases, we can flush column families, wait for the
944
+ // flush to complete, but delete the column family handle before the wait
945
+ // finishes. For example in CompactRange.
946
+ Status TEST_AtomicFlushMemTables(const autovector<ColumnFamilyData*>& cfds,
947
+ const FlushOptions& flush_opts);
948
+
949
+ // Wait for memtable compaction
950
+ Status TEST_WaitForFlushMemTable(ColumnFamilyHandle* column_family = nullptr);
951
+
952
+ // Wait for any compaction
953
+ // We add a bool parameter to wait for unscheduledCompactions_ == 0, but this
954
+ // is only for the special test of CancelledCompactions
955
+ Status TEST_WaitForCompact(bool waitUnscheduled = false);
956
+
957
+ // Get the background error status
958
+ Status TEST_GetBGError();
959
+
960
+ // Return the maximum overlapping data (in bytes) at next level for any
961
+ // file at a level >= 1.
962
+ int64_t TEST_MaxNextLevelOverlappingBytes(
963
+ ColumnFamilyHandle* column_family = nullptr);
964
+
965
+ // Return the current manifest file no.
966
+ uint64_t TEST_Current_Manifest_FileNo();
967
+
968
+ // Returns the number that'll be assigned to the next file that's created.
969
+ uint64_t TEST_Current_Next_FileNo();
970
+
971
+ // get total level0 file size. Only for testing.
972
+ uint64_t TEST_GetLevel0TotalSize();
973
+
974
+ void TEST_GetFilesMetaData(ColumnFamilyHandle* column_family,
975
+ std::vector<std::vector<FileMetaData>>* metadata);
976
+
977
+ void TEST_LockMutex();
978
+
979
+ void TEST_UnlockMutex();
980
+
981
+ // REQUIRES: mutex locked
982
+ void* TEST_BeginWrite();
983
+
984
+ // REQUIRES: mutex locked
985
+ // pass the pointer that you got from TEST_BeginWrite()
986
+ void TEST_EndWrite(void* w);
987
+
988
+ uint64_t TEST_MaxTotalInMemoryState() const {
989
+ return max_total_in_memory_state_;
990
+ }
991
+
992
+ size_t TEST_LogsToFreeSize();
993
+
994
+ uint64_t TEST_LogfileNumber();
995
+
996
+ uint64_t TEST_total_log_size() const { return total_log_size_; }
997
+
998
+ // Returns column family name to ImmutableCFOptions map.
999
+ Status TEST_GetAllImmutableCFOptions(
1000
+ std::unordered_map<std::string, const ImmutableCFOptions*>* iopts_map);
1001
+
1002
+ // Return the lastest MutableCFOptions of a column family
1003
+ Status TEST_GetLatestMutableCFOptions(ColumnFamilyHandle* column_family,
1004
+ MutableCFOptions* mutable_cf_options);
1005
+
1006
+ Cache* TEST_table_cache() { return table_cache_.get(); }
1007
+
1008
+ WriteController& TEST_write_controler() { return write_controller_; }
1009
+
1010
+ uint64_t TEST_FindMinLogContainingOutstandingPrep();
1011
+ uint64_t TEST_FindMinPrepLogReferencedByMemTable();
1012
+ size_t TEST_PreparedSectionCompletedSize();
1013
+ size_t TEST_LogsWithPrepSize();
1014
+
1015
+ int TEST_BGCompactionsAllowed() const;
1016
+ int TEST_BGFlushesAllowed() const;
1017
+ size_t TEST_GetWalPreallocateBlockSize(uint64_t write_buffer_size) const;
1018
+ void TEST_WaitForStatsDumpRun(std::function<void()> callback) const;
1019
+ size_t TEST_EstimateInMemoryStatsHistorySize() const;
1020
+
1021
+ VersionSet* TEST_GetVersionSet() const { return versions_.get(); }
1022
+
1023
+ uint64_t TEST_GetCurrentLogNumber() const {
1024
+ InstrumentedMutexLock l(mutex());
1025
+ assert(!logs_.empty());
1026
+ return logs_.back().number;
1027
+ }
1028
+
1029
+ const std::unordered_set<uint64_t>& TEST_GetFilesGrabbedForPurge() const {
1030
+ return files_grabbed_for_purge_;
1031
+ }
1032
+
1033
+ #ifndef ROCKSDB_LITE
1034
+ PeriodicWorkTestScheduler* TEST_GetPeriodicWorkScheduler() const;
1035
+ #endif // !ROCKSDB_LITE
1036
+
1037
+ #endif // NDEBUG
1038
+
1039
+ // persist stats to column family "_persistent_stats"
1040
+ void PersistStats();
1041
+
1042
+ // dump rocksdb.stats to LOG
1043
+ void DumpStats();
1044
+
1045
+ // flush LOG out of application buffer
1046
+ void FlushInfoLog();
1047
+
1048
+ protected:
1049
+ const std::string dbname_;
1050
+ std::string db_id_;
1051
+ // db_session_id_ is an identifier that gets reset
1052
+ // every time the DB is opened
1053
+ std::string db_session_id_;
1054
+ std::unique_ptr<VersionSet> versions_;
1055
+ // Flag to check whether we allocated and own the info log file
1056
+ bool own_info_log_;
1057
+ const DBOptions initial_db_options_;
1058
+ Env* const env_;
1059
+ std::shared_ptr<IOTracer> io_tracer_;
1060
+ const ImmutableDBOptions immutable_db_options_;
1061
+ FileSystemPtr fs_;
1062
+ MutableDBOptions mutable_db_options_;
1063
+ Statistics* stats_;
1064
+ std::unordered_map<std::string, RecoveredTransaction*>
1065
+ recovered_transactions_;
1066
+ std::unique_ptr<Tracer> tracer_;
1067
+ InstrumentedMutex trace_mutex_;
1068
+ BlockCacheTracer block_cache_tracer_;
1069
+
1070
+ // State below is protected by mutex_
1071
+ // With two_write_queues enabled, some of the variables that accessed during
1072
+ // WriteToWAL need different synchronization: log_empty_, alive_log_files_,
1073
+ // logs_, logfile_number_. Refer to the definition of each variable below for
1074
+ // more description.
1075
+ mutable InstrumentedMutex mutex_;
1076
+
1077
+ ColumnFamilyHandleImpl* default_cf_handle_;
1078
+ InternalStats* default_cf_internal_stats_;
1079
+
1080
+ // only used for dynamically adjusting max_total_wal_size. it is a sum of
1081
+ // [write_buffer_size * max_write_buffer_number] over all column families
1082
+ uint64_t max_total_in_memory_state_;
1083
+ // If true, we have only one (default) column family. We use this to optimize
1084
+ // some code-paths
1085
+ bool single_column_family_mode_;
1086
+
1087
+ // The options to access storage files
1088
+ const FileOptions file_options_;
1089
+
1090
+ // Additonal options for compaction and flush
1091
+ FileOptions file_options_for_compaction_;
1092
+
1093
+ std::unique_ptr<ColumnFamilyMemTablesImpl> column_family_memtables_;
1094
+
1095
+ // Increase the sequence number after writing each batch, whether memtable is
1096
+ // disabled for that or not. Otherwise the sequence number is increased after
1097
+ // writing each key into memtable. This implies that when disable_memtable is
1098
+ // set, the seq is not increased at all.
1099
+ //
1100
+ // Default: false
1101
+ const bool seq_per_batch_;
1102
+ // This determines during recovery whether we expect one writebatch per
1103
+ // recovered transaction, or potentially multiple writebatches per
1104
+ // transaction. For WriteUnprepared, this is set to false, since multiple
1105
+ // batches can exist per transaction.
1106
+ //
1107
+ // Default: true
1108
+ const bool batch_per_txn_;
1109
+
1110
+ // Except in DB::Open(), WriteOptionsFile can only be called when:
1111
+ // Persist options to options file.
1112
+ // If need_mutex_lock = false, the method will lock DB mutex.
1113
+ // If need_enter_write_thread = false, the method will enter write thread.
1114
+ Status WriteOptionsFile(bool need_mutex_lock, bool need_enter_write_thread);
1115
+
1116
+ Status CompactRangeInternal(const CompactRangeOptions& options,
1117
+ ColumnFamilyHandle* column_family,
1118
+ const Slice* begin, const Slice* end);
1119
+
1120
+ Status GetApproximateSizesInternal(const SizeApproximationOptions& options,
1121
+ ColumnFamilyHandle* column_family,
1122
+ const Range* range, int n,
1123
+ uint64_t* sizes);
1124
+
1125
+ // The following two functions can only be called when:
1126
+ // 1. WriteThread::Writer::EnterUnbatched() is used.
1127
+ // 2. db_mutex is NOT held
1128
+ Status RenameTempFileToOptionsFile(const std::string& file_name);
1129
+ Status DeleteObsoleteOptionsFiles();
1130
+
1131
+ void NotifyOnFlushBegin(ColumnFamilyData* cfd, FileMetaData* file_meta,
1132
+ const MutableCFOptions& mutable_cf_options,
1133
+ int job_id);
1134
+
1135
+ void NotifyOnFlushCompleted(
1136
+ ColumnFamilyData* cfd, const MutableCFOptions& mutable_cf_options,
1137
+ std::list<std::unique_ptr<FlushJobInfo>>* flush_jobs_info);
1138
+
1139
+ void NotifyOnCompactionBegin(ColumnFamilyData* cfd, Compaction* c,
1140
+ const Status& st,
1141
+ const CompactionJobStats& job_stats, int job_id);
1142
+
1143
+ void NotifyOnCompactionCompleted(ColumnFamilyData* cfd, Compaction* c,
1144
+ const Status& st,
1145
+ const CompactionJobStats& job_stats,
1146
+ int job_id);
1147
+ void NotifyOnMemTableSealed(ColumnFamilyData* cfd,
1148
+ const MemTableInfo& mem_table_info);
1149
+
1150
+ #ifndef ROCKSDB_LITE
1151
+ void NotifyOnExternalFileIngested(
1152
+ ColumnFamilyData* cfd, const ExternalSstFileIngestionJob& ingestion_job);
1153
+ #endif // !ROCKSDB_LITE
1154
+
1155
+ void NewThreadStatusCfInfo(ColumnFamilyData* cfd) const;
1156
+
1157
+ void EraseThreadStatusCfInfo(ColumnFamilyData* cfd) const;
1158
+
1159
+ void EraseThreadStatusDbInfo() const;
1160
+
1161
+ // If disable_memtable is set the application logic must guarantee that the
1162
+ // batch will still be skipped from memtable during the recovery. An excption
1163
+ // to this is seq_per_batch_ mode, in which since each batch already takes one
1164
+ // seq, it is ok for the batch to write to memtable during recovery as long as
1165
+ // it only takes one sequence number: i.e., no duplicate keys.
1166
+ // In WriteCommitted it is guarnateed since disable_memtable is used for
1167
+ // prepare batch which will be written to memtable later during the commit,
1168
+ // and in WritePrepared it is guaranteed since it will be used only for WAL
1169
+ // markers which will never be written to memtable. If the commit marker is
1170
+ // accompanied with CommitTimeWriteBatch that is not written to memtable as
1171
+ // long as it has no duplicate keys, it does not violate the one-seq-per-batch
1172
+ // policy.
1173
+ // batch_cnt is expected to be non-zero in seq_per_batch mode and
1174
+ // indicates the number of sub-patches. A sub-patch is a subset of the write
1175
+ // batch that does not have duplicate keys.
1176
+ Status WriteImpl(const WriteOptions& options, WriteBatch* updates,
1177
+ WriteCallback* callback = nullptr,
1178
+ uint64_t* log_used = nullptr, uint64_t log_ref = 0,
1179
+ bool disable_memtable = false, uint64_t* seq_used = nullptr,
1180
+ size_t batch_cnt = 0,
1181
+ PreReleaseCallback* pre_release_callback = nullptr);
1182
+
1183
+ Status PipelinedWriteImpl(const WriteOptions& options, WriteBatch* updates,
1184
+ WriteCallback* callback = nullptr,
1185
+ uint64_t* log_used = nullptr, uint64_t log_ref = 0,
1186
+ bool disable_memtable = false,
1187
+ uint64_t* seq_used = nullptr);
1188
+
1189
+ // Write only to memtables without joining any write queue
1190
+ Status UnorderedWriteMemtable(const WriteOptions& write_options,
1191
+ WriteBatch* my_batch, WriteCallback* callback,
1192
+ uint64_t log_ref, SequenceNumber seq,
1193
+ const size_t sub_batch_cnt);
1194
+
1195
+ // Whether the batch requires to be assigned with an order
1196
+ enum AssignOrder : bool { kDontAssignOrder, kDoAssignOrder };
1197
+ // Whether it requires publishing last sequence or not
1198
+ enum PublishLastSeq : bool { kDontPublishLastSeq, kDoPublishLastSeq };
1199
+
1200
+ // Join the write_thread to write the batch only to the WAL. It is the
1201
+ // responsibility of the caller to also write the write batch to the memtable
1202
+ // if it required.
1203
+ //
1204
+ // sub_batch_cnt is expected to be non-zero when assign_order = kDoAssignOrder
1205
+ // indicating the number of sub-batches in my_batch. A sub-patch is a subset
1206
+ // of the write batch that does not have duplicate keys. When seq_per_batch is
1207
+ // not set, each key is a separate sub_batch. Otherwise each duplicate key
1208
+ // marks start of a new sub-batch.
1209
+ Status WriteImplWALOnly(
1210
+ WriteThread* write_thread, const WriteOptions& options,
1211
+ WriteBatch* updates, WriteCallback* callback, uint64_t* log_used,
1212
+ const uint64_t log_ref, uint64_t* seq_used, const size_t sub_batch_cnt,
1213
+ PreReleaseCallback* pre_release_callback, const AssignOrder assign_order,
1214
+ const PublishLastSeq publish_last_seq, const bool disable_memtable);
1215
+
1216
+ // write cached_recoverable_state_ to memtable if it is not empty
1217
+ // The writer must be the leader in write_thread_ and holding mutex_
1218
+ Status WriteRecoverableState();
1219
+
1220
+ // Actual implementation of Close()
1221
+ Status CloseImpl();
1222
+
1223
+ // Recover the descriptor from persistent storage. May do a significant
1224
+ // amount of work to recover recently logged updates. Any changes to
1225
+ // be made to the descriptor are added to *edit.
1226
+ // recovered_seq is set to less than kMaxSequenceNumber if the log's tail is
1227
+ // skipped.
1228
+ virtual Status Recover(
1229
+ const std::vector<ColumnFamilyDescriptor>& column_families,
1230
+ bool read_only = false, bool error_if_wal_file_exists = false,
1231
+ bool error_if_data_exists_in_wals = false,
1232
+ uint64_t* recovered_seq = nullptr);
1233
+
1234
+ virtual bool OwnTablesAndLogs() const { return true; }
1235
+
1236
+ // Set DB identity file, and write DB ID to manifest if necessary.
1237
+ Status SetDBId();
1238
+
1239
+ // REQUIRES: db mutex held when calling this function, but the db mutex can
1240
+ // be released and re-acquired. Db mutex will be held when the function
1241
+ // returns.
1242
+ // After recovery, there may be SST files in db/cf paths that are
1243
+ // not referenced in the MANIFEST (e.g.
1244
+ // 1. It's best effort recovery;
1245
+ // 2. The VersionEdits referencing the SST files are appended to
1246
+ // MANIFEST, DB crashes when syncing the MANIFEST, the VersionEdits are
1247
+ // still not synced to MANIFEST during recovery.)
1248
+ // We delete these SST files. In the
1249
+ // meantime, we find out the largest file number present in the paths, and
1250
+ // bump up the version set's next_file_number_ to be 1 + largest_file_number.
1251
+ Status DeleteUnreferencedSstFiles();
1252
+
1253
+ // SetDbSessionId() should be called in the constuctor DBImpl()
1254
+ // to ensure that db_session_id_ gets updated every time the DB is opened
1255
+ void SetDbSessionId();
1256
+
1257
+ private:
1258
+ friend class DB;
1259
+ friend class ErrorHandler;
1260
+ friend class InternalStats;
1261
+ friend class PessimisticTransaction;
1262
+ friend class TransactionBaseImpl;
1263
+ friend class WriteCommittedTxn;
1264
+ friend class WritePreparedTxn;
1265
+ friend class WritePreparedTxnDB;
1266
+ friend class WriteBatchWithIndex;
1267
+ friend class WriteUnpreparedTxnDB;
1268
+ friend class WriteUnpreparedTxn;
1269
+
1270
+ #ifndef ROCKSDB_LITE
1271
+ friend class ForwardIterator;
1272
+ #endif
1273
+ friend struct SuperVersion;
1274
+ friend class CompactedDBImpl;
1275
+ friend class DBTest_ConcurrentFlushWAL_Test;
1276
+ friend class DBTest_MixedSlowdownOptionsStop_Test;
1277
+ friend class DBCompactionTest_CompactBottomLevelFilesWithDeletions_Test;
1278
+ friend class DBCompactionTest_CompactionDuringShutdown_Test;
1279
+ friend class StatsHistoryTest_PersistentStatsCreateColumnFamilies_Test;
1280
+ #ifndef NDEBUG
1281
+ friend class DBTest2_ReadCallbackTest_Test;
1282
+ friend class WriteCallbackPTest_WriteWithCallbackTest_Test;
1283
+ friend class XFTransactionWriteHandler;
1284
+ friend class DBBlobIndexTest;
1285
+ friend class WriteUnpreparedTransactionTest_RecoveryTest_Test;
1286
+ #endif
1287
+
1288
+ struct CompactionState;
1289
+ struct PrepickedCompaction;
1290
+ struct PurgeFileInfo;
1291
+
1292
+ struct WriteContext {
1293
+ SuperVersionContext superversion_context;
1294
+ autovector<MemTable*> memtables_to_free_;
1295
+
1296
+ explicit WriteContext(bool create_superversion = false)
1297
+ : superversion_context(create_superversion) {}
1298
+
1299
+ ~WriteContext() {
1300
+ superversion_context.Clean();
1301
+ for (auto& m : memtables_to_free_) {
1302
+ delete m;
1303
+ }
1304
+ }
1305
+ };
1306
+
1307
+ struct LogFileNumberSize {
1308
+ explicit LogFileNumberSize(uint64_t _number) : number(_number) {}
1309
+ void AddSize(uint64_t new_size) { size += new_size; }
1310
+ uint64_t number;
1311
+ uint64_t size = 0;
1312
+ bool getting_flushed = false;
1313
+ };
1314
+
1315
+ struct LogWriterNumber {
1316
+ // pass ownership of _writer
1317
+ LogWriterNumber(uint64_t _number, log::Writer* _writer)
1318
+ : number(_number), writer(_writer) {}
1319
+
1320
+ log::Writer* ReleaseWriter() {
1321
+ auto* w = writer;
1322
+ writer = nullptr;
1323
+ return w;
1324
+ }
1325
+ Status ClearWriter() {
1326
+ Status s = writer->WriteBuffer();
1327
+ delete writer;
1328
+ writer = nullptr;
1329
+ return s;
1330
+ }
1331
+
1332
+ uint64_t number;
1333
+ // Visual Studio doesn't support deque's member to be noncopyable because
1334
+ // of a std::unique_ptr as a member.
1335
+ log::Writer* writer; // own
1336
+ // true for some prefix of logs_
1337
+ bool getting_synced = false;
1338
+ };
1339
+
1340
+ // PurgeFileInfo is a structure to hold information of files to be deleted in
1341
+ // purge_files_
1342
+ struct PurgeFileInfo {
1343
+ std::string fname;
1344
+ std::string dir_to_sync;
1345
+ FileType type;
1346
+ uint64_t number;
1347
+ int job_id;
1348
+ PurgeFileInfo(std::string fn, std::string d, FileType t, uint64_t num,
1349
+ int jid)
1350
+ : fname(fn), dir_to_sync(d), type(t), number(num), job_id(jid) {}
1351
+ };
1352
+
1353
+ // Argument required by background flush thread.
1354
+ struct BGFlushArg {
1355
+ BGFlushArg()
1356
+ : cfd_(nullptr), max_memtable_id_(0), superversion_context_(nullptr) {}
1357
+ BGFlushArg(ColumnFamilyData* cfd, uint64_t max_memtable_id,
1358
+ SuperVersionContext* superversion_context)
1359
+ : cfd_(cfd),
1360
+ max_memtable_id_(max_memtable_id),
1361
+ superversion_context_(superversion_context) {}
1362
+
1363
+ // Column family to flush.
1364
+ ColumnFamilyData* cfd_;
1365
+ // Maximum ID of memtable to flush. In this column family, memtables with
1366
+ // IDs smaller than this value must be flushed before this flush completes.
1367
+ uint64_t max_memtable_id_;
1368
+ // Pointer to a SuperVersionContext object. After flush completes, RocksDB
1369
+ // installs a new superversion for the column family. This operation
1370
+ // requires a SuperVersionContext object (currently embedded in JobContext).
1371
+ SuperVersionContext* superversion_context_;
1372
+ };
1373
+
1374
+ // Argument passed to flush thread.
1375
+ struct FlushThreadArg {
1376
+ DBImpl* db_;
1377
+
1378
+ Env::Priority thread_pri_;
1379
+ };
1380
+
1381
+ // Information for a manual compaction
1382
+ struct ManualCompactionState {
1383
+ ColumnFamilyData* cfd;
1384
+ int input_level;
1385
+ int output_level;
1386
+ uint32_t output_path_id;
1387
+ Status status;
1388
+ bool done;
1389
+ bool in_progress; // compaction request being processed?
1390
+ bool incomplete; // only part of requested range compacted
1391
+ bool exclusive; // current behavior of only one manual
1392
+ bool disallow_trivial_move; // Force actual compaction to run
1393
+ const InternalKey* begin; // nullptr means beginning of key range
1394
+ const InternalKey* end; // nullptr means end of key range
1395
+ InternalKey* manual_end; // how far we are compacting
1396
+ InternalKey tmp_storage; // Used to keep track of compaction progress
1397
+ InternalKey tmp_storage1; // Used to keep track of compaction progress
1398
+ };
1399
+ struct PrepickedCompaction {
1400
+ // background compaction takes ownership of `compaction`.
1401
+ Compaction* compaction;
1402
+ // caller retains ownership of `manual_compaction_state` as it is reused
1403
+ // across background compactions.
1404
+ ManualCompactionState* manual_compaction_state; // nullptr if non-manual
1405
+ // task limiter token is requested during compaction picking.
1406
+ std::unique_ptr<TaskLimiterToken> task_token;
1407
+ };
1408
+
1409
+ struct CompactionArg {
1410
+ // caller retains ownership of `db`.
1411
+ DBImpl* db;
1412
+ // background compaction takes ownership of `prepicked_compaction`.
1413
+ PrepickedCompaction* prepicked_compaction;
1414
+ };
1415
+
1416
+ // Initialize the built-in column family for persistent stats. Depending on
1417
+ // whether on-disk persistent stats have been enabled before, it may either
1418
+ // create a new column family and column family handle or just a column family
1419
+ // handle.
1420
+ // Required: DB mutex held
1421
+ Status InitPersistStatsColumnFamily();
1422
+
1423
+ // Persistent Stats column family has two format version key which are used
1424
+ // for compatibility check. Write format version if it's created for the
1425
+ // first time, read format version and check compatibility if recovering
1426
+ // from disk. This function requires DB mutex held at entrance but may
1427
+ // release and re-acquire DB mutex in the process.
1428
+ // Required: DB mutex held
1429
+ Status PersistentStatsProcessFormatVersion();
1430
+
1431
+ Status ResumeImpl(DBRecoverContext context);
1432
+
1433
+ void MaybeIgnoreError(Status* s) const;
1434
+
1435
+ const Status CreateArchivalDirectory();
1436
+
1437
+ Status CreateColumnFamilyImpl(const ColumnFamilyOptions& cf_options,
1438
+ const std::string& cf_name,
1439
+ ColumnFamilyHandle** handle);
1440
+
1441
+ Status DropColumnFamilyImpl(ColumnFamilyHandle* column_family);
1442
+
1443
+ // Delete any unneeded files and stale in-memory entries.
1444
+ void DeleteObsoleteFiles();
1445
+ // Delete obsolete files and log status and information of file deletion
1446
+ void DeleteObsoleteFileImpl(int job_id, const std::string& fname,
1447
+ const std::string& path_to_sync, FileType type,
1448
+ uint64_t number);
1449
+
1450
+ // Background process needs to call
1451
+ // auto x = CaptureCurrentFileNumberInPendingOutputs()
1452
+ // auto file_num = versions_->NewFileNumber();
1453
+ // <do something>
1454
+ // ReleaseFileNumberFromPendingOutputs(x)
1455
+ // This will protect any file with number `file_num` or greater from being
1456
+ // deleted while <do something> is running.
1457
+ // -----------
1458
+ // This function will capture current file number and append it to
1459
+ // pending_outputs_. This will prevent any background process to delete any
1460
+ // file created after this point.
1461
+ std::list<uint64_t>::iterator CaptureCurrentFileNumberInPendingOutputs();
1462
+ // This function should be called with the result of
1463
+ // CaptureCurrentFileNumberInPendingOutputs(). It then marks that any file
1464
+ // created between the calls CaptureCurrentFileNumberInPendingOutputs() and
1465
+ // ReleaseFileNumberFromPendingOutputs() can now be deleted (if it's not live
1466
+ // and blocked by any other pending_outputs_ calls)
1467
+ void ReleaseFileNumberFromPendingOutputs(
1468
+ std::unique_ptr<std::list<uint64_t>::iterator>& v);
1469
+
1470
+ IOStatus SyncClosedLogs(JobContext* job_context);
1471
+
1472
+ // Flush the in-memory write buffer to storage. Switches to a new
1473
+ // log-file/memtable and writes a new descriptor iff successful. Then
1474
+ // installs a new super version for the column family.
1475
+ Status FlushMemTableToOutputFile(
1476
+ ColumnFamilyData* cfd, const MutableCFOptions& mutable_cf_options,
1477
+ bool* madeProgress, JobContext* job_context,
1478
+ SuperVersionContext* superversion_context,
1479
+ std::vector<SequenceNumber>& snapshot_seqs,
1480
+ SequenceNumber earliest_write_conflict_snapshot,
1481
+ SnapshotChecker* snapshot_checker, LogBuffer* log_buffer,
1482
+ Env::Priority thread_pri);
1483
+
1484
+ // Flush the memtables of (multiple) column families to multiple files on
1485
+ // persistent storage.
1486
+ Status FlushMemTablesToOutputFiles(
1487
+ const autovector<BGFlushArg>& bg_flush_args, bool* made_progress,
1488
+ JobContext* job_context, LogBuffer* log_buffer, Env::Priority thread_pri);
1489
+
1490
+ Status AtomicFlushMemTablesToOutputFiles(
1491
+ const autovector<BGFlushArg>& bg_flush_args, bool* made_progress,
1492
+ JobContext* job_context, LogBuffer* log_buffer, Env::Priority thread_pri);
1493
+
1494
+ // REQUIRES: log_numbers are sorted in ascending order
1495
+ // corrupted_log_found is set to true if we recover from a corrupted log file.
1496
+ Status RecoverLogFiles(const std::vector<uint64_t>& log_numbers,
1497
+ SequenceNumber* next_sequence, bool read_only,
1498
+ bool* corrupted_log_found);
1499
+
1500
+ // The following two methods are used to flush a memtable to
1501
+ // storage. The first one is used at database RecoveryTime (when the
1502
+ // database is opened) and is heavyweight because it holds the mutex
1503
+ // for the entire period. The second method WriteLevel0Table supports
1504
+ // concurrent flush memtables to storage.
1505
+ Status WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
1506
+ MemTable* mem, VersionEdit* edit);
1507
+
1508
+ // Restore alive_log_files_ and total_log_size_ after recovery.
1509
+ // It needs to run only when there's no flush during recovery
1510
+ // (e.g. avoid_flush_during_recovery=true). May also trigger flush
1511
+ // in case total_log_size > max_total_wal_size.
1512
+ Status RestoreAliveLogFiles(const std::vector<uint64_t>& log_numbers);
1513
+
1514
+ // num_bytes: for slowdown case, delay time is calculated based on
1515
+ // `num_bytes` going through.
1516
+ Status DelayWrite(uint64_t num_bytes, const WriteOptions& write_options);
1517
+
1518
+ Status ThrottleLowPriWritesIfNeeded(const WriteOptions& write_options,
1519
+ WriteBatch* my_batch);
1520
+
1521
+ // REQUIRES: mutex locked and in write thread.
1522
+ Status ScheduleFlushes(WriteContext* context);
1523
+
1524
+ void MaybeFlushStatsCF(autovector<ColumnFamilyData*>* cfds);
1525
+
1526
+ Status TrimMemtableHistory(WriteContext* context);
1527
+
1528
+ Status SwitchMemtable(ColumnFamilyData* cfd, WriteContext* context);
1529
+
1530
+ void SelectColumnFamiliesForAtomicFlush(autovector<ColumnFamilyData*>* cfds);
1531
+
1532
+ // Force current memtable contents to be flushed.
1533
+ Status FlushMemTable(ColumnFamilyData* cfd, const FlushOptions& options,
1534
+ FlushReason flush_reason, bool writes_stopped = false);
1535
+
1536
+ Status AtomicFlushMemTables(
1537
+ const autovector<ColumnFamilyData*>& column_family_datas,
1538
+ const FlushOptions& options, FlushReason flush_reason,
1539
+ bool writes_stopped = false);
1540
+
1541
+ // Wait until flushing this column family won't stall writes
1542
+ Status WaitUntilFlushWouldNotStallWrites(ColumnFamilyData* cfd,
1543
+ bool* flush_needed);
1544
+
1545
+ // Wait for memtable flushed.
1546
+ // If flush_memtable_id is non-null, wait until the memtable with the ID
1547
+ // gets flush. Otherwise, wait until the column family don't have any
1548
+ // memtable pending flush.
1549
+ // resuming_from_bg_err indicates whether the caller is attempting to resume
1550
+ // from background error.
1551
+ Status WaitForFlushMemTable(ColumnFamilyData* cfd,
1552
+ const uint64_t* flush_memtable_id = nullptr,
1553
+ bool resuming_from_bg_err = false) {
1554
+ return WaitForFlushMemTables({cfd}, {flush_memtable_id},
1555
+ resuming_from_bg_err);
1556
+ }
1557
+ // Wait for memtables to be flushed for multiple column families.
1558
+ Status WaitForFlushMemTables(
1559
+ const autovector<ColumnFamilyData*>& cfds,
1560
+ const autovector<const uint64_t*>& flush_memtable_ids,
1561
+ bool resuming_from_bg_err);
1562
+
1563
+ inline void WaitForPendingWrites() {
1564
+ mutex_.AssertHeld();
1565
+ TEST_SYNC_POINT("DBImpl::WaitForPendingWrites:BeforeBlock");
1566
+ // In case of pipelined write is enabled, wait for all pending memtable
1567
+ // writers.
1568
+ if (immutable_db_options_.enable_pipelined_write) {
1569
+ // Memtable writers may call DB::Get in case max_successive_merges > 0,
1570
+ // which may lock mutex. Unlocking mutex here to avoid deadlock.
1571
+ mutex_.Unlock();
1572
+ write_thread_.WaitForMemTableWriters();
1573
+ mutex_.Lock();
1574
+ }
1575
+
1576
+ if (!immutable_db_options_.unordered_write) {
1577
+ // Then the writes are finished before the next write group starts
1578
+ return;
1579
+ }
1580
+
1581
+ // Wait for the ones who already wrote to the WAL to finish their
1582
+ // memtable write.
1583
+ if (pending_memtable_writes_.load() != 0) {
1584
+ std::unique_lock<std::mutex> guard(switch_mutex_);
1585
+ switch_cv_.wait(guard,
1586
+ [&] { return pending_memtable_writes_.load() == 0; });
1587
+ }
1588
+ }
1589
+
1590
+ // REQUIRES: mutex locked and in write thread.
1591
+ void AssignAtomicFlushSeq(const autovector<ColumnFamilyData*>& cfds);
1592
+
1593
+ // REQUIRES: mutex locked and in write thread.
1594
+ Status SwitchWAL(WriteContext* write_context);
1595
+
1596
+ // REQUIRES: mutex locked and in write thread.
1597
+ Status HandleWriteBufferFull(WriteContext* write_context);
1598
+
1599
+ // REQUIRES: mutex locked
1600
+ Status PreprocessWrite(const WriteOptions& write_options, bool* need_log_sync,
1601
+ WriteContext* write_context);
1602
+
1603
+ WriteBatch* MergeBatch(const WriteThread::WriteGroup& write_group,
1604
+ WriteBatch* tmp_batch, size_t* write_with_wal,
1605
+ WriteBatch** to_be_cached_state);
1606
+
1607
+ IOStatus WriteToWAL(const WriteBatch& merged_batch, log::Writer* log_writer,
1608
+ uint64_t* log_used, uint64_t* log_size);
1609
+
1610
+ IOStatus WriteToWAL(const WriteThread::WriteGroup& write_group,
1611
+ log::Writer* log_writer, uint64_t* log_used,
1612
+ bool need_log_sync, bool need_log_dir_sync,
1613
+ SequenceNumber sequence);
1614
+
1615
+ IOStatus ConcurrentWriteToWAL(const WriteThread::WriteGroup& write_group,
1616
+ uint64_t* log_used,
1617
+ SequenceNumber* last_sequence, size_t seq_inc);
1618
+
1619
+ // Used by WriteImpl to update bg_error_ if paranoid check is enabled.
1620
+ // Caller must hold mutex_.
1621
+ void WriteStatusCheckOnLocked(const Status& status);
1622
+
1623
+ // Used by WriteImpl to update bg_error_ if paranoid check is enabled.
1624
+ void WriteStatusCheck(const Status& status);
1625
+
1626
+ // Used by WriteImpl to update bg_error_ when IO error happens, e.g., write
1627
+ // WAL, sync WAL fails, if paranoid check is enabled.
1628
+ void IOStatusCheck(const IOStatus& status);
1629
+
1630
+ // Used by WriteImpl to update bg_error_ in case of memtable insert error.
1631
+ void MemTableInsertStatusCheck(const Status& memtable_insert_status);
1632
+
1633
+ #ifndef ROCKSDB_LITE
1634
+
1635
+ Status CompactFilesImpl(const CompactionOptions& compact_options,
1636
+ ColumnFamilyData* cfd, Version* version,
1637
+ const std::vector<std::string>& input_file_names,
1638
+ std::vector<std::string>* const output_file_names,
1639
+ const int output_level, int output_path_id,
1640
+ JobContext* job_context, LogBuffer* log_buffer,
1641
+ CompactionJobInfo* compaction_job_info);
1642
+
1643
+ // Wait for current IngestExternalFile() calls to finish.
1644
+ // REQUIRES: mutex_ held
1645
+ void WaitForIngestFile();
1646
+
1647
+ #else
1648
+ // IngestExternalFile is not supported in ROCKSDB_LITE so this function
1649
+ // will be no-op
1650
+ void WaitForIngestFile() {}
1651
+ #endif // ROCKSDB_LITE
1652
+
1653
+ ColumnFamilyData* GetColumnFamilyDataByName(const std::string& cf_name);
1654
+
1655
+ void MaybeScheduleFlushOrCompaction();
1656
+
1657
+ // A flush request specifies the column families to flush as well as the
1658
+ // largest memtable id to persist for each column family. Once all the
1659
+ // memtables whose IDs are smaller than or equal to this per-column-family
1660
+ // specified value, this flush request is considered to have completed its
1661
+ // work of flushing this column family. After completing the work for all
1662
+ // column families in this request, this flush is considered complete.
1663
+ typedef std::vector<std::pair<ColumnFamilyData*, uint64_t>> FlushRequest;
1664
+
1665
+ void GenerateFlushRequest(const autovector<ColumnFamilyData*>& cfds,
1666
+ FlushRequest* req);
1667
+
1668
+ void SchedulePendingFlush(const FlushRequest& req, FlushReason flush_reason);
1669
+
1670
+ void SchedulePendingCompaction(ColumnFamilyData* cfd);
1671
+ void SchedulePendingPurge(std::string fname, std::string dir_to_sync,
1672
+ FileType type, uint64_t number, int job_id);
1673
+ static void BGWorkCompaction(void* arg);
1674
+ // Runs a pre-chosen universal compaction involving bottom level in a
1675
+ // separate, bottom-pri thread pool.
1676
+ static void BGWorkBottomCompaction(void* arg);
1677
+ static void BGWorkFlush(void* arg);
1678
+ static void BGWorkPurge(void* arg);
1679
+ static void UnscheduleCompactionCallback(void* arg);
1680
+ static void UnscheduleFlushCallback(void* arg);
1681
+ void BackgroundCallCompaction(PrepickedCompaction* prepicked_compaction,
1682
+ Env::Priority thread_pri);
1683
+ void BackgroundCallFlush(Env::Priority thread_pri);
1684
+ void BackgroundCallPurge();
1685
+ Status BackgroundCompaction(bool* madeProgress, JobContext* job_context,
1686
+ LogBuffer* log_buffer,
1687
+ PrepickedCompaction* prepicked_compaction,
1688
+ Env::Priority thread_pri);
1689
+ Status BackgroundFlush(bool* madeProgress, JobContext* job_context,
1690
+ LogBuffer* log_buffer, FlushReason* reason,
1691
+ Env::Priority thread_pri);
1692
+
1693
+ bool EnoughRoomForCompaction(ColumnFamilyData* cfd,
1694
+ const std::vector<CompactionInputFiles>& inputs,
1695
+ bool* sfm_bookkeeping, LogBuffer* log_buffer);
1696
+
1697
+ // Request compaction tasks token from compaction thread limiter.
1698
+ // It always succeeds if force = true or limiter is disable.
1699
+ bool RequestCompactionToken(ColumnFamilyData* cfd, bool force,
1700
+ std::unique_ptr<TaskLimiterToken>* token,
1701
+ LogBuffer* log_buffer);
1702
+
1703
+ // Schedule background tasks
1704
+ void StartPeriodicWorkScheduler();
1705
+
1706
+ void PrintStatistics();
1707
+
1708
+ size_t EstimateInMemoryStatsHistorySize() const;
1709
+
1710
+ // Return the minimum empty level that could hold the total data in the
1711
+ // input level. Return the input level, if such level could not be found.
1712
+ int FindMinimumEmptyLevelFitting(ColumnFamilyData* cfd,
1713
+ const MutableCFOptions& mutable_cf_options,
1714
+ int level);
1715
+
1716
+ // Move the files in the input level to the target level.
1717
+ // If target_level < 0, automatically calculate the minimum level that could
1718
+ // hold the data set.
1719
+ Status ReFitLevel(ColumnFamilyData* cfd, int level, int target_level = -1);
1720
+
1721
+ // helper functions for adding and removing from flush & compaction queues
1722
+ void AddToCompactionQueue(ColumnFamilyData* cfd);
1723
+ ColumnFamilyData* PopFirstFromCompactionQueue();
1724
+ FlushRequest PopFirstFromFlushQueue();
1725
+
1726
+ // Pick the first unthrottled compaction with task token from queue.
1727
+ ColumnFamilyData* PickCompactionFromQueue(
1728
+ std::unique_ptr<TaskLimiterToken>* token, LogBuffer* log_buffer);
1729
+
1730
+ // helper function to call after some of the logs_ were synced
1731
+ Status MarkLogsSynced(uint64_t up_to, bool synced_dir);
1732
+ // WALs with log number up to up_to are not synced successfully.
1733
+ void MarkLogsNotSynced(uint64_t up_to);
1734
+
1735
+ SnapshotImpl* GetSnapshotImpl(bool is_write_conflict_boundary,
1736
+ bool lock = true);
1737
+
1738
+ uint64_t GetMaxTotalWalSize() const;
1739
+
1740
+ FSDirectory* GetDataDir(ColumnFamilyData* cfd, size_t path_id) const;
1741
+
1742
+ Status CloseHelper();
1743
+
1744
+ void WaitForBackgroundWork();
1745
+
1746
+ // Background threads call this function, which is just a wrapper around
1747
+ // the InstallSuperVersion() function. Background threads carry
1748
+ // sv_context which can have new_superversion already
1749
+ // allocated.
1750
+ // All ColumnFamily state changes go through this function. Here we analyze
1751
+ // the new state and we schedule background work if we detect that the new
1752
+ // state needs flush or compaction.
1753
+ void InstallSuperVersionAndScheduleWork(
1754
+ ColumnFamilyData* cfd, SuperVersionContext* sv_context,
1755
+ const MutableCFOptions& mutable_cf_options);
1756
+
1757
+ bool GetIntPropertyInternal(ColumnFamilyData* cfd,
1758
+ const DBPropertyInfo& property_info,
1759
+ bool is_locked, uint64_t* value);
1760
+ bool GetPropertyHandleOptionsStatistics(std::string* value);
1761
+
1762
+ bool HasPendingManualCompaction();
1763
+ bool HasExclusiveManualCompaction();
1764
+ void AddManualCompaction(ManualCompactionState* m);
1765
+ void RemoveManualCompaction(ManualCompactionState* m);
1766
+ bool ShouldntRunManualCompaction(ManualCompactionState* m);
1767
+ bool HaveManualCompaction(ColumnFamilyData* cfd);
1768
+ bool MCOverlap(ManualCompactionState* m, ManualCompactionState* m1);
1769
+ #ifndef ROCKSDB_LITE
1770
+ void BuildCompactionJobInfo(const ColumnFamilyData* cfd, Compaction* c,
1771
+ const Status& st,
1772
+ const CompactionJobStats& compaction_job_stats,
1773
+ const int job_id, const Version* current,
1774
+ CompactionJobInfo* compaction_job_info) const;
1775
+ // Reserve the next 'num' file numbers for to-be-ingested external SST files,
1776
+ // and return the current file_number in 'next_file_number'.
1777
+ // Write a version edit to the MANIFEST.
1778
+ Status ReserveFileNumbersBeforeIngestion(
1779
+ ColumnFamilyData* cfd, uint64_t num,
1780
+ std::unique_ptr<std::list<uint64_t>::iterator>& pending_output_elem,
1781
+ uint64_t* next_file_number);
1782
+ #endif //! ROCKSDB_LITE
1783
+
1784
+ bool ShouldPurge(uint64_t file_number) const;
1785
+ void MarkAsGrabbedForPurge(uint64_t file_number);
1786
+
1787
+ size_t GetWalPreallocateBlockSize(uint64_t write_buffer_size) const;
1788
+ Env::WriteLifeTimeHint CalculateWALWriteHint() { return Env::WLTH_SHORT; }
1789
+
1790
+ IOStatus CreateWAL(uint64_t log_file_num, uint64_t recycle_log_number,
1791
+ size_t preallocate_block_size, log::Writer** new_log);
1792
+
1793
+ // Validate self-consistency of DB options
1794
+ static Status ValidateOptions(const DBOptions& db_options);
1795
+ // Validate self-consistency of DB options and its consistency with cf options
1796
+ static Status ValidateOptions(
1797
+ const DBOptions& db_options,
1798
+ const std::vector<ColumnFamilyDescriptor>& column_families);
1799
+
1800
+ // Utility function to do some debug validation and sort the given vector
1801
+ // of MultiGet keys
1802
+ void PrepareMultiGetKeys(
1803
+ const size_t num_keys, bool sorted,
1804
+ autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE>* key_ptrs);
1805
+
1806
+ // A structure to hold the information required to process MultiGet of keys
1807
+ // belonging to one column family. For a multi column family MultiGet, there
1808
+ // will be a container of these objects.
1809
+ struct MultiGetColumnFamilyData {
1810
+ ColumnFamilyHandle* cf;
1811
+ ColumnFamilyData* cfd;
1812
+
1813
+ // For the batched MultiGet which relies on sorted keys, start specifies
1814
+ // the index of first key belonging to this column family in the sorted
1815
+ // list.
1816
+ size_t start;
1817
+
1818
+ // For the batched MultiGet case, num_keys specifies the number of keys
1819
+ // belonging to this column family in the sorted list
1820
+ size_t num_keys;
1821
+
1822
+ // SuperVersion for the column family obtained in a manner that ensures a
1823
+ // consistent view across all column families in the DB
1824
+ SuperVersion* super_version;
1825
+ MultiGetColumnFamilyData(ColumnFamilyHandle* column_family,
1826
+ SuperVersion* sv)
1827
+ : cf(column_family),
1828
+ cfd(static_cast<ColumnFamilyHandleImpl*>(cf)->cfd()),
1829
+ start(0),
1830
+ num_keys(0),
1831
+ super_version(sv) {}
1832
+
1833
+ MultiGetColumnFamilyData(ColumnFamilyHandle* column_family, size_t first,
1834
+ size_t count, SuperVersion* sv)
1835
+ : cf(column_family),
1836
+ cfd(static_cast<ColumnFamilyHandleImpl*>(cf)->cfd()),
1837
+ start(first),
1838
+ num_keys(count),
1839
+ super_version(sv) {}
1840
+
1841
+ MultiGetColumnFamilyData() = default;
1842
+ };
1843
+
1844
+ // A common function to obtain a consistent snapshot, which can be implicit
1845
+ // if the user doesn't specify a snapshot in read_options, across
1846
+ // multiple column families for MultiGet. It will attempt to get an implicit
1847
+ // snapshot without acquiring the db_mutes, but will give up after a few
1848
+ // tries and acquire the mutex if a memtable flush happens. The template
1849
+ // allows both the batched and non-batched MultiGet to call this with
1850
+ // either an std::unordered_map or autovector of column families.
1851
+ //
1852
+ // If callback is non-null, the callback is refreshed with the snapshot
1853
+ // sequence number
1854
+ //
1855
+ // A return value of true indicates that the SuperVersions were obtained
1856
+ // from the ColumnFamilyData, whereas false indicates they are thread
1857
+ // local
1858
+ template <class T>
1859
+ bool MultiCFSnapshot(
1860
+ const ReadOptions& read_options, ReadCallback* callback,
1861
+ std::function<MultiGetColumnFamilyData*(typename T::iterator&)>&
1862
+ iter_deref_func,
1863
+ T* cf_list, SequenceNumber* snapshot);
1864
+
1865
+ // The actual implementation of the batching MultiGet. The caller is expected
1866
+ // to have acquired the SuperVersion and pass in a snapshot sequence number
1867
+ // in order to construct the LookupKeys. The start_key and num_keys specify
1868
+ // the range of keys in the sorted_keys vector for a single column family.
1869
+ Status MultiGetImpl(
1870
+ const ReadOptions& read_options, size_t start_key, size_t num_keys,
1871
+ autovector<KeyContext*, MultiGetContext::MAX_BATCH_SIZE>* sorted_keys,
1872
+ SuperVersion* sv, SequenceNumber snap_seqnum, ReadCallback* callback);
1873
+
1874
+ Status DisableFileDeletionsWithLock();
1875
+
1876
+ // table_cache_ provides its own synchronization
1877
+ std::shared_ptr<Cache> table_cache_;
1878
+
1879
+ // Lock over the persistent DB state. Non-nullptr iff successfully acquired.
1880
+ FileLock* db_lock_;
1881
+
1882
+ // In addition to mutex_, log_write_mutex_ protected writes to stats_history_
1883
+ InstrumentedMutex stats_history_mutex_;
1884
+ // In addition to mutex_, log_write_mutex_ protected writes to logs_ and
1885
+ // logfile_number_. With two_write_queues it also protects alive_log_files_,
1886
+ // and log_empty_. Refer to the definition of each variable below for more
1887
+ // details.
1888
+ // Note: to avoid dealock, if needed to acquire both log_write_mutex_ and
1889
+ // mutex_, the order should be first mutex_ and then log_write_mutex_.
1890
+ InstrumentedMutex log_write_mutex_;
1891
+
1892
+ std::atomic<bool> shutting_down_;
1893
+
1894
+ // If zero, manual compactions are allowed to proceed. If non-zero, manual
1895
+ // compactions may still be running, but will quickly fail with
1896
+ // `Status::Incomplete`. The value indicates how many threads have paused
1897
+ // manual compactions. It is accessed in read mode outside the DB mutex in
1898
+ // compaction code paths.
1899
+ std::atomic<int> manual_compaction_paused_;
1900
+
1901
+ // This condition variable is signaled on these conditions:
1902
+ // * whenever bg_compaction_scheduled_ goes down to 0
1903
+ // * if AnyManualCompaction, whenever a compaction finishes, even if it hasn't
1904
+ // made any progress
1905
+ // * whenever a compaction made any progress
1906
+ // * whenever bg_flush_scheduled_ or bg_purge_scheduled_ value decreases
1907
+ // (i.e. whenever a flush is done, even if it didn't make any progress)
1908
+ // * whenever there is an error in background purge, flush or compaction
1909
+ // * whenever num_running_ingest_file_ goes to 0.
1910
+ // * whenever pending_purge_obsolete_files_ goes to 0.
1911
+ // * whenever disable_delete_obsolete_files_ goes to 0.
1912
+ // * whenever SetOptions successfully updates options.
1913
+ // * whenever a column family is dropped.
1914
+ InstrumentedCondVar bg_cv_;
1915
+ // Writes are protected by locking both mutex_ and log_write_mutex_, and reads
1916
+ // must be under either mutex_ or log_write_mutex_. Since after ::Open,
1917
+ // logfile_number_ is currently updated only in write_thread_, it can be read
1918
+ // from the same write_thread_ without any locks.
1919
+ uint64_t logfile_number_;
1920
+ std::deque<uint64_t>
1921
+ log_recycle_files_; // a list of log files that we can recycle
1922
+ bool log_dir_synced_;
1923
+ // Without two_write_queues, read and writes to log_empty_ are protected by
1924
+ // mutex_. Since it is currently updated/read only in write_thread_, it can be
1925
+ // accessed from the same write_thread_ without any locks. With
1926
+ // two_write_queues writes, where it can be updated in different threads,
1927
+ // read and writes are protected by log_write_mutex_ instead. This is to avoid
1928
+ // expesnive mutex_ lock during WAL write, which update log_empty_.
1929
+ bool log_empty_;
1930
+
1931
+ ColumnFamilyHandleImpl* persist_stats_cf_handle_;
1932
+
1933
+ bool persistent_stats_cfd_exists_ = true;
1934
+
1935
+ // Without two_write_queues, read and writes to alive_log_files_ are
1936
+ // protected by mutex_. However since back() is never popped, and push_back()
1937
+ // is done only from write_thread_, the same thread can access the item
1938
+ // reffered by back() without mutex_. With two_write_queues_, writes
1939
+ // are protected by locking both mutex_ and log_write_mutex_, and reads must
1940
+ // be under either mutex_ or log_write_mutex_.
1941
+ std::deque<LogFileNumberSize> alive_log_files_;
1942
+ // Log files that aren't fully synced, and the current log file.
1943
+ // Synchronization:
1944
+ // - push_back() is done from write_thread_ with locked mutex_ and
1945
+ // log_write_mutex_
1946
+ // - pop_front() is done from any thread with locked mutex_ and
1947
+ // log_write_mutex_
1948
+ // - reads are done with either locked mutex_ or log_write_mutex_
1949
+ // - back() and items with getting_synced=true are not popped,
1950
+ // - The same thread that sets getting_synced=true will reset it.
1951
+ // - it follows that the object referred by back() can be safely read from
1952
+ // the write_thread_ without using mutex
1953
+ // - it follows that the items with getting_synced=true can be safely read
1954
+ // from the same thread that has set getting_synced=true
1955
+ std::deque<LogWriterNumber> logs_;
1956
+ // Signaled when getting_synced becomes false for some of the logs_.
1957
+ InstrumentedCondVar log_sync_cv_;
1958
+ // This is the app-level state that is written to the WAL but will be used
1959
+ // only during recovery. Using this feature enables not writing the state to
1960
+ // memtable on normal writes and hence improving the throughput. Each new
1961
+ // write of the state will replace the previous state entirely even if the
1962
+ // keys in the two consecuitive states do not overlap.
1963
+ // It is protected by log_write_mutex_ when two_write_queues_ is enabled.
1964
+ // Otherwise only the heaad of write_thread_ can access it.
1965
+ WriteBatch cached_recoverable_state_;
1966
+ std::atomic<bool> cached_recoverable_state_empty_ = {true};
1967
+ std::atomic<uint64_t> total_log_size_;
1968
+
1969
+ // If this is non-empty, we need to delete these log files in background
1970
+ // threads. Protected by db mutex.
1971
+ autovector<log::Writer*> logs_to_free_;
1972
+
1973
+ bool is_snapshot_supported_;
1974
+
1975
+ std::map<uint64_t, std::map<std::string, uint64_t>> stats_history_;
1976
+
1977
+ std::map<std::string, uint64_t> stats_slice_;
1978
+
1979
+ bool stats_slice_initialized_ = false;
1980
+
1981
+ Directories directories_;
1982
+
1983
+ WriteBufferManager* write_buffer_manager_;
1984
+
1985
+ WriteThread write_thread_;
1986
+ WriteBatch tmp_batch_;
1987
+ // The write thread when the writers have no memtable write. This will be used
1988
+ // in 2PC to batch the prepares separately from the serial commit.
1989
+ WriteThread nonmem_write_thread_;
1990
+
1991
+ WriteController write_controller_;
1992
+
1993
+ // Size of the last batch group. In slowdown mode, next write needs to
1994
+ // sleep if it uses up the quota.
1995
+ // Note: This is to protect memtable and compaction. If the batch only writes
1996
+ // to the WAL its size need not to be included in this.
1997
+ uint64_t last_batch_group_size_;
1998
+
1999
+ FlushScheduler flush_scheduler_;
2000
+
2001
+ TrimHistoryScheduler trim_history_scheduler_;
2002
+
2003
+ SnapshotList snapshots_;
2004
+
2005
+ // For each background job, pending_outputs_ keeps the current file number at
2006
+ // the time that background job started.
2007
+ // FindObsoleteFiles()/PurgeObsoleteFiles() never deletes any file that has
2008
+ // number bigger than any of the file number in pending_outputs_. Since file
2009
+ // numbers grow monotonically, this also means that pending_outputs_ is always
2010
+ // sorted. After a background job is done executing, its file number is
2011
+ // deleted from pending_outputs_, which allows PurgeObsoleteFiles() to clean
2012
+ // it up.
2013
+ // State is protected with db mutex.
2014
+ std::list<uint64_t> pending_outputs_;
2015
+
2016
+ // flush_queue_ and compaction_queue_ hold column families that we need to
2017
+ // flush and compact, respectively.
2018
+ // A column family is inserted into flush_queue_ when it satisfies condition
2019
+ // cfd->imm()->IsFlushPending()
2020
+ // A column family is inserted into compaction_queue_ when it satisfied
2021
+ // condition cfd->NeedsCompaction()
2022
+ // Column families in this list are all Ref()-erenced
2023
+ // TODO(icanadi) Provide some kind of ReferencedColumnFamily class that will
2024
+ // do RAII on ColumnFamilyData
2025
+ // Column families are in this queue when they need to be flushed or
2026
+ // compacted. Consumers of these queues are flush and compaction threads. When
2027
+ // column family is put on this queue, we increase unscheduled_flushes_ and
2028
+ // unscheduled_compactions_. When these variables are bigger than zero, that
2029
+ // means we need to schedule background threads for flush and compaction.
2030
+ // Once the background threads are scheduled, we decrease unscheduled_flushes_
2031
+ // and unscheduled_compactions_. That way we keep track of number of
2032
+ // compaction and flush threads we need to schedule. This scheduling is done
2033
+ // in MaybeScheduleFlushOrCompaction()
2034
+ // invariant(column family present in flush_queue_ <==>
2035
+ // ColumnFamilyData::pending_flush_ == true)
2036
+ std::deque<FlushRequest> flush_queue_;
2037
+ // invariant(column family present in compaction_queue_ <==>
2038
+ // ColumnFamilyData::pending_compaction_ == true)
2039
+ std::deque<ColumnFamilyData*> compaction_queue_;
2040
+
2041
+ // A map to store file numbers and filenames of the files to be purged
2042
+ std::unordered_map<uint64_t, PurgeFileInfo> purge_files_;
2043
+
2044
+ // A vector to store the file numbers that have been assigned to certain
2045
+ // JobContext. Current implementation tracks table and blob files only.
2046
+ std::unordered_set<uint64_t> files_grabbed_for_purge_;
2047
+
2048
+ // A queue to store log writers to close
2049
+ std::deque<log::Writer*> logs_to_free_queue_;
2050
+ std::deque<SuperVersion*> superversions_to_free_queue_;
2051
+ int unscheduled_flushes_;
2052
+ int unscheduled_compactions_;
2053
+
2054
+ // count how many background compactions are running or have been scheduled in
2055
+ // the BOTTOM pool
2056
+ int bg_bottom_compaction_scheduled_;
2057
+
2058
+ // count how many background compactions are running or have been scheduled
2059
+ int bg_compaction_scheduled_;
2060
+
2061
+ // stores the number of compactions are currently running
2062
+ int num_running_compactions_;
2063
+
2064
+ // number of background memtable flush jobs, submitted to the HIGH pool
2065
+ int bg_flush_scheduled_;
2066
+
2067
+ // stores the number of flushes are currently running
2068
+ int num_running_flushes_;
2069
+
2070
+ // number of background obsolete file purge jobs, submitted to the HIGH pool
2071
+ int bg_purge_scheduled_;
2072
+
2073
+ std::deque<ManualCompactionState*> manual_compaction_dequeue_;
2074
+
2075
+ // shall we disable deletion of obsolete files
2076
+ // if 0 the deletion is enabled.
2077
+ // if non-zero, files will not be getting deleted
2078
+ // This enables two different threads to call
2079
+ // EnableFileDeletions() and DisableFileDeletions()
2080
+ // without any synchronization
2081
+ int disable_delete_obsolete_files_;
2082
+
2083
+ // Number of times FindObsoleteFiles has found deletable files and the
2084
+ // corresponding call to PurgeObsoleteFiles has not yet finished.
2085
+ int pending_purge_obsolete_files_;
2086
+
2087
+ // last time when DeleteObsoleteFiles with full scan was executed. Originally
2088
+ // initialized with startup time.
2089
+ uint64_t delete_obsolete_files_last_run_;
2090
+
2091
+ // last time stats were dumped to LOG
2092
+ std::atomic<uint64_t> last_stats_dump_time_microsec_;
2093
+
2094
+ // The thread that wants to switch memtable, can wait on this cv until the
2095
+ // pending writes to memtable finishes.
2096
+ std::condition_variable switch_cv_;
2097
+ // The mutex used by switch_cv_. mutex_ should be acquired beforehand.
2098
+ std::mutex switch_mutex_;
2099
+ // Number of threads intending to write to memtable
2100
+ std::atomic<size_t> pending_memtable_writes_ = {};
2101
+
2102
+ // Each flush or compaction gets its own job id. this counter makes sure
2103
+ // they're unique
2104
+ std::atomic<int> next_job_id_;
2105
+
2106
+ // A flag indicating whether the current rocksdb database has any
2107
+ // data that is not yet persisted into either WAL or SST file.
2108
+ // Used when disableWAL is true.
2109
+ std::atomic<bool> has_unpersisted_data_;
2110
+
2111
+ // if an attempt was made to flush all column families that
2112
+ // the oldest log depends on but uncommitted data in the oldest
2113
+ // log prevents the log from being released.
2114
+ // We must attempt to free the dependent memtables again
2115
+ // at a later time after the transaction in the oldest
2116
+ // log is fully commited.
2117
+ bool unable_to_release_oldest_log_;
2118
+
2119
+ static const int KEEP_LOG_FILE_NUM = 1000;
2120
+ // MSVC version 1800 still does not have constexpr for ::max()
2121
+ static const uint64_t kNoTimeOut = port::kMaxUint64;
2122
+
2123
+ std::string db_absolute_path_;
2124
+
2125
+ // Number of running IngestExternalFile() or CreateColumnFamilyWithImport()
2126
+ // calls.
2127
+ // REQUIRES: mutex held
2128
+ int num_running_ingest_file_;
2129
+
2130
+ #ifndef ROCKSDB_LITE
2131
+ WalManager wal_manager_;
2132
+ #endif // ROCKSDB_LITE
2133
+
2134
+ // Unified interface for logging events
2135
+ EventLogger event_logger_;
2136
+
2137
+ // A value of > 0 temporarily disables scheduling of background work
2138
+ int bg_work_paused_;
2139
+
2140
+ // A value of > 0 temporarily disables scheduling of background compaction
2141
+ int bg_compaction_paused_;
2142
+
2143
+ // Guard against multiple concurrent refitting
2144
+ bool refitting_level_;
2145
+
2146
+ // Indicate DB was opened successfully
2147
+ bool opened_successfully_;
2148
+
2149
+ // The min threshold to triggere bottommost compaction for removing
2150
+ // garbages, among all column families.
2151
+ SequenceNumber bottommost_files_mark_threshold_ = kMaxSequenceNumber;
2152
+
2153
+ LogsWithPrepTracker logs_with_prep_tracker_;
2154
+
2155
+ // Callback for compaction to check if a key is visible to a snapshot.
2156
+ // REQUIRES: mutex held
2157
+ std::unique_ptr<SnapshotChecker> snapshot_checker_;
2158
+
2159
+ // Callback for when the cached_recoverable_state_ is written to memtable
2160
+ // Only to be set during initialization
2161
+ std::unique_ptr<PreReleaseCallback> recoverable_state_pre_release_callback_;
2162
+
2163
+ #ifndef ROCKSDB_LITE
2164
+ // Scheduler to run DumpStats(), PersistStats(), and FlushInfoLog().
2165
+ // Currently, it always use a global instance from
2166
+ // PeriodicWorkScheduler::Default(). Only in unittest, it can be overrided by
2167
+ // PeriodicWorkTestScheduler.
2168
+ PeriodicWorkScheduler* periodic_work_scheduler_;
2169
+ #endif
2170
+
2171
+ // When set, we use a separate queue for writes that don't write to memtable.
2172
+ // In 2PC these are the writes at Prepare phase.
2173
+ const bool two_write_queues_;
2174
+ const bool manual_wal_flush_;
2175
+
2176
+ // LastSequence also indicates last published sequence visibile to the
2177
+ // readers. Otherwise LastPublishedSequence should be used.
2178
+ const bool last_seq_same_as_publish_seq_;
2179
+ // It indicates that a customized gc algorithm must be used for
2180
+ // flush/compaction and if it is not provided vis SnapshotChecker, we should
2181
+ // disable gc to be safe.
2182
+ const bool use_custom_gc_;
2183
+ // Flag to indicate that the DB instance shutdown has been initiated. This
2184
+ // different from shutting_down_ atomic in that it is set at the beginning
2185
+ // of shutdown sequence, specifically in order to prevent any background
2186
+ // error recovery from going on in parallel. The latter, shutting_down_,
2187
+ // is set a little later during the shutdown after scheduling memtable
2188
+ // flushes
2189
+ std::atomic<bool> shutdown_initiated_;
2190
+ // Flag to indicate whether sst_file_manager object was allocated in
2191
+ // DB::Open() or passed to us
2192
+ bool own_sfm_;
2193
+
2194
+ // Clients must periodically call SetPreserveDeletesSequenceNumber()
2195
+ // to advance this seqnum. Default value is 0 which means ALL deletes are
2196
+ // preserved. Note that this has no effect if DBOptions.preserve_deletes
2197
+ // is set to false.
2198
+ std::atomic<SequenceNumber> preserve_deletes_seqnum_;
2199
+ const bool preserve_deletes_;
2200
+
2201
+ // Flag to check whether Close() has been called on this DB
2202
+ bool closed_;
2203
+
2204
+ ErrorHandler error_handler_;
2205
+
2206
+ // Conditional variable to coordinate installation of atomic flush results.
2207
+ // With atomic flush, each bg thread installs the result of flushing multiple
2208
+ // column families, and different threads can flush different column
2209
+ // families. It's difficult to rely on one thread to perform batch
2210
+ // installation for all threads. This is different from the non-atomic flush
2211
+ // case.
2212
+ // atomic_flush_install_cv_ makes sure that threads install atomic flush
2213
+ // results sequentially. Flush results of memtables with lower IDs get
2214
+ // installed to MANIFEST first.
2215
+ InstrumentedCondVar atomic_flush_install_cv_;
2216
+
2217
+ bool wal_in_db_path_;
2218
+ };
2219
+
2220
+ extern Options SanitizeOptions(const std::string& db, const Options& src);
2221
+
2222
+ extern DBOptions SanitizeOptions(const std::string& db, const DBOptions& src);
2223
+
2224
+ extern CompressionType GetCompressionFlush(
2225
+ const ImmutableCFOptions& ioptions,
2226
+ const MutableCFOptions& mutable_cf_options);
2227
+
2228
+ // Return the earliest log file to keep after the memtable flush is
2229
+ // finalized.
2230
+ // `cfd_to_flush` is the column family whose memtable (specified in
2231
+ // `memtables_to_flush`) will be flushed and thus will not depend on any WAL
2232
+ // file.
2233
+ // The function is only applicable to 2pc mode.
2234
+ extern uint64_t PrecomputeMinLogNumberToKeep2PC(
2235
+ VersionSet* vset, const ColumnFamilyData& cfd_to_flush,
2236
+ const autovector<VersionEdit*>& edit_list,
2237
+ const autovector<MemTable*>& memtables_to_flush,
2238
+ LogsWithPrepTracker* prep_tracker);
2239
+ // For atomic flush.
2240
+ extern uint64_t PrecomputeMinLogNumberToKeep2PC(
2241
+ VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush,
2242
+ const autovector<autovector<VersionEdit*>>& edit_lists,
2243
+ const autovector<const autovector<MemTable*>*>& memtables_to_flush,
2244
+ LogsWithPrepTracker* prep_tracker);
2245
+
2246
+ // In non-2PC mode, WALs with log number < the returned number can be
2247
+ // deleted after the cfd_to_flush column family is flushed successfully.
2248
+ extern uint64_t PrecomputeMinLogNumberToKeepNon2PC(
2249
+ VersionSet* vset, const ColumnFamilyData& cfd_to_flush,
2250
+ const autovector<VersionEdit*>& edit_list);
2251
+ // For atomic flush.
2252
+ extern uint64_t PrecomputeMinLogNumberToKeepNon2PC(
2253
+ VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush,
2254
+ const autovector<autovector<VersionEdit*>>& edit_lists);
2255
+
2256
+ // `cfd_to_flush` is the column family whose memtable will be flushed and thus
2257
+ // will not depend on any WAL file. nullptr means no memtable is being flushed.
2258
+ // The function is only applicable to 2pc mode.
2259
+ extern uint64_t FindMinPrepLogReferencedByMemTable(
2260
+ VersionSet* vset, const ColumnFamilyData* cfd_to_flush,
2261
+ const autovector<MemTable*>& memtables_to_flush);
2262
+ // For atomic flush.
2263
+ extern uint64_t FindMinPrepLogReferencedByMemTable(
2264
+ VersionSet* vset, const autovector<ColumnFamilyData*>& cfds_to_flush,
2265
+ const autovector<const autovector<MemTable*>*>& memtables_to_flush);
2266
+
2267
+ // Fix user-supplied options to be reasonable
2268
+ template <class T, class V>
2269
+ static void ClipToRange(T* ptr, V minvalue, V maxvalue) {
2270
+ if (static_cast<V>(*ptr) > maxvalue) *ptr = maxvalue;
2271
+ if (static_cast<V>(*ptr) < minvalue) *ptr = minvalue;
2272
+ }
2273
+
2274
+ } // namespace ROCKSDB_NAMESPACE