@nxtedition/rocksdb 8.1.4 → 8.1.5
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.
- package/deps/rocksdb/rocksdb/CMakeLists.txt +21 -0
- package/deps/rocksdb/rocksdb/Makefile +15 -3
- package/deps/rocksdb/rocksdb/TARGETS +6 -0
- package/deps/rocksdb/rocksdb/cache/cache_bench_tool.cc +32 -35
- package/deps/rocksdb/rocksdb/cache/cache_entry_roles.cc +0 -30
- package/deps/rocksdb/rocksdb/cache/cache_entry_roles.h +0 -83
- package/deps/rocksdb/rocksdb/cache/cache_entry_stats.h +13 -14
- package/deps/rocksdb/rocksdb/cache/cache_helpers.cc +40 -0
- package/deps/rocksdb/rocksdb/cache/cache_helpers.h +14 -20
- package/deps/rocksdb/rocksdb/cache/cache_reservation_manager.cc +8 -9
- package/deps/rocksdb/rocksdb/cache/cache_reservation_manager.h +5 -4
- package/deps/rocksdb/rocksdb/cache/cache_test.cc +124 -156
- package/deps/rocksdb/rocksdb/cache/charged_cache.cc +10 -26
- package/deps/rocksdb/rocksdb/cache/charged_cache.h +11 -16
- package/deps/rocksdb/rocksdb/cache/clock_cache.cc +35 -32
- package/deps/rocksdb/rocksdb/cache/clock_cache.h +19 -21
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.cc +42 -30
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache.h +9 -8
- package/deps/rocksdb/rocksdb/cache/compressed_secondary_cache_test.cc +91 -143
- package/deps/rocksdb/rocksdb/cache/lru_cache.cc +54 -60
- package/deps/rocksdb/rocksdb/cache/lru_cache.h +37 -63
- package/deps/rocksdb/rocksdb/cache/lru_cache_test.cc +120 -106
- package/deps/rocksdb/rocksdb/cache/secondary_cache.cc +14 -5
- package/deps/rocksdb/rocksdb/cache/sharded_cache.h +16 -31
- package/deps/rocksdb/rocksdb/cache/typed_cache.h +339 -0
- package/deps/rocksdb/rocksdb/db/blob/blob_contents.cc +0 -48
- package/deps/rocksdb/rocksdb/db/blob/blob_contents.h +18 -15
- package/deps/rocksdb/rocksdb/db/blob/blob_file_builder.cc +5 -26
- package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.cc +7 -8
- package/deps/rocksdb/rocksdb/db/blob/blob_file_cache.h +6 -3
- package/deps/rocksdb/rocksdb/db/blob/blob_file_reader.cc +2 -7
- package/deps/rocksdb/rocksdb/db/blob/blob_source.cc +19 -47
- package/deps/rocksdb/rocksdb/db/blob/blob_source.h +13 -5
- package/deps/rocksdb/rocksdb/db/blob/blob_source_test.cc +15 -22
- package/deps/rocksdb/rocksdb/db/builder.cc +24 -10
- package/deps/rocksdb/rocksdb/db/builder.h +2 -1
- package/deps/rocksdb/rocksdb/db/c.cc +15 -0
- package/deps/rocksdb/rocksdb/db/c_test.c +3 -0
- package/deps/rocksdb/rocksdb/db/column_family.cc +11 -6
- package/deps/rocksdb/rocksdb/db/column_family.h +20 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction.cc +31 -34
- package/deps/rocksdb/rocksdb/db/compaction/compaction.h +3 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.cc +21 -3
- package/deps/rocksdb/rocksdb/db/compaction/compaction_iterator.h +1 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.cc +4 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job.h +4 -2
- package/deps/rocksdb/rocksdb/db/compaction/compaction_job_test.cc +9 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.cc +275 -82
- package/deps/rocksdb/rocksdb/db/compaction/compaction_outputs.h +7 -0
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.cc +11 -18
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker.h +17 -16
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.cc +19 -6
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_fifo.h +5 -5
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.cc +22 -22
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_level.h +5 -5
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_test.cc +81 -52
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.cc +5 -1
- package/deps/rocksdb/rocksdb/db/compaction/compaction_picker_universal.h +5 -5
- package/deps/rocksdb/rocksdb/db/compaction/compaction_service_job.cc +8 -2
- package/deps/rocksdb/rocksdb/db/compaction/subcompaction_state.h +3 -0
- package/deps/rocksdb/rocksdb/db/compaction/tiered_compaction_test.cc +266 -138
- package/deps/rocksdb/rocksdb/db/corruption_test.cc +86 -1
- package/deps/rocksdb/rocksdb/db/db_basic_test.cc +98 -9
- package/deps/rocksdb/rocksdb/db/db_block_cache_test.cc +28 -28
- package/deps/rocksdb/rocksdb/db/db_bloom_filter_test.cc +2 -3
- package/deps/rocksdb/rocksdb/db/db_compaction_test.cc +1022 -123
- package/deps/rocksdb/rocksdb/db/db_flush_test.cc +65 -4
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.cc +32 -21
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl.h +32 -24
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_compaction_flush.cc +199 -77
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_debug.cc +1 -1
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_experimental.cc +3 -2
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_files.cc +3 -0
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_open.cc +8 -4
- package/deps/rocksdb/rocksdb/db/db_impl/db_impl_write.cc +43 -23
- package/deps/rocksdb/rocksdb/db/db_iter.cc +8 -2
- package/deps/rocksdb/rocksdb/db/db_merge_operand_test.cc +42 -0
- package/deps/rocksdb/rocksdb/db/db_merge_operator_test.cc +155 -0
- package/deps/rocksdb/rocksdb/db/db_properties_test.cc +12 -12
- package/deps/rocksdb/rocksdb/db/db_range_del_test.cc +230 -2
- package/deps/rocksdb/rocksdb/db/db_test.cc +3 -0
- package/deps/rocksdb/rocksdb/db/db_test2.cc +233 -8
- package/deps/rocksdb/rocksdb/db/db_test_util.cc +11 -10
- package/deps/rocksdb/rocksdb/db/db_test_util.h +39 -24
- package/deps/rocksdb/rocksdb/db/db_wal_test.cc +129 -0
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_basic_test.cc +28 -0
- package/deps/rocksdb/rocksdb/db/db_with_timestamp_compaction_test.cc +21 -0
- package/deps/rocksdb/rocksdb/db/dbformat.cc +25 -0
- package/deps/rocksdb/rocksdb/db/dbformat.h +2 -0
- package/deps/rocksdb/rocksdb/db/experimental.cc +3 -2
- package/deps/rocksdb/rocksdb/db/external_sst_file_basic_test.cc +3 -0
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.cc +92 -13
- package/deps/rocksdb/rocksdb/db/external_sst_file_ingestion_job.h +38 -1
- package/deps/rocksdb/rocksdb/db/external_sst_file_test.cc +14 -110
- package/deps/rocksdb/rocksdb/db/flush_job.cc +12 -10
- package/deps/rocksdb/rocksdb/db/flush_job.h +3 -2
- package/deps/rocksdb/rocksdb/db/flush_job_test.cc +29 -29
- package/deps/rocksdb/rocksdb/db/import_column_family_job.cc +56 -53
- package/deps/rocksdb/rocksdb/db/import_column_family_test.cc +3 -4
- package/deps/rocksdb/rocksdb/db/internal_stats.cc +11 -11
- package/deps/rocksdb/rocksdb/db/internal_stats.h +2 -2
- package/deps/rocksdb/rocksdb/db/log_reader.cc +8 -6
- package/deps/rocksdb/rocksdb/db/log_test.cc +35 -2
- package/deps/rocksdb/rocksdb/db/memtable.cc +31 -6
- package/deps/rocksdb/rocksdb/db/merge_helper.cc +47 -29
- package/deps/rocksdb/rocksdb/db/merge_helper.h +14 -6
- package/deps/rocksdb/rocksdb/db/periodic_task_scheduler_test.cc +10 -10
- package/deps/rocksdb/rocksdb/db/range_tombstone_fragmenter_test.cc +1 -1
- package/deps/rocksdb/rocksdb/db/repair.cc +65 -22
- package/deps/rocksdb/rocksdb/db/repair_test.cc +54 -0
- package/deps/rocksdb/rocksdb/db/seqno_time_test.cc +26 -26
- package/deps/rocksdb/rocksdb/db/table_cache.cc +41 -91
- package/deps/rocksdb/rocksdb/db/table_cache.h +17 -19
- package/deps/rocksdb/rocksdb/db/table_cache_sync_and_async.h +7 -9
- package/deps/rocksdb/rocksdb/db/table_properties_collector.h +3 -1
- package/deps/rocksdb/rocksdb/db/version_builder.cc +102 -52
- package/deps/rocksdb/rocksdb/db/version_builder.h +20 -0
- package/deps/rocksdb/rocksdb/db/version_builder_test.cc +218 -93
- package/deps/rocksdb/rocksdb/db/version_edit.cc +27 -1
- package/deps/rocksdb/rocksdb/db/version_edit.h +34 -9
- package/deps/rocksdb/rocksdb/db/version_edit_handler.cc +13 -6
- package/deps/rocksdb/rocksdb/db/version_edit_handler.h +17 -6
- package/deps/rocksdb/rocksdb/db/version_edit_test.cc +19 -17
- package/deps/rocksdb/rocksdb/db/version_set.cc +160 -28
- package/deps/rocksdb/rocksdb/db/version_set.h +34 -4
- package/deps/rocksdb/rocksdb/db/version_set_sync_and_async.h +1 -1
- package/deps/rocksdb/rocksdb/db/version_set_test.cc +65 -31
- package/deps/rocksdb/rocksdb/db/write_batch.cc +4 -1
- package/deps/rocksdb/rocksdb/db/write_thread.cc +5 -2
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_common.h +1 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.cc +31 -32
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_driver.h +2 -1
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_env_wrapper.h +8 -6
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_gflags.cc +4 -0
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_test_base.cc +11 -4
- package/deps/rocksdb/rocksdb/db_stress_tool/db_stress_tool.cc +16 -15
- package/deps/rocksdb/rocksdb/db_stress_tool/no_batched_ops_stress.cc +13 -1
- package/deps/rocksdb/rocksdb/file/file_prefetch_buffer.cc +1 -0
- package/deps/rocksdb/rocksdb/file/prefetch_test.cc +286 -217
- package/deps/rocksdb/rocksdb/include/rocksdb/c.h +8 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/cache.h +137 -135
- package/deps/rocksdb/rocksdb/include/rocksdb/db.h +6 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/listener.h +7 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/merge_operator.h +21 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/metadata.h +9 -3
- package/deps/rocksdb/rocksdb/include/rocksdb/options.h +2 -1
- package/deps/rocksdb/rocksdb/include/rocksdb/secondary_cache.h +8 -6
- package/deps/rocksdb/rocksdb/include/rocksdb/status.h +3 -0
- package/deps/rocksdb/rocksdb/include/rocksdb/utilities/backup_engine.h +69 -9
- package/deps/rocksdb/rocksdb/include/rocksdb/version.h +1 -1
- package/deps/rocksdb/rocksdb/memory/arena.cc +23 -87
- package/deps/rocksdb/rocksdb/memory/arena.h +25 -31
- package/deps/rocksdb/rocksdb/memory/arena_test.cc +90 -0
- package/deps/rocksdb/rocksdb/memory/memory_allocator.h +9 -0
- package/deps/rocksdb/rocksdb/monitoring/stats_history_test.cc +26 -26
- package/deps/rocksdb/rocksdb/options/customizable_test.cc +4 -3
- package/deps/rocksdb/rocksdb/port/mmap.cc +98 -0
- package/deps/rocksdb/rocksdb/port/mmap.h +70 -0
- package/deps/rocksdb/rocksdb/port/port_posix.h +2 -0
- package/{prebuilds → deps/rocksdb/rocksdb/prebuilds}/linux-x64/node.napi.node +0 -0
- package/deps/rocksdb/rocksdb/src.mk +3 -0
- package/deps/rocksdb/rocksdb/table/adaptive/adaptive_table_factory.cc +3 -2
- package/deps/rocksdb/rocksdb/table/block_based/block.h +3 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.cc +25 -67
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_builder.h +3 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_factory.cc +18 -13
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.cc +159 -225
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader.h +31 -50
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_impl.h +52 -20
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_sync_and_async.h +3 -3
- package/deps/rocksdb/rocksdb/table/block_based/block_based_table_reader_test.cc +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_cache.cc +96 -0
- package/deps/rocksdb/rocksdb/table/block_based/block_cache.h +132 -0
- package/deps/rocksdb/rocksdb/table/block_based/cachable_entry.h +28 -0
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.cc +6 -5
- package/deps/rocksdb/rocksdb/table/block_based/filter_block_reader_common.h +1 -4
- package/deps/rocksdb/rocksdb/table/block_based/full_filter_block.cc +6 -7
- package/deps/rocksdb/rocksdb/table/block_based/index_reader_common.cc +3 -1
- package/deps/rocksdb/rocksdb/table/block_based/parsed_full_filter_block.h +6 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.cc +19 -18
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block.h +9 -5
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_filter_block_test.cc +3 -1
- package/deps/rocksdb/rocksdb/table/block_based/partitioned_index_reader.cc +2 -1
- package/deps/rocksdb/rocksdb/table/block_based/uncompression_dict_reader.cc +2 -2
- package/deps/rocksdb/rocksdb/table/block_fetcher_test.cc +3 -3
- package/deps/rocksdb/rocksdb/table/format.cc +24 -20
- package/deps/rocksdb/rocksdb/table/format.h +6 -3
- package/deps/rocksdb/rocksdb/table/get_context.cc +12 -3
- package/deps/rocksdb/rocksdb/table/internal_iterator.h +0 -2
- package/deps/rocksdb/rocksdb/table/merging_iterator.cc +69 -35
- package/deps/rocksdb/rocksdb/table/meta_blocks.cc +2 -2
- package/deps/rocksdb/rocksdb/table/sst_file_dumper.cc +1 -1
- package/deps/rocksdb/rocksdb/table/table_test.cc +7 -6
- package/deps/rocksdb/rocksdb/test_util/testutil.h +10 -0
- package/deps/rocksdb/rocksdb/tools/block_cache_analyzer/block_cache_trace_analyzer_test.cc +66 -1
- package/deps/rocksdb/rocksdb/tools/db_bench_tool.cc +9 -2
- package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.cc +5 -0
- package/deps/rocksdb/rocksdb/trace_replay/block_cache_tracer.h +2 -2
- package/deps/rocksdb/rocksdb/trace_replay/trace_replay.cc +1 -1
- package/deps/rocksdb/rocksdb/util/async_file_reader.cc +20 -12
- package/deps/rocksdb/rocksdb/util/bloom_test.cc +1 -1
- package/deps/rocksdb/rocksdb/util/compression.cc +2 -2
- package/deps/rocksdb/rocksdb/util/compression.h +11 -2
- package/deps/rocksdb/rocksdb/util/status.cc +7 -0
- package/deps/rocksdb/rocksdb/util/xxhash.h +1901 -887
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine.cc +250 -74
- package/deps/rocksdb/rocksdb/utilities/backup/backup_engine_test.cc +199 -4
- package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.cc +35 -57
- package/deps/rocksdb/rocksdb/utilities/cache_dump_load_impl.h +4 -5
- package/deps/rocksdb/rocksdb/utilities/checkpoint/checkpoint_impl.cc +1 -0
- package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.cc +39 -0
- package/deps/rocksdb/rocksdb/utilities/fault_injection_fs.h +9 -0
- package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.cc +11 -6
- package/deps/rocksdb/rocksdb/utilities/fault_injection_secondary_cache.h +6 -5
- package/deps/rocksdb/rocksdb/utilities/memory_allocators.h +0 -1
- package/deps/rocksdb/rocksdb/utilities/simulator_cache/cache_simulator.cc +10 -11
- package/deps/rocksdb/rocksdb/utilities/simulator_cache/sim_cache.cc +31 -31
- package/deps/rocksdb/rocksdb/utilities/transactions/lock/range/range_tree/lib/portability/toku_time.h +4 -0
- package/deps/rocksdb/rocksdb/utilities/transactions/transaction_test.cc +111 -0
- package/deps/rocksdb/rocksdb/utilities/ttl/db_ttl_impl.cc +1 -0
- package/deps/rocksdb/rocksdb/utilities/write_batch_with_index/write_batch_with_index_internal.cc +12 -3
- package/package.json +1 -1
- package/deps/rocksdb/rocksdb/table/block_based/block_like_traits.h +0 -182
|
@@ -986,6 +986,10 @@ rocksdb_block_based_options_set_partition_filters(
|
|
|
986
986
|
rocksdb_block_based_table_options_t* options,
|
|
987
987
|
unsigned char partition_filters);
|
|
988
988
|
extern ROCKSDB_LIBRARY_API void
|
|
989
|
+
rocksdb_block_based_options_set_optimize_filters_for_memory(
|
|
990
|
+
rocksdb_block_based_table_options_t* options,
|
|
991
|
+
unsigned char optimize_filters_for_memory);
|
|
992
|
+
extern ROCKSDB_LIBRARY_API void
|
|
989
993
|
rocksdb_block_based_options_set_use_delta_encoding(
|
|
990
994
|
rocksdb_block_based_table_options_t* options,
|
|
991
995
|
unsigned char use_delta_encoding);
|
|
@@ -1890,6 +1894,10 @@ extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_io_timeout(
|
|
|
1890
1894
|
rocksdb_readoptions_t*, uint64_t microseconds);
|
|
1891
1895
|
extern ROCKSDB_LIBRARY_API uint64_t
|
|
1892
1896
|
rocksdb_readoptions_get_io_timeout(rocksdb_readoptions_t*);
|
|
1897
|
+
extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_async_io(
|
|
1898
|
+
rocksdb_readoptions_t*, unsigned char);
|
|
1899
|
+
extern ROCKSDB_LIBRARY_API unsigned char rocksdb_readoptions_get_async_io(
|
|
1900
|
+
rocksdb_readoptions_t*);
|
|
1893
1901
|
extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_timestamp(
|
|
1894
1902
|
rocksdb_readoptions_t*, const char* ts, size_t tslen);
|
|
1895
1903
|
extern ROCKSDB_LIBRARY_API void rocksdb_readoptions_set_iter_start_ts(
|
|
@@ -7,18 +7,7 @@
|
|
|
7
7
|
// Use of this source code is governed by a BSD-style license that can be
|
|
8
8
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
9
9
|
//
|
|
10
|
-
//
|
|
11
|
-
// synchronization and may be safely accessed concurrently from
|
|
12
|
-
// multiple threads. It may automatically evict entries to make room
|
|
13
|
-
// for new entries. Values have a specified charge against the cache
|
|
14
|
-
// capacity. For example, a cache where the values are variable
|
|
15
|
-
// length strings, may use the length of the string as the charge for
|
|
16
|
-
// the string.
|
|
17
|
-
//
|
|
18
|
-
// A builtin cache implementation with a least-recently-used eviction
|
|
19
|
-
// policy is provided. Clients may use their own implementations if
|
|
20
|
-
// they want something more sophisticated (like scan-resistance, a
|
|
21
|
-
// custom eviction policy, variable cache sizing, etc.)
|
|
10
|
+
// Various APIs for creating and customizing read caches in RocksDB.
|
|
22
11
|
|
|
23
12
|
#pragma once
|
|
24
13
|
|
|
@@ -363,11 +352,33 @@ extern std::shared_ptr<Cache> NewClockCache(
|
|
|
363
352
|
CacheMetadataChargePolicy metadata_charge_policy =
|
|
364
353
|
kDefaultCacheMetadataChargePolicy);
|
|
365
354
|
|
|
355
|
+
// A Cache maps keys to objects resident in memory, tracks reference counts
|
|
356
|
+
// on those key-object entries, and is able to remove unreferenced entries
|
|
357
|
+
// whenever it wants. All operations are fully thread safe except as noted.
|
|
358
|
+
// Inserted entries have a specified "charge" which is some quantity in
|
|
359
|
+
// unspecified units, typically bytes of memory used. A Cache will typically
|
|
360
|
+
// have a finite capacity in units of charge, and evict entries as needed
|
|
361
|
+
// to stay at or below that capacity.
|
|
362
|
+
//
|
|
363
|
+
// NOTE: This API is for expert use only and is more intended for providing
|
|
364
|
+
// custom implementations than for calling into. It is subject to change
|
|
365
|
+
// as RocksDB evolves, especially the RocksDB block cache.
|
|
366
|
+
//
|
|
367
|
+
// INTERNAL: See typed_cache.h for convenient wrappers on top of this API.
|
|
366
368
|
class Cache {
|
|
367
|
-
public: //
|
|
369
|
+
public: // types hidden from API client
|
|
368
370
|
// Opaque handle to an entry stored in the cache.
|
|
369
371
|
struct Handle {};
|
|
370
372
|
|
|
373
|
+
public: // types hidden from Cache implementation
|
|
374
|
+
// Pointer to cached object of unspecified type. (This type alias is
|
|
375
|
+
// provided for clarity, not really for type checking.)
|
|
376
|
+
using ObjectPtr = void*;
|
|
377
|
+
|
|
378
|
+
// Opaque object providing context (settings, etc.) to create objects
|
|
379
|
+
// for primary cache from saved (serialized) secondary cache entries.
|
|
380
|
+
struct CreateContext {};
|
|
381
|
+
|
|
371
382
|
public: // type defs
|
|
372
383
|
// Depending on implementation, cache entries with higher priority levels
|
|
373
384
|
// could be less likely to get evicted than entries with lower priority
|
|
@@ -400,48 +411,84 @@ class Cache {
|
|
|
400
411
|
// so anything required for these operations should be contained in the
|
|
401
412
|
// object itself.
|
|
402
413
|
//
|
|
403
|
-
// The SizeCallback takes a
|
|
414
|
+
// The SizeCallback takes a pointer to the object and returns the size
|
|
404
415
|
// of the persistable data. It can be used by the secondary cache to allocate
|
|
405
416
|
// memory if needed.
|
|
406
417
|
//
|
|
407
418
|
// RocksDB callbacks are NOT exception-safe. A callback completing with an
|
|
408
419
|
// exception can lead to undefined behavior in RocksDB, including data loss,
|
|
409
420
|
// unreported corruption, deadlocks, and more.
|
|
410
|
-
using SizeCallback = size_t (*)(
|
|
421
|
+
using SizeCallback = size_t (*)(ObjectPtr obj);
|
|
411
422
|
|
|
412
|
-
// The SaveToCallback takes
|
|
423
|
+
// The SaveToCallback takes an object pointer and saves the persistable
|
|
413
424
|
// data into a buffer. The secondary cache may decide to not store it in a
|
|
414
425
|
// contiguous buffer, in which case this callback will be called multiple
|
|
415
426
|
// times with increasing offset
|
|
416
|
-
using SaveToCallback = Status (*)(
|
|
417
|
-
size_t length,
|
|
418
|
-
|
|
419
|
-
// A function pointer type for
|
|
420
|
-
//
|
|
421
|
-
//
|
|
422
|
-
|
|
427
|
+
using SaveToCallback = Status (*)(ObjectPtr from_obj, size_t from_offset,
|
|
428
|
+
size_t length, char* out_buf);
|
|
429
|
+
|
|
430
|
+
// A function pointer type for destruction of a cache object. This will
|
|
431
|
+
// typically call the destructor for the appropriate type of the object.
|
|
432
|
+
// The Cache is responsible for copying and reclaiming space for the key,
|
|
433
|
+
// but objects are managed in part using this callback. Generally a DeleterFn
|
|
434
|
+
// can be nullptr if the ObjectPtr does not need destruction (e.g. nullptr or
|
|
435
|
+
// pointer into static data).
|
|
436
|
+
using DeleterFn = void (*)(ObjectPtr obj, MemoryAllocator* allocator);
|
|
437
|
+
|
|
438
|
+
// The CreateCallback is takes in a buffer from the NVM cache and constructs
|
|
439
|
+
// an object using it. The callback doesn't have ownership of the buffer and
|
|
440
|
+
// should copy the contents into its own buffer. The CreateContext* is
|
|
441
|
+
// provided by Lookup and may be used to follow DB- or CF-specific settings.
|
|
442
|
+
// In case of some error, non-OK is returned and the caller should ignore
|
|
443
|
+
// any result in out_obj. (The implementation must clean up after itself.)
|
|
444
|
+
using CreateCallback = Status (*)(const Slice& data, CreateContext* context,
|
|
445
|
+
MemoryAllocator* allocator,
|
|
446
|
+
ObjectPtr* out_obj, size_t* out_charge);
|
|
423
447
|
|
|
424
448
|
// A struct with pointers to helper functions for spilling items from the
|
|
425
449
|
// cache into the secondary cache. May be extended in the future. An
|
|
426
450
|
// instance of this struct is expected to outlive the cache.
|
|
427
451
|
struct CacheItemHelper {
|
|
452
|
+
// Function for deleting an object on its removal from the Cache.
|
|
453
|
+
// nullptr is only for entries that require no destruction, such as
|
|
454
|
+
// "placeholder" cache entries with nullptr object.
|
|
455
|
+
DeleterFn del_cb; // (<- Most performance critical)
|
|
456
|
+
// Next three are used for persisting values as described above.
|
|
457
|
+
// If any is nullptr, then all three should be nullptr and persisting the
|
|
458
|
+
// entry to/from secondary cache is not supported.
|
|
428
459
|
SizeCallback size_cb;
|
|
429
460
|
SaveToCallback saveto_cb;
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
:
|
|
461
|
+
CreateCallback create_cb;
|
|
462
|
+
// Classification of the entry for monitoring purposes in block cache.
|
|
463
|
+
CacheEntryRole role;
|
|
464
|
+
|
|
465
|
+
constexpr CacheItemHelper()
|
|
466
|
+
: del_cb(nullptr),
|
|
467
|
+
size_cb(nullptr),
|
|
468
|
+
saveto_cb(nullptr),
|
|
469
|
+
create_cb(nullptr),
|
|
470
|
+
role(CacheEntryRole::kMisc) {}
|
|
471
|
+
|
|
472
|
+
explicit constexpr CacheItemHelper(CacheEntryRole _role,
|
|
473
|
+
DeleterFn _del_cb = nullptr,
|
|
474
|
+
SizeCallback _size_cb = nullptr,
|
|
475
|
+
SaveToCallback _saveto_cb = nullptr,
|
|
476
|
+
CreateCallback _create_cb = nullptr)
|
|
477
|
+
: del_cb(_del_cb),
|
|
478
|
+
size_cb(_size_cb),
|
|
479
|
+
saveto_cb(_saveto_cb),
|
|
480
|
+
create_cb(_create_cb),
|
|
481
|
+
role(_role) {
|
|
482
|
+
// Either all three secondary cache callbacks are non-nullptr or
|
|
483
|
+
// all three are nullptr
|
|
484
|
+
assert((size_cb != nullptr) == (saveto_cb != nullptr));
|
|
485
|
+
assert((size_cb != nullptr) == (create_cb != nullptr));
|
|
486
|
+
}
|
|
487
|
+
inline bool IsSecondaryCacheCompatible() const {
|
|
488
|
+
return size_cb != nullptr;
|
|
489
|
+
}
|
|
436
490
|
};
|
|
437
491
|
|
|
438
|
-
// The CreateCallback is passed by the block cache user to Lookup(). It
|
|
439
|
-
// takes in a buffer from the NVM cache and constructs an object using
|
|
440
|
-
// it. The callback doesn't have ownership of the buffer and should
|
|
441
|
-
// copy the contents into its own buffer.
|
|
442
|
-
using CreateCallback = std::function<Status(const void* buf, size_t size,
|
|
443
|
-
void** out_obj, size_t* charge)>;
|
|
444
|
-
|
|
445
492
|
public: // ctor/dtor/create
|
|
446
493
|
Cache(std::shared_ptr<MemoryAllocator> allocator = nullptr)
|
|
447
494
|
: memory_allocator_(std::move(allocator)) {}
|
|
@@ -471,8 +518,6 @@ class Cache {
|
|
|
471
518
|
// The type of the Cache
|
|
472
519
|
virtual const char* Name() const = 0;
|
|
473
520
|
|
|
474
|
-
// EXPERIMENTAL SecondaryCache support:
|
|
475
|
-
// Some APIs here are experimental and might change in the future.
|
|
476
521
|
// The Insert and Lookup APIs below are intended to allow cached objects
|
|
477
522
|
// to be demoted/promoted between the primary block cache and a secondary
|
|
478
523
|
// cache. The secondary cache could be a non-volatile cache, and will
|
|
@@ -484,46 +529,27 @@ class Cache {
|
|
|
484
529
|
// multiple DBs share the same cache and the set of DBs can change
|
|
485
530
|
// over time.
|
|
486
531
|
|
|
487
|
-
// Insert a mapping from key->
|
|
488
|
-
// and assign it with the specified charge against the total cache capacity.
|
|
489
|
-
// If strict_capacity_limit is true and cache reaches its full capacity,
|
|
490
|
-
// return Status::MemoryLimit.
|
|
491
|
-
//
|
|
492
|
-
// If handle is not nullptr, returns a handle that corresponds to the
|
|
493
|
-
// mapping. The caller must call this->Release(handle) when the returned
|
|
494
|
-
// mapping is no longer needed. In case of error caller is responsible to
|
|
495
|
-
// cleanup the value (i.e. calling "deleter").
|
|
496
|
-
//
|
|
497
|
-
// If handle is nullptr, it is as if Release is called immediately after
|
|
498
|
-
// insert. In case of error value will be cleanup.
|
|
499
|
-
//
|
|
500
|
-
// When the inserted entry is no longer needed, the key and
|
|
501
|
-
// value will be passed to "deleter" which must delete the value.
|
|
502
|
-
// (The Cache is responsible for copying and reclaiming space for
|
|
503
|
-
// the key.)
|
|
504
|
-
virtual Status Insert(const Slice& key, void* value, size_t charge,
|
|
505
|
-
DeleterFn deleter, Handle** handle = nullptr,
|
|
506
|
-
Priority priority = Priority::LOW) = 0;
|
|
507
|
-
|
|
508
|
-
// EXPERIMENTAL
|
|
509
|
-
// Insert a mapping from key->value into the cache and assign it
|
|
532
|
+
// Insert a mapping from key->object into the cache and assign it
|
|
510
533
|
// the specified charge against the total cache capacity. If
|
|
511
534
|
// strict_capacity_limit is true and cache reaches its full capacity,
|
|
512
|
-
// return Status::MemoryLimit. `
|
|
513
|
-
//
|
|
514
|
-
//
|
|
535
|
+
// return Status::MemoryLimit. `obj` must be non-nullptr if compatible
|
|
536
|
+
// with secondary cache (helper->size_cb != nullptr), because Value() ==
|
|
537
|
+
// nullptr is reserved for indicating some secondary cache failure cases.
|
|
538
|
+
// On success, returns OK and takes ownership of `obj`, eventually deleting
|
|
539
|
+
// it with helper->del_cb. On non-OK return, the caller maintains ownership
|
|
540
|
+
// of `obj` so will often need to delete it in such cases.
|
|
515
541
|
//
|
|
516
542
|
// The helper argument is saved by the cache and will be used when the
|
|
517
|
-
// inserted object is evicted or
|
|
518
|
-
//
|
|
519
|
-
//
|
|
520
|
-
//
|
|
521
|
-
//
|
|
522
|
-
// mapping is no longer needed. In case of error caller is responsible to
|
|
523
|
-
// cleanup the value (i.e. calling "deleter").
|
|
543
|
+
// inserted object is evicted or considered for promotion to the secondary
|
|
544
|
+
// cache. Promotion to secondary cache is only enabled if helper->size_cb
|
|
545
|
+
// != nullptr. The helper must outlive the cache. Callers may use
|
|
546
|
+
// &kNoopCacheItemHelper as a trivial helper (no deleter for the object,
|
|
547
|
+
// no secondary cache). `helper` must not be nullptr (efficiency).
|
|
524
548
|
//
|
|
525
|
-
// If handle is nullptr
|
|
526
|
-
//
|
|
549
|
+
// If `handle` is not nullptr and return status is OK, `handle` is set
|
|
550
|
+
// to a Handle* for the entry. The caller must call this->Release(handle)
|
|
551
|
+
// when the returned entry is no longer needed. If `handle` is nullptr, it is
|
|
552
|
+
// as if Release is called immediately after Insert.
|
|
527
553
|
//
|
|
528
554
|
// Regardless of whether the item was inserted into the cache,
|
|
529
555
|
// it will attempt to insert it into the secondary cache if one is
|
|
@@ -532,42 +558,23 @@ class Cache {
|
|
|
532
558
|
// the item is only inserted into the primary cache. It may
|
|
533
559
|
// defer the insertion to the secondary cache as it sees fit.
|
|
534
560
|
//
|
|
535
|
-
// When the inserted entry is no longer needed,
|
|
536
|
-
//
|
|
537
|
-
virtual Status Insert(const Slice& key,
|
|
561
|
+
// When the inserted entry is no longer needed, it will be destroyed using
|
|
562
|
+
// helper->del_cb (if non-nullptr).
|
|
563
|
+
virtual Status Insert(const Slice& key, ObjectPtr obj,
|
|
538
564
|
const CacheItemHelper* helper, size_t charge,
|
|
539
565
|
Handle** handle = nullptr,
|
|
540
|
-
Priority priority = Priority::LOW)
|
|
541
|
-
if (!helper) {
|
|
542
|
-
return Status::InvalidArgument();
|
|
543
|
-
}
|
|
544
|
-
return Insert(key, value, charge, helper->del_cb, handle, priority);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// If the cache has no mapping for "key", returns nullptr.
|
|
548
|
-
//
|
|
549
|
-
// Else return a handle that corresponds to the mapping. The caller
|
|
550
|
-
// must call this->Release(handle) when the returned mapping is no
|
|
551
|
-
// longer needed.
|
|
552
|
-
// If stats is not nullptr, relative tickers could be used inside the
|
|
553
|
-
// function.
|
|
554
|
-
virtual Handle* Lookup(const Slice& key, Statistics* stats = nullptr) = 0;
|
|
566
|
+
Priority priority = Priority::LOW) = 0;
|
|
555
567
|
|
|
556
|
-
//
|
|
557
|
-
//
|
|
558
|
-
// The create_cb callback function object will be used to contruct the
|
|
559
|
-
// cached object.
|
|
560
|
-
// If none of the caches have the mapping for the key, returns nullptr.
|
|
561
|
-
// Else, returns a handle that corresponds to the mapping.
|
|
568
|
+
// Lookup the key, returning nullptr if not found. If found, returns
|
|
569
|
+
// a handle to the mapping that must eventually be passed to Release().
|
|
562
570
|
//
|
|
563
|
-
//
|
|
564
|
-
//
|
|
565
|
-
//
|
|
566
|
-
//
|
|
567
|
-
// to
|
|
568
|
-
//
|
|
569
|
-
//
|
|
570
|
-
// outlive the cache.
|
|
571
|
+
// If a non-nullptr helper argument is provided with a non-nullptr
|
|
572
|
+
// create_cb, and a secondary cache is configured, then the secondary
|
|
573
|
+
// cache is also queried if lookup in the primary cache fails. If found
|
|
574
|
+
// in secondary cache, the provided create_db and create_context are
|
|
575
|
+
// used to promote the entry to an object in the primary cache.
|
|
576
|
+
// In that case, the helper may be saved and used later when the object
|
|
577
|
+
// is evicted, so as usual, the pointed-to helper must outlive the cache.
|
|
571
578
|
//
|
|
572
579
|
// ======================== Async Lookup (wait=false) ======================
|
|
573
580
|
// When wait=false, the handle returned might be in any of three states:
|
|
@@ -576,8 +583,8 @@ class Cache {
|
|
|
576
583
|
// * Pending, not ready (IsReady() == false) - secondary cache is still
|
|
577
584
|
// working to retrieve the value. Might become ready any time.
|
|
578
585
|
// * Pending, ready (IsReady() == true) - secondary cache has the value
|
|
579
|
-
// but it has not been loaded into primary cache. Call to
|
|
580
|
-
// will not block.
|
|
586
|
+
// but it has not been loaded as an object into primary cache. Call to
|
|
587
|
+
// Wait()/WaitAll() will not block.
|
|
581
588
|
//
|
|
582
589
|
// IMPORTANT: Pending handles are not thread-safe, and only these functions
|
|
583
590
|
// are allowed on them: Value(), IsReady(), Wait(), WaitAll(). Even Release()
|
|
@@ -594,11 +601,15 @@ class Cache {
|
|
|
594
601
|
// Pending+ready state from the Failed state is to Wait() on it. A cache
|
|
595
602
|
// entry not compatible with secondary cache can also have Value()==nullptr
|
|
596
603
|
// like the Failed state, but this is not generally a concern.
|
|
597
|
-
virtual Handle* Lookup(const Slice& key,
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
604
|
+
virtual Handle* Lookup(const Slice& key,
|
|
605
|
+
const CacheItemHelper* helper = nullptr,
|
|
606
|
+
CreateContext* create_context = nullptr,
|
|
607
|
+
Priority priority = Priority::LOW, bool wait = true,
|
|
608
|
+
Statistics* stats = nullptr) = 0;
|
|
609
|
+
|
|
610
|
+
// Convenience wrapper when secondary cache not supported
|
|
611
|
+
inline Handle* BasicLookup(const Slice& key, Statistics* stats) {
|
|
612
|
+
return Lookup(key, nullptr, nullptr, Priority::LOW, true, stats);
|
|
602
613
|
}
|
|
603
614
|
|
|
604
615
|
// Increments the reference count for the handle if it refers to an entry in
|
|
@@ -620,11 +631,12 @@ class Cache {
|
|
|
620
631
|
// REQUIRES: handle must have been returned by a method on *this.
|
|
621
632
|
virtual bool Release(Handle* handle, bool erase_if_last_ref = false) = 0;
|
|
622
633
|
|
|
623
|
-
// Return the
|
|
624
|
-
//
|
|
634
|
+
// Return the object assiciated with a handle returned by a successful
|
|
635
|
+
// Lookup(). For historical reasons, this is also known at the "value"
|
|
636
|
+
// associated with the key.
|
|
625
637
|
// REQUIRES: handle must not have been released yet.
|
|
626
638
|
// REQUIRES: handle must have been returned by a method on *this.
|
|
627
|
-
virtual
|
|
639
|
+
virtual ObjectPtr Value(Handle* handle) = 0;
|
|
628
640
|
|
|
629
641
|
// If the cache contains the entry for the key, erase it. Note that the
|
|
630
642
|
// underlying entry will be kept around until all existing handles
|
|
@@ -675,11 +687,8 @@ class Cache {
|
|
|
675
687
|
// Returns the charge for the specific entry in the cache.
|
|
676
688
|
virtual size_t GetCharge(Handle* handle) const = 0;
|
|
677
689
|
|
|
678
|
-
// Returns the
|
|
679
|
-
|
|
680
|
-
// the deleter can essentially verify that a cache entry is of an
|
|
681
|
-
// expected type from an expected code source.
|
|
682
|
-
virtual DeleterFn GetDeleter(Handle* handle) const = 0;
|
|
690
|
+
// Returns the helper for the specified entry.
|
|
691
|
+
virtual const CacheItemHelper* GetCacheItemHelper(Handle* handle) const = 0;
|
|
683
692
|
|
|
684
693
|
// Call this on shutdown if you want to speed it up. Cache will disown
|
|
685
694
|
// any underlying data and will not free it on delete. This call will leak
|
|
@@ -705,19 +714,10 @@ class Cache {
|
|
|
705
714
|
// entries is iterated over if other threads are operating on the Cache
|
|
706
715
|
// also.
|
|
707
716
|
virtual void ApplyToAllEntries(
|
|
708
|
-
const std::function<void(const Slice& key,
|
|
709
|
-
|
|
717
|
+
const std::function<void(const Slice& key, ObjectPtr obj, size_t charge,
|
|
718
|
+
const CacheItemHelper* helper)>& callback,
|
|
710
719
|
const ApplyToAllEntriesOptions& opts) = 0;
|
|
711
720
|
|
|
712
|
-
// DEPRECATED version of above. (Default implementation uses above.)
|
|
713
|
-
virtual void ApplyToAllCacheEntries(void (*callback)(void* value,
|
|
714
|
-
size_t charge),
|
|
715
|
-
bool /*thread_safe*/) {
|
|
716
|
-
ApplyToAllEntries([callback](const Slice&, void* value, size_t charge,
|
|
717
|
-
DeleterFn) { callback(value, charge); },
|
|
718
|
-
{});
|
|
719
|
-
}
|
|
720
|
-
|
|
721
721
|
// Remove all entries.
|
|
722
722
|
// Prerequisite: no entry is referenced.
|
|
723
723
|
virtual void EraseUnRefEntries() = 0;
|
|
@@ -734,6 +734,8 @@ class Cache {
|
|
|
734
734
|
MemoryAllocator* memory_allocator() const { return memory_allocator_.get(); }
|
|
735
735
|
|
|
736
736
|
// EXPERIMENTAL
|
|
737
|
+
// The following APIs are experimental and might change in the future.
|
|
738
|
+
|
|
737
739
|
// Release a mapping returned by a previous Lookup(). The "useful"
|
|
738
740
|
// parameter specifies whether the data was actually used or not,
|
|
739
741
|
// which may be used by the cache implementation to decide whether
|
|
@@ -744,24 +746,21 @@ class Cache {
|
|
|
744
746
|
return Release(handle, erase_if_last_ref);
|
|
745
747
|
}
|
|
746
748
|
|
|
747
|
-
// EXPERIMENTAL
|
|
748
749
|
// Determines if the handle returned by Lookup() can give a value without
|
|
749
750
|
// blocking, though Wait()/WaitAll() might be required to publish it to
|
|
750
751
|
// Value(). See secondary cache compatible Lookup() above for details.
|
|
751
752
|
// This call is not thread safe on "pending" handles.
|
|
752
753
|
virtual bool IsReady(Handle* /*handle*/) { return true; }
|
|
753
754
|
|
|
754
|
-
// EXPERIMENTAL
|
|
755
755
|
// Convert a "pending" handle into a full thread-shareable handle by
|
|
756
756
|
// * If necessary, wait until secondary cache finishes loading the value.
|
|
757
|
-
// * Construct the
|
|
757
|
+
// * Construct the object for primary cache and set it in the handle.
|
|
758
758
|
// Even after Wait() on a pending handle, the caller must check for
|
|
759
759
|
// Value() == nullptr in case of failure. This call is not thread-safe
|
|
760
760
|
// on pending handles. This call has no effect on non-pending handles.
|
|
761
761
|
// See secondary cache compatible Lookup() above for details.
|
|
762
762
|
virtual void Wait(Handle* /*handle*/) {}
|
|
763
763
|
|
|
764
|
-
// EXPERIMENTAL
|
|
765
764
|
// Wait for a vector of handles to become ready. As with Wait(), the user
|
|
766
765
|
// should check the Value() of each handle for nullptr. This call is not
|
|
767
766
|
// thread-safe on pending handles.
|
|
@@ -771,5 +770,8 @@ class Cache {
|
|
|
771
770
|
std::shared_ptr<MemoryAllocator> memory_allocator_;
|
|
772
771
|
};
|
|
773
772
|
|
|
773
|
+
// Useful for cache entries requiring no clean-up, such as for cache
|
|
774
|
+
// reservations
|
|
775
|
+
inline constexpr Cache::CacheItemHelper kNoopCacheItemHelper{};
|
|
774
776
|
|
|
775
777
|
} // namespace ROCKSDB_NAMESPACE
|
|
@@ -1445,11 +1445,17 @@ class DB {
|
|
|
1445
1445
|
virtual Status SyncWAL() = 0;
|
|
1446
1446
|
|
|
1447
1447
|
// Lock the WAL. Also flushes the WAL after locking.
|
|
1448
|
+
// After this method returns ok, writes to the database will be stopped until
|
|
1449
|
+
// UnlockWAL() is called.
|
|
1450
|
+
// This method may internally acquire and release DB mutex and the WAL write
|
|
1451
|
+
// mutex, but after it returns, neither mutex is held by caller.
|
|
1448
1452
|
virtual Status LockWAL() {
|
|
1449
1453
|
return Status::NotSupported("LockWAL not implemented");
|
|
1450
1454
|
}
|
|
1451
1455
|
|
|
1452
1456
|
// Unlock the WAL.
|
|
1457
|
+
// The write stop on the database will be cleared.
|
|
1458
|
+
// This method may internally acquire and release DB mutex.
|
|
1453
1459
|
virtual Status UnlockWAL() {
|
|
1454
1460
|
return Status::NotSupported("UnlockWAL not implemented");
|
|
1455
1461
|
}
|
|
@@ -140,7 +140,10 @@ enum class CompactionReason : int {
|
|
|
140
140
|
// According to the comments in flush_job.cc, RocksDB treats flush as
|
|
141
141
|
// a level 0 compaction in internal stats.
|
|
142
142
|
kFlush,
|
|
143
|
-
//
|
|
143
|
+
// [InternalOnly] External sst file ingestion treated as a compaction
|
|
144
|
+
// with placeholder input level L0 as file ingestion
|
|
145
|
+
// technically does not have an input level like other compactions.
|
|
146
|
+
// Used only for internal stats and conflict checking with other compactions
|
|
144
147
|
kExternalSstIngestion,
|
|
145
148
|
// Compaction due to SST file being too old
|
|
146
149
|
kPeriodicCompaction,
|
|
@@ -151,6 +154,9 @@ enum class CompactionReason : int {
|
|
|
151
154
|
// A special TTL compaction for RoundRobin policy, which basically the same as
|
|
152
155
|
// kLevelMaxLevelSize, but the goal is to compact TTLed files.
|
|
153
156
|
kRoundRobinTtl,
|
|
157
|
+
// [InternalOnly] DBImpl::ReFitLevel treated as a compaction,
|
|
158
|
+
// Used only for internal conflict checking with other compactions
|
|
159
|
+
kRefitLevel,
|
|
154
160
|
// total number of compaction reasons, new reasons must be added above this.
|
|
155
161
|
kNumOfReasons,
|
|
156
162
|
};
|
|
@@ -104,6 +104,13 @@ class MergeOperator : public Customizable {
|
|
|
104
104
|
Logger* logger;
|
|
105
105
|
};
|
|
106
106
|
|
|
107
|
+
enum class OpFailureScope {
|
|
108
|
+
kDefault,
|
|
109
|
+
kTryMerge,
|
|
110
|
+
kMustMerge,
|
|
111
|
+
kOpFailureScopeMax,
|
|
112
|
+
};
|
|
113
|
+
|
|
107
114
|
struct MergeOperationOutput {
|
|
108
115
|
explicit MergeOperationOutput(std::string& _new_value,
|
|
109
116
|
Slice& _existing_operand)
|
|
@@ -115,6 +122,20 @@ class MergeOperator : public Customizable {
|
|
|
115
122
|
// client can set this field to the operand (or existing_value) instead of
|
|
116
123
|
// using new_value.
|
|
117
124
|
Slice& existing_operand;
|
|
125
|
+
// Indicates the blast radius of the failure. It is only meaningful to
|
|
126
|
+
// provide a failure scope when returning `false` from the API populating
|
|
127
|
+
// the `MergeOperationOutput`. Currently RocksDB operations handle these
|
|
128
|
+
// values as follows:
|
|
129
|
+
//
|
|
130
|
+
// - `OpFailureScope::kDefault`: fallback to default
|
|
131
|
+
// (`OpFailureScope::kTryMerge`)
|
|
132
|
+
// - `OpFailureScope::kTryMerge`: operations that try to merge that key will
|
|
133
|
+
// fail. This includes flush and compaction, which puts the DB in
|
|
134
|
+
// read-only mode.
|
|
135
|
+
// - `OpFailureScope::kMustMerge`: operations that must merge that key will
|
|
136
|
+
// fail (e.g., `Get()`, `MultiGet()`, iteration). Flushes/compactions can
|
|
137
|
+
// still proceed by copying the original input operands to the output.
|
|
138
|
+
OpFailureScope op_failure_scope = OpFailureScope::kDefault;
|
|
118
139
|
};
|
|
119
140
|
|
|
120
141
|
// This function applies a stack of merge operands in chronological order
|
|
@@ -82,7 +82,7 @@ struct SstFileMetaData : public FileStorageInfo {
|
|
|
82
82
|
bool _being_compacted, Temperature _temperature,
|
|
83
83
|
uint64_t _oldest_blob_file_number,
|
|
84
84
|
uint64_t _oldest_ancester_time, uint64_t _file_creation_time,
|
|
85
|
-
std::string& _file_checksum,
|
|
85
|
+
uint64_t _epoch_number, std::string& _file_checksum,
|
|
86
86
|
std::string& _file_checksum_func_name)
|
|
87
87
|
: smallest_seqno(_smallest_seqno),
|
|
88
88
|
largest_seqno(_largest_seqno),
|
|
@@ -94,7 +94,8 @@ struct SstFileMetaData : public FileStorageInfo {
|
|
|
94
94
|
num_deletions(0),
|
|
95
95
|
oldest_blob_file_number(_oldest_blob_file_number),
|
|
96
96
|
oldest_ancester_time(_oldest_ancester_time),
|
|
97
|
-
file_creation_time(_file_creation_time)
|
|
97
|
+
file_creation_time(_file_creation_time),
|
|
98
|
+
epoch_number(_epoch_number) {
|
|
98
99
|
if (!_file_name.empty()) {
|
|
99
100
|
if (_file_name[0] == '/') {
|
|
100
101
|
relative_filename = _file_name.substr(1);
|
|
@@ -141,7 +142,12 @@ struct SstFileMetaData : public FileStorageInfo {
|
|
|
141
142
|
// Timestamp when the SST file is created, provided by
|
|
142
143
|
// SystemClock::GetCurrentTime(). 0 if the information is not available.
|
|
143
144
|
uint64_t file_creation_time = 0;
|
|
144
|
-
|
|
145
|
+
// The order of a file being flushed or ingested/imported.
|
|
146
|
+
// Compaction output file will be assigned with the minimum `epoch_number`
|
|
147
|
+
// among input files'.
|
|
148
|
+
// For L0, larger `epoch_number` indicates newer L0 file.
|
|
149
|
+
// 0 if the information is not available.
|
|
150
|
+
uint64_t epoch_number = 0;
|
|
145
151
|
// DEPRECATED: The name of the file within its directory with a
|
|
146
152
|
// leading slash (e.g. "/123456.sst"). Use relative_filename from base struct
|
|
147
153
|
// instead.
|
|
@@ -1933,7 +1933,8 @@ struct IngestExternalFileOptions {
|
|
|
1933
1933
|
// that where created before the file was ingested.
|
|
1934
1934
|
bool snapshot_consistency = true;
|
|
1935
1935
|
// If set to false, IngestExternalFile() will fail if the file key range
|
|
1936
|
-
// overlaps with existing keys or tombstones
|
|
1936
|
+
// overlaps with existing keys or tombstones or output of ongoing compaction
|
|
1937
|
+
// during file ingestion in the DB.
|
|
1937
1938
|
bool allow_global_seqno = true;
|
|
1938
1939
|
// If set to false and the file key range overlaps with the memtable key range
|
|
1939
1940
|
// (memtable flush required), IngestExternalFile will fail.
|
|
@@ -20,7 +20,7 @@ namespace ROCKSDB_NAMESPACE {
|
|
|
20
20
|
// A handle for lookup result. The handle may not be immediately ready or
|
|
21
21
|
// have a valid value. The caller must call isReady() to determine if its
|
|
22
22
|
// ready, and call Wait() in order to block until it becomes ready.
|
|
23
|
-
// The caller must call
|
|
23
|
+
// The caller must call Value() after it becomes ready to determine if the
|
|
24
24
|
// handle successfullly read the item.
|
|
25
25
|
class SecondaryCacheResultHandle {
|
|
26
26
|
public:
|
|
@@ -32,8 +32,9 @@ class SecondaryCacheResultHandle {
|
|
|
32
32
|
// Block until handle becomes ready
|
|
33
33
|
virtual void Wait() = 0;
|
|
34
34
|
|
|
35
|
-
// Return the value. If nullptr, it means
|
|
36
|
-
|
|
35
|
+
// Return the cache entry object (also known as value). If nullptr, it means
|
|
36
|
+
// the lookup was unsuccessful.
|
|
37
|
+
virtual Cache::ObjectPtr Value() = 0;
|
|
37
38
|
|
|
38
39
|
// Return the size of value
|
|
39
40
|
virtual size_t Size() = 0;
|
|
@@ -74,7 +75,7 @@ class SecondaryCache : public Customizable {
|
|
|
74
75
|
// Lookup() might return the same parsed value back. But more typically, if
|
|
75
76
|
// the implementation only uses `value` for getting persistable data during
|
|
76
77
|
// the call, then the default implementation of `InsertSaved()` suffices.
|
|
77
|
-
virtual Status Insert(const Slice& key,
|
|
78
|
+
virtual Status Insert(const Slice& key, Cache::ObjectPtr obj,
|
|
78
79
|
const Cache::CacheItemHelper* helper) = 0;
|
|
79
80
|
|
|
80
81
|
// Insert a value from its saved/persistable data (typically uncompressed
|
|
@@ -101,8 +102,9 @@ class SecondaryCache : public Customizable {
|
|
|
101
102
|
// is_in_sec_cache is to indicate whether the handle is possibly erased
|
|
102
103
|
// from the secondary cache after the Lookup.
|
|
103
104
|
virtual std::unique_ptr<SecondaryCacheResultHandle> Lookup(
|
|
104
|
-
const Slice& key, const Cache::
|
|
105
|
-
|
|
105
|
+
const Slice& key, const Cache::CacheItemHelper* helper,
|
|
106
|
+
Cache::CreateContext* create_context, bool wait, bool advise_erase,
|
|
107
|
+
bool& is_in_sec_cache) = 0;
|
|
106
108
|
|
|
107
109
|
// Indicate whether a handle can be erased in this secondary cache.
|
|
108
110
|
[[nodiscard]] virtual bool SupportForceErase() const = 0;
|
|
@@ -135,6 +135,9 @@ class Status {
|
|
|
135
135
|
Status(Code _code, SubCode _subcode, Severity _sev, const Slice& msg)
|
|
136
136
|
: Status(_code, _subcode, msg, "", _sev) {}
|
|
137
137
|
|
|
138
|
+
static Status CopyAppendMessage(const Status& s, const Slice& delim,
|
|
139
|
+
const Slice& msg);
|
|
140
|
+
|
|
138
141
|
Severity severity() const {
|
|
139
142
|
MarkChecked();
|
|
140
143
|
return sev_;
|