1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! Boundaries that compaction must cut SST files on.
//!
//! An SST partitioner is consulted for every key a compaction writes. When it
//! reports a boundary, the compaction closes the output file it is filling and
//! starts a new one, so the keys on either side of the boundary never share a
//! file. Trivial moves are held to the same rule: a file only moves down a
//! level untouched if the partitioner says its first and last key belong
//! together.
//!
//! The point is to line file boundaries up with something the application
//! cares about, usually a key prefix that identifies a tenant, a shard, or a
//! table. Once a prefix owns whole files, work scoped to that prefix gets
//! cheaper. [`DB::delete_file_in_range`](crate::DB::delete_file_in_range) only
//! drops files that sit entirely inside the range, so a partitioned prefix can
//! be deleted by unlinking files rather than by writing tombstones that later
//! compactions have to carry. Promoting one prefix to the next level stops
//! dragging its neighbours along, which is the write amplification argument
//! upstream makes for the feature.
//!
//! Partitioning only shapes files that future compactions produce. Files
//! already on disk keep whatever boundaries they were written with, and are
//! only re-cut when a compaction happens to rewrite them.
//!
//! Upstream marks the feature experimental in `options.h`.
use NonNull;
use crateffi;
/// A factory RocksDB asks for a partitioner at the start of every compaction.
///
/// Install one with
/// [`Options::set_sst_partitioner_factory`](crate::Options::set_sst_partitioner_factory).
/// The setter copies the underlying `shared_ptr`, so a factory can be installed
/// on any number of `Options` and dropped as soon as the last call returns.
// `rocksdb_sst_partitioner_factory_t` is a `std::shared_ptr<SstPartitionerFactory>`
// and nothing else (c.cc:501). Destroying the handle only drops that one
// reference, and the only other operation this crate performs on it is the
// refcount bump in `rocksdb_options_set_sst_partitioner_factory` (c.cc:6142),
// which is atomic. So the handle carries no thread affinity, and concurrent
// reads through `&SstPartitionerFactory` cannot race.
unsafe
unsafe