volume

package
v0.0.0-...-61472b1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const FixedNeedleSize uint64 = 24

Variables

View Source
var (
	DefaultDir      string = "/tmp/fs"
	MaxVolumeSize   uint64 = 1 << 36 //64GB
	VolumeIndexSize uint64 = 8       //每个Volume File用1byte来存储当前的offset的偏移量
)

Functions

func MarshalBinary

func MarshalBinary(N *Needle) ([]byte, error)

Types

type CassandraDirectory

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

func NewCassandraDirectory

func NewCassandraDirectory(config *config.Config) (c *CassandraDirectory, err error)

func (*CassandraDirectory) Close

func (c *CassandraDirectory) Close()

func (*CassandraDirectory) Del

func (c *CassandraDirectory) Del(vid, nid uint64) (err error)

func (*CassandraDirectory) Get

func (c *CassandraDirectory) Get(vid, nid uint64) (n *Needle, err error)

func (*CassandraDirectory) Has

func (c *CassandraDirectory) Has(vid, nid uint64) (has bool)

func (*CassandraDirectory) Set

func (c *CassandraDirectory) Set(vid, nid uint64, needle *Needle) (err error)

type ClickHouseDirectory

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

func NewClickHouseDirectory

func NewClickHouseDirectory(config *config.Config) (c *ClickHouseDirectory, err error)

func (*ClickHouseDirectory) Close

func (c *ClickHouseDirectory) Close()

func (*ClickHouseDirectory) Del

func (c *ClickHouseDirectory) Del(vid, nid uint64) (err error)

func (*ClickHouseDirectory) Get

func (c *ClickHouseDirectory) Get(vid, nid uint64) (n *Needle, err error)

func (*ClickHouseDirectory) Has

func (c *ClickHouseDirectory) Has(vid, nid uint64) (has bool)

func (*ClickHouseDirectory) Set

func (c *ClickHouseDirectory) Set(vid, nid uint64, needle *Needle) (err error)

type Directory

type Directory interface {
	Get(vid, nid uint64) (n *Needle, err error)
	Has(vid, nid uint64) (has bool)
	Del(vid, nid uint64) (err error)
	Set(vid, nid uint64, n *Needle) (err error)
	Iter() (iter Iterator)
	Close()
}

type Iterator

type Iterator interface {
	Next() (key []byte, exists bool)
	Release()
}

type LeveldbDirectory

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

func NewLeveldbDirectory

func NewLeveldbDirectory(config *config.Config) (d *LeveldbDirectory, err error)

func (*LeveldbDirectory) Close

func (d *LeveldbDirectory) Close()

func (*LeveldbDirectory) Del

func (d *LeveldbDirectory) Del(vid, nid uint64) (err error)

func (*LeveldbDirectory) Get

func (d *LeveldbDirectory) Get(vid, nid uint64) (n *Needle, err error)

func (*LeveldbDirectory) Has

func (d *LeveldbDirectory) Has(vid, nid uint64) (has bool)

func (*LeveldbDirectory) Iter

func (d *LeveldbDirectory) Iter() (iter Iterator)

func (*LeveldbDirectory) Set

func (d *LeveldbDirectory) Set(vid, nid uint64, needle *Needle) (err error)

type LeveldbIterator

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

func (*LeveldbIterator) Next

func (it *LeveldbIterator) Next() (key []byte, exists bool)

func (*LeveldbIterator) Release

func (it *LeveldbIterator) Release()

type Needle

type Needle struct {
	Id            uint64
	FileSize      uint64
	NeedleOffset  uint64
	FileName      string
	File          *os.File
	CurrentOffset uint64 //当前读写操作的offset
}

func UnMarshalBinary

func UnMarshalBinary(data []byte) (N *Needle, err error)

func (*Needle) Read

func (f *Needle) Read(b []byte) (n int, err error)

func (*Needle) Write

func (f *Needle) Write(b []byte) (n int, err error)

type Volume

type Volume struct {
	ID            uint64
	MaxSize       uint64
	CurrentOffset uint64 //当前最新文件所在的offset
	Path          string
	File          *os.File // Volume File 用一个Byte来存储当前的Offset

	Writeable bool
	// contains filtered or unexported fields
}

func NewVolume

func NewVolume(vid uint64, dir string) (v *Volume, err error)

func (*Volume) GetVolumeSize

func (v *Volume) GetVolumeSize() uint64

func (*Volume) NewFile

func (v *Volume) NewFile(id uint64, data *[]byte, fileName string) (needle *Needle, err error)

func (*Volume) NewNeedle

func (v *Volume) NewNeedle(id uint64, fileName string, fileSize uint64) (n *Needle, err error)

1. alloc space 2. set needle's header 3. create meta info

func (*Volume) RemainingSpace

func (v *Volume) RemainingSpace() uint64

func (*Volume) SetCurrentIndex

func (v *Volume) SetCurrentIndex(currentIndex uint64) (err error)

Jump to

Keyboard shortcuts

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