Documentation ¶
Index ¶
- Constants
- Variables
- func Build(path string, method FileRWMethod, blockSize int64) (ArchivedFiles, FileIds, error)
- func BuildType(path string, method FileRWMethod, blockSize int64, eType uint16) (ArchivedFiles, FileIds, error)
- type ArchivedFiles
- type DBFile
- type Entry
- func Decode(buf []byte) (*Entry, error)
- func NewEntry(key, value, extra []byte, t, mark uint16) *Entry
- func NewEntryNoExtra(key, value []byte, t, mark uint16) *Entry
- func NewEntryWithExpire(key, value []byte, deadline int64, t, mark uint16) *Entry
- func NewEntryWithTxn(key, value, extra []byte, t, mark uint16, txId uint64) *Entry
- type FileIds
- type FileRWMethod
- type Meta
Constants ¶
View Source
const ( // FilePerm default permission of the newly created db file. FilePerm = 0644 // PathSeparator the default path separator. PathSeparator = string(os.PathSeparator) )
View Source
const ( String uint16 = iota List Hash Set ZSet ALl )
data structure type of value, support five types now.
Variables ¶
View Source
var ( // DBFileFormatNames name format of the db files. DBFileFormatNames = map[uint16]string{ 0: "%09d.data.str", 1: "%09d.data.list", 2: "%09d.data.hash", 3: "%09d.data.set", 4: "%09d.data.zset", } // DBFileSuffixName represents the suffix names of the db files. DBFileSuffixName = map[string]uint16{"str": 0, "list": 1, "hash": 2, "set": 3, "zset": 4} )
View Source
var ( // ErrEmptyEntry the entry is empty. ErrEmptyEntry = errors.New("storage/db_file: entry or the Key of entry is empty") // ErrEntryTooLarge the entry is too large. ErrEntryTooLarge = errors.New("storage/db_file: entry is too large to store in mmap mode") )
View Source
var ( // ErrInvalidEntry invalid entry. ErrInvalidEntry = errors.New("storage/entry: invalid entry") // ErrInvalidCrc invalid crc. ErrInvalidCrc = errors.New("storage/entry: invalid crc") )
Functions ¶
func Build ¶
func Build(path string, method FileRWMethod, blockSize int64) (ArchivedFiles, FileIds, error)
Build load all db files from disk.
func BuildType ¶
func BuildType(path string, method FileRWMethod, blockSize int64, eType uint16) (ArchivedFiles, FileIds, error)
Types ¶
type ArchivedFiles ¶
ArchivedFiles define the archived files, which mean these files can only be read. and will never be opened for writing.
type DBFile ¶
type DBFile struct { Id uint32 Path string File *os.File Offset int64 // contains filtered or unexported fields }
DBFile define the data file of rosedb.
func NewDBFile ¶
func NewDBFile(path string, fileId uint32, method FileRWMethod, blockSize int64, eType uint16) (*DBFile, error)
NewDBFile create a new db file, truncate the file if rw method is mmap.
func (*DBFile) FindValidEntries ¶
type Entry ¶
type Entry struct { Meta *Meta Timestamp uint64 // Timestamp is the time when entry was written. TxId uint64 // TxId represents transaction id of an Entry. // contains filtered or unexported fields }
Entry is a record which will be appended to a db file.
func NewEntryNoExtra ¶
NewEntryNoExtra create a new entry without extra info.
func NewEntryWithExpire ¶
NewEntryWithExpire create a new Entry with expired info.
func NewEntryWithTxn ¶
NewEntryWithTx create a new Entry with transaction info.
type FileRWMethod ¶
type FileRWMethod uint8
FileRWMethod db file read and write method.
const ( // FileIO Indicates that data file read and write using system standard IO. FileIO FileRWMethod = iota // MMap Indicates that data file read and write using mmap. MMap )
Click to show internal directories.
Click to hide internal directories.