Documentation ¶
Index ¶
- func RewriteManifest(dir string, m *Manifest) (*os.File, int, error)
- func SyncDir(dir string) error
- type LevelManifest
- type LogFile
- func (lf *LogFile) AddSize(offset uint32)
- func (lf *LogFile) Bootstrap() error
- func (lf *LogFile) Close() error
- func (lf *LogFile) DecodeEntry(buf []byte, offset uint32) (*utils2.Entry, error)
- func (lf *LogFile) DoneWriting(offset uint32) error
- func (lf *LogFile) EncodeEntry(e *utils2.Entry, buf *bytes.Buffer, offset uint32) (int, error)
- func (lf *LogFile) FD() *os.File
- func (lf *LogFile) FileName() string
- func (lf *LogFile) Init() error
- func (lf *LogFile) Iterate(offset uint32, fn utils2.LogEntry) (uint32, error)
- func (lf *LogFile) Open(opt *Option) error
- func (lf *LogFile) Read(p *utils2.ValuePtr) (buf []byte, err error)
- func (lf *LogFile) Seek(offset int64, whence int) (ret int64, err error)
- func (lf *LogFile) Size() int64
- func (lf *LogFile) Sync() error
- func (lf *LogFile) Truncate(offset int64) error
- func (lf *LogFile) Write(offset uint32, buf []byte) (err error)
- type Manifest
- type ManifestFile
- func (f *ManifestFile) AddChanges(changesParam []*pb.ManifestModify) error
- func (f *ManifestFile) AddTableMeta(levelNum int, t *TableMeta) (err error)
- func (f *ManifestFile) Close() error
- func (f *ManifestFile) FilterValidTables(ids map[uint64]struct{}) error
- func (f *ManifestFile) Manifest() *Manifest
- type MmapFile
- func (m *MmapFile) AllocateSlice(sz, offset int) ([]byte, int, error)
- func (m *MmapFile) AppendBuffer(offset uint32, buf []byte) error
- func (m *MmapFile) Bytes(off, sz int) ([]byte, error)
- func (m *MmapFile) Close() error
- func (m *MmapFile) Delete() error
- func (m *MmapFile) NewReader(offset int) io.Reader
- func (m *MmapFile) Slice(offset int) []byte
- func (m *MmapFile) Sync() error
- func (m *MmapFile) Truncate(maxSz int64) error
- type Option
- type SSTable
- func (s *SSTable) Bytes(off, sz int) ([]byte, error)
- func (s *SSTable) GetCreatedAt() *time.Time
- func (s *SSTable) HasBloomFilter() bool
- func (s *SSTable) Index() *pb.TableIndex
- func (s *SSTable) Init() error
- func (s *SSTable) MaxKey() []byte
- func (s *SSTable) MinKey() []byte
- func (s *SSTable) SetCreatedAt(t *time.Time)
- func (s *SSTable) SetMaxKey(maxKey []byte)
- func (s *SSTable) Size() int64
- type SafeRead
- type TableManifest
- type TableMeta
- type Wal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RewriteManifest ¶
RewriteManifest 覆盖写manifest文件
Types ¶
type LevelManifest ¶
type LevelManifest struct {
Tables map[uint64]struct{} // 每层的table集合
}
type LogFile ¶
func (*LogFile) DecodeEntry ¶
func (*LogFile) DoneWriting ¶
func (*LogFile) EncodeEntry ¶
EncodeEntry will encode entry to the buf layout of entry +--------+-----+-------+-------+ | header | key | value | crc32 | +--------+-----+-------+-------+
type Manifest ¶
type Manifest struct { Levels []LevelManifest // 每个level的table集合 Tables map[uint64]TableManifest // tableID--{level,crc}的映射 Creations int Deletions int }
Manifest 存放当前kv的level元数据 磁盘存储结构: magic-num | version | length change | crc | change
32 bit | 32bit | 32 bit | 32bit | ...
func (*Manifest) GetModifies ¶
func (m *Manifest) GetModifies() []*pb.ManifestModify
type ManifestFile ¶
type ManifestFile struct {
// contains filtered or unexported fields
}
func OpenManifestFile ¶
func OpenManifestFile(opt *Option) (*ManifestFile, error)
OpenManifestFile 打开manifest文件
func (*ManifestFile) AddChanges ¶
func (f *ManifestFile) AddChanges(changesParam []*pb.ManifestModify) error
func (*ManifestFile) AddTableMeta ¶
func (f *ManifestFile) AddTableMeta(levelNum int, t *TableMeta) (err error)
AddTableMeta 存储level表到manifest的level中
func (*ManifestFile) FilterValidTables ¶
func (f *ManifestFile) FilterValidTables(ids map[uint64]struct{}) error
FilterValidTables 用来将磁盘中存储的sst文件集合与内存中的manifest进行对比过滤 两个集合:manifest,sst目录下集合 以manifest为基准,保证manifest中的所有文件都存在:如果出现某table存在于manifest中,但是磁盘中并不存在此sst文件,返回error 如果manifest中多了,需要将多余的文件删除
func (*ManifestFile) Manifest ¶
func (f *ManifestFile) Manifest() *Manifest
type MmapFile ¶
func (*MmapFile) AllocateSlice ¶
func (*MmapFile) AppendBuffer ¶
AppendBuffer 向内存中追加一个buffer,如果空间不足则重新映射,扩大空间
type SSTable ¶
type SSTable struct {
// contains filtered or unexported fields
}
SSTable construct of : block1 | block2 | ... | index_data | index_len | check_sum | check_sum_len
func OpenSSTable ¶
func (*SSTable) HasBloomFilter ¶
func (*SSTable) Index ¶
func (s *SSTable) Index() *pb.TableIndex