rocksdb-native 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/binding.c +92 -10
  2. package/index.js +9 -0
  3. package/lib/batch.js +11 -1
  4. package/lib/iterator.js +3 -1
  5. package/lib/snapshot.js +21 -0
  6. package/package.json +1 -1
  7. package/prebuilds/darwin-arm64/rocksdb-native.bare +0 -0
  8. package/prebuilds/darwin-arm64/rocksdb-native.node +0 -0
  9. package/prebuilds/darwin-x64/rocksdb-native.bare +0 -0
  10. package/prebuilds/darwin-x64/rocksdb-native.node +0 -0
  11. package/prebuilds/linux-arm64/rocksdb-native.bare +0 -0
  12. package/prebuilds/linux-arm64/rocksdb-native.node +0 -0
  13. package/prebuilds/linux-x64/rocksdb-native.bare +0 -0
  14. package/prebuilds/linux-x64/rocksdb-native.node +0 -0
  15. package/prebuilds/win32-x64/rocksdb-native.bare +0 -0
  16. package/prebuilds/win32-x64/rocksdb-native.node +0 -0
  17. package/vendor/librocksdb/include/rocksdb.h +38 -4
  18. package/vendor/librocksdb/src/rocksdb.cc +114 -14
  19. package/vendor/librocksdb/vendor/rocksdb/CMakeLists.txt +21 -4
  20. package/vendor/librocksdb/vendor/rocksdb/cache/secondary_cache_adapter.cc +6 -3
  21. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.cc +4 -4
  22. package/vendor/librocksdb/vendor/rocksdb/db/arena_wrapped_db_iter.h +4 -2
  23. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.cc +20 -0
  24. package/vendor/librocksdb/vendor/rocksdb/db/attribute_group_iterator_impl.h +83 -0
  25. package/vendor/librocksdb/vendor/rocksdb/db/builder.cc +9 -5
  26. package/vendor/librocksdb/vendor/rocksdb/db/builder.h +1 -1
  27. package/vendor/librocksdb/vendor/rocksdb/db/c.cc +231 -6
  28. package/vendor/librocksdb/vendor/rocksdb/db/c_test.c +202 -2
  29. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.cc +47 -0
  30. package/vendor/librocksdb/vendor/rocksdb/db/coalescing_iterator.h +79 -0
  31. package/vendor/librocksdb/vendor/rocksdb/db/column_family.cc +28 -0
  32. package/vendor/librocksdb/vendor/rocksdb/db/column_family.h +17 -0
  33. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.cc +8 -1
  34. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction.h +11 -9
  35. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.cc +50 -23
  36. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_iterator.h +13 -0
  37. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.cc +22 -25
  38. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_job.h +2 -0
  39. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.cc +8 -1
  40. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_outputs.h +1 -0
  41. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.cc +40 -17
  42. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker.h +20 -14
  43. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_level.cc +11 -6
  44. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_picker_universal.cc +77 -24
  45. package/vendor/librocksdb/vendor/rocksdb/db/compaction/compaction_service_job.cc +2 -0
  46. package/vendor/librocksdb/vendor/rocksdb/db/convenience.cc +3 -0
  47. package/vendor/librocksdb/vendor/rocksdb/db/db_filesnapshot.cc +125 -31
  48. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.cc +457 -231
  49. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl.h +172 -73
  50. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_compaction_flush.cc +152 -133
  51. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_debug.cc +5 -0
  52. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_files.cc +58 -52
  53. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.cc +348 -0
  54. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_follower.h +54 -0
  55. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_open.cc +136 -117
  56. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.cc +4 -3
  57. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_secondary.h +7 -6
  58. package/vendor/librocksdb/vendor/rocksdb/db/db_impl/db_impl_write.cc +134 -80
  59. package/vendor/librocksdb/vendor/rocksdb/db/db_iter.cc +11 -0
  60. package/vendor/librocksdb/vendor/rocksdb/db/db_test2.cc +1 -1
  61. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.cc +11 -1
  62. package/vendor/librocksdb/vendor/rocksdb/db/db_test_util.h +11 -7
  63. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.cc +19 -4
  64. package/vendor/librocksdb/vendor/rocksdb/db/dbformat.h +3 -2
  65. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.cc +34 -39
  66. package/vendor/librocksdb/vendor/rocksdb/db/error_handler.h +3 -4
  67. package/vendor/librocksdb/vendor/rocksdb/db/event_helpers.cc +6 -3
  68. package/vendor/librocksdb/vendor/rocksdb/db/experimental.cc +3 -2
  69. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.cc +76 -18
  70. package/vendor/librocksdb/vendor/rocksdb/db/external_sst_file_ingestion_job.h +11 -0
  71. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.cc +37 -5
  72. package/vendor/librocksdb/vendor/rocksdb/db/flush_job.h +14 -0
  73. package/vendor/librocksdb/vendor/rocksdb/db/import_column_family_job.cc +49 -45
  74. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.cc +60 -1
  75. package/vendor/librocksdb/vendor/rocksdb/db/internal_stats.h +20 -1
  76. package/vendor/librocksdb/vendor/rocksdb/db/log_reader.cc +15 -6
  77. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.cc +59 -10
  78. package/vendor/librocksdb/vendor/rocksdb/db/log_writer.h +8 -0
  79. package/vendor/librocksdb/vendor/rocksdb/db/memtable.cc +24 -40
  80. package/vendor/librocksdb/vendor/rocksdb/db/memtable.h +10 -10
  81. package/vendor/librocksdb/vendor/rocksdb/db/memtable_list.cc +9 -8
  82. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator_impl.h +296 -0
  83. package/vendor/librocksdb/vendor/rocksdb/db/range_tombstone_fragmenter.h +8 -10
  84. package/vendor/librocksdb/vendor/rocksdb/db/repair.cc +4 -3
  85. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.cc +30 -0
  86. package/vendor/librocksdb/vendor/rocksdb/db/seqno_to_time_mapping.h +9 -0
  87. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.cc +17 -2
  88. package/vendor/librocksdb/vendor/rocksdb/db/table_cache.h +9 -1
  89. package/vendor/librocksdb/vendor/rocksdb/db/table_properties_collector.h +9 -2
  90. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.cc +3 -3
  91. package/vendor/librocksdb/vendor/rocksdb/db/transaction_log_impl.h +7 -7
  92. package/vendor/librocksdb/vendor/rocksdb/db/version_edit.cc +0 -1
  93. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.cc +39 -5
  94. package/vendor/librocksdb/vendor/rocksdb/db/version_edit_handler.h +24 -15
  95. package/vendor/librocksdb/vendor/rocksdb/db/version_set.cc +117 -64
  96. package/vendor/librocksdb/vendor/rocksdb/db/version_set.h +27 -10
  97. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.cc +37 -29
  98. package/vendor/librocksdb/vendor/rocksdb/db/wal_manager.h +6 -5
  99. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns.cc +2 -3
  100. package/vendor/librocksdb/vendor/rocksdb/db/wide/wide_columns_helper.cc +6 -0
  101. package/vendor/librocksdb/vendor/rocksdb/db/write_batch.cc +89 -31
  102. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.cc +53 -5
  103. package/vendor/librocksdb/vendor/rocksdb/db/write_thread.h +36 -4
  104. package/vendor/librocksdb/vendor/rocksdb/env/composite_env_wrapper.h +21 -0
  105. package/vendor/librocksdb/vendor/rocksdb/env/env.cc +15 -0
  106. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.cc +331 -0
  107. package/vendor/librocksdb/vendor/rocksdb/env/fs_on_demand.h +139 -0
  108. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.cc +8 -6
  109. package/vendor/librocksdb/vendor/rocksdb/env/io_posix.h +1 -1
  110. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.cc +130 -27
  111. package/vendor/librocksdb/vendor/rocksdb/file/delete_scheduler.h +61 -8
  112. package/vendor/librocksdb/vendor/rocksdb/file/file_util.cc +25 -4
  113. package/vendor/librocksdb/vendor/rocksdb/file/file_util.h +15 -0
  114. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.cc +1 -0
  115. package/vendor/librocksdb/vendor/rocksdb/file/sequence_file_reader.h +9 -4
  116. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.cc +18 -0
  117. package/vendor/librocksdb/vendor/rocksdb/file/sst_file_manager_impl.h +31 -4
  118. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.cc +40 -38
  119. package/vendor/librocksdb/vendor/rocksdb/file/writable_file_writer.h +48 -15
  120. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/advanced_options.h +12 -3
  121. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/attribute_groups.h +114 -0
  122. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/c.h +90 -0
  123. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/cache.h +5 -0
  124. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/comparator.h +27 -0
  125. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/db.h +71 -12
  126. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/env.h +9 -0
  127. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/experimental.h +5 -0
  128. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/file_system.h +14 -0
  129. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator.h +9 -71
  130. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/iterator_base.h +90 -0
  131. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/listener.h +21 -0
  132. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/options.h +125 -12
  133. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/perf_context.h +1 -1
  134. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/sst_file_reader.h +11 -1
  135. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table.h +6 -6
  136. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/table_properties.h +19 -0
  137. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/transaction_log.h +12 -6
  138. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/types.h +12 -0
  139. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/universal_compaction.h +31 -0
  140. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/user_write_callback.h +29 -0
  141. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/cache_dump_load.h +4 -0
  142. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/checkpoint.h +4 -2
  143. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/customizable_util.h +0 -1
  144. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/env_mirror.h +1 -1
  145. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/ldb_cmd.h +24 -7
  146. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -4
  147. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/stackable_db.h +24 -5
  148. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +46 -0
  149. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction.h +42 -17
  150. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/transaction_db.h +5 -0
  151. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/types_util.h +36 -0
  152. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +71 -3
  153. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/version.h +2 -2
  154. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/wide_columns.h +87 -72
  155. package/vendor/librocksdb/vendor/rocksdb/include/rocksdb/write_batch_base.h +1 -1
  156. package/vendor/librocksdb/vendor/rocksdb/memory/memory_allocator.cc +1 -0
  157. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.cc +13 -2
  158. package/vendor/librocksdb/vendor/rocksdb/options/cf_options.h +6 -2
  159. package/vendor/librocksdb/vendor/rocksdb/options/db_options.cc +27 -1
  160. package/vendor/librocksdb/vendor/rocksdb/options/db_options.h +10 -3
  161. package/vendor/librocksdb/vendor/rocksdb/options/options.cc +3 -0
  162. package/vendor/librocksdb/vendor/rocksdb/options/options_helper.cc +1 -0
  163. package/vendor/librocksdb/vendor/rocksdb/port/jemalloc_helper.h +2 -2
  164. package/vendor/librocksdb/vendor/rocksdb/port/stack_trace.cc +1 -0
  165. package/vendor/librocksdb/vendor/rocksdb/port/win/port_win.cc +3 -2
  166. package/vendor/librocksdb/vendor/rocksdb/table/block_based/binary_search_index_reader.cc +1 -2
  167. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_builder.cc +47 -31
  168. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_factory.cc +15 -0
  169. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.cc +37 -18
  170. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_iterator.h +10 -3
  171. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.cc +102 -41
  172. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader.h +15 -7
  173. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_impl.h +1 -3
  174. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +5 -6
  175. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_cache.h +31 -0
  176. package/vendor/librocksdb/vendor/rocksdb/table/block_based/block_prefetcher.cc +6 -0
  177. package/vendor/librocksdb/vendor/rocksdb/table/block_based/cachable_entry.h +10 -5
  178. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block.h +34 -28
  179. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.cc +17 -11
  180. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_block_reader_common.h +5 -2
  181. package/vendor/librocksdb/vendor/rocksdb/table/block_based/filter_policy.cc +12 -3
  182. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.cc +37 -30
  183. package/vendor/librocksdb/vendor/rocksdb/table/block_based/full_filter_block.h +11 -13
  184. package/vendor/librocksdb/vendor/rocksdb/table/block_based/hash_index_reader.cc +1 -2
  185. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.cc +62 -53
  186. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_builder.h +60 -38
  187. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.cc +14 -9
  188. package/vendor/librocksdb/vendor/rocksdb/table/block_based/index_reader_common.h +4 -1
  189. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.cc +135 -94
  190. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_filter_block.h +52 -46
  191. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.cc +51 -13
  192. package/vendor/librocksdb/vendor/rocksdb/table/block_based/partitioned_index_reader.h +2 -0
  193. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.cc +3 -11
  194. package/vendor/librocksdb/vendor/rocksdb/table/block_based/uncompression_dict_reader.h +2 -3
  195. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.cc +8 -10
  196. package/vendor/librocksdb/vendor/rocksdb/table/block_fetcher.h +2 -1
  197. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.cc +9 -10
  198. package/vendor/librocksdb/vendor/rocksdb/table/compaction_merging_iterator.h +3 -2
  199. package/vendor/librocksdb/vendor/rocksdb/table/format.cc +1 -2
  200. package/vendor/librocksdb/vendor/rocksdb/table/iterator.cc +4 -0
  201. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.cc +18 -13
  202. package/vendor/librocksdb/vendor/rocksdb/table/merging_iterator.h +5 -3
  203. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.cc +18 -4
  204. package/vendor/librocksdb/vendor/rocksdb/table/meta_blocks.h +4 -0
  205. package/vendor/librocksdb/vendor/rocksdb/table/plain/plain_table_builder.cc +2 -2
  206. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_dumper.cc +6 -6
  207. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_reader.cc +24 -2
  208. package/vendor/librocksdb/vendor/rocksdb/table/sst_file_writer_collectors.h +3 -1
  209. package/vendor/librocksdb/vendor/rocksdb/table/table_builder.h +8 -7
  210. package/vendor/librocksdb/vendor/rocksdb/table/table_iterator.h +69 -0
  211. package/vendor/librocksdb/vendor/rocksdb/table/table_reader.h +9 -0
  212. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.cc +25 -0
  213. package/vendor/librocksdb/vendor/rocksdb/test_util/testutil.h +12 -0
  214. package/vendor/librocksdb/vendor/rocksdb/tools/db_bench_tool.cc +32 -0
  215. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd.cc +618 -124
  216. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_cmd_impl.h +19 -1
  217. package/vendor/librocksdb/vendor/rocksdb/tools/ldb_tool.cc +9 -0
  218. package/vendor/librocksdb/vendor/rocksdb/util/aligned_storage.h +24 -0
  219. package/vendor/librocksdb/vendor/rocksdb/util/autovector.h +4 -0
  220. package/vendor/librocksdb/vendor/rocksdb/util/comparator.cc +12 -0
  221. package/vendor/librocksdb/vendor/rocksdb/util/filter_bench.cc +1 -1
  222. package/vendor/librocksdb/vendor/rocksdb/util/random.cc +2 -1
  223. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.cc +3 -4
  224. package/vendor/librocksdb/vendor/rocksdb/util/stderr_logger.h +1 -1
  225. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.cc +33 -0
  226. package/vendor/librocksdb/vendor/rocksdb/util/udt_util.h +7 -0
  227. package/vendor/librocksdb/vendor/rocksdb/util/write_batch_util.h +5 -0
  228. package/vendor/librocksdb/vendor/rocksdb/util/xxhash.h +36 -29
  229. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl.h +3 -0
  230. package/vendor/librocksdb/vendor/rocksdb/utilities/blob_db/blob_db_impl_filesnapshot.cc +20 -0
  231. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.cc +29 -9
  232. package/vendor/librocksdb/vendor/rocksdb/utilities/cache_dump_load_impl.h +14 -3
  233. package/vendor/librocksdb/vendor/rocksdb/utilities/debug.cc +16 -4
  234. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.cc +677 -248
  235. package/vendor/librocksdb/vendor/rocksdb/utilities/fault_injection_fs.h +325 -158
  236. package/vendor/librocksdb/vendor/rocksdb/utilities/option_change_migration/option_change_migration.cc +1 -8
  237. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +144 -0
  238. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +45 -0
  239. package/vendor/librocksdb/vendor/rocksdb/utilities/table_properties_collectors/compact_on_deletion_collector.cc +12 -0
  240. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +1 -1
  241. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/lock/range/range_tree/lib/util/growable_array.h +3 -3
  242. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.cc +116 -20
  243. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction.h +33 -1
  244. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +78 -13
  245. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/pessimistic_transaction_db.h +33 -1
  246. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.cc +106 -7
  247. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_base.h +68 -10
  248. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_test.h +7 -3
  249. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.cc +8 -5
  250. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/transaction_util.h +7 -4
  251. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -12
  252. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.cc +4 -4
  253. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_prepared_txn_db.h +17 -0
  254. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn.cc +11 -9
  255. package/vendor/librocksdb/vendor/rocksdb/utilities/transactions/write_unprepared_txn_db.cc +2 -1
  256. package/vendor/librocksdb/vendor/rocksdb/utilities/types_util.cc +88 -0
  257. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +313 -14
  258. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +7 -0
  259. package/vendor/librocksdb/vendor/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +1 -1
  260. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.cc +0 -102
  261. package/vendor/librocksdb/vendor/rocksdb/db/multi_cf_iterator.h +0 -159
@@ -105,6 +105,16 @@ extern const WideColumns kNoWideColumns;
105
105
  // wide-column queries.
106
106
  class PinnableWideColumns {
107
107
  public:
108
+ PinnableWideColumns() = default;
109
+
110
+ PinnableWideColumns(const PinnableWideColumns&) = delete;
111
+ PinnableWideColumns& operator=(const PinnableWideColumns&) = delete;
112
+
113
+ PinnableWideColumns(PinnableWideColumns&&);
114
+ PinnableWideColumns& operator=(PinnableWideColumns&&);
115
+
116
+ ~PinnableWideColumns() = default;
117
+
108
118
  const WideColumns& columns() const { return columns_; }
109
119
  size_t serialized_size() const { return value_.size(); }
110
120
 
@@ -121,6 +131,7 @@ class PinnableWideColumns {
121
131
  void Reset();
122
132
 
123
133
  private:
134
+ void Move(PinnableWideColumns&& other);
124
135
  void CopyValue(const Slice& value);
125
136
  void PinOrCopyValue(const Slice& value, Cleanable* cleanable);
126
137
  void MoveValue(PinnableSlice&& value);
@@ -133,6 +144,42 @@ class PinnableWideColumns {
133
144
  WideColumns columns_;
134
145
  };
135
146
 
147
+ inline void PinnableWideColumns::Reset() {
148
+ value_.Reset();
149
+ columns_.clear();
150
+ }
151
+
152
+ inline void PinnableWideColumns::Move(PinnableWideColumns&& other) {
153
+ assert(columns_.empty());
154
+
155
+ if (other.columns_.empty()) {
156
+ return;
157
+ }
158
+
159
+ const char* const data = other.value_.data();
160
+ const bool is_plain_value =
161
+ other.columns_.size() == 1 &&
162
+ other.columns_.front().name() == kDefaultWideColumnName &&
163
+ other.columns_.front().value() == other.value_;
164
+
165
+ MoveValue(std::move(other.value_));
166
+
167
+ if (value_.data() == data) {
168
+ columns_ = std::move(other.columns_);
169
+ } else {
170
+ if (is_plain_value) {
171
+ CreateIndexForPlainValue();
172
+ } else {
173
+ const Status s = CreateIndexForWideColumns();
174
+ assert(s.ok());
175
+
176
+ s.PermitUncheckedError();
177
+ }
178
+ }
179
+
180
+ other.Reset();
181
+ }
182
+
136
183
  inline void PinnableWideColumns::CopyValue(const Slice& value) {
137
184
  value_.PinSelf(value);
138
185
  }
@@ -186,28 +233,61 @@ inline void PinnableWideColumns::SetPlainValue(std::string&& value) {
186
233
 
187
234
  inline Status PinnableWideColumns::SetWideColumnValue(const Slice& value) {
188
235
  CopyValue(value);
189
- return CreateIndexForWideColumns();
236
+
237
+ const Status s = CreateIndexForWideColumns();
238
+ if (!s.ok()) {
239
+ Reset();
240
+ }
241
+
242
+ return s;
190
243
  }
191
244
 
192
245
  inline Status PinnableWideColumns::SetWideColumnValue(const Slice& value,
193
246
  Cleanable* cleanable) {
194
247
  PinOrCopyValue(value, cleanable);
195
- return CreateIndexForWideColumns();
248
+
249
+ const Status s = CreateIndexForWideColumns();
250
+ if (!s.ok()) {
251
+ Reset();
252
+ }
253
+
254
+ return s;
196
255
  }
197
256
 
198
257
  inline Status PinnableWideColumns::SetWideColumnValue(PinnableSlice&& value) {
199
258
  MoveValue(std::move(value));
200
- return CreateIndexForWideColumns();
259
+
260
+ const Status s = CreateIndexForWideColumns();
261
+ if (!s.ok()) {
262
+ Reset();
263
+ }
264
+
265
+ return s;
201
266
  }
202
267
 
203
268
  inline Status PinnableWideColumns::SetWideColumnValue(std::string&& value) {
204
269
  MoveValue(std::move(value));
205
- return CreateIndexForWideColumns();
270
+
271
+ const Status s = CreateIndexForWideColumns();
272
+ if (!s.ok()) {
273
+ Reset();
274
+ }
275
+
276
+ return s;
206
277
  }
207
278
 
208
- inline void PinnableWideColumns::Reset() {
209
- value_.Reset();
210
- columns_.clear();
279
+ inline PinnableWideColumns::PinnableWideColumns(PinnableWideColumns&& other) {
280
+ Move(std::move(other));
281
+ }
282
+
283
+ inline PinnableWideColumns& PinnableWideColumns::operator=(
284
+ PinnableWideColumns&& other) {
285
+ if (this != &other) {
286
+ Reset();
287
+ Move(std::move(other));
288
+ }
289
+
290
+ return *this;
211
291
  }
212
292
 
213
293
  inline bool operator==(const PinnableWideColumns& lhs,
@@ -220,69 +300,4 @@ inline bool operator!=(const PinnableWideColumns& lhs,
220
300
  return !(lhs == rhs);
221
301
  }
222
302
 
223
- // Class representing attribute group. Attribute group is a logical grouping of
224
- // wide-column entities by leveraging Column Families.
225
- // Used in Write Path
226
- class AttributeGroup {
227
- public:
228
- ColumnFamilyHandle* column_family() const { return column_family_; }
229
- const WideColumns& columns() const { return columns_; }
230
- WideColumns& columns() { return columns_; }
231
-
232
- explicit AttributeGroup(ColumnFamilyHandle* column_family,
233
- const WideColumns& columns)
234
- : column_family_(column_family), columns_(columns) {}
235
-
236
- private:
237
- ColumnFamilyHandle* column_family_;
238
- WideColumns columns_;
239
- };
240
-
241
- inline bool operator==(const AttributeGroup& lhs, const AttributeGroup& rhs) {
242
- return lhs.column_family() == rhs.column_family() &&
243
- lhs.columns() == rhs.columns();
244
- }
245
-
246
- // A collection of Attribute Groups.
247
- using AttributeGroups = std::vector<AttributeGroup>;
248
-
249
- // An empty set of Attribute Groups.
250
- extern const AttributeGroups kNoAttributeGroups;
251
-
252
- // Used in Read Path. Wide-columns returned from the query are pinnable.
253
- class PinnableAttributeGroup {
254
- public:
255
- ColumnFamilyHandle* column_family() const { return column_family_; }
256
- const Status& status() const { return status_; }
257
- const WideColumns& columns() const { return columns_.columns(); }
258
-
259
- explicit PinnableAttributeGroup(ColumnFamilyHandle* column_family)
260
- : column_family_(column_family), status_(Status::OK()) {}
261
-
262
- void SetStatus(const Status& status);
263
- void SetColumns(PinnableWideColumns&& columns);
264
-
265
- void Reset();
266
-
267
- private:
268
- ColumnFamilyHandle* column_family_;
269
- Status status_;
270
- PinnableWideColumns columns_;
271
- };
272
-
273
- inline void PinnableAttributeGroup::SetStatus(const Status& status) {
274
- status_ = status;
275
- }
276
- inline void PinnableAttributeGroup::SetColumns(PinnableWideColumns&& columns) {
277
- columns_ = std::move(columns);
278
- }
279
-
280
- inline void PinnableAttributeGroup::Reset() {
281
- SetStatus(Status::OK());
282
- columns_.Reset();
283
- }
284
-
285
- // A collection of Pinnable Attribute Groups.
286
- using PinnableAttributeGroups = std::vector<PinnableAttributeGroup>;
287
-
288
303
  } // namespace ROCKSDB_NAMESPACE
@@ -10,8 +10,8 @@
10
10
 
11
11
  #include <cstddef>
12
12
 
13
+ #include "rocksdb/attribute_groups.h"
13
14
  #include "rocksdb/rocksdb_namespace.h"
14
- #include "rocksdb/wide_columns.h"
15
15
 
16
16
  namespace ROCKSDB_NAMESPACE {
17
17
 
@@ -77,4 +77,5 @@ Status MemoryAllocator::CreateFromString(
77
77
  copy.invoke_prepare_options = true;
78
78
  return LoadManagedObject<MemoryAllocator>(copy, value, result);
79
79
  }
80
+
80
81
  } // namespace ROCKSDB_NAMESPACE
@@ -239,6 +239,10 @@ static std::unordered_map<std::string, OptionTypeInfo>
239
239
  {offsetof(class CompactionOptionsUniversal, compression_size_percent),
240
240
  OptionType::kInt, OptionVerificationType::kNormal,
241
241
  OptionTypeFlags::kMutable}},
242
+ {"max_read_amp",
243
+ {offsetof(class CompactionOptionsUniversal, max_read_amp),
244
+ OptionType::kInt, OptionVerificationType::kNormal,
245
+ OptionTypeFlags::kMutable}},
242
246
  {"stop_style",
243
247
  {offsetof(class CompactionOptionsUniversal, stop_style),
244
248
  OptionType::kCompactionStopStyle, OptionVerificationType::kNormal,
@@ -519,6 +523,10 @@ static std::unordered_map<std::string, OptionTypeInfo>
519
523
  {offsetof(struct MutableCFOptions, bottommost_file_compaction_delay),
520
524
  OptionType::kUInt32T, OptionVerificationType::kNormal,
521
525
  OptionTypeFlags::kMutable}},
526
+ {"uncache_aggressiveness",
527
+ {offsetof(struct MutableCFOptions, uncache_aggressiveness),
528
+ OptionType::kUInt32T, OptionVerificationType::kNormal,
529
+ OptionTypeFlags::kMutable}},
522
530
  {"block_protection_bytes_per_key",
523
531
  {offsetof(struct MutableCFOptions, block_protection_bytes_per_key),
524
532
  OptionType::kUInt8T, OptionVerificationType::kNormal,
@@ -1118,11 +1126,12 @@ void MutableCFOptions::Dump(Logger* log) const {
1118
1126
  report_bg_io_stats);
1119
1127
  ROCKS_LOG_INFO(log, " compression: %d",
1120
1128
  static_cast<int>(compression));
1121
- ROCKS_LOG_INFO(log,
1122
- " experimental_mempurge_threshold: %f",
1129
+ ROCKS_LOG_INFO(log, " experimental_mempurge_threshold: %f",
1123
1130
  experimental_mempurge_threshold);
1124
1131
  ROCKS_LOG_INFO(log, " bottommost_file_compaction_delay: %" PRIu32,
1125
1132
  bottommost_file_compaction_delay);
1133
+ ROCKS_LOG_INFO(log, " uncache_aggressiveness: %" PRIu32,
1134
+ uncache_aggressiveness);
1126
1135
 
1127
1136
  // Universal Compaction Options
1128
1137
  ROCKS_LOG_INFO(log, "compaction_options_universal.size_ratio : %d",
@@ -1137,6 +1146,8 @@ void MutableCFOptions::Dump(Logger* log) const {
1137
1146
  ROCKS_LOG_INFO(log,
1138
1147
  "compaction_options_universal.compression_size_percent : %d",
1139
1148
  compaction_options_universal.compression_size_percent);
1149
+ ROCKS_LOG_INFO(log, "compaction_options_universal.max_read_amp: %d",
1150
+ compaction_options_universal.max_read_amp);
1140
1151
  ROCKS_LOG_INFO(log, "compaction_options_universal.stop_style : %d",
1141
1152
  compaction_options_universal.stop_style);
1142
1153
  ROCKS_LOG_INFO(
@@ -173,7 +173,8 @@ struct MutableCFOptions {
173
173
  compression_per_level(options.compression_per_level),
174
174
  memtable_max_range_deletions(options.memtable_max_range_deletions),
175
175
  bottommost_file_compaction_delay(
176
- options.bottommost_file_compaction_delay) {
176
+ options.bottommost_file_compaction_delay),
177
+ uncache_aggressiveness(options.uncache_aggressiveness) {
177
178
  RefreshDerivedOptions(options.num_levels, options.compaction_style);
178
179
  }
179
180
 
@@ -223,7 +224,9 @@ struct MutableCFOptions {
223
224
  memtable_protection_bytes_per_key(0),
224
225
  block_protection_bytes_per_key(0),
225
226
  sample_for_compression(0),
226
- memtable_max_range_deletions(0) {}
227
+ memtable_max_range_deletions(0),
228
+ bottommost_file_compaction_delay(0),
229
+ uncache_aggressiveness(0) {}
227
230
 
228
231
  explicit MutableCFOptions(const Options& options);
229
232
 
@@ -319,6 +322,7 @@ struct MutableCFOptions {
319
322
  std::vector<CompressionType> compression_per_level;
320
323
  uint32_t memtable_max_range_deletions;
321
324
  uint32_t bottommost_file_compaction_delay;
325
+ uint32_t uncache_aggressiveness;
322
326
 
323
327
  // Derived options
324
328
  // Per-level target file size.
@@ -37,6 +37,7 @@ static std::unordered_map<std::string, WALRecoveryMode>
37
37
 
38
38
  static std::unordered_map<std::string, CacheTier> cache_tier_string_map = {
39
39
  {"kVolatileTier", CacheTier::kVolatileTier},
40
+ {"kVolatileCompressedTier", CacheTier::kVolatileCompressedTier},
40
41
  {"kNonVolatileBlockTier", CacheTier::kNonVolatileBlockTier}};
41
42
 
42
43
  static std::unordered_map<std::string, InfoLogLevel> info_log_level_string_map =
@@ -387,6 +388,10 @@ static std::unordered_map<std::string, OptionTypeInfo>
387
388
  {offsetof(struct ImmutableDBOptions, wal_compression),
388
389
  OptionType::kCompressionType, OptionVerificationType::kNormal,
389
390
  OptionTypeFlags::kNone}},
391
+ {"background_close_inactive_wals",
392
+ {offsetof(struct ImmutableDBOptions, background_close_inactive_wals),
393
+ OptionType::kBoolean, OptionVerificationType::kNormal,
394
+ OptionTypeFlags::kNone}},
390
395
  {"seq_per_batch",
391
396
  {0, OptionType::kBoolean, OptionVerificationType::kDeprecated,
392
397
  OptionTypeFlags::kNone}},
@@ -558,6 +563,19 @@ static std::unordered_map<std::string, OptionTypeInfo>
558
563
  {offsetof(struct ImmutableDBOptions, enforce_single_del_contracts),
559
564
  OptionType::kBoolean, OptionVerificationType::kNormal,
560
565
  OptionTypeFlags::kNone}},
566
+ {"follower_refresh_catchup_period_ms",
567
+ {offsetof(struct ImmutableDBOptions,
568
+ follower_refresh_catchup_period_ms),
569
+ OptionType::kUInt64T, OptionVerificationType::kNormal,
570
+ OptionTypeFlags::kNone}},
571
+ {"follower_catchup_retry_count",
572
+ {offsetof(struct ImmutableDBOptions, follower_catchup_retry_count),
573
+ OptionType::kUInt64T, OptionVerificationType::kNormal,
574
+ OptionTypeFlags::kNone}},
575
+ {"follower_catchup_retry_wait_ms",
576
+ {offsetof(struct ImmutableDBOptions, follower_catchup_retry_wait_ms),
577
+ OptionType::kUInt64T, OptionVerificationType::kNormal,
578
+ OptionTypeFlags::kNone}},
561
579
  };
562
580
 
563
581
  const std::string OptionsHelper::kDBOptionsName = "DBOptions";
@@ -741,6 +759,7 @@ ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options)
741
759
  two_write_queues(options.two_write_queues),
742
760
  manual_wal_flush(options.manual_wal_flush),
743
761
  wal_compression(options.wal_compression),
762
+ background_close_inactive_wals(options.background_close_inactive_wals),
744
763
  atomic_flush(options.atomic_flush),
745
764
  avoid_unnecessary_blocking_io(options.avoid_unnecessary_blocking_io),
746
765
  persist_stats_to_disk(options.persist_stats_to_disk),
@@ -755,7 +774,11 @@ ImmutableDBOptions::ImmutableDBOptions(const DBOptions& options)
755
774
  checksum_handoff_file_types(options.checksum_handoff_file_types),
756
775
  lowest_used_cache_tier(options.lowest_used_cache_tier),
757
776
  compaction_service(options.compaction_service),
758
- enforce_single_del_contracts(options.enforce_single_del_contracts) {
777
+ enforce_single_del_contracts(options.enforce_single_del_contracts),
778
+ follower_refresh_catchup_period_ms(
779
+ options.follower_refresh_catchup_period_ms),
780
+ follower_catchup_retry_count(options.follower_catchup_retry_count),
781
+ follower_catchup_retry_wait_ms(options.follower_catchup_retry_wait_ms) {
759
782
  fs = env->GetFileSystem();
760
783
  clock = env->GetSystemClock().get();
761
784
  logger = info_log.get();
@@ -903,6 +926,9 @@ void ImmutableDBOptions::Dump(Logger* log) const {
903
926
  manual_wal_flush);
904
927
  ROCKS_LOG_HEADER(log, " Options.wal_compression: %d",
905
928
  wal_compression);
929
+ ROCKS_LOG_HEADER(log,
930
+ " Options.background_close_inactive_wals: %d",
931
+ background_close_inactive_wals);
906
932
  ROCKS_LOG_HEADER(log, " Options.atomic_flush: %d", atomic_flush);
907
933
  ROCKS_LOG_HEADER(log,
908
934
  " Options.avoid_unnecessary_blocking_io: %d",
@@ -84,6 +84,7 @@ struct ImmutableDBOptions {
84
84
  bool two_write_queues;
85
85
  bool manual_wal_flush;
86
86
  CompressionType wal_compression;
87
+ bool background_close_inactive_wals;
87
88
  bool atomic_flush;
88
89
  bool avoid_unnecessary_blocking_io;
89
90
  bool persist_stats_to_disk;
@@ -97,13 +98,19 @@ struct ImmutableDBOptions {
97
98
  std::string db_host_id;
98
99
  FileTypeSet checksum_handoff_file_types;
99
100
  CacheTier lowest_used_cache_tier;
100
- // Convenience/Helper objects that are not part of the base DBOptions
101
+ std::shared_ptr<CompactionService> compaction_service;
102
+ bool enforce_single_del_contracts;
103
+ uint64_t follower_refresh_catchup_period_ms;
104
+ uint64_t follower_catchup_retry_count;
105
+ uint64_t follower_catchup_retry_wait_ms;
106
+
107
+ // Beginning convenience/helper objects that are not part of the base
108
+ // DBOptions
101
109
  std::shared_ptr<FileSystem> fs;
102
110
  SystemClock* clock;
103
111
  Statistics* stats;
104
112
  Logger* logger;
105
- std::shared_ptr<CompactionService> compaction_service;
106
- bool enforce_single_del_contracts;
113
+ // End of convenience/helper objects.
107
114
 
108
115
  bool IsWalDirSameAsDBPath() const;
109
116
  bool IsWalDirSameAsDBPath(const std::string& path) const;
@@ -360,6 +360,9 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
360
360
  ROCKS_LOG_HEADER(log,
361
361
  "Options.compaction_options_universal.stop_style: %s",
362
362
  str_compaction_stop_style.c_str());
363
+ ROCKS_LOG_HEADER(log,
364
+ "Options.compaction_options_universal.max_read_amp: %d",
365
+ compaction_options_universal.max_read_amp);
363
366
  ROCKS_LOG_HEADER(
364
367
  log, "Options.compaction_options_fifo.max_table_files_size: %" PRIu64,
365
368
  compaction_options_fifo.max_table_files_size);
@@ -274,6 +274,7 @@ void UpdateColumnFamilyOptions(const MutableCFOptions& moptions,
274
274
  cf_opts->last_level_temperature = moptions.last_level_temperature;
275
275
  cf_opts->default_write_temperature = moptions.default_write_temperature;
276
276
  cf_opts->memtable_max_range_deletions = moptions.memtable_max_range_deletions;
277
+ cf_opts->uncache_aggressiveness = moptions.uncache_aggressiveness;
277
278
  }
278
279
 
279
280
  void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions,
@@ -6,7 +6,7 @@
6
6
  #pragma once
7
7
 
8
8
  #if defined(__clang__) && defined(__GLIBC__)
9
- // glibc's `posix_memalign()` declaration specifies `throw()` while clang's
9
+ // glibc's `posix_memalign()` declaration specifies `noexcept` while clang's
10
10
  // declaration does not. There is a hack in clang to make its re-declaration
11
11
  // compatible with glibc's if they are declared consecutively. That hack breaks
12
12
  // if yet another `posix_memalign()` declaration comes between glibc's and
@@ -14,7 +14,7 @@
14
14
  // declarations both come before "jemalloc.h"'s `posix_memalign()` declaration.
15
15
  //
16
16
  // This problem could also be avoided if "jemalloc.h"'s `posix_memalign()`
17
- // declaration did not specify `throw()` when built with clang.
17
+ // declaration did not specify `noexcept` when built with clang.
18
18
  #include <mm_malloc.h>
19
19
  #endif
20
20
 
@@ -39,6 +39,7 @@ void* SaveStack(int* /*num_frames*/, int /*first_frames_to_skip*/) {
39
39
  #endif // OS_OPENBSD
40
40
  #ifdef OS_FREEBSD
41
41
  #include <sys/sysctl.h>
42
+ #include <sys/wait.h>
42
43
  #endif // OS_FREEBSD
43
44
  #ifdef OS_LINUX
44
45
  #include <sys/prctl.h>
@@ -101,8 +101,9 @@ bool CondVar::TimedWait(uint64_t abs_time_us) {
101
101
  std::unique_lock<std::mutex> lk(mu_->getLock(), std::adopt_lock);
102
102
 
103
103
  // Work around https://github.com/microsoft/STL/issues/369
104
- #if defined(_MSC_VER) && \
105
- (!defined(_MSVC_STL_UPDATE) || _MSVC_STL_UPDATE < 202008L)
104
+ // std::condition_variable_any::wait_for had a fix, but
105
+ // std::condition_variable still doesn't have a fix in STL yet
106
+ #if defined(_MSC_VER)
106
107
  if (relTimeUs == std::chrono::microseconds::zero()) {
107
108
  lk.unlock();
108
109
  lk.lock();
@@ -44,9 +44,8 @@ InternalIteratorBase<IndexValue>* BinarySearchIndexReader::NewIterator(
44
44
  IndexBlockIter* iter, GetContext* get_context,
45
45
  BlockCacheLookupContext* lookup_context) {
46
46
  const BlockBasedTable::Rep* rep = table()->get_rep();
47
- const bool no_io = (read_options.read_tier == kBlockCacheTier);
48
47
  CachableEntry<Block> index_block;
49
- const Status s = GetOrReadIndexBlock(no_io, get_context, lookup_context,
48
+ const Status s = GetOrReadIndexBlock(get_context, lookup_context,
50
49
  &index_block, read_options);
51
50
  if (!s.ok()) {
52
51
  if (iter != nullptr) {
@@ -293,9 +293,10 @@ struct BlockBasedTableBuilder::Rep {
293
293
 
294
294
  InternalKeySliceTransform internal_prefix_transform;
295
295
  std::unique_ptr<IndexBuilder> index_builder;
296
+ std::string index_separator_scratch;
296
297
  PartitionedIndexBuilder* p_index_builder_ = nullptr;
297
298
 
298
- std::string last_key;
299
+ std::string last_ikey; // Internal key or empty (unset)
299
300
  const Slice* first_key_in_next_block = nullptr;
300
301
  CompressionType compression_type;
301
302
  uint64_t sample_for_compression;
@@ -582,8 +583,10 @@ struct BlockBasedTableBuilder::Rep {
582
583
  assert(factory);
583
584
 
584
585
  std::unique_ptr<InternalTblPropColl> collector{
585
- factory->CreateInternalTblPropColl(tbo.column_family_id,
586
- tbo.level_at_creation)};
586
+ factory->CreateInternalTblPropColl(
587
+ tbo.column_family_id, tbo.level_at_creation,
588
+ tbo.ioptions.num_levels,
589
+ tbo.last_level_inclusive_max_seqno_threshold)};
587
590
  if (collector) {
588
591
  table_properties_collectors.emplace_back(std::move(collector));
589
592
  }
@@ -626,6 +629,14 @@ struct BlockBasedTableBuilder::Rep {
626
629
  } else {
627
630
  base_context_checksum = 0;
628
631
  }
632
+
633
+ if (alignment > 0 && compression_type != kNoCompression) {
634
+ // With better sanitization in `CompactionPicker::CompactFiles()`, we
635
+ // would not need to handle this case here and could change it to an
636
+ // assertion instead.
637
+ SetStatus(Status::InvalidArgument(
638
+ "Enable block_align, but compression enabled"));
639
+ }
629
640
  }
630
641
 
631
642
  Rep(const Rep&) = delete;
@@ -987,24 +998,24 @@ BlockBasedTableBuilder::~BlockBasedTableBuilder() {
987
998
  delete rep_;
988
999
  }
989
1000
 
990
- void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
1001
+ void BlockBasedTableBuilder::Add(const Slice& ikey, const Slice& value) {
991
1002
  Rep* r = rep_;
992
1003
  assert(rep_->state != Rep::State::kClosed);
993
1004
  if (!ok()) {
994
1005
  return;
995
1006
  }
996
- ValueType value_type = ExtractValueType(key);
1007
+ ValueType value_type = ExtractValueType(ikey);
997
1008
  if (IsValueType(value_type)) {
998
1009
  #ifndef NDEBUG
999
1010
  if (r->props.num_entries > r->props.num_range_deletions) {
1000
- assert(r->internal_comparator.Compare(key, Slice(r->last_key)) > 0);
1011
+ assert(r->internal_comparator.Compare(ikey, Slice(r->last_ikey)) > 0);
1001
1012
  }
1002
1013
  #endif // !NDEBUG
1003
1014
 
1004
- auto should_flush = r->flush_block_policy->Update(key, value);
1015
+ auto should_flush = r->flush_block_policy->Update(ikey, value);
1005
1016
  if (should_flush) {
1006
1017
  assert(!r->data_block.empty());
1007
- r->first_key_in_next_block = &key;
1018
+ r->first_key_in_next_block = &ikey;
1008
1019
  Flush();
1009
1020
  if (r->state == Rep::State::kBuffered) {
1010
1021
  bool exceeds_buffer_limit =
@@ -1039,8 +1050,9 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
1039
1050
  if (r->IsParallelCompressionEnabled()) {
1040
1051
  r->pc_rep->curr_block_keys->Clear();
1041
1052
  } else {
1042
- r->index_builder->AddIndexEntry(&r->last_key, &key,
1043
- r->pending_handle);
1053
+ r->index_builder->AddIndexEntry(r->last_ikey, &ikey,
1054
+ r->pending_handle,
1055
+ &r->index_separator_scratch);
1044
1056
  }
1045
1057
  }
1046
1058
  }
@@ -1049,27 +1061,28 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
1049
1061
  // builder after being added to index builder.
1050
1062
  if (r->state == Rep::State::kUnbuffered) {
1051
1063
  if (r->IsParallelCompressionEnabled()) {
1052
- r->pc_rep->curr_block_keys->PushBack(key);
1064
+ r->pc_rep->curr_block_keys->PushBack(ikey);
1053
1065
  } else {
1054
1066
  if (r->filter_builder != nullptr) {
1055
1067
  r->filter_builder->Add(
1056
- ExtractUserKeyAndStripTimestamp(key, r->ts_sz));
1068
+ ExtractUserKeyAndStripTimestamp(ikey, r->ts_sz));
1057
1069
  }
1058
1070
  }
1059
1071
  }
1060
1072
 
1061
- r->data_block.AddWithLastKey(key, value, r->last_key);
1062
- r->last_key.assign(key.data(), key.size());
1073
+ r->data_block.AddWithLastKey(ikey, value, r->last_ikey);
1074
+ r->last_ikey.assign(ikey.data(), ikey.size());
1075
+ assert(!r->last_ikey.empty());
1063
1076
  if (r->state == Rep::State::kBuffered) {
1064
1077
  // Buffered keys will be replayed from data_block_buffers during
1065
1078
  // `Finish()` once compression dictionary has been finalized.
1066
1079
  } else {
1067
1080
  if (!r->IsParallelCompressionEnabled()) {
1068
- r->index_builder->OnKeyAdded(key);
1081
+ r->index_builder->OnKeyAdded(ikey);
1069
1082
  }
1070
1083
  }
1071
1084
  // TODO offset passed in is not accurate for parallel compression case
1072
- NotifyCollectTableCollectorsOnAdd(key, value, r->get_offset(),
1085
+ NotifyCollectTableCollectorsOnAdd(ikey, value, r->get_offset(),
1073
1086
  r->table_properties_collectors,
1074
1087
  r->ioptions.logger);
1075
1088
 
@@ -1083,9 +1096,9 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
1083
1096
  if (r->ts_sz > 0 && !r->persist_user_defined_timestamps) {
1084
1097
  persisted_end = StripTimestampFromUserKey(value, r->ts_sz);
1085
1098
  }
1086
- r->range_del_block.Add(key, persisted_end);
1099
+ r->range_del_block.Add(ikey, persisted_end);
1087
1100
  // TODO offset passed in is not accurate for parallel compression case
1088
- NotifyCollectTableCollectorsOnAdd(key, value, r->get_offset(),
1101
+ NotifyCollectTableCollectorsOnAdd(ikey, value, r->get_offset(),
1089
1102
  r->table_properties_collectors,
1090
1103
  r->ioptions.logger);
1091
1104
  } else {
@@ -1097,7 +1110,7 @@ void BlockBasedTableBuilder::Add(const Slice& key, const Slice& value) {
1097
1110
  }
1098
1111
 
1099
1112
  r->props.num_entries++;
1100
- r->props.raw_key_size += key.size();
1113
+ r->props.raw_key_size += ikey.size();
1101
1114
  if (!r->persist_user_defined_timestamps) {
1102
1115
  r->props.raw_key_size -= r->ts_sz;
1103
1116
  }
@@ -1475,14 +1488,15 @@ void BlockBasedTableBuilder::BGWorkWriteMaybeCompressedBlock() {
1475
1488
  ++r->props.num_data_blocks;
1476
1489
 
1477
1490
  if (block_rep->first_key_in_next_block == nullptr) {
1478
- r->index_builder->AddIndexEntry(&(block_rep->keys->Back()), nullptr,
1479
- r->pending_handle);
1491
+ r->index_builder->AddIndexEntry(block_rep->keys->Back(), nullptr,
1492
+ r->pending_handle,
1493
+ &r->index_separator_scratch);
1480
1494
  } else {
1481
1495
  Slice first_key_in_next_block =
1482
1496
  Slice(*block_rep->first_key_in_next_block);
1483
- r->index_builder->AddIndexEntry(&(block_rep->keys->Back()),
1484
- &first_key_in_next_block,
1485
- r->pending_handle);
1497
+ r->index_builder->AddIndexEntry(
1498
+ block_rep->keys->Back(), &first_key_in_next_block, r->pending_handle,
1499
+ &r->index_separator_scratch);
1486
1500
  }
1487
1501
 
1488
1502
  r->pc_rep->ReapBlock(block_rep);
@@ -1566,9 +1580,10 @@ void BlockBasedTableBuilder::WriteFilterBlock(
1566
1580
  // See FilterBlockBuilder::Finish() for more on the difference in
1567
1581
  // transferred filter data payload among different FilterBlockBuilder
1568
1582
  // subtypes.
1569
- std::unique_ptr<const char[]> filter_data;
1570
- Slice filter_content =
1571
- rep_->filter_builder->Finish(filter_block_handle, &s, &filter_data);
1583
+ std::unique_ptr<const char[]> filter_owner;
1584
+ Slice filter_content;
1585
+ s = rep_->filter_builder->Finish(filter_block_handle, &filter_content,
1586
+ &filter_owner);
1572
1587
 
1573
1588
  assert(s.ok() || s.IsIncomplete() || s.IsCorruption());
1574
1589
  if (s.IsCorruption()) {
@@ -1977,9 +1992,9 @@ void BlockBasedTableBuilder::EnterUnbuffered() {
1977
1992
  Slice* first_key_in_next_block_ptr = &first_key_in_next_block;
1978
1993
 
1979
1994
  iter->SeekToLast();
1980
- std::string last_key = iter->key().ToString();
1981
- r->index_builder->AddIndexEntry(&last_key, first_key_in_next_block_ptr,
1982
- r->pending_handle);
1995
+ r->index_builder->AddIndexEntry(
1996
+ iter->key(), first_key_in_next_block_ptr, r->pending_handle,
1997
+ &r->index_separator_scratch);
1983
1998
  }
1984
1999
  }
1985
2000
  std::swap(iter, next_block_iter);
@@ -2015,7 +2030,8 @@ Status BlockBasedTableBuilder::Finish() {
2015
2030
  // block, we will finish writing all index entries first.
2016
2031
  if (ok() && !empty_data_block) {
2017
2032
  r->index_builder->AddIndexEntry(
2018
- &r->last_key, nullptr /* no next data block */, r->pending_handle);
2033
+ r->last_ikey, nullptr /* no next data block */, r->pending_handle,
2034
+ &r->index_separator_scratch);
2019
2035
  }
2020
2036
  }
2021
2037