block

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilenameSuffixInSecond string = "20060102150405"
	FilenameBlockIndex     string = "blockIndex"
	FilenameBlockIndexTemp string = "blockIndexTemp"
)

Variables

This section is empty.

Functions

func FileBlockRegister

func FileBlockRegister(name string, handler fileBlockHandler) (err error)

func FileBlockUse

func FileBlockUse(name string) (handler fileBlockHandler, err error)

func LoadIndexFromFile

func LoadIndexFromFile(filename string) (indexTable map[string]*Index, err error)

func NewIndexWriter

func NewIndexWriter(filename string, trunc bool) (w *indexWriter, err error)

func RangeIndexFromFile

func RangeIndexFromFile(filename string, doFunc func(key string, index *Index)) (err error)

Types

type Block

type Block struct {
	// contains filtered or unexported fields
}

func (*Block) DefragContent

func (b *Block) DefragContent(defragDuration time.Duration) (err error)

content整理 set相同key的时候, 之前key的index会更新, 但是旧content还保留着 删除key时, content还保留着

func (*Block) Del

func (b *Block) Del(key string) (err error)

func (*Block) Get

func (b *Block) Get(key string) (value []byte, err error)

func (*Block) Initiate

func (b *Block) Initiate(ctx context.Context, conf *config.Instance) (err error)

func (*Block) Range

func (b *Block) Range(doFunc func(key string, exist bool)) (err error)

func (*Block) Set

func (b *Block) Set(key string, value []byte) (err error)

type BlockHandler

type BlockHandler interface {
	Initiate(ctx context.Context, conf *config.Instance) error
	Set(key string, value []byte) (err error)
	Get(key string) (value []byte, err error)
	Del(key string) (err error)
	DefragContent(defragDuration time.Duration) (err error)
	Range(doFunc func(key string, exist bool)) (err error)
}

func NewFileBlockHandler

func NewFileBlockHandler() BlockHandler

type ContentReader

type ContentReader interface {
	Read(offset uint64, length uint32) (value []byte, err error)
	SequentialRead() (key string, index *Index, err error)
	Close() error
}

func NewContentReader

func NewContentReader(filename, basepath string) (r ContentReader, err error)

type ContentWriter

type ContentWriter interface {
	Write(key []byte, value []byte) (index *Index, err error)
	Close() error
	Size() int64
}

func NewContentWriter

func NewContentWriter(filename, basepath string) (w ContentWriter, err error)

type Index

type Index struct {
	// contains filtered or unexported fields
}

func NewDelIndex

func NewDelIndex() (idx *Index)

func NewIndex

func NewIndex(filename string, offset uint64, length uint32) (idx *Index)

func (*Index) Filename

func (idx *Index) Filename() string

func (*Index) IsDel

func (idx *Index) IsDel() bool

func (*Index) MarshalBinary

func (idx *Index) MarshalBinary() (data []byte, err error)

func (*Index) Same

func (idx *Index) Same(other *Index) bool

func (*Index) UnmarshalBinary

func (idx *Index) UnmarshalBinary(data []byte) (err error)

type IndexReader

type IndexReader interface {
	SequentialRead() (key string, index *Index, err error)
	Close() error
}

func NewIndexReader

func NewIndexReader(filename string) (r IndexReader, err error)

type IndexWriter

type IndexWriter interface {
	Write(key string, index *Index) (err error)
	Close() error
	WriteAndBuffered()
	BufferWriteTo(w *indexWriter) (n int64, err error)
}

type Instance

type Instance struct {
	Config *config.Instance
	// contains filtered or unexported fields
}

func NewInstance

func NewInstance() *Instance

func (*Instance) DefragContent

func (this *Instance) DefragContent(defragDuration time.Duration) (err error)

func (*Instance) Del

func (this *Instance) Del(key string) (err error)

func (*Instance) Get

func (this *Instance) Get(key string) (value []byte, err error)

func (*Instance) Initiate

func (this *Instance) Initiate(ctx context.Context) (newCtx context.Context, err error)

func (*Instance) OnRequestShutdown

func (this *Instance) OnRequestShutdown(ctx context.Context, c *routing.Context) (context.Context, error)

func (*Instance) OnRequestStartup

func (this *Instance) OnRequestStartup(ctx context.Context, c *routing.Context) (context.Context, error)

func (*Instance) OnShutdown

func (this *Instance) OnShutdown(ctx context.Context) (context.Context, error)

func (*Instance) OnStartup

func (this *Instance) OnStartup(ctx context.Context) (newCtx context.Context, err error)

func (*Instance) Range

func (this *Instance) Range(doFunc func(key string, exist bool)) (err error)

func (*Instance) Set

func (this *Instance) Set(key string, value []byte) (err error)

func (*Instance) Use

func (this *Instance) Use(ctx context.Context, handlerName string) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL