mirror of
https://github.com/talent-plan/tinykv.git
synced 2025-02-26 11:51:05 +08:00
Signed-off-by: Connor <zbk602423539@gmail.com> Co-authored-by: Nick Cameron <nrc@ncameron.org> Co-authored-by: linning <linningde25@gmail.com> Co-authored-by: YangKeao <keao.yang@yahoo.com> Co-authored-by: andylokandy <andylokandy@hotmail.com> Co-authored-by: Iosmanthus Teng <myosmanthustree@gmail.com>
38 lines
540 B
Go
38 lines
540 B
Go
package storage
|
|
|
|
// Modify is a single modification to TinyKV's underlying storage.
|
|
type Modify struct {
|
|
Data interface{}
|
|
}
|
|
|
|
type Put struct {
|
|
Key []byte
|
|
Value []byte
|
|
Cf string
|
|
}
|
|
|
|
type Delete struct {
|
|
Key []byte
|
|
Cf string
|
|
}
|
|
|
|
func (m *Modify) Key() []byte {
|
|
switch m.Data.(type) {
|
|
case Put:
|
|
return m.Data.(Put).Key
|
|
case Delete:
|
|
return m.Data.(Delete).Key
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (m *Modify) Cf() string {
|
|
switch m.Data.(type) {
|
|
case Put:
|
|
return m.Data.(Put).Cf
|
|
case Delete:
|
|
return m.Data.(Delete).Cf
|
|
}
|
|
return ""
|
|
}
|