@@ -1281,94 +1281,16 @@ type ValueSeparationPolicy struct {
12811281 GarbageRatioHighPriority float64
12821282}
12831283
1284- // SpanPolicy contains policies that can vary by key range. The zero value is
1285- // the default value.
1286- type SpanPolicy struct {
1287- // Prefer a faster compression algorithm for the keys in this span.
1288- //
1289- // This is useful for keys that are frequently read or written but which don't
1290- // amount to a significant amount of space.
1291- PreferFastCompression bool
1292-
1293- // ValueStoragePolicy is a hint used to determine where to store the values
1294- // for KVs.
1295- ValueStoragePolicy ValueStoragePolicyAdjustment
1296- }
1297-
1298- // String returns a string representation of the SpanPolicy.
1299- func (p SpanPolicy ) String () string {
1300- var sb strings.Builder
1301- if p .PreferFastCompression {
1302- sb .WriteString ("fast-compression," )
1303- }
1304- if p .ValueStoragePolicy .DisableSeparationBySuffix {
1305- sb .WriteString ("disable-value-separation-by-suffix," )
1306- }
1307- if p .ValueStoragePolicy .DisableBlobSeparation {
1308- sb .WriteString ("no-blob-value-separation," )
1309- }
1310- if p .ValueStoragePolicy .OverrideBlobSeparationMinimumSize > 0 {
1311- sb .WriteString ("override-value-separation-min-size," )
1312- }
1313- if p .ValueStoragePolicy .MinimumMVCCGarbageSize > 0 {
1314- sb .WriteString ("minimum-mvcc-garbage-size" )
1315- }
1316- return strings .TrimSuffix (sb .String (), "," )
1317- }
1318-
1319- // ValueStoragePolicyAdjustment is used to determine where to store the values for
1320- // KVs, overriding global policies. Values can be configured to be stored in-place,
1321- // in value blocks, or in blob files.
1322- type ValueStoragePolicyAdjustment struct {
1323- // DisableSeparationBySuffix disables discriminating KVs depending on
1324- // suffix.
1325- //
1326- // Among a set of keys with the same prefix, Pebble's default heuristics
1327- // optimize access to the KV with the smallest suffix. This is useful for MVCC
1328- // keys (where the smallest suffix is the latest version), but should be
1329- // disabled for keys where the suffix does not correspond to a version.
1330- // See sstable.IsLikelyMVCCGarbage for the exact criteria we use to
1331- // determine whether a value is likely MVCC garbage.
1332- //
1333- // If separation by suffix is enabled, KVs with older suffix values will be
1334- // written according to the following rules:
1335- // - If the value is empty, no separation is performed.
1336- // - If blob separation is enabled the value will be separated into a blob
1337- // file even if its size is smaller than the minimum value size.
1338- // - If blob separation is disabled, the value will be written to a value
1339- // block within the sstable.
1340- DisableSeparationBySuffix bool
1341-
1342- // DisableBlobSeparation disables separating values into blob files.
1343- DisableBlobSeparation bool
1344-
1345- // OverrideBlobSeparationMinimumSize overrides the minimum size required
1346- // for value separation into a blob file. Note that value separation must
1347- // be enabled globally for this to take effect.
1348- OverrideBlobSeparationMinimumSize int
1349-
1350- // MinimumMVCCGarbageSize, when non-zero, imposes a new minimum size required
1351- // for value separation into a blob file only if the value is likely MVCC
1352- // garbage. Note that value separation must be enabled globally for this to
1353- // take effect.
1354- MinimumMVCCGarbageSize int
1355- }
1356-
1357- func (vsp * ValueStoragePolicyAdjustment ) ContainsOverrides () bool {
1358- return vsp .OverrideBlobSeparationMinimumSize > 0 || vsp .DisableSeparationBySuffix ||
1359- vsp .MinimumMVCCGarbageSize > 0
1360- }
1361-
13621284// ValueStorageLatencyTolerant is the suggested ValueStoragePolicyAdjustment
13631285// to use for key ranges that can tolerate higher value retrieval
13641286// latency.
1365- var ValueStorageLatencyTolerant = ValueStoragePolicyAdjustment {
1287+ var ValueStorageLatencyTolerant = base. ValueStoragePolicyAdjustment {
13661288 OverrideBlobSeparationMinimumSize : 10 ,
13671289}
13681290
13691291// ValueStorageLowReadLatency is the suggested ValueStoragePolicyAdjustment
13701292// to use for key ranges that require low value retrieval latency.
1371- var ValueStorageLowReadLatency = ValueStoragePolicyAdjustment {
1293+ var ValueStorageLowReadLatency = base. ValueStoragePolicyAdjustment {
13721294 DisableBlobSeparation : true ,
13731295 DisableSeparationBySuffix : true ,
13741296}
@@ -1384,12 +1306,12 @@ var ValueStorageLowReadLatency = ValueStoragePolicyAdjustment{
13841306//
13851307// The end key can be empty, in which case the policy is valid for the entire
13861308// keyspace after startKey.
1387- type SpanPolicyFunc func (startKey []byte ) (policy SpanPolicy , endKey []byte , err error )
1309+ type SpanPolicyFunc func (startKey []byte ) (policy base. SpanPolicy , endKey []byte , err error )
13881310
13891311// SpanAndPolicy defines a key range and the policy to apply to it.
13901312type SpanAndPolicy struct {
13911313 KeyRange KeyRange
1392- Policy SpanPolicy
1314+ Policy base. SpanPolicy
13931315}
13941316
13951317// MakeStaticSpanPolicyFunc returns a SpanPolicyFunc that applies a given policy
@@ -1406,28 +1328,28 @@ func MakeStaticSpanPolicyFunc(cmp base.Compare, inputPolicies ...SpanAndPolicy)
14061328 uniqueKeys = slices .CompactFunc (uniqueKeys , func (a , b []byte ) bool { return cmp (a , b ) == 0 })
14071329
14081330 // Create a list of policies.
1409- policies := make ([]SpanPolicy , len (uniqueKeys )- 1 )
1331+ policies := make ([]base. SpanPolicy , len (uniqueKeys )- 1 )
14101332 for _ , p := range inputPolicies {
14111333 idx , _ := slices .BinarySearchFunc (uniqueKeys , p .KeyRange .Start , cmp )
14121334 policies [idx ] = p .Policy
14131335 }
14141336
1415- return func (startKey []byte ) (_ SpanPolicy , endKey []byte , _ error ) {
1337+ return func (startKey []byte ) (_ base. SpanPolicy , endKey []byte , _ error ) {
14161338 // Find the policy that applies to the start key.
14171339 idx , eq := slices .BinarySearchFunc (uniqueKeys , startKey , cmp )
14181340 switch idx {
14191341 case len (uniqueKeys ):
14201342 // The start key is after the last policy.
1421- return SpanPolicy {}, nil , nil
1343+ return base. SpanPolicy {}, nil , nil
14221344 case len (uniqueKeys ) - 1 :
14231345 if eq {
14241346 // The start key is exactly the start of the last policy.
1425- return SpanPolicy {}, nil , nil
1347+ return base. SpanPolicy {}, nil , nil
14261348 }
14271349 case 0 :
14281350 if ! eq {
14291351 // The start key is before the first policy.
1430- return SpanPolicy {}, uniqueKeys [0 ], nil
1352+ return base. SpanPolicy {}, uniqueKeys [0 ], nil
14311353 }
14321354 }
14331355 if eq {
@@ -1696,7 +1618,7 @@ func (o *Options) EnsureDefaults() {
16961618 o .Experimental .MultiLevelCompactionHeuristic = OptionWriteAmpHeuristic
16971619 }
16981620 if o .Experimental .SpanPolicyFunc == nil {
1699- o .Experimental .SpanPolicyFunc = func (startKey []byte ) (SpanPolicy , []byte , error ) { return SpanPolicy {}, nil , nil }
1621+ o .Experimental .SpanPolicyFunc = func (startKey []byte ) (base. SpanPolicy , []byte , error ) { return base. SpanPolicy {}, nil , nil }
17001622 }
17011623 if o .Experimental .VirtualTableRewriteUnreferencedFraction == nil {
17021624 o .Experimental .VirtualTableRewriteUnreferencedFraction = func () float64 { return defaultVirtualTableUnreferencedFraction }
0 commit comments