@nxtedition/rocksdb 7.1.14 → 7.1.15

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 (223) hide show
  1. package/binding.cc +1 -0
  2. package/deps/rocksdb/rocksdb/CMakeLists.txt +72 -18
  3. package/deps/rocksdb/rocksdb/Makefile +91 -11
  4. package/deps/rocksdb/rocksdb/TARGETS +8 -4
  5. package/deps/rocksdb/rocksdb/cache/cache.cc +5 -0
  6. package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +13 -8
  7. package/deps/rocksdb/rocksdb/cache/cache_entry_roles.cc +2 -0
  8. package/deps/rocksdb/rocksdb/cache/cache_test.cc +116 -57
  9. package/deps/rocksdb/rocksdb/cache/clock_cache.cc +958 -459
  10. package/deps/rocksdb/rocksdb/cache/clock_cache.h +407 -622
  11. package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.cc +104 -40
  12. package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.h +23 -8
  13. package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache_test.cc +350 -184
  14. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.cc +12 -2
  15. package/deps/rocksdb/rocksdb/cache/fast_lru_cache.h +2 -0
  16. package/deps/rocksdb/rocksdb/cache/lru_cache.cc +130 -43
  17. package/deps/rocksdb/rocksdb/cache/lru_cache.h +24 -2
  18. package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +423 -98
  19. package/deps/rocksdb/rocksdb/cache/sharded_cache.cc +19 -2
  20. package/deps/rocksdb/rocksdb/cache/sharded_cache.h +10 -7
  21. package/deps/rocksdb/rocksdb/crash_test.mk +2 -2
  22. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.cc +46 -26
  23. package/deps/rocksdb/rocksdb/db/arena_wrapped_db_iter.h +9 -3
  24. package/deps/rocksdb/rocksdb/db/blob/blob_contents.cc +90 -0
  25. package/deps/rocksdb/rocksdb/db/blob/blob_contents.h +56 -0
  26. package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.cc +23 -10
  27. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.cc +64 -59
  28. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.h +11 -8
  29. package/deps/rocksdb/rocksdb/db/blob/blob_file_reader_test.cc +92 -62
  30. package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +159 -136
  31. package/deps/rocksdb/rocksdb/db/blob/blob_source.h +13 -13
  32. package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +129 -57
  33. package/deps/rocksdb/rocksdb/db/blob/db_blob_basic_test.cc +81 -3
  34. package/deps/rocksdb/rocksdb/db/c.cc +29 -0
  35. package/deps/rocksdb/rocksdb/db/column_family.cc +10 -1
  36. package/deps/rocksdb/rocksdb/db/column_family_test.cc +21 -0
  37. package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +42 -36
  38. package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +344 -102
  39. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.cc +163 -28
  40. package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +52 -17
  41. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +35 -30
  42. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +8 -3
  43. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +167 -11
  44. package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +8 -8
  45. package/deps/rocksdb/rocksdb/db/compaction/compaction_service_test.cc +10 -13
  46. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.cc +0 -117
  47. package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +6 -49
  48. package/deps/rocksdb/rocksdb/db/db_basic_test.cc +29 -4
  49. package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +18 -11
  50. package/deps/rocksdb/rocksdb/db/db_compaction_filter_test.cc +4 -10
  51. package/deps/rocksdb/rocksdb/db/db_impl/compacted_db_impl.cc +1 -1
  52. package/deps/rocksdb/rocksdb/db/db_impl/compacted_db_impl.h +12 -0
  53. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +144 -93
  54. package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +28 -32
  55. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +1 -1
  56. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +5 -9
  57. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +2 -33
  58. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.cc +3 -5
  59. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_readonly.h +11 -0
  60. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.cc +1 -2
  61. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_secondary.h +8 -0
  62. package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +2 -1
  63. package/deps/rocksdb/rocksdb/db/db_iter.cc +76 -138
  64. package/deps/rocksdb/rocksdb/db/db_iter.h +26 -23
  65. package/deps/rocksdb/rocksdb/db/db_properties_test.cc +1 -1
  66. package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +931 -0
  67. package/deps/rocksdb/rocksdb/db/db_sst_test.cc +2 -2
  68. package/deps/rocksdb/rocksdb/db/db_table_properties_test.cc +6 -0
  69. package/deps/rocksdb/rocksdb/db/db_test2.cc +44 -22
  70. package/deps/rocksdb/rocksdb/db/db_test_util.cc +6 -14
  71. package/deps/rocksdb/rocksdb/db/db_with_timestamp_compaction_test.cc +155 -0
  72. package/deps/rocksdb/rocksdb/db/db_write_test.cc +45 -0
  73. package/deps/rocksdb/rocksdb/db/dbformat.h +2 -1
  74. package/deps/rocksdb/rocksdb/db/error_handler_fs_test.cc +8 -0
  75. package/deps/rocksdb/rocksdb/db/experimental.cc +5 -1
  76. package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +24 -12
  77. package/deps/rocksdb/rocksdb/db/internal_stats.cc +7 -1
  78. package/deps/rocksdb/rocksdb/db/internal_stats.h +3 -0
  79. package/deps/rocksdb/rocksdb/db/memtable.cc +79 -18
  80. package/deps/rocksdb/rocksdb/db/memtable.h +5 -0
  81. package/deps/rocksdb/rocksdb/db/memtable_list.cc +26 -4
  82. package/deps/rocksdb/rocksdb/db/memtable_list.h +2 -1
  83. package/deps/rocksdb/rocksdb/db/periodic_task_scheduler.cc +113 -0
  84. package/deps/rocksdb/rocksdb/db/periodic_task_scheduler.h +110 -0
  85. package/deps/rocksdb/rocksdb/db/{periodic_work_scheduler_test.cc → periodic_task_scheduler_test.cc} +33 -39
  86. package/deps/rocksdb/rocksdb/db/range_del_aggregator.cc +12 -20
  87. package/deps/rocksdb/rocksdb/db/range_del_aggregator.h +6 -5
  88. package/deps/rocksdb/rocksdb/db/range_del_aggregator_test.cc +12 -8
  89. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.cc +20 -5
  90. package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter.h +14 -0
  91. package/deps/rocksdb/rocksdb/db/repair.cc +17 -8
  92. package/deps/rocksdb/rocksdb/db/repair_test.cc +2 -1
  93. package/deps/rocksdb/rocksdb/db/seqno_time_test.cc +49 -66
  94. package/deps/rocksdb/rocksdb/db/table_cache.cc +92 -63
  95. package/deps/rocksdb/rocksdb/db/table_cache.h +16 -9
  96. package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +2 -2
  97. package/deps/rocksdb/rocksdb/db/table_properties_collector.cc +2 -2
  98. package/deps/rocksdb/rocksdb/db/table_properties_collector.h +3 -3
  99. package/deps/rocksdb/rocksdb/db/table_properties_collector_test.cc +1 -1
  100. package/deps/rocksdb/rocksdb/db/version_builder.cc +1 -1
  101. package/deps/rocksdb/rocksdb/db/version_edit.h +1 -2
  102. package/deps/rocksdb/rocksdb/db/version_set.cc +379 -145
  103. package/deps/rocksdb/rocksdb/db/version_set.h +26 -24
  104. package/deps/rocksdb/rocksdb/db/version_set_test.cc +9 -9
  105. package/deps/rocksdb/rocksdb/db/version_util.h +3 -2
  106. package/deps/rocksdb/rocksdb/db/wide/db_wide_basic_test.cc +10 -2
  107. package/deps/rocksdb/rocksdb/db/wide/wide_column_serialization.cc +2 -0
  108. package/deps/rocksdb/rocksdb/db_stress_tool/batched_ops_stress.cc +5 -8
  109. package/deps/rocksdb/rocksdb/db_stress_tool/cf_consistency_stress.cc +5 -8
  110. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress.cc +2 -0
  111. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.cc +71 -0
  112. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +14 -0
  113. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +23 -0
  114. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +26 -1
  115. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +105 -34
  116. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.h +16 -8
  117. package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +6 -0
  118. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.cc +4 -8
  119. package/deps/rocksdb/rocksdb/db_stress_tool/multi_ops_txns_stress.h +4 -8
  120. package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +282 -25
  121. package/deps/rocksdb/rocksdb/env/fs_posix.cc +6 -4
  122. package/deps/rocksdb/rocksdb/env/io_posix.cc +3 -1
  123. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +367 -177
  124. package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.h +144 -56
  125. package/deps/rocksdb/rocksdb/file/filename.cc +3 -3
  126. package/deps/rocksdb/rocksdb/file/filename.h +4 -2
  127. package/deps/rocksdb/rocksdb/file/prefetch_test.cc +415 -0
  128. package/deps/rocksdb/rocksdb/file/random_access_file_reader.cc +2 -0
  129. package/deps/rocksdb/rocksdb/file/writable_file_writer.cc +36 -45
  130. package/deps/rocksdb/rocksdb/file/writable_file_writer.h +21 -3
  131. package/deps/rocksdb/rocksdb/include/rocksdb/advanced_options.h +11 -11
  132. package/deps/rocksdb/rocksdb/include/rocksdb/c.h +15 -1
  133. package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +163 -68
  134. package/deps/rocksdb/rocksdb/include/rocksdb/db.h +26 -12
  135. package/deps/rocksdb/rocksdb/include/rocksdb/iterator.h +23 -5
  136. package/deps/rocksdb/rocksdb/include/rocksdb/options.h +21 -17
  137. package/deps/rocksdb/rocksdb/include/rocksdb/perf_context.h +17 -0
  138. package/deps/rocksdb/rocksdb/include/rocksdb/persistent_cache.h +3 -3
  139. package/deps/rocksdb/rocksdb/include/rocksdb/secondary_cache.h +17 -6
  140. package/deps/rocksdb/rocksdb/include/rocksdb/statistics.h +3 -0
  141. package/deps/rocksdb/rocksdb/include/rocksdb/table.h +20 -0
  142. package/deps/rocksdb/rocksdb/include/rocksdb/table_properties.h +3 -3
  143. package/deps/rocksdb/rocksdb/include/rocksdb/utilities/option_change_migration.h +4 -0
  144. package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
  145. package/deps/rocksdb/rocksdb/include/rocksdb/wide_columns.h +3 -0
  146. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch.h +2 -1
  147. package/deps/rocksdb/rocksdb/include/rocksdb/write_batch_base.h +2 -1
  148. package/deps/rocksdb/rocksdb/logging/env_logger.h +2 -2
  149. package/deps/rocksdb/rocksdb/monitoring/histogram.cc +4 -2
  150. package/deps/rocksdb/rocksdb/monitoring/histogram.h +2 -0
  151. package/deps/rocksdb/rocksdb/monitoring/histogram_test.cc +15 -1
  152. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.cc +17 -0
  153. package/deps/rocksdb/rocksdb/monitoring/instrumented_mutex.h +14 -3
  154. package/deps/rocksdb/rocksdb/monitoring/iostats_context_imp.h +3 -0
  155. package/deps/rocksdb/rocksdb/monitoring/perf_context.cc +50 -0
  156. package/deps/rocksdb/rocksdb/monitoring/statistics.cc +1 -0
  157. package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +31 -32
  158. package/deps/rocksdb/rocksdb/options/customizable_test.cc +4 -1
  159. package/deps/rocksdb/rocksdb/options/options.cc +2 -2
  160. package/deps/rocksdb/rocksdb/options/options_settable_test.cc +2 -1
  161. package/deps/rocksdb/rocksdb/port/jemalloc_helper.h +1 -0
  162. package/deps/rocksdb/rocksdb/src.mk +4 -2
  163. package/deps/rocksdb/rocksdb/table/block_based/block.h +9 -8
  164. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +110 -99
  165. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +12 -10
  166. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +11 -2
  167. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +138 -83
  168. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +25 -24
  169. package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +31 -30
  170. package/deps/rocksdb/rocksdb/table/block_based/block_prefetcher.cc +16 -13
  171. package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +4 -4
  172. package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +3 -3
  173. package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +3 -3
  174. package/deps/rocksdb/rocksdb/table/block_fetcher.cc +17 -19
  175. package/deps/rocksdb/rocksdb/table/block_fetcher.h +1 -1
  176. package/deps/rocksdb/rocksdb/table/format.cc +26 -29
  177. package/deps/rocksdb/rocksdb/table/format.h +44 -26
  178. package/deps/rocksdb/rocksdb/table/get_context.cc +17 -12
  179. package/deps/rocksdb/rocksdb/table/internal_iterator.h +7 -0
  180. package/deps/rocksdb/rocksdb/table/iterator_wrapper.h +4 -0
  181. package/deps/rocksdb/rocksdb/table/merging_iterator.cc +950 -104
  182. package/deps/rocksdb/rocksdb/table/merging_iterator.h +28 -1
  183. package/deps/rocksdb/rocksdb/table/meta_blocks.cc +3 -2
  184. package/deps/rocksdb/rocksdb/table/meta_blocks.h +1 -1
  185. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.cc +10 -9
  186. package/deps/rocksdb/rocksdb/table/persistent_cache_helper.h +22 -20
  187. package/deps/rocksdb/rocksdb/table/plain/plain_table_builder.cc +1 -1
  188. package/deps/rocksdb/rocksdb/table/sst_file_writer_collectors.h +1 -1
  189. package/deps/rocksdb/rocksdb/table/table_builder.h +9 -21
  190. package/deps/rocksdb/rocksdb/table/table_test.cc +12 -12
  191. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_pysim_test.py +4 -4
  192. package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_plot.py +1 -0
  193. package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +116 -34
  194. package/deps/rocksdb/rocksdb/tools/ldb_cmd.cc +6 -1
  195. package/deps/rocksdb/rocksdb/tools/trace_analyzer_tool.cc +1 -1
  196. package/deps/rocksdb/rocksdb/util/autovector.h +12 -0
  197. package/deps/rocksdb/rocksdb/util/rate_limiter_test.cc +3 -2
  198. package/deps/rocksdb/rocksdb/util/stderr_logger.cc +30 -0
  199. package/deps/rocksdb/rocksdb/util/stderr_logger.h +5 -18
  200. package/deps/rocksdb/rocksdb/util/timer.h +2 -3
  201. package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +9 -2
  202. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_db_impl.cc +1 -1
  203. package/deps/rocksdb/rocksdb/utilities/blob_db/blob_dump_tool.cc +1 -1
  204. package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.cc +34 -53
  205. package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.h +9 -14
  206. package/deps/rocksdb/rocksdb/utilities/debug.cc +2 -4
  207. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +4 -0
  208. package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +1 -1
  209. package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.cc +4 -3
  210. package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.h +3 -1
  211. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration.cc +26 -8
  212. package/deps/rocksdb/rocksdb/utilities/option_change_migration/option_change_migration_test.cc +114 -16
  213. package/deps/rocksdb/rocksdb/utilities/persistent_cache/persistent_cache_test.cc +1 -1
  214. package/deps/rocksdb/rocksdb/utilities/transactions/optimistic_transaction_test.cc +59 -0
  215. package/deps/rocksdb/rocksdb/utilities/transactions/pessimistic_transaction.cc +3 -0
  216. package/deps/rocksdb/rocksdb/utilities/transactions/timestamped_snapshot_test.cc +39 -0
  217. package/deps/rocksdb/rocksdb.gyp +0 -1
  218. package/index.js +6 -10
  219. package/package.json +1 -1
  220. package/prebuilds/darwin-arm64/node.napi.node +0 -0
  221. package/prebuilds/linux-x64/node.napi.node +0 -0
  222. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.cc +0 -168
  223. package/deps/rocksdb/rocksdb/db/periodic_work_scheduler.h +0 -90
@@ -70,9 +70,6 @@ class BlockBasedTable : public TableReader {
70
70
  static const std::string kFullFilterBlockPrefix;
71
71
  static const std::string kPartitionedFilterBlockPrefix;
72
72
 
73
- // All the below fields control iterator readahead
74
- static const int kMinNumFileReadsToStartAutoReadahead = 2;
75
-
76
73
  // 1-byte compression type + 32-bit checksum
77
74
  static constexpr size_t kBlockTrailerSize = 5;
78
75
 
@@ -111,7 +108,8 @@ class BlockBasedTable : public TableReader {
111
108
  TailPrefetchStats* tail_prefetch_stats = nullptr,
112
109
  BlockCacheTracer* const block_cache_tracer = nullptr,
113
110
  size_t max_file_size_for_l0_meta_pin = 0,
114
- const std::string& cur_db_session_id = "", uint64_t cur_file_num = 0);
111
+ const std::string& cur_db_session_id = "", uint64_t cur_file_num = 0,
112
+ UniqueId64x2 expected_unique_id = {});
115
113
 
116
114
  bool PrefixRangeMayMatch(const Slice& internal_key,
117
115
  const ReadOptions& read_options,
@@ -251,16 +249,16 @@ class BlockBasedTable : public TableReader {
251
249
  return static_cast<size_t>(handle.size() + kBlockTrailerSize);
252
250
  }
253
251
 
254
- // It's the caller's responsibility to make sure that this is
255
- // for raw block contents, which contains the compression
256
- // byte in the end.
252
+ // It is the caller's responsibility to make sure that this is called with
253
+ // block-based table serialized block contents, which contains the compression
254
+ // byte in the trailer after `block_size`.
257
255
  static inline CompressionType GetBlockCompressionType(const char* block_data,
258
256
  size_t block_size) {
259
257
  return static_cast<CompressionType>(block_data[block_size]);
260
258
  }
261
259
  static inline CompressionType GetBlockCompressionType(
262
260
  const BlockContents& contents) {
263
- assert(contents.is_raw_block);
261
+ assert(contents.has_trailer);
264
262
  return GetBlockCompressionType(contents.data.data(), contents.data.size());
265
263
  }
266
264
 
@@ -329,7 +327,7 @@ class BlockBasedTable : public TableReader {
329
327
  Status InsertEntryToCache(const CacheTier& cache_tier, Cache* block_cache,
330
328
  const Slice& key,
331
329
  const Cache::CacheItemHelper* cache_helper,
332
- std::unique_ptr<TBlocklike>& block_holder,
330
+ std::unique_ptr<TBlocklike>&& block_holder,
333
331
  size_t charge, Cache::Handle** cache_handle,
334
332
  Cache::Priority priority) const;
335
333
 
@@ -413,13 +411,13 @@ class BlockBasedTable : public TableReader {
413
411
  BlockType block_type, const bool wait,
414
412
  GetContext* get_context) const;
415
413
 
416
- // Put a raw block (maybe compressed) to the corresponding block caches.
417
- // This method will perform decompression against raw_block if needed and then
418
- // populate the block caches.
414
+ // Put a maybe compressed block to the corresponding block caches.
415
+ // This method will perform decompression against block_contents if needed
416
+ // and then populate the block caches.
419
417
  // On success, Status::OK will be returned; also @block will be populated with
420
418
  // uncompressed block and its cache handle.
421
419
  //
422
- // Allocated memory managed by raw_block_contents will be transferred to
420
+ // Allocated memory managed by block_contents will be transferred to
423
421
  // PutDataBlockToCache(). After the call, the object will be invalid.
424
422
  // @param uncompression_dict Data for presetting the compression library's
425
423
  // dictionary.
@@ -427,8 +425,8 @@ class BlockBasedTable : public TableReader {
427
425
  Status PutDataBlockToCache(const Slice& cache_key, Cache* block_cache,
428
426
  Cache* block_cache_compressed,
429
427
  CachableEntry<TBlocklike>* cached_block,
430
- BlockContents* raw_block_contents,
431
- CompressionType raw_block_comp_type,
428
+ BlockContents&& block_contents,
429
+ CompressionType block_comp_type,
432
430
  const UncompressionDict& uncompression_dict,
433
431
  MemoryAllocator* memory_allocator,
434
432
  BlockType block_type,
@@ -659,25 +657,28 @@ struct BlockBasedTable::Rep {
659
657
  uint64_t sst_number_for_tracing() const {
660
658
  return file ? TableFileNameToNumber(file->file_name()) : UINT64_MAX;
661
659
  }
662
- void CreateFilePrefetchBuffer(size_t readahead_size,
663
- size_t max_readahead_size,
664
- std::unique_ptr<FilePrefetchBuffer>* fpb,
665
- bool implicit_auto_readahead,
666
- uint64_t num_file_reads) const {
660
+ void CreateFilePrefetchBuffer(
661
+ size_t readahead_size, size_t max_readahead_size,
662
+ std::unique_ptr<FilePrefetchBuffer>* fpb, bool implicit_auto_readahead,
663
+ uint64_t num_file_reads,
664
+ uint64_t num_file_reads_for_auto_readahead) const {
667
665
  fpb->reset(new FilePrefetchBuffer(
668
666
  readahead_size, max_readahead_size,
669
667
  !ioptions.allow_mmap_reads /* enable */, false /* track_min_offset */,
670
- implicit_auto_readahead, num_file_reads, ioptions.fs.get(),
671
- ioptions.clock, ioptions.stats));
668
+ implicit_auto_readahead, num_file_reads,
669
+ num_file_reads_for_auto_readahead, ioptions.fs.get(), ioptions.clock,
670
+ ioptions.stats));
672
671
  }
673
672
 
674
673
  void CreateFilePrefetchBufferIfNotExists(
675
674
  size_t readahead_size, size_t max_readahead_size,
676
675
  std::unique_ptr<FilePrefetchBuffer>* fpb, bool implicit_auto_readahead,
677
- uint64_t num_file_reads) const {
676
+ uint64_t num_file_reads,
677
+ uint64_t num_file_reads_for_auto_readahead) const {
678
678
  if (!(*fpb)) {
679
679
  CreateFilePrefetchBuffer(readahead_size, max_readahead_size, fpb,
680
- implicit_auto_readahead, num_file_reads);
680
+ implicit_auto_readahead, num_file_reads,
681
+ num_file_reads_for_auto_readahead);
681
682
  }
682
683
  }
683
684
 
@@ -191,7 +191,7 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
191
191
  }
192
192
  }
193
193
 
194
- BlockContents raw_block_contents;
194
+ BlockContents serialized_block;
195
195
  if (s.ok()) {
196
196
  if (!use_shared_buffer) {
197
197
  // We allocated a buffer for this block. Give ownership of it to
@@ -199,17 +199,17 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
199
199
  assert(req.result.data() == req.scratch);
200
200
  assert(req.result.size() == BlockSizeWithTrailer(handle));
201
201
  assert(req_offset == 0);
202
- std::unique_ptr<char[]> raw_block(req.scratch);
203
- raw_block_contents = BlockContents(std::move(raw_block), handle.size());
202
+ serialized_block =
203
+ BlockContents(std::unique_ptr<char[]>(req.scratch), handle.size());
204
204
  } else {
205
205
  // We used the scratch buffer or direct io buffer
206
206
  // which are shared by the blocks.
207
- // raw_block_contents does not have the ownership.
208
- raw_block_contents =
207
+ // serialized_block does not have the ownership.
208
+ serialized_block =
209
209
  BlockContents(Slice(req.result.data() + req_offset, handle.size()));
210
210
  }
211
211
  #ifndef NDEBUG
212
- raw_block_contents.is_raw_block = true;
212
+ serialized_block.has_trailer = true;
213
213
  #endif
214
214
 
215
215
  if (options.verify_checksums) {
@@ -232,28 +232,29 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
232
232
 
233
233
  if (s.ok()) {
234
234
  // When the blocks share the same underlying buffer (scratch or direct io
235
- // buffer), we may need to manually copy the block into heap if the raw
236
- // block has to be inserted into a cache. That falls into th following
237
- // cases -
238
- // 1. Raw block is not compressed, it needs to be inserted into the
239
- // uncompressed block cache if there is one
240
- // 2. If the raw block is compressed, it needs to be inserted into the
241
- // compressed block cache if there is one
235
+ // buffer), we may need to manually copy the block into heap if the
236
+ // serialized block has to be inserted into a cache. That falls into the
237
+ // following cases -
238
+ // 1. serialized block is not compressed, it needs to be inserted into
239
+ // the uncompressed block cache if there is one
240
+ // 2. If the serialized block is compressed, it needs to be inserted
241
+ // into the compressed block cache if there is one
242
242
  //
243
- // In all other cases, the raw block is either uncompressed into a heap
244
- // buffer or there is no cache at all.
243
+ // In all other cases, the serialized block is either uncompressed into a
244
+ // heap buffer or there is no cache at all.
245
245
  CompressionType compression_type =
246
- GetBlockCompressionType(raw_block_contents);
246
+ GetBlockCompressionType(serialized_block);
247
247
  if (use_shared_buffer && (compression_type == kNoCompression ||
248
248
  (compression_type != kNoCompression &&
249
249
  rep_->table_options.block_cache_compressed))) {
250
- Slice raw =
250
+ Slice serialized =
251
251
  Slice(req.result.data() + req_offset, BlockSizeWithTrailer(handle));
252
- raw_block_contents = BlockContents(
253
- CopyBufferToHeap(GetMemoryAllocator(rep_->table_options), raw),
252
+ serialized_block = BlockContents(
253
+ CopyBufferToHeap(GetMemoryAllocator(rep_->table_options),
254
+ serialized),
254
255
  handle.size());
255
256
  #ifndef NDEBUG
256
- raw_block_contents.is_raw_block = true;
257
+ serialized_block.has_trailer = true;
257
258
  #endif
258
259
  }
259
260
  }
@@ -264,13 +265,13 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
264
265
  TableReaderCaller::kUserMultiGet);
265
266
  CachableEntry<Block>* block_entry = &(*results)[idx_in_batch];
266
267
  // MaybeReadBlockAndLoadToCache will insert into the block caches if
267
- // necessary. Since we're passing the raw block contents, it will
268
- // avoid looking up the block cache
268
+ // necessary. Since we're passing the serialized block contents, it
269
+ // will avoid looking up the block cache
269
270
  s = MaybeReadBlockAndLoadToCache(
270
271
  nullptr, options, handle, uncompression_dict, /*wait=*/true,
271
272
  /*for_compaction=*/false, block_entry, BlockType::kData,
272
273
  mget_iter->get_context, &lookup_data_block_context,
273
- &raw_block_contents, /*async_read=*/false);
274
+ &serialized_block, /*async_read=*/false);
274
275
 
275
276
  // block_entry value could be null if no block cache is present, i.e
276
277
  // BlockBasedTableOptions::no_block_cache is true and no compressed
@@ -283,12 +284,12 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
283
284
  }
284
285
 
285
286
  CompressionType compression_type =
286
- GetBlockCompressionType(raw_block_contents);
287
+ GetBlockCompressionType(serialized_block);
287
288
  BlockContents contents;
288
289
  if (compression_type != kNoCompression) {
289
290
  UncompressionContext context(compression_type);
290
291
  UncompressionInfo info(context, uncompression_dict, compression_type);
291
- s = UncompressBlockContents(
292
+ s = UncompressSerializedBlock(
292
293
  info, req.result.data() + req_offset, handle.size(), &contents,
293
294
  footer.format_version(), rep_->ioptions, memory_allocator);
294
295
  } else {
@@ -296,13 +297,13 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::RetrieveMultipleBlocks)
296
297
  // 1) caller uses the shared buffer (scratch or direct io buffer);
297
298
  // 2) we use the requst buffer.
298
299
  // If scratch buffer or direct io buffer is used, we ensure that
299
- // all raw blocks are copyed to the heap as single blocks. If scratch
300
- // buffer is not used, we also have no combined read, so the raw
301
- // block can be used directly.
302
- contents = std::move(raw_block_contents);
300
+ // all serialized blocks are copyed to the heap as single blocks. If
301
+ // scratch buffer is not used, we also have no combined read, so the
302
+ // serialized block can be used directly.
303
+ contents = std::move(serialized_block);
303
304
  }
304
305
  if (s.ok()) {
305
- (*results)[idx_in_batch].SetOwnedValue(new Block(
306
+ (*results)[idx_in_batch].SetOwnedValue(std::make_unique<Block>(
306
307
  std::move(contents), read_amp_bytes_per_bit, ioptions.stats));
307
308
  }
308
309
  }
@@ -23,7 +23,7 @@ void BlockPrefetcher::PrefetchIfNeeded(
23
23
  rep->CreateFilePrefetchBufferIfNotExists(
24
24
  compaction_readahead_size_, compaction_readahead_size_,
25
25
  &prefetch_buffer_, /*implicit_auto_readahead=*/false,
26
- /*num_file_reads=*/0);
26
+ /*num_file_reads=*/0, /*num_file_reads_for_auto_readahead=*/0);
27
27
  return;
28
28
  }
29
29
 
@@ -31,7 +31,8 @@ void BlockPrefetcher::PrefetchIfNeeded(
31
31
  if (readahead_size > 0) {
32
32
  rep->CreateFilePrefetchBufferIfNotExists(
33
33
  readahead_size, readahead_size, &prefetch_buffer_,
34
- /*implicit_auto_readahead=*/false, /*num_file_reads=*/0);
34
+ /*implicit_auto_readahead=*/false, /*num_file_reads=*/0,
35
+ /*num_file_reads_for_auto_readahead=*/0);
35
36
  return;
36
37
  }
37
38
 
@@ -44,13 +45,18 @@ void BlockPrefetcher::PrefetchIfNeeded(
44
45
  return;
45
46
  }
46
47
 
48
+ if (initial_auto_readahead_size_ > max_auto_readahead_size) {
49
+ initial_auto_readahead_size_ = max_auto_readahead_size;
50
+ }
51
+
47
52
  // In case of no_sequential_checking, it will skip the num_file_reads_ and
48
53
  // will always creates the FilePrefetchBuffer.
49
54
  if (no_sequential_checking) {
50
55
  rep->CreateFilePrefetchBufferIfNotExists(
51
56
  initial_auto_readahead_size_, max_auto_readahead_size,
52
57
  &prefetch_buffer_, /*implicit_auto_readahead=*/true,
53
- /*num_file_reads=*/0);
58
+ /*num_file_reads=*/0,
59
+ rep->table_options.num_file_reads_for_auto_readahead);
54
60
  return;
55
61
  }
56
62
 
@@ -72,22 +78,18 @@ void BlockPrefetcher::PrefetchIfNeeded(
72
78
  UpdateReadPattern(offset, len);
73
79
 
74
80
  // Implicit auto readahead, which will be enabled if the number of reads
75
- // reached `kMinNumFileReadsToStartAutoReadahead` (default: 2) and scans are
76
- // sequential.
81
+ // reached `table_options.num_file_reads_for_auto_readahead` (default: 2) and
82
+ // scans are sequential.
77
83
  num_file_reads_++;
78
- if (num_file_reads_ <=
79
- BlockBasedTable::kMinNumFileReadsToStartAutoReadahead) {
84
+ if (num_file_reads_ <= rep->table_options.num_file_reads_for_auto_readahead) {
80
85
  return;
81
86
  }
82
87
 
83
- if (initial_auto_readahead_size_ > max_auto_readahead_size) {
84
- initial_auto_readahead_size_ = max_auto_readahead_size;
85
- }
86
-
87
88
  if (rep->file->use_direct_io()) {
88
89
  rep->CreateFilePrefetchBufferIfNotExists(
89
90
  initial_auto_readahead_size_, max_auto_readahead_size,
90
- &prefetch_buffer_, /*implicit_auto_readahead=*/true, num_file_reads_);
91
+ &prefetch_buffer_, /*implicit_auto_readahead=*/true, num_file_reads_,
92
+ rep->table_options.num_file_reads_for_auto_readahead);
91
93
  return;
92
94
  }
93
95
 
@@ -105,7 +107,8 @@ void BlockPrefetcher::PrefetchIfNeeded(
105
107
  if (s.IsNotSupported()) {
106
108
  rep->CreateFilePrefetchBufferIfNotExists(
107
109
  initial_auto_readahead_size_, max_auto_readahead_size,
108
- &prefetch_buffer_, /*implicit_auto_readahead=*/true, num_file_reads_);
110
+ &prefetch_buffer_, /*implicit_auto_readahead=*/true, num_file_reads_,
111
+ rep->table_options.num_file_reads_for_auto_readahead);
109
112
  return;
110
113
  }
111
114
 
@@ -132,17 +132,17 @@ public:
132
132
  ResetFields();
133
133
  }
134
134
 
135
- void SetOwnedValue(T* value) {
136
- assert(value != nullptr);
135
+ void SetOwnedValue(std::unique_ptr<T>&& value) {
136
+ assert(value.get() != nullptr);
137
137
 
138
- if (UNLIKELY(value_ == value && own_value_)) {
138
+ if (UNLIKELY(value_ == value.get() && own_value_)) {
139
139
  assert(cache_ == nullptr && cache_handle_ == nullptr);
140
140
  return;
141
141
  }
142
142
 
143
143
  Reset();
144
144
 
145
- value_ = value;
145
+ value_ = value.release();
146
146
  own_value_ = true;
147
147
  }
148
148
 
@@ -493,9 +493,9 @@ Status PartitionedFilterBlockReader::CacheDependencies(const ReadOptions& ro,
493
493
  handle.offset() + handle.size() + BlockBasedTable::kBlockTrailerSize;
494
494
  uint64_t prefetch_len = last_off - prefetch_off;
495
495
  std::unique_ptr<FilePrefetchBuffer> prefetch_buffer;
496
- rep->CreateFilePrefetchBuffer(0, 0, &prefetch_buffer,
497
- false /* Implicit autoreadahead */,
498
- 0 /*num_reads_*/);
496
+ rep->CreateFilePrefetchBuffer(
497
+ 0, 0, &prefetch_buffer, false /* Implicit autoreadahead */,
498
+ 0 /*num_reads_*/, 0 /*num_file_reads_for_auto_readahead*/);
499
499
 
500
500
  IOOptions opts;
501
501
  s = rep->file->PrepareIOOptions(ro, opts);
@@ -156,9 +156,9 @@ Status PartitionIndexReader::CacheDependencies(const ReadOptions& ro,
156
156
  handle.offset() + BlockBasedTable::BlockSizeWithTrailer(handle);
157
157
  uint64_t prefetch_len = last_off - prefetch_off;
158
158
  std::unique_ptr<FilePrefetchBuffer> prefetch_buffer;
159
- rep->CreateFilePrefetchBuffer(0, 0, &prefetch_buffer,
160
- false /*Implicit auto readahead*/,
161
- 0 /*num_reads_*/);
159
+ rep->CreateFilePrefetchBuffer(
160
+ 0, 0, &prefetch_buffer, false /*Implicit auto readahead*/,
161
+ 0 /*num_reads_*/, 0 /*num_file_reads_for_auto_readahead*/);
162
162
  IOOptions opts;
163
163
  {
164
164
  Status s = rep->file->PrepareIOOptions(ro, opts);
@@ -49,7 +49,7 @@ inline void BlockFetcher::ProcessTrailerIfPresent() {
49
49
  inline bool BlockFetcher::TryGetUncompressBlockFromPersistentCache() {
50
50
  if (cache_options_.persistent_cache &&
51
51
  !cache_options_.persistent_cache->IsCompressed()) {
52
- Status status = PersistentCacheHelper::LookupUncompressedPage(
52
+ Status status = PersistentCacheHelper::LookupUncompressed(
53
53
  cache_options_, handle_, contents_);
54
54
  if (status.ok()) {
55
55
  // uncompressed page is found for the block handle
@@ -99,15 +99,14 @@ inline bool BlockFetcher::TryGetFromPrefetchBuffer() {
99
99
  return got_from_prefetch_buffer_;
100
100
  }
101
101
 
102
- inline bool BlockFetcher::TryGetCompressedBlockFromPersistentCache() {
102
+ inline bool BlockFetcher::TryGetSerializedBlockFromPersistentCache() {
103
103
  if (cache_options_.persistent_cache &&
104
104
  cache_options_.persistent_cache->IsCompressed()) {
105
- // lookup uncompressed cache mode p-cache
106
- std::unique_ptr<char[]> raw_data;
107
- io_status_ = status_to_io_status(PersistentCacheHelper::LookupRawPage(
108
- cache_options_, handle_, &raw_data, block_size_with_trailer_));
105
+ std::unique_ptr<char[]> buf;
106
+ io_status_ = status_to_io_status(PersistentCacheHelper::LookupSerialized(
107
+ cache_options_, handle_, &buf, block_size_with_trailer_));
109
108
  if (io_status_.ok()) {
110
- heap_buf_ = CacheAllocationPtr(raw_data.release());
109
+ heap_buf_ = CacheAllocationPtr(buf.release());
111
110
  used_buf_ = heap_buf_.get();
112
111
  slice_ = Slice(heap_buf_.get(), block_size_);
113
112
  ProcessTrailerIfPresent();
@@ -162,9 +161,8 @@ inline void BlockFetcher::InsertCompressedBlockToPersistentCacheIfNeeded() {
162
161
  if (io_status_.ok() && read_options_.fill_cache &&
163
162
  cache_options_.persistent_cache &&
164
163
  cache_options_.persistent_cache->IsCompressed()) {
165
- // insert to raw cache
166
- PersistentCacheHelper::InsertRawPage(cache_options_, handle_, used_buf_,
167
- block_size_with_trailer_);
164
+ PersistentCacheHelper::InsertSerialized(cache_options_, handle_, used_buf_,
165
+ block_size_with_trailer_);
168
166
  }
169
167
  }
170
168
 
@@ -173,8 +171,8 @@ inline void BlockFetcher::InsertUncompressedBlockToPersistentCacheIfNeeded() {
173
171
  read_options_.fill_cache && cache_options_.persistent_cache &&
174
172
  !cache_options_.persistent_cache->IsCompressed()) {
175
173
  // insert to uncompressed cache
176
- PersistentCacheHelper::InsertUncompressedPage(cache_options_, handle_,
177
- *contents_);
174
+ PersistentCacheHelper::InsertUncompressed(cache_options_, handle_,
175
+ *contents_);
178
176
  }
179
177
  }
180
178
 
@@ -234,7 +232,7 @@ inline void BlockFetcher::GetBlockContents() {
234
232
  *contents_ = BlockContents(std::move(heap_buf_), block_size_);
235
233
  }
236
234
  #ifndef NDEBUG
237
- contents_->is_raw_block = true;
235
+ contents_->has_trailer = footer_.GetBlockTrailerSize() > 0;
238
236
  #endif
239
237
  }
240
238
 
@@ -242,7 +240,7 @@ IOStatus BlockFetcher::ReadBlockContents() {
242
240
  if (TryGetUncompressBlockFromPersistentCache()) {
243
241
  compression_type_ = kNoCompression;
244
242
  #ifndef NDEBUG
245
- contents_->is_raw_block = true;
243
+ contents_->has_trailer = footer_.GetBlockTrailerSize() > 0;
246
244
  #endif // NDEBUG
247
245
  return IOStatus::OK();
248
246
  }
@@ -250,7 +248,7 @@ IOStatus BlockFetcher::ReadBlockContents() {
250
248
  if (!io_status_.ok()) {
251
249
  return io_status_;
252
250
  }
253
- } else if (!TryGetCompressedBlockFromPersistentCache()) {
251
+ } else if (!TryGetSerializedBlockFromPersistentCache()) {
254
252
  IOOptions opts;
255
253
  io_status_ = file_->PrepareIOOptions(read_options_, opts);
256
254
  // Actual file read
@@ -327,7 +325,7 @@ IOStatus BlockFetcher::ReadBlockContents() {
327
325
  // compressed page, uncompress, update cache
328
326
  UncompressionContext context(compression_type_);
329
327
  UncompressionInfo info(context, uncompression_dict_, compression_type_);
330
- io_status_ = status_to_io_status(UncompressBlockContents(
328
+ io_status_ = status_to_io_status(UncompressSerializedBlock(
331
329
  info, slice_.data(), block_size_, contents_, footer_.format_version(),
332
330
  ioptions_, memory_allocator_));
333
331
  #ifndef NDEBUG
@@ -347,10 +345,10 @@ IOStatus BlockFetcher::ReadAsyncBlockContents() {
347
345
  if (TryGetUncompressBlockFromPersistentCache()) {
348
346
  compression_type_ = kNoCompression;
349
347
  #ifndef NDEBUG
350
- contents_->is_raw_block = true;
348
+ contents_->has_trailer = footer_.GetBlockTrailerSize() > 0;
351
349
  #endif // NDEBUG
352
350
  return IOStatus::OK();
353
- } else if (!TryGetCompressedBlockFromPersistentCache()) {
351
+ } else if (!TryGetSerializedBlockFromPersistentCache()) {
354
352
  assert(prefetch_buffer_ != nullptr);
355
353
  if (!for_compaction_) {
356
354
  IOOptions opts;
@@ -378,7 +376,7 @@ IOStatus BlockFetcher::ReadAsyncBlockContents() {
378
376
  UncompressionContext context(compression_type_);
379
377
  UncompressionInfo info(context, uncompression_dict_,
380
378
  compression_type_);
381
- io_status_ = status_to_io_status(UncompressBlockContents(
379
+ io_status_ = status_to_io_status(UncompressSerializedBlock(
382
380
  info, slice_.data(), block_size_, contents_,
383
381
  footer_.format_version(), ioptions_, memory_allocator_));
384
382
  #ifndef NDEBUG
@@ -128,7 +128,7 @@ class BlockFetcher {
128
128
  bool TryGetUncompressBlockFromPersistentCache();
129
129
  // return true if found
130
130
  bool TryGetFromPrefetchBuffer();
131
- bool TryGetCompressedBlockFromPersistentCache();
131
+ bool TryGetSerializedBlockFromPersistentCache();
132
132
  void PrepareBufferForBlockFromFile();
133
133
  // Copy content from used_buf_ to new heap_buf_.
134
134
  void CopyBufferToHeapBuf();
@@ -390,6 +390,10 @@ Status ReadFooterFromFile(const IOOptions& opts, RandomAccessFileReader* file,
390
390
  // Check that we actually read the whole footer from the file. It may be
391
391
  // that size isn't correct.
392
392
  if (footer_input.size() < Footer::kMinEncodedLength) {
393
+ // FIXME: this error message is bad. We should be checking whether the
394
+ // provided file_size matches what's on disk, at least in this case.
395
+ // Unfortunately FileSystem/Env does not provide a way to get the size
396
+ // of an open file, so getting file size requires a full path seek.
393
397
  return Status::Corruption("file is too short (" +
394
398
  std::to_string(file_size) +
395
399
  " bytes) to be an "
@@ -494,10 +498,11 @@ uint32_t ComputeBuiltinChecksumWithLastByte(ChecksumType type, const char* data,
494
498
  }
495
499
  }
496
500
 
497
- Status UncompressBlockContentsForCompressionType(
498
- const UncompressionInfo& uncompression_info, const char* data, size_t n,
499
- BlockContents* contents, uint32_t format_version,
500
- const ImmutableOptions& ioptions, MemoryAllocator* allocator) {
501
+ Status UncompressBlockData(const UncompressionInfo& uncompression_info,
502
+ const char* data, size_t size,
503
+ BlockContents* out_contents, uint32_t format_version,
504
+ const ImmutableOptions& ioptions,
505
+ MemoryAllocator* allocator) {
501
506
  Status ret = Status::OK();
502
507
 
503
508
  assert(uncompression_info.type() != kNoCompression &&
@@ -507,7 +512,7 @@ Status UncompressBlockContentsForCompressionType(
507
512
  ShouldReportDetailedTime(ioptions.env, ioptions.stats));
508
513
  size_t uncompressed_size = 0;
509
514
  CacheAllocationPtr ubuf =
510
- UncompressData(uncompression_info, data, n, &uncompressed_size,
515
+ UncompressData(uncompression_info, data, size, &uncompressed_size,
511
516
  GetCompressFormatForVersion(format_version), allocator);
512
517
  if (!ubuf) {
513
518
  if (!CompressionTypeSupported(uncompression_info.type())) {
@@ -521,44 +526,36 @@ Status UncompressBlockContentsForCompressionType(
521
526
  }
522
527
  }
523
528
 
524
- *contents = BlockContents(std::move(ubuf), uncompressed_size);
529
+ *out_contents = BlockContents(std::move(ubuf), uncompressed_size);
525
530
 
526
531
  if (ShouldReportDetailedTime(ioptions.env, ioptions.stats)) {
527
532
  RecordTimeToHistogram(ioptions.stats, DECOMPRESSION_TIMES_NANOS,
528
533
  timer.ElapsedNanos());
529
534
  }
530
535
  RecordTimeToHistogram(ioptions.stats, BYTES_DECOMPRESSED,
531
- contents->data.size());
536
+ out_contents->data.size());
532
537
  RecordTick(ioptions.stats, NUMBER_BLOCK_DECOMPRESSED);
533
538
 
539
+ TEST_SYNC_POINT_CALLBACK("UncompressBlockData:TamperWithReturnValue",
540
+ static_cast<void*>(&ret));
534
541
  TEST_SYNC_POINT_CALLBACK(
535
- "UncompressBlockContentsForCompressionType:TamperWithReturnValue",
536
- static_cast<void*>(&ret));
537
- TEST_SYNC_POINT_CALLBACK(
538
- "UncompressBlockContentsForCompressionType:"
542
+ "UncompressBlockData:"
539
543
  "TamperWithDecompressionOutput",
540
- static_cast<void*>(contents));
544
+ static_cast<void*>(out_contents));
541
545
 
542
546
  return ret;
543
547
  }
544
548
 
545
- //
546
- // The 'data' points to the raw block contents that was read in from file.
547
- // This method allocates a new heap buffer and the raw block
548
- // contents are uncompresed into this buffer. This
549
- // buffer is returned via 'result' and it is upto the caller to
550
- // free this buffer.
551
- // format_version is the block format as defined in include/rocksdb/table.h
552
- Status UncompressBlockContents(const UncompressionInfo& uncompression_info,
553
- const char* data, size_t n,
554
- BlockContents* contents, uint32_t format_version,
555
- const ImmutableOptions& ioptions,
556
- MemoryAllocator* allocator) {
557
- assert(data[n] != kNoCompression);
558
- assert(data[n] == static_cast<char>(uncompression_info.type()));
559
- return UncompressBlockContentsForCompressionType(uncompression_info, data, n,
560
- contents, format_version,
561
- ioptions, allocator);
549
+ Status UncompressSerializedBlock(const UncompressionInfo& uncompression_info,
550
+ const char* data, size_t size,
551
+ BlockContents* out_contents,
552
+ uint32_t format_version,
553
+ const ImmutableOptions& ioptions,
554
+ MemoryAllocator* allocator) {
555
+ assert(data[size] != kNoCompression);
556
+ assert(data[size] == static_cast<char>(uncompression_info.type()));
557
+ return UncompressBlockData(uncompression_info, data, size, out_contents,
558
+ format_version, ioptions, allocator);
562
559
  }
563
560
 
564
561
  // Replace the contents of db_host_id with the actual hostname, if db_host_id