@nxtedition/rocksdb 13.1.5 → 13.2.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 (237) hide show
  1. package/binding.cc +37 -12
  2. package/deps/rocksdb/rocksdb/{TARGETS → BUCK} +27 -0
  3. package/deps/rocksdb/rocksdb/CMakeLists.txt +3 -1
  4. package/deps/rocksdb/rocksdb/Makefile +2 -2
  5. package/deps/rocksdb/rocksdb/cache/cache.cc +3 -1
  6. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +2 -0
  7. package/deps/rocksdb/rocksdb/db/attribute_group_iterator_impl.h +34 -9
  8. package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +7 -6
  9. package/deps/rocksdb/rocksdb/db/blob/blob_source.h +5 -1
  10. package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +22 -14
  11. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +149 -0
  12. package/deps/rocksdb/rocksdb/db/builder.cc +13 -24
  13. package/deps/rocksdb/rocksdb/db/coalescing_iterator.h +35 -10
  14. package/deps/rocksdb/rocksdb/db/column_family.cc +21 -10
  15. package/deps/rocksdb/rocksdb/db/column_family.h +15 -8
  16. package/deps/rocksdb/rocksdb/db/column_family_test.cc +98 -7
  17. package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +126 -16
  18. package/deps/rocksdb/rocksdb/db/compaction/compaction.h +51 -5
  19. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +2 -2
  20. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +2 -8
  21. package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator_test.cc +24 -0
  22. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +52 -22
  23. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +9 -7
  24. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +36 -9
  25. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +6 -0
  26. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +30 -17
  27. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +26 -23
  28. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +43 -33
  29. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +6 -5
  30. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +19 -9
  31. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +6 -5
  32. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +632 -411
  33. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +171 -51
  34. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +7 -5
  35. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +37 -10
  36. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +51 -11
  37. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +10 -3
  38. package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +350 -154
  39. package/deps/rocksdb/rocksdb/db/convenience.cc +1 -1
  40. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +62 -27
  41. package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +68 -1
  42. package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +91 -0
  43. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +134 -70
  44. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +71 -23
  45. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +43 -16
  46. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +47 -33
  47. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +27 -19
  48. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +38 -25
  49. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +3 -3
  50. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +7 -4
  51. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +258 -42
  52. package/deps/rocksdb/rocksdb/db/db_io_failure_test.cc +161 -9
  53. package/deps/rocksdb/rocksdb/db/db_iter.cc +118 -86
  54. package/deps/rocksdb/rocksdb/db/db_iter.h +44 -17
  55. package/deps/rocksdb/rocksdb/db/db_options_test.cc +27 -6
  56. package/deps/rocksdb/rocksdb/db/db_test.cc +48 -16
  57. package/deps/rocksdb/rocksdb/db/db_test2.cc +60 -15
  58. package/deps/rocksdb/rocksdb/db/db_test_util.cc +97 -44
  59. package/deps/rocksdb/rocksdb/db/db_test_util.h +7 -1
  60. package/deps/rocksdb/rocksdb/db/dbformat.cc +15 -5
  61. package/deps/rocksdb/rocksdb/db/dbformat.h +137 -55
  62. package/deps/rocksdb/rocksdb/db/event_helpers.cc +1 -0
  63. package/deps/rocksdb/rocksdb/db/experimental.cc +54 -0
  64. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +663 -8
  65. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +152 -91
  66. package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +134 -11
  67. package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +55 -9
  68. package/deps/rocksdb/rocksdb/db/flush_job.cc +52 -29
  69. package/deps/rocksdb/rocksdb/db/flush_job.h +5 -3
  70. package/deps/rocksdb/rocksdb/db/flush_job_test.cc +18 -12
  71. package/deps/rocksdb/rocksdb/db/forward_iterator.cc +23 -29
  72. package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +3 -2
  73. package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +2 -0
  74. package/deps/rocksdb/rocksdb/db/internal_stats.cc +9 -6
  75. package/deps/rocksdb/rocksdb/db/internal_stats.h +54 -0
  76. package/deps/rocksdb/rocksdb/db/job_context.h +1 -1
  77. package/deps/rocksdb/rocksdb/db/log_reader.cc +6 -7
  78. package/deps/rocksdb/rocksdb/db/manifest_ops.cc +47 -0
  79. package/deps/rocksdb/rocksdb/db/manifest_ops.h +20 -0
  80. package/deps/rocksdb/rocksdb/db/memtable.cc +165 -64
  81. package/deps/rocksdb/rocksdb/db/memtable.h +422 -243
  82. package/deps/rocksdb/rocksdb/db/memtable_list.cc +99 -68
  83. package/deps/rocksdb/rocksdb/db/memtable_list.h +63 -38
  84. package/deps/rocksdb/rocksdb/db/memtable_list_test.cc +28 -25
  85. package/deps/rocksdb/rocksdb/db/multi_cf_iterator_impl.h +118 -60
  86. package/deps/rocksdb/rocksdb/db/multi_cf_iterator_test.cc +344 -89
  87. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +2 -3
  88. package/deps/rocksdb/rocksdb/db/repair.cc +15 -14
  89. package/deps/rocksdb/rocksdb/db/repair_test.cc +0 -13
  90. package/deps/rocksdb/rocksdb/db/snapshot_checker.h +7 -0
  91. package/deps/rocksdb/rocksdb/db/table_cache.cc +62 -65
  92. package/deps/rocksdb/rocksdb/db/table_cache.h +70 -76
  93. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +5 -6
  94. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +1 -1
  95. package/deps/rocksdb/rocksdb/db/transaction_log_impl.cc +8 -7
  96. package/deps/rocksdb/rocksdb/db/version_builder.cc +17 -19
  97. package/deps/rocksdb/rocksdb/db/version_builder.h +13 -12
  98. package/deps/rocksdb/rocksdb/db/version_edit.h +30 -0
  99. package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +3 -5
  100. package/deps/rocksdb/rocksdb/db/version_set.cc +89 -129
  101. package/deps/rocksdb/rocksdb/db/version_set.h +12 -4
  102. package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +1 -2
  103. package/deps/rocksdb/rocksdb/db/version_set_test.cc +12 -8
  104. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.cc +0 -15
  105. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.h +0 -2
  106. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization_test.cc +9 -7
  107. package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.cc +0 -8
  108. package/deps/rocksdb/rocksdb/db/wide/wide_columns_helper.h +28 -2
  109. package/deps/rocksdb/rocksdb/db/write_batch.cc +32 -10
  110. package/deps/rocksdb/rocksdb/db/write_batch_internal.h +9 -0
  111. package/deps/rocksdb/rocksdb/db/write_batch_test.cc +2 -1
  112. package/deps/rocksdb/rocksdb/db/write_thread.cc +3 -1
  113. package/deps/rocksdb/rocksdb/db/write_thread.h +6 -2
  114. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +15 -0
  115. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +7 -0
  116. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +4 -0
  117. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +18 -2
  118. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +100 -22
  119. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +15 -4
  120. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +34 -8
  121. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +223 -78
  122. package/deps/rocksdb/rocksdb/env/file_system.cc +6 -1
  123. package/deps/rocksdb/rocksdb/env/fs_posix.cc +53 -0
  124. package/deps/rocksdb/rocksdb/env/io_posix.cc +63 -17
  125. package/deps/rocksdb/rocksdb/env/io_posix.h +30 -1
  126. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +132 -48
  127. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +92 -24
  128. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +727 -109
  129. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +3 -4
  130. package/deps/rocksdb/rocksdb/file/random_access_file_reader.h +1 -1
  131. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +8 -0
  132. package/deps/rocksdb/rocksdb/include/rocksdb/attribute_groups.h +20 -1
  133. package/deps/rocksdb/rocksdb/include/rocksdb/compaction_job_stats.h +9 -0
  134. package/deps/rocksdb/rocksdb/include/rocksdb/configurable.h +9 -5
  135. package/deps/rocksdb/rocksdb/include/rocksdb/convenience.h +2 -0
  136. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +10 -2
  137. package/deps/rocksdb/rocksdb/include/rocksdb/env.h +1 -0
  138. package/deps/rocksdb/rocksdb/include/rocksdb/experimental.h +7 -0
  139. package/deps/rocksdb/rocksdb/include/rocksdb/file_system.h +34 -37
  140. package/deps/rocksdb/rocksdb/include/rocksdb/iterator_base.h +21 -0
  141. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +56 -28
  142. package/deps/rocksdb/rocksdb/include/rocksdb/sst_file_writer.h +3 -0
  143. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +36 -28
  144. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +11 -0
  145. package/deps/rocksdb/rocksdb/include/rocksdb/thread_status.h +1 -0
  146. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/options_type.h +84 -60
  147. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/secondary_index.h +102 -0
  148. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/table_properties_collectors.h +89 -2
  149. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction.h +32 -0
  150. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/transaction_db.h +30 -1
  151. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/write_batch_with_index.h +23 -2
  152. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +2 -2
  153. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +2 -0
  154. package/deps/rocksdb/rocksdb/memtable/inlineskiplist.h +79 -21
  155. package/deps/rocksdb/rocksdb/memtable/skiplist.h +41 -18
  156. package/deps/rocksdb/rocksdb/memtable/skiplistrep.cc +1 -5
  157. package/deps/rocksdb/rocksdb/memtable/wbwi_memtable.cc +169 -0
  158. package/deps/rocksdb/rocksdb/memtable/wbwi_memtable.h +400 -0
  159. package/deps/rocksdb/rocksdb/monitoring/thread_status_util_debug.cc +2 -0
  160. package/deps/rocksdb/rocksdb/options/cf_options.cc +137 -82
  161. package/deps/rocksdb/rocksdb/options/cf_options.h +18 -6
  162. package/deps/rocksdb/rocksdb/options/configurable.cc +31 -17
  163. package/deps/rocksdb/rocksdb/options/configurable_helper.h +7 -6
  164. package/deps/rocksdb/rocksdb/options/options_helper.cc +10 -8
  165. package/deps/rocksdb/rocksdb/options/options_parser.cc +74 -54
  166. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +89 -0
  167. package/deps/rocksdb/rocksdb/options/options_test.cc +112 -26
  168. package/deps/rocksdb/rocksdb/port/port.h +5 -9
  169. package/deps/rocksdb/rocksdb/src.mk +8 -0
  170. package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.h +4 -0
  171. package/deps/rocksdb/rocksdb/table/block_based/block.h +1 -7
  172. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +2 -0
  173. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +62 -80
  174. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.h +13 -3
  175. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.cc +16 -5
  176. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_iterator.h +38 -7
  177. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +12 -4
  178. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +4 -1
  179. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +4 -1
  180. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +204 -1
  181. package/deps/rocksdb/rocksdb/table/block_based/data_block_hash_index_test.cc +3 -3
  182. package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +2 -1
  183. package/deps/rocksdb/rocksdb/table/cuckoo/cuckoo_table_factory.h +4 -0
  184. package/deps/rocksdb/rocksdb/table/format.cc +3 -3
  185. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +4 -1
  186. package/deps/rocksdb/rocksdb/table/mock_table.cc +0 -50
  187. package/deps/rocksdb/rocksdb/table/mock_table.h +53 -0
  188. package/deps/rocksdb/rocksdb/table/plain/plain_table_factory.h +4 -0
  189. package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +1 -1
  190. package/deps/rocksdb/rocksdb/table/sst_file_writer.cc +10 -5
  191. package/deps/rocksdb/rocksdb/table/table_builder.h +3 -1
  192. package/deps/rocksdb/rocksdb/table/table_properties.cc +181 -0
  193. package/deps/rocksdb/rocksdb/table/table_reader_bench.cc +5 -5
  194. package/deps/rocksdb/rocksdb/table/table_test.cc +71 -64
  195. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim.py +45 -45
  196. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim_test.py +35 -35
  197. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_plot.py +43 -43
  198. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +41 -4
  199. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +1 -0
  200. package/deps/rocksdb/rocksdb/tools/sst_dump_test.cc +1 -1
  201. package/deps/rocksdb/rocksdb/unreleased_history/add.sh +13 -0
  202. package/deps/rocksdb/rocksdb/util/aligned_buffer.h +24 -5
  203. package/deps/rocksdb/rocksdb/util/compaction_job_stats_impl.cc +7 -0
  204. package/deps/rocksdb/rocksdb/util/file_checksum_helper.cc +0 -52
  205. package/deps/rocksdb/rocksdb/util/file_checksum_helper.h +1 -10
  206. package/deps/rocksdb/rocksdb/util/file_reader_writer_test.cc +92 -0
  207. package/deps/rocksdb/rocksdb/util/thread_operation.h +1 -0
  208. package/deps/rocksdb/rocksdb/util/udt_util.cc +50 -4
  209. package/deps/rocksdb/rocksdb/util/udt_util.h +24 -11
  210. package/deps/rocksdb/rocksdb/util/udt_util_test.cc +26 -13
  211. package/deps/rocksdb/rocksdb/utilities/memory/memory_test.cc +1 -16
  212. package/deps/rocksdb/rocksdb/utilities/options/options_util_test.cc +2 -0
  213. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index.cc +214 -0
  214. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index.h +60 -0
  215. package/deps/rocksdb/rocksdb/utilities/secondary_index/faiss_ivf_index_test.cc +124 -0
  216. package/deps/rocksdb/rocksdb/utilities/secondary_index/secondary_index_mixin.h +441 -0
  217. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.cc +34 -3
  218. package/deps/rocksdb/rocksdb/utilities/table_properties_collectors/compact_for_tiering_collector.h +7 -2
  219. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +437 -0
  220. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +34 -11
  221. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.h +14 -7
  222. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction_db.cc +7 -1
  223. package/deps/rocksdb/rocksdb/utilities/transactions/snapshot_checker.cc +17 -0
  224. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.cc +69 -0
  225. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_base.h +20 -0
  226. package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +1290 -0
  227. package/deps/rocksdb/rocksdb/utilities/transactions/write_committed_transaction_ts_test.cc +324 -0
  228. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.cc +18 -1
  229. package/deps/rocksdb/rocksdb/utilities/transactions/write_prepared_txn.h +8 -1
  230. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index.cc +57 -12
  231. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +32 -3
  232. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.h +33 -2
  233. package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_test.cc +721 -9
  234. package/deps/rocksdb/rocksdb.gyp +2 -0
  235. package/package.json +1 -1
  236. package/prebuilds/darwin-arm64/@nxtedition+rocksdb.node +0 -0
  237. package/prebuilds/linux-x64/@nxtedition+rocksdb.node +0 -0
@@ -43,9 +43,9 @@ random.shuffle(colors)
43
43
  def num_to_gb(n):
44
44
  one_gb = 1024 * 1024 * 1024
45
45
  if float(n) % one_gb == 0:
46
- return "{}".format(n / one_gb)
46
+ return f"{n / one_gb}"
47
47
  # Keep two decimal points.
48
- return "{0:.2f}".format(float(n) / one_gb)
48
+ return f"{float(n) / one_gb:.2f}"
49
49
 
50
50
 
51
51
  def plot_miss_stats_graphs(
@@ -57,9 +57,9 @@ def plot_miss_stats_graphs(
57
57
  continue
58
58
  if not file.endswith(file_suffix):
59
59
  continue
60
- print("Processing file {}/{}".format(csv_result_dir, file))
60
+ print(f"Processing file {csv_result_dir}/{file}")
61
61
  mrc_file_path = csv_result_dir + "/" + file
62
- with open(mrc_file_path, "r") as csvfile:
62
+ with open(mrc_file_path) as csvfile:
63
63
  rows = csv.reader(csvfile, delimiter=",")
64
64
  for row in rows:
65
65
  cache_name = row[0]
@@ -67,7 +67,7 @@ def plot_miss_stats_graphs(
67
67
  ghost_capacity = int(row[2])
68
68
  capacity = int(row[3])
69
69
  miss_ratio = float(row[4])
70
- config = "{}-{}-{}".format(cache_name, num_shard_bits, ghost_capacity)
70
+ config = f"{cache_name}-{num_shard_bits}-{ghost_capacity}"
71
71
  if config not in miss_ratios:
72
72
  miss_ratios[config] = {}
73
73
  miss_ratios[config]["x"] = []
@@ -83,10 +83,10 @@ def plot_miss_stats_graphs(
83
83
  plt.ylabel(ylabel)
84
84
  plt.xscale("log", basex=2)
85
85
  plt.ylim(ymin=0)
86
- plt.title("{}".format(file))
86
+ plt.title(f"{file}")
87
87
  plt.legend()
88
88
  fig.savefig(
89
- output_result_dir + "/{}.pdf".format(pdf_file_name), bbox_inches="tight"
89
+ output_result_dir + f"/{pdf_file_name}.pdf", bbox_inches="tight"
90
90
  )
91
91
 
92
92
 
@@ -99,9 +99,9 @@ def plot_miss_stats_diff_lru_graphs(
99
99
  continue
100
100
  if not file.endswith(file_suffix):
101
101
  continue
102
- print("Processing file {}/{}".format(csv_result_dir, file))
102
+ print(f"Processing file {csv_result_dir}/{file}")
103
103
  mrc_file_path = csv_result_dir + "/" + file
104
- with open(mrc_file_path, "r") as csvfile:
104
+ with open(mrc_file_path) as csvfile:
105
105
  rows = csv.reader(csvfile, delimiter=",")
106
106
  for row in rows:
107
107
  cache_name = row[0]
@@ -109,7 +109,7 @@ def plot_miss_stats_diff_lru_graphs(
109
109
  ghost_capacity = int(row[2])
110
110
  capacity = int(row[3])
111
111
  miss_ratio = float(row[4])
112
- config = "{}-{}-{}".format(cache_name, num_shard_bits, ghost_capacity)
112
+ config = f"{cache_name}-{num_shard_bits}-{ghost_capacity}"
113
113
  if config not in miss_ratios:
114
114
  miss_ratios[config] = {}
115
115
  miss_ratios[config]["x"] = []
@@ -132,10 +132,10 @@ def plot_miss_stats_diff_lru_graphs(
132
132
  plt.xlabel("Cache capacity")
133
133
  plt.ylabel(ylabel)
134
134
  plt.xscale("log", basex=2)
135
- plt.title("{}".format(file))
135
+ plt.title(f"{file}")
136
136
  plt.legend()
137
137
  fig.savefig(
138
- output_result_dir + "/{}.pdf".format(pdf_file_name), bbox_inches="tight"
138
+ output_result_dir + f"/{pdf_file_name}.pdf", bbox_inches="tight"
139
139
  )
140
140
 
141
141
 
@@ -226,8 +226,8 @@ def plot_line_charts(
226
226
  continue
227
227
  if not file.startswith(filename_prefix):
228
228
  continue
229
- print("Processing file {}/{}".format(csv_result_dir, file))
230
- with open(csv_result_dir + "/" + file, "r") as csvfile:
229
+ print(f"Processing file {csv_result_dir}/{file}")
230
+ with open(csv_result_dir + "/" + file) as csvfile:
231
231
  x, labels, label_stats = read_data_for_plot(csvfile, vertical)
232
232
  if len(x) == 0 or len(labels) == 0:
233
233
  continue
@@ -247,11 +247,11 @@ def plot_line_charts(
247
247
 
248
248
  # Translate time unit into x labels.
249
249
  if "_60" in file:
250
- plt.xlabel("{} (Minute)".format(xlabel))
250
+ plt.xlabel(f"{xlabel} (Minute)")
251
251
  if "_3600" in file:
252
- plt.xlabel("{} (Hour)".format(xlabel))
252
+ plt.xlabel(f"{xlabel} (Hour)")
253
253
  plt.ylabel(ylabel)
254
- plt.title("{} {}".format(title, file))
254
+ plt.title(f"{title} {file}")
255
255
  if legend:
256
256
  plt.legend()
257
257
  pdf.savefig(fig)
@@ -271,13 +271,13 @@ def plot_stacked_bar_charts(
271
271
  ):
272
272
  global color_index, bar_color_maps, colors
273
273
  pdf = matplotlib.backends.backend_pdf.PdfPages(
274
- "{}/{}".format(output_result_dir, pdf_name)
274
+ f"{output_result_dir}/{pdf_name}"
275
275
  )
276
276
  for file in os.listdir(csv_result_dir):
277
277
  if not file.endswith(filename_suffix):
278
278
  continue
279
- with open(csv_result_dir + "/" + file, "r") as csvfile:
280
- print("Processing file {}/{}".format(csv_result_dir, file))
279
+ with open(csv_result_dir + "/" + file) as csvfile:
280
+ print(f"Processing file {csv_result_dir}/{file}")
281
281
  x, labels, label_stats = read_data_for_plot(csvfile, vertical)
282
282
  if len(x) == 0 or len(label_stats) == 0:
283
283
  continue
@@ -310,25 +310,25 @@ def plot_stacked_bar_charts(
310
310
  ind, [x_prefix + x[i] for i in range(len(x))], rotation=20, fontsize=8
311
311
  )
312
312
  plt.legend(bars, labels)
313
- plt.title("{} filename:{}".format(title, file))
313
+ plt.title(f"{title} filename:{file}")
314
314
  pdf.savefig(fig)
315
315
  pdf.close()
316
316
 
317
317
 
318
318
  def plot_heatmap(csv_result_dir, output_result_dir, filename_suffix, pdf_name, title):
319
319
  pdf = matplotlib.backends.backend_pdf.PdfPages(
320
- "{}/{}".format(output_result_dir, pdf_name)
320
+ f"{output_result_dir}/{pdf_name}"
321
321
  )
322
322
  for file in os.listdir(csv_result_dir):
323
323
  if not file.endswith(filename_suffix):
324
324
  continue
325
- csv_file_name = "{}/{}".format(csv_result_dir, file)
326
- print("Processing file {}/{}".format(csv_result_dir, file))
325
+ csv_file_name = f"{csv_result_dir}/{file}"
326
+ print(f"Processing file {csv_result_dir}/{file}")
327
327
  corr_table = pd.read_csv(csv_file_name)
328
328
  corr_table = corr_table.pivot("label", "corr", "value")
329
329
  fig = plt.figure()
330
330
  sns.heatmap(corr_table, annot=True, linewidths=0.5, fmt=".2")
331
- plt.title("{} filename:{}".format(title, file))
331
+ plt.title(f"{title} filename:{file}")
332
332
  pdf.savefig(fig)
333
333
  pdf.close()
334
334
 
@@ -360,16 +360,16 @@ def plot_correlation(csv_result_dir, output_result_dir):
360
360
  for file in os.listdir(csv_result_dir):
361
361
  if not file.endswith("correlation_input"):
362
362
  continue
363
- csv_file_name = "{}/{}".format(csv_result_dir, file)
364
- print("Processing file {}/{}".format(csv_result_dir, file))
363
+ csv_file_name = f"{csv_result_dir}/{file}"
364
+ print(f"Processing file {csv_result_dir}/{file}")
365
365
  corr_table = pd.read_csv(csv_file_name)
366
366
  label_str = file.split("_")[0]
367
367
  label = file[len(label_str) + 1 :]
368
368
  label = label[: len(label) - len("_correlation_input")]
369
369
 
370
- output_file = "{}/{}_correlation_output".format(csv_result_dir, label_str)
370
+ output_file = f"{csv_result_dir}/{label_str}_correlation_output"
371
371
  if output_file not in label_str_file:
372
- f = open("{}/{}_correlation_output".format(csv_result_dir, label_str), "w+")
372
+ f = open(f"{csv_result_dir}/{label_str}_correlation_output", "w+")
373
373
  label_str_file[output_file] = f
374
374
  f.write("label,corr,value\n")
375
375
  f = label_str_file[output_file]
@@ -666,9 +666,9 @@ if __name__ == "__main__":
666
666
  csv_abs_dir = csv_result_dir + "/" + csv_relative_dir
667
667
  result_dir = output_result_dir + "/" + csv_relative_dir
668
668
  if not os.path.isdir(csv_abs_dir):
669
- print("{} is not a directory".format(csv_abs_dir))
669
+ print(f"{csv_abs_dir} is not a directory")
670
670
  continue
671
- print("Processing experiment dir: {}".format(csv_relative_dir))
671
+ print(f"Processing experiment dir: {csv_relative_dir}")
672
672
  if not os.path.exists(result_dir):
673
673
  os.makedirs(result_dir)
674
674
  plot_access_count_summary(csv_abs_dir, result_dir)
@@ -698,32 +698,32 @@ if __name__ == "__main__":
698
698
  plot_miss_stats_graphs(
699
699
  csv_abs_dir,
700
700
  result_dir,
701
- file_prefix="ml_{}_".format(time_unit),
701
+ file_prefix=f"ml_{time_unit}_",
702
702
  file_suffix="p95mb",
703
- ylabel="p95 number of byte miss per {} seconds".format(time_unit),
704
- pdf_file_name="p95mb_per{}_seconds".format(time_unit),
703
+ ylabel=f"p95 number of byte miss per {time_unit} seconds",
704
+ pdf_file_name=f"p95mb_per{time_unit}_seconds",
705
705
  )
706
706
  plot_miss_stats_graphs(
707
707
  csv_abs_dir,
708
708
  result_dir,
709
- file_prefix="ml_{}_".format(time_unit),
709
+ file_prefix=f"ml_{time_unit}_",
710
710
  file_suffix="avgmb",
711
- ylabel="Average number of byte miss per {} seconds".format(time_unit),
712
- pdf_file_name="avgmb_per{}_seconds".format(time_unit),
711
+ ylabel=f"Average number of byte miss per {time_unit} seconds",
712
+ pdf_file_name=f"avgmb_per{time_unit}_seconds",
713
713
  )
714
714
  plot_miss_stats_diff_lru_graphs(
715
715
  csv_abs_dir,
716
716
  result_dir,
717
- file_prefix="ml_{}_".format(time_unit),
717
+ file_prefix=f"ml_{time_unit}_",
718
718
  file_suffix="p95mb",
719
- ylabel="p95 number of byte miss per {} seconds".format(time_unit),
720
- pdf_file_name="p95mb_per{}_seconds_diff_lru".format(time_unit),
719
+ ylabel=f"p95 number of byte miss per {time_unit} seconds",
720
+ pdf_file_name=f"p95mb_per{time_unit}_seconds_diff_lru",
721
721
  )
722
722
  plot_miss_stats_diff_lru_graphs(
723
723
  csv_abs_dir,
724
724
  result_dir,
725
- file_prefix="ml_{}_".format(time_unit),
725
+ file_prefix=f"ml_{time_unit}_",
726
726
  file_suffix="avgmb",
727
- ylabel="Average number of byte miss per {} seconds".format(time_unit),
728
- pdf_file_name="avgmb_per{}_seconds_diff_lru".format(time_unit),
727
+ ylabel=f"Average number of byte miss per {time_unit} seconds",
728
+ pdf_file_name=f"avgmb_per{time_unit}_seconds_diff_lru",
729
729
  )
@@ -153,10 +153,11 @@ DEFINE_string(
153
153
  "randomtransaction,"
154
154
  "randomreplacekeys,"
155
155
  "timeseries,"
156
- "getmergeoperands,",
156
+ "getmergeoperands,"
157
157
  "readrandomoperands,"
158
158
  "backup,"
159
- "restore"
159
+ "restore,"
160
+ "approximatememtablestats",
160
161
 
161
162
  "Comma-separated list of operations to run in the specified"
162
163
  " order. Available benchmarks:\n"
@@ -243,9 +244,14 @@ DEFINE_string(
243
244
  "operation includes a rare but possible retry in case it got "
244
245
  "`Status::Incomplete()`. This happens upon encountering more keys than "
245
246
  "have ever been seen by the thread (or eight initially)\n"
246
- "\tbackup -- Create a backup of the current DB and verify that a new backup is corrected. "
247
+ "\tbackup -- Create a backup of the current DB and verify that a new "
248
+ "backup is corrected. "
247
249
  "Rate limit can be specified through --backup_rate_limit\n"
248
- "\trestore -- Restore the DB from the latest backup available, rate limit can be specified through --restore_rate_limit\n");
250
+ "\trestore -- Restore the DB from the latest backup available, rate limit "
251
+ "can be specified through --restore_rate_limit\n"
252
+ "\tapproximatememtablestats -- Tests accuracy of "
253
+ "GetApproximateMemTableStats, ideally\n"
254
+ "after fillrandom, where actual answer is batch_size");
249
255
 
250
256
  DEFINE_int64(num, 1000000, "Number of key/values to place in database");
251
257
 
@@ -3621,6 +3627,8 @@ class Benchmark {
3621
3627
  fprintf(stderr, "entries_per_batch = %" PRIi64 "\n",
3622
3628
  entries_per_batch_);
3623
3629
  method = &Benchmark::ApproximateSizeRandom;
3630
+ } else if (name == "approximatememtablestats") {
3631
+ method = &Benchmark::ApproximateMemtableStats;
3624
3632
  } else if (name == "mixgraph") {
3625
3633
  method = &Benchmark::MixGraph;
3626
3634
  } else if (name == "readmissing") {
@@ -6298,6 +6306,35 @@ class Benchmark {
6298
6306
  thread->stats.AddMessage(msg);
6299
6307
  }
6300
6308
 
6309
+ void ApproximateMemtableStats(ThreadState* thread) {
6310
+ const size_t batch_size = entries_per_batch_;
6311
+ std::unique_ptr<const char[]> skey_guard;
6312
+ Slice skey = AllocateKey(&skey_guard);
6313
+ std::unique_ptr<const char[]> ekey_guard;
6314
+ Slice ekey = AllocateKey(&ekey_guard);
6315
+ Duration duration(FLAGS_duration, reads_);
6316
+ if (FLAGS_num < static_cast<int64_t>(batch_size)) {
6317
+ std::terminate();
6318
+ }
6319
+ uint64_t range = static_cast<uint64_t>(FLAGS_num) - batch_size;
6320
+ auto count_hist = std::make_shared<HistogramImpl>();
6321
+ while (!duration.Done(1)) {
6322
+ DB* db = SelectDB(thread);
6323
+ uint64_t start_key = thread->rand.Uniform(range);
6324
+ GenerateKeyFromInt(start_key, FLAGS_num, &skey);
6325
+ uint64_t end_key = start_key + batch_size;
6326
+ GenerateKeyFromInt(end_key, FLAGS_num, &ekey);
6327
+ uint64_t count = UINT64_MAX;
6328
+ uint64_t size = UINT64_MAX;
6329
+ db->GetApproximateMemTableStats({skey, ekey}, &count, &size);
6330
+ count_hist->Add(count);
6331
+ thread->stats.FinishedOps(nullptr, db, 1, kOthers);
6332
+ }
6333
+ thread->stats.AddMessage("\nReported entry count stats (expected " +
6334
+ std::to_string(batch_size) + "):");
6335
+ thread->stats.AddMessage("\n" + count_hist->ToString());
6336
+ }
6337
+
6301
6338
  // Calls ApproximateSize over random key ranges.
6302
6339
  void ApproximateSizeRandom(ThreadState* thread) {
6303
6340
  int64_t size_sum = 0;
@@ -3053,6 +3053,7 @@ void DumpWalFile(Options options, const std::string& wal_file,
3053
3053
  status = HandleWriteBatchTimestampSizeDifference(
3054
3054
  &batch, running_ts_sz, recorded_ts_sz,
3055
3055
  TimestampSizeConsistencyMode::kVerifyConsistency,
3056
+ /* seq_per_batch */ false, /* batch_per_txn */ true,
3056
3057
  /*new_batch=*/nullptr);
3057
3058
  if (!status.ok()) {
3058
3059
  std::stringstream oss;
@@ -132,7 +132,7 @@ class SSTDumpToolTest : public testing::Test {
132
132
  &internal_tbl_prop_coll_factories, CompressionType::kNoCompression,
133
133
  CompressionOptions(),
134
134
  TablePropertiesCollectorFactory::Context::kUnknownColumnFamily,
135
- column_family_name, unknown_level),
135
+ column_family_name, unknown_level, kUnknownNewestKeyTime),
136
136
  file_writer.get()));
137
137
 
138
138
  // Populate slightly more than 1K keys
@@ -4,7 +4,20 @@
4
4
  set -e
5
5
  set -o pipefail
6
6
 
7
+ cat << EOF
8
+ Release note advice:
9
+ * Speak to the RocksDB user and what is impacted in the public API
10
+
11
+ Formatting with markdown:
12
+ * This is an example list item referring to \`BlockBasedTableOptions\`.
13
+ If not starting with "* " it will be inserted at release time. This is OK.
14
+ *This asterisk begins italics, NOT a list item. PROBABLY WRONG
15
+
16
+ EOF
17
+
7
18
  if [ "$1" ]; then
19
+ echo "Press return to continue"
20
+ read
8
21
  # Target file specified on command line
9
22
  TARGET="$1"
10
23
  else
@@ -12,7 +12,7 @@
12
12
  #include <cassert>
13
13
 
14
14
  #include "port/port.h"
15
-
15
+ #include "rocksdb/file_system.h"
16
16
  namespace ROCKSDB_NAMESPACE {
17
17
 
18
18
  // This file contains utilities to handle the alignment of pages and buffers.
@@ -56,7 +56,7 @@ inline size_t Rounddown(size_t x, size_t y) { return (x / y) * y; }
56
56
  // copy_offset, copy_len);
57
57
  class AlignedBuffer {
58
58
  size_t alignment_;
59
- std::unique_ptr<char[]> buf_;
59
+ FSAllocationPtr buf_;
60
60
  size_t capacity_;
61
61
  size_t cursize_;
62
62
  char* bufstart_;
@@ -100,11 +100,11 @@ class AlignedBuffer {
100
100
 
101
101
  void Clear() { cursize_ = 0; }
102
102
 
103
- char* Release() {
103
+ FSAllocationPtr Release() {
104
104
  cursize_ = 0;
105
105
  capacity_ = 0;
106
106
  bufstart_ = nullptr;
107
- return buf_.release();
107
+ return std::move(buf_);
108
108
  }
109
109
 
110
110
  void Alignment(size_t alignment) {
@@ -113,6 +113,21 @@ class AlignedBuffer {
113
113
  alignment_ = alignment;
114
114
  }
115
115
 
116
+ // Points the buffer to the result without allocating extra
117
+ // memory or performing any data copies. Takes ownership of the
118
+ // FSAllocationPtr. This method is called when we want to reuse the buffer
119
+ // provided by the file system
120
+ void SetBuffer(Slice& result, FSAllocationPtr new_buf) {
121
+ alignment_ = 1;
122
+ capacity_ = result.size();
123
+ cursize_ = result.size();
124
+ buf_ = std::move(new_buf);
125
+ assert(buf_.get() != nullptr);
126
+ // Note: bufstart_ must point to result.data() and not new_buf, which can
127
+ // point to any arbitrary object
128
+ bufstart_ = const_cast<char*>(result.data());
129
+ }
130
+
116
131
  // Allocates a new buffer and sets the start position to the first aligned
117
132
  // byte.
118
133
  //
@@ -156,7 +171,11 @@ class AlignedBuffer {
156
171
 
157
172
  bufstart_ = new_bufstart;
158
173
  capacity_ = new_capacity;
159
- buf_.reset(new_buf);
174
+ // buf_ is a FSAllocationPtr which takes in a deleter
175
+ // we can just wrap the regular default delete that would have been called
176
+ buf_ = std::unique_ptr<void, std::function<void(void*)>>(
177
+ static_cast<void*>(new_buf),
178
+ [](void* p) { delete[] static_cast<char*>(p); });
160
179
  }
161
180
 
162
181
  // Append to the buffer.
@@ -17,6 +17,8 @@ void CompactionJobStats::Reset() {
17
17
  num_blobs_read = 0;
18
18
  num_input_files = 0;
19
19
  num_input_files_at_output_level = 0;
20
+ num_filtered_input_files = 0;
21
+ num_filtered_input_files_at_output_level = 0;
20
22
 
21
23
  num_output_records = 0;
22
24
  num_output_files = 0;
@@ -30,6 +32,7 @@ void CompactionJobStats::Reset() {
30
32
  total_blob_bytes_read = 0;
31
33
  total_output_bytes = 0;
32
34
  total_output_bytes_blob = 0;
35
+ total_skipped_input_bytes = 0;
33
36
 
34
37
  num_records_replaced = 0;
35
38
 
@@ -62,6 +65,9 @@ void CompactionJobStats::Add(const CompactionJobStats& stats) {
62
65
  num_blobs_read += stats.num_blobs_read;
63
66
  num_input_files += stats.num_input_files;
64
67
  num_input_files_at_output_level += stats.num_input_files_at_output_level;
68
+ num_filtered_input_files += stats.num_filtered_input_files;
69
+ num_filtered_input_files_at_output_level +=
70
+ stats.num_filtered_input_files_at_output_level;
65
71
 
66
72
  num_output_records += stats.num_output_records;
67
73
  num_output_files += stats.num_output_files;
@@ -71,6 +77,7 @@ void CompactionJobStats::Add(const CompactionJobStats& stats) {
71
77
  total_blob_bytes_read += stats.total_blob_bytes_read;
72
78
  total_output_bytes += stats.total_output_bytes;
73
79
  total_output_bytes_blob += stats.total_output_bytes_blob;
80
+ total_skipped_input_bytes += stats.total_skipped_input_bytes;
74
81
 
75
82
  num_records_replaced += stats.num_records_replaced;
76
83
 
@@ -9,12 +9,6 @@
9
9
 
10
10
  #include "util/file_checksum_helper.h"
11
11
 
12
- #include <unordered_set>
13
-
14
- #include "db/log_reader.h"
15
- #include "db/version_edit.h"
16
- #include "db/version_edit_handler.h"
17
- #include "file/sequence_file_reader.h"
18
12
  #include "rocksdb/utilities/customizable_util.h"
19
13
 
20
14
  namespace ROCKSDB_NAMESPACE {
@@ -91,52 +85,6 @@ std::shared_ptr<FileChecksumGenFactory> GetFileChecksumGenCrc32cFactory() {
91
85
  return default_crc32c_gen_factory;
92
86
  }
93
87
 
94
- Status GetFileChecksumsFromManifest(Env* src_env, const std::string& abs_path,
95
- uint64_t manifest_file_size,
96
- FileChecksumList* checksum_list) {
97
- if (checksum_list == nullptr) {
98
- return Status::InvalidArgument("checksum_list is nullptr");
99
- }
100
- assert(checksum_list);
101
- // TODO: plumb Env::IOActivity, Env::IOPriority
102
- const ReadOptions read_options;
103
- checksum_list->reset();
104
- Status s;
105
-
106
- std::unique_ptr<SequentialFileReader> file_reader;
107
- {
108
- std::unique_ptr<FSSequentialFile> file;
109
- const std::shared_ptr<FileSystem>& fs = src_env->GetFileSystem();
110
- s = fs->NewSequentialFile(abs_path,
111
- fs->OptimizeForManifestRead(FileOptions()), &file,
112
- nullptr /* dbg */);
113
- if (!s.ok()) {
114
- return s;
115
- }
116
- file_reader.reset(new SequentialFileReader(std::move(file), abs_path));
117
- }
118
-
119
- struct LogReporter : public log::Reader::Reporter {
120
- Status* status_ptr;
121
- void Corruption(size_t /*bytes*/, const Status& st) override {
122
- if (status_ptr->ok()) {
123
- *status_ptr = st;
124
- }
125
- }
126
- } reporter;
127
- reporter.status_ptr = &s;
128
- log::Reader reader(nullptr, std::move(file_reader), &reporter,
129
- true /* checksum */, 0 /* log_number */);
130
- FileChecksumRetriever retriever(read_options, manifest_file_size,
131
- *checksum_list);
132
- retriever.Iterate(reader, &s);
133
- assert(!retriever.status().ok() ||
134
- manifest_file_size == std::numeric_limits<uint64_t>::max() ||
135
- reader.LastRecordEnd() == manifest_file_size);
136
-
137
- return retriever.status();
138
- }
139
-
140
88
  namespace {
141
89
  static int RegisterFileChecksumGenFactories(ObjectLibrary& library,
142
90
  const std::string& /*arg*/) {
@@ -4,13 +4,10 @@
4
4
  // (found in the LICENSE.Apache file in the root directory).
5
5
 
6
6
  #pragma once
7
- #include <cassert>
7
+
8
8
  #include <unordered_map>
9
9
 
10
- #include "port/port.h"
11
- #include "rocksdb/env.h"
12
10
  #include "rocksdb/file_checksum.h"
13
- #include "rocksdb/status.h"
14
11
  #include "util/coding.h"
15
12
  #include "util/crc32c.h"
16
13
  #include "util/math.h"
@@ -92,10 +89,4 @@ class FileChecksumListImpl : public FileChecksumList {
92
89
  checksum_map_;
93
90
  };
94
91
 
95
- // If manifest_file_size < std::numeric_limits<uint64_t>::max(), only use
96
- // that length prefix of the manifest file.
97
- Status GetFileChecksumsFromManifest(Env* src_env, const std::string& abs_path,
98
- uint64_t manifest_file_size,
99
- FileChecksumList* checksum_list);
100
-
101
92
  } // namespace ROCKSDB_NAMESPACE
@@ -230,6 +230,98 @@ TEST_F(WritableFileWriterTest, IncrementalBuffer) {
230
230
  }
231
231
  }
232
232
 
233
+ TEST_F(WritableFileWriterTest, AlignedBufferedWrites) {
234
+ class FakeWF : public FSWritableFile {
235
+ public:
236
+ explicit FakeWF(std::string* _file_data) : file_data_(_file_data) {}
237
+ ~FakeWF() override = default;
238
+
239
+ using FSWritableFile::Append;
240
+ IOStatus Append(const Slice& data, const IOOptions& /*options*/,
241
+ IODebugContext* /*dbg*/) override {
242
+ EXPECT_EQ(data.size() & (data.size() - 1), 0);
243
+ file_data_->append(data.data(), data.size());
244
+ size_ += data.size();
245
+ return IOStatus::OK();
246
+ }
247
+ using FSWritableFile::PositionedAppend;
248
+ IOStatus PositionedAppend(const Slice& data, uint64_t pos,
249
+ const IOOptions& /*options*/,
250
+ IODebugContext* /*dbg*/) override {
251
+ EXPECT_TRUE(pos % 512 == 0);
252
+ EXPECT_TRUE(data.size() % 512 == 0);
253
+ file_data_->resize(pos);
254
+ file_data_->append(data.data(), data.size());
255
+ size_ += data.size();
256
+ return IOStatus::OK();
257
+ }
258
+
259
+ IOStatus Truncate(uint64_t size, const IOOptions& /*options*/,
260
+ IODebugContext* /*dbg*/) override {
261
+ file_data_->resize(size);
262
+ return IOStatus::OK();
263
+ }
264
+ IOStatus Close(const IOOptions& /*options*/,
265
+ IODebugContext* /*dbg*/) override {
266
+ return IOStatus::OK();
267
+ }
268
+ IOStatus Flush(const IOOptions& /*options*/,
269
+ IODebugContext* /*dbg*/) override {
270
+ return IOStatus::OK();
271
+ }
272
+ IOStatus Sync(const IOOptions& /*options*/,
273
+ IODebugContext* /*dbg*/) override {
274
+ return IOStatus::OK();
275
+ }
276
+ IOStatus Fsync(const IOOptions& /*options*/,
277
+ IODebugContext* /*dbg*/) override {
278
+ return IOStatus::OK();
279
+ }
280
+ void SetIOPriority(Env::IOPriority /*pri*/) override {}
281
+ uint64_t GetFileSize(const IOOptions& /*options*/,
282
+ IODebugContext* /*dbg*/) override {
283
+ return size_;
284
+ }
285
+ void GetPreallocationStatus(size_t* /*block_size*/,
286
+ size_t* /*last_allocated_block*/) override {}
287
+ size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const override {
288
+ return 0;
289
+ }
290
+ IOStatus InvalidateCache(size_t /*offset*/, size_t /*length*/) override {
291
+ return IOStatus::OK();
292
+ }
293
+ bool use_direct_io() const override { return false; }
294
+
295
+ std::string* file_data_;
296
+ size_t size_ = 0;
297
+ };
298
+
299
+ Random r(301);
300
+ EnvOptions env_options;
301
+ env_options.writable_file_max_buffer_size = 64 * 1024 * 1024;
302
+ std::string actual;
303
+ std::unique_ptr<FakeWF> wf(new FakeWF(&actual));
304
+ std::unique_ptr<WritableFileWriter> writer(
305
+ new WritableFileWriter(std::move(wf), "" /* don't care */, env_options));
306
+
307
+ std::string target;
308
+ uint32_t left =
309
+ static_cast<uint32_t>(2 * env_options.writable_file_max_buffer_size);
310
+ ;
311
+ while (left > 0) {
312
+ uint32_t num = 4096 + r.Uniform(8192);
313
+ num = std::min<uint32_t>(num, left);
314
+ std::string random_string = r.RandomString(num);
315
+ ASSERT_OK(writer->Append(IOOptions(), Slice(random_string.c_str(), num)));
316
+ target.append(random_string.c_str(), num);
317
+ left -= num;
318
+ }
319
+ ASSERT_OK(writer->Flush(IOOptions()));
320
+ ASSERT_OK(writer->Close(IOOptions()));
321
+ ASSERT_EQ(target.size(), actual.size());
322
+ ASSERT_EQ(target, actual);
323
+ }
324
+
233
325
  TEST_F(WritableFileWriterTest, BufferWithZeroCapacityDirectIO) {
234
326
  EnvOptions env_opts;
235
327
  env_opts.use_direct_writes = true;
@@ -47,6 +47,7 @@ static OperationInfo global_operation_table[] = {
47
47
  {ThreadStatus::OP_VERIFY_FILE_CHECKSUMS, "VerifyFileChecksums"},
48
48
  {ThreadStatus::OP_GETENTITY, "GetEntity"},
49
49
  {ThreadStatus::OP_MULTIGETENTITY, "MultiGetEntity"},
50
+ {ThreadStatus::OP_READ_MANIFEST, "ReadManifest"},
50
51
 
51
52
  };
52
53