Documentation ¶
Overview ¶
Package db string 类型命令实现
Index ¶
- Constants
- Variables
- func Decode(buf []byte) (*logEntry, error)
- func DecodeHeader(buf []byte) (*logEntry, error)
- func DefaultBitCaskDB() *bitCaskDB
- func NewBitCaskDB(options *Options) *bitCaskDB
- func NewLogEntry(key, value string, optType uint16) *logEntry
- func NewLogFile(filePath string, logType logType) (lf *logFile, err error)
- func NewStrIndex() *strIndex
- type Options
- type RadixTree
- func (art *RadixTree) Delete(key string) (val interface{}, updated bool)
- func (art *RadixTree) Get(key string) interface{}
- func (art *RadixTree) Iterator() rt.Iterator
- func (art *RadixTree) PrefixScan(prefix string, count int) (keys [][]byte)
- func (node *RadixTree) Put(key string, v Value) (oldVal interface{}, updated bool)
- func (art *RadixTree) Size() int
- type Value
Constants ¶
View Source
const ( OPT_ADD uint16 = iota OPT_DEL // 日志记录的请求头大小 LOG_ENTRY_HEADER_SIZE = 10 )
View Source
const ( STR_TYPE logType = iota LIST_TYPE // 日志文件的权限 111 LOG_FILE_PERM = 0644 // LOG_FILE_PREFIX 日志文件的前缀 LOG_FILE_PREFIX = "kv.data" )
View Source
const ( DB_HOME_DIR_NAME = "kvdb" LOG_FILE_MAX_SIZE = 512 << 20 )
DB_HOME_DIR_NAME 数据库存在的目录
Variables ¶
View Source
var ( // ErrWriteSizeNotEqual 写入数据大小不一致错误 ErrWriteSizeNotEqual = errors.New("logfile: write size is not equal to entry size") LogType2FileName = map[logType]string{ STR_TYPE: "string", } FileName2LogType = map[string]logType{ "string": STR_TYPE, } )
定义错误信息
View Source
var (
ErrKeyNotFound = errors.New("key not found")
)
Functions ¶
func NewBitCaskDB ¶
func NewBitCaskDB(options *Options) *bitCaskDB
NewBitCaskDB 根据 Options 配置创建 bitCaskDB 实列
func NewLogEntry ¶
NewLogEntry 创建一个日志记录
func NewLogFile ¶
NewLogFile 根据目录和日志类型创建日志文件
Types ¶
type RadixTree ¶
type RadixTree struct {
// contains filtered or unexported fields
}
RadixTree 基数树 所有数据存放的地方
func NewRadixTree ¶
func NewRadixTree() *RadixTree
func (*RadixTree) PrefixScan ¶
Click to show internal directories.
Click to hide internal directories.