Documentation ¶
Index ¶
- Constants
- Variables
- func ArrayToSpan(in []tablepb.TableID) []tablepb.Span
- func EndCompare(lhs []byte, rhs []byte) int
- func GetAllDDLSpan() []tablepb.Span
- func GetTableRange(tableID int64) (startKey, endKey []byte)
- func HackSpan(span tablepb.Span) tablepb.Span
- func HashTableSpan(span tablepb.Span, slots int) int
- func HexKey(key []byte) string
- func Intersect(lhs tablepb.Span, rhs tablepb.Span) (span tablepb.Span, err error)
- func IsSubSpan(sub tablepb.Span, parents ...tablepb.Span) bool
- func KeyInSpan(k tablepb.Key, span tablepb.Span) bool
- func Sort(spans []tablepb.Span)
- func StartCompare(lhs []byte, rhs []byte) int
- func TableIDToComparableRange(tableID tablepb.TableID) (start, end tablepb.Span)
- func TableIDToComparableSpan(tableID tablepb.TableID) tablepb.Span
- func ToComparableKey(key []byte) tablepb.Key
- func ToSpan(startKey, endKey []byte) tablepb.Span
- type BtreeMap
- func (m *BtreeMap[T]) Ascend(iterator ItemIterator[T])
- func (m *BtreeMap[T]) AscendRange(start, end tablepb.Span, iterator ItemIterator[T])
- func (m *BtreeMap[T]) Delete(span tablepb.Span) (T, bool)
- func (m *BtreeMap[T]) FindHoles(start, end tablepb.Span) ([]tablepb.Span, []tablepb.Span)
- func (m *BtreeMap[T]) Get(span tablepb.Span) (T, bool)
- func (m *BtreeMap[T]) GetV(span tablepb.Span) T
- func (m *BtreeMap[T]) Has(span tablepb.Span) bool
- func (m *BtreeMap[T]) Len() int
- func (m *BtreeMap[T]) ReplaceOrInsert(span tablepb.Span, value T) (T, bool)
- type HashMap
- func (m *HashMap[T]) Delete(span tablepb.Span)
- func (m *HashMap[T]) Get(span tablepb.Span) (T, bool)
- func (m *HashMap[T]) GetV(span tablepb.Span) T
- func (m *HashMap[T]) Has(span tablepb.Span) bool
- func (m *HashMap[T]) Len() int
- func (m *HashMap[T]) Range(iterator ItemIterator[T])
- func (m *HashMap[T]) ReplaceOrInsert(span tablepb.Span, value T)
- type ItemIterator
- type Set
- type SyncMap
- func (m *SyncMap) Delete(key tablepb.Span)
- func (m *SyncMap) Load(key tablepb.Span) (value any, ok bool)
- func (m *SyncMap) LoadAndDelete(key tablepb.Span) (value any, loaded bool)
- func (m *SyncMap) LoadOrStore(key tablepb.Span, value any) (actual any, loaded bool)
- func (m *SyncMap) Range(f func(span tablepb.Span, value any) bool)
- func (m *SyncMap) Store(key tablepb.Span, value any)
Constants ¶
const ( // JobTableID is the id of `tidb_ddl_job`. JobTableID = ddl.JobTableID // JobHistoryID is the id of `tidb_ddl_history` JobHistoryID = ddl.HistoryTableID )
Variables ¶
var UpperBoundKey = []byte{255, 255, 255, 255, 255}
UpperBoundKey represents the maximum value.
Functions ¶
func ArrayToSpan ¶
ArrayToSpan converts an array of TableID to an array of Span.
func EndCompare ¶
EndCompare compares two end keys. The result will be 0 if lhs==rhs, -1 if lhs < rhs, and +1 if lhs > rhs
func GetAllDDLSpan ¶
GetAllDDLSpan return all cdc interested spans for DDL.
func GetTableRange ¶
GetTableRange returns the span to watch for the specified table Note that returned keys are not in memcomparable format.
func HashTableSpan ¶
HashTableSpan hashes the given span to a slot offset.
func Intersect ¶
Intersect return to intersect part of lhs and rhs span. Return error if there's no intersect part
func StartCompare ¶
StartCompare compares two start keys. The result will be 0 if lhs==rhs, -1 if lhs < rhs, and +1 if lhs > rhs
func TableIDToComparableRange ¶
TableIDToComparableRange returns a range of a table, start and end are encoded in Comparable format.
func TableIDToComparableSpan ¶
TableIDToComparableSpan converts a TableID to a Span whose StartKey and EndKey are encoded in Comparable format.
func ToComparableKey ¶
ToComparableKey returns a memcomparable key. See: https://github.com/facebook/mysql-5.6/wiki/MyRocks-record-format
Types ¶
type BtreeMap ¶
type BtreeMap[T any] struct { // contains filtered or unexported fields }
BtreeMap is a specialized btree map that map a Span to a value.
func NewBtreeMapWithDegree ¶
NewBtreeMapWithDegree returns a new BtreeMap with the given degree.
func (*BtreeMap[T]) Ascend ¶
func (m *BtreeMap[T]) Ascend(iterator ItemIterator[T])
Ascend calls the iterator for every value in the tree within the range [first, last], until iterator returns false.
func (*BtreeMap[T]) AscendRange ¶
func (m *BtreeMap[T]) AscendRange(start, end tablepb.Span, iterator ItemIterator[T])
AscendRange calls the iterator for every value in the tree within the range [start, end), until iterator returns false.
func (*BtreeMap[T]) Delete ¶
Delete removes an item equal to the passed in item from the tree, returning it. If no such item exists, returns (zeroValue, false).
func (*BtreeMap[T]) FindHoles ¶
FindHoles returns an array of Span that are not covered in the range [start, end). Note: * Table ID is not set in returned holes. * Returned slice is read only and will be changed on next FindHoles.
func (*BtreeMap[T]) Get ¶
Get looks for the key item in the tree, returning it. It returns (zeroValue, false) if unable to find that item.
func (*BtreeMap[T]) GetV ¶
GetV looks for the key item in the tree, returning it. It returns zeroValue if unable to find that item.
func (*BtreeMap[T]) ReplaceOrInsert ¶
ReplaceOrInsert adds the given item to the tree. If an item in the tree already equals the given one, it is removed from the tree and returned, and the second return value is true. Otherwise, (zeroValue, false)
nil cannot be added to the tree (will panic).
type HashMap ¶
type HashMap[T any] struct { // contains filtered or unexported fields }
HashMap is a specialized hash map that map a Span to a value.
func (*HashMap[T]) Get ¶
Get looks for the key item in the map, returning it. It returns (zeroValue, false) if unable to find that item.
func (*HashMap[T]) GetV ¶
GetV looks for the key item in the map, returning it. It returns zeroValue if unable to find that item.
func (*HashMap[T]) Range ¶
func (m *HashMap[T]) Range(iterator ItemIterator[T])
Range calls the iterator for every value in the map until iterator returns false.
func (*HashMap[T]) ReplaceOrInsert ¶
ReplaceOrInsert adds the given item to the map.
type ItemIterator ¶
ItemIterator allows callers of Ascend to iterate in-order over portions of the tree. Similar to btree.ItemIterator. Note: The span must not be mutated.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set maintains a set of Span.
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
SyncMap is thread-safe map, its key is tablepb.Span.
func (*SyncMap) Load ¶
Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.
func (*SyncMap) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.
func (*SyncMap) LoadOrStore ¶
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.