Documentation
¶
Overview ¶
This package is copied from tikv/pd
Index ¶
Constants ¶
const ( // RawKeyspaceModePrefix is the raw keyspace prefix mode byte. RawKeyspaceModePrefix = byte('r') // TxnKeyspaceModePrefix is the txn keyspace prefix mode byte. TxnKeyspaceModePrefix = byte('x') // KeyspacePrefixLen is the raw keyspace prefix length before memcomparable encoding. KeyspacePrefixLen = 4 // DefaultKeyspaceID is the default keyspace ID. // Valid keyspace id range is [0, 0xFFFFFF](uint24max, or 16777215) // 0 is reserved for default keyspace with the name "DEFAULT", It's initialized // when PD bootstrap and reserved for users who haven't been assigned keyspace. DefaultKeyspaceID = uint32(0) // MaxValidKeyspaceID is the max valid keyspace id. // Valid keyspace id range is [0, 0xFFFFFF](uint24max, or 16777215) // In kv encode, the first byte is represented by r/x, which means txn kv/raw kv, so there are 24 bits left. MaxValidKeyspaceID = uint32(0xFFFFFF) )
Variables ¶
This section is empty.
Functions ¶
func MakeKeyspacePrefix ¶
Types ¶
type Key ¶
type Key []byte
Key represents high-level Key type.
func EncodeBytes ¶
EncodeBytes guarantees the encoded value is in ascending order for comparison, encoding with the following rule:
[group1][marker1]...[groupN][markerN] group is 8 bytes slice which is padding with 0. marker is `0xFF - padding 0 count`
For example:
[] -> [0, 0, 0, 0, 0, 0, 0, 0, 247] [1, 2, 3] -> [1, 2, 3, 0, 0, 0, 0, 0, 250] [1, 2, 3, 0] -> [1, 2, 3, 0, 0, 0, 0, 0, 251] [1, 2, 3, 4, 5, 6, 7, 8] -> [1, 2, 3, 4, 5, 6, 7, 8, 255, 0, 0, 0, 0, 0, 0, 0, 0, 247]
Refer: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format#memcomparable-format
type KeyRange ¶
func MakeRegionBound ¶
type RegionBound ¶
type RegionBound struct {
RawLeftBound []byte
RawRightBound []byte
TxnLeftBound []byte
TxnRightBound []byte
}
RegionBound represents the region boundary of the given keyspace. For a keyspace with id ['a', 'b', 'c'], it has four boundaries:
Lower bound for raw mode: ['r', 'a', 'b', 'c'] Upper bound for raw mode: ['r', 'a', 'b', 'c + 1'] Lower bound for txn mode: ['x', 'a', 'b', 'c'] Upper bound for txn mode: ['x', 'a', 'b', 'c + 1'] For the max valid keyspace ID, the upper bound advances the mode byte as an exclusive fencepost.
From which it shares the lower bound with keyspace with id ['a', 'b', 'c-1']. And shares upper bound with keyspace with id ['a', 'b', 'c + 1']. These repeated bound will not cause any problem, as repetitive bound will be ignored during rangeListBuild, but provides guard against hole in keyspace allocations should it occur.