Documentation ¶
Overview ¶
Package blockfile package
Index ¶
- Constants
- Variables
- func AppendChecksum(dst []byte, checksum uint32) []byte
- func AppendFileEntry(data []byte, fw *FileWriter, dataSize int, logger protocol.Logger) error
- func AppendUvarint(dst []byte, x uint64) []byte
- func CheckSegmentName(name string) bool
- func CopyThenRemoveFile(src, dst string, srcf *os.File) error
- func FileIndexToString(fiIndex *storePb.StoreInfo) string
- func LoadNextBinaryEntry(data []byte) (n, prefixLen int, err error)
- func SegmentIndexPath(name, path string) string
- func SegmentNameToUint64(fileName string) (uint64, error)
- func SegmentPath(name, path string) string
- func Uint64ToSegmentName(index uint64) string
- type Bpos
- type CRC
- type FileWriter
- type IndexPair
- type LockableFile
- type SegIndex
- type SegName
Constants ¶
const ( DBFileSuffix = ".fdb" DBFileNameLen = 20 BlockFilenameTemplate = "%020d" LastFileSuffix = ".END" )
nolint
const ( ArchivingPath = "archiving" RestoringPath = "restoring" ArchivingBlockFileName = ".block.archiving.json" ArchivingResultFileName = ".result.archiving.json" RestoringIndexFileName = ".restoring.json" MergingFileSuffix = ".merging" BakFileSuffix = ".bak" )
nolint
Variables ¶
var ( //ErrInvalidateRestoreBlocks invalidate restore blocks ErrInvalidateRestoreBlocks = errors.New("invalidate restore blocks") //ErrConfigBlockArchive config block do not need to archive ErrConfigBlockArchive = errors.New("config block do not need archive") //ErrArchivedTx archived transaction ErrArchivedTx = errors.New("archived transaction") //ErrArchivedRWSet archived RWSet ErrArchivedRWSet = errors.New("archived RWSet") //ErrArchivedBlock archived block ErrArchivedBlock = errors.New("archived block") )
Functions ¶
func AppendChecksum ¶
AppendChecksum Customize part start
@Description: @param dst @param checksum @return []byte
func AppendFileEntry ¶
func AppendFileEntry(data []byte, fw *FileWriter, dataSize int, logger protocol.Logger) error
AppendFileEntry add next time @Description: @receiver l @param s @return error
func AppendUvarint ¶
AppendUvarint Customize part end
@Description: @param dst @param x 整型序列化 @return []byte
func CheckSegmentName ¶
CheckSegmentName add next time @Description: @param name @return bool
func CopyThenRemoveFile ¶
CopyThenRemoveFile copy src file to dst file.
these two path may be located in different disk, so can not use 'mv' directly to prevent network or power issue
@Description: @param src @param dst @return error
func LoadNextBinaryEntry ¶
LoadNextBinaryEntry 读取entry,返回
@Description: @param data @return n @return prefixLen @return err
func SegmentIndexPath ¶
SegmentIndexPath build segment index dir path
@Description: @receiver l @param name @return string
func SegmentNameToUint64 ¶
SegmentNameToUint64 add next time @Description: @param fileName @return uint64 @return error
func SegmentPath ¶
SegmentPath build segment dir path
@Description: @receiver l @param name @return string
Types ¶
type Bpos ¶
Bpos byte position info @Description:
func AppendBinaryEntry ¶
AppendBinaryEntry append an entry
@Description: @receiver l @param dst @param data @return out @return epos
func LoadEntriesForRestarting ¶
LoadEntriesForRestarting loads ebuf and epos in the segment when restarting
@Description: @receiver l @param s @return error
type CRC ¶
type CRC uint32
CRC is a CRC-32 checksum computed using Castagnoli's polynomial.
func (CRC) Update ¶
Update updates the crc with the given bytes.
@Description: @receiver c @param b @return CRC
type FileWriter ¶
type FileWriter struct { Path string Lfile *LockableFile // index file handle Ebuf []byte // cached entries buffer, storage format of one log entry: checksum|data_size|data Epos []Bpos // cached entries positions in buffer }
FileWriter block file db file writer @Description:
func NewFileWriter ¶
func NewFileWriter(path string) (*FileWriter, error)
NewFileWriter add next time @Description: @param path @return *FileWriter @return error
type IndexPair ¶
IndexPair index pair to contain update batch data
type LockableFile ¶
LockableFile add next time @Description:
type SegIndex ¶
type SegIndex struct { Height uint64 BIndex *serialization.BlockIndexMeta }
SegIndex restore segment index structure @Description:
func LoadArchiveSegIndex ¶
func LoadArchiveSegIndex(fw *FileWriter) ([]*SegIndex, error)
LoadArchiveSegIndex add next time @Description: @receiver l @param s @return error