storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: Apache-2.0, MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

View Source
const (
	MAJOR_VERSION           uint16 = 1
	MINOR_VERSION           uint16 = 1
	MAX_JOURNAL_REGION_SIZE uint64 = (1 << 40) - 1
	MAX_DATA_REGION_SIZE    uint64 = MAX_JOURNAL_REGION_SIZE * uint64(block.MIN)
)
View Source
const (
	LUMP_DATA_TRAILER_SIZE = 2
)

Variables

View Source
var (
	MAGIC_NUMBER = [4]byte{'l', 'u', 's', 'f'}
)

Functions

This section is empty.

Types

type DataRegion

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

func (*DataRegion) Get

func (region *DataRegion) Get(dataPortion portion.DataPortion) (lump.LumpData, error)

func (*DataRegion) GetSize

func (region *DataRegion) GetSize(dataPortion portion.DataPortion) (size uint32, err error)

func (*DataRegion) GetWithOffset

func (region *DataRegion) GetWithOffset(dataPortion portion.DataPortion,
	startOffset uint32, length uint32) ([]byte, error)

more friendly data portion read. only read up user required data. the returned bytes could be less than length

func (*DataRegion) Put

func (region *DataRegion) Put(data lump.LumpData) (portion.DataPortion, error)

WARNING: this PUT would CHANGE (data *lump.LumpData),

func (*DataRegion) Release

func (region *DataRegion) Release(portion portion.DataPortion)

func (*DataRegion) Update

func (region *DataRegion) Update(dataPortion portion.DataPortion,
	startOffset uint32, payload []byte) error

type JournalSnapshot

type JournalSnapshot struct {
	UnreleasedHead uint64
	Head           uint64
	Tail           uint64
	Entries        []journal.JournalEntry
}

type Storage

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

func CreateCannylsStorage

func CreateCannylsStorage(path string, capacity uint64, journal_ratio float64) (*Storage, error)

func OpenCannylsStorage

func OpenCannylsStorage(path string) (*Storage, error)

func (*Storage) Close

func (store *Storage) Close()

func (*Storage) CreateSnapshot added in v0.2.0

func (store *Storage) CreateSnapshot() error

func (*Storage) Delete

func (store *Storage) Delete(lumpid lump.LumpId) (updated bool, size uint32, err error)

func (*Storage) DeleteSnapshot added in v0.2.0

func (store *Storage) DeleteSnapshot() error

func (*Storage) GenerateEmptyId

func (store *Storage) GenerateEmptyId() (id lump.LumpId, have bool)

func (*Storage) Get

func (store *Storage) Get(lumpid lump.LumpId) ([]byte, error)

func (*Storage) GetAllocationStatus

func (store *Storage) GetAllocationStatus() []float64

return value: len([]float) no more than 12800 points, each point is 4MB

func (*Storage) GetSize

func (store *Storage) GetSize(lumpid lump.LumpId) (size uint32, err error)

Get accurate size of object, require a disk IO

func (*Storage) GetSizeOnDisk

func (store *Storage) GetSizeOnDisk(lumpid lump.LumpId) (size uint32, err error)

Note the returned size is not accurate size of object, but aligned to block size. For accurate object size, use GetSize, which requires a disk IO.

func (*Storage) GetSnapshotReader added in v0.2.0

func (store *Storage) GetSnapshotReader() (*nvm.SnapshotReader, error)

func (*Storage) GetWithOffset

func (store *Storage) GetWithOffset(lumpId lump.LumpId, startOffset uint32, length uint32) ([]byte, error)

func (*Storage) Header

func (store *Storage) Header() nvm.StorageHeader

func (*Storage) JournalGC

func (store *Storage) JournalGC()

func (*Storage) JournalSnapshot

func (store *Storage) JournalSnapshot() JournalSnapshot

func (*Storage) JournalSync

func (store *Storage) JournalSync()

func (*Storage) List

func (store *Storage) List() []lump.LumpId

func (*Storage) ListRange

func (store *Storage) ListRange(start, end lump.LumpId) []lump.LumpId

func (*Storage) MaxId

func (store *Storage) MaxId() (lump.LumpId, bool)

func (*Storage) MinId

func (store *Storage) MinId() (lump.LumpId, bool)

func (*Storage) Put

func (store *Storage) Put(lumpid lump.LumpId, lumpdata lump.LumpData) (updated bool, err error)

func (*Storage) PutEmbed

func (store *Storage) PutEmbed(lumpid lump.LumpId, data []byte) (updated bool, err error)

func (*Storage) PutWithOffset

func (store *Storage) PutWithOffset(lumpid lump.LumpId, lumpdata lump.LumpData,
	startOffset uint32, reservation uint32) (err error)

Put object with offset and space reservation. For object creation, object size is max(reservation, startOffset + len(lumpdata)); for object update, `reservation` is ignored since space is already allocated, and return error when write offset exceeds reserved object size. Untouched space are zeroed.

func (*Storage) RunSideJobOnce

func (store *Storage) RunSideJobOnce()

func (*Storage) SetAutomaticGcMode

func (store *Storage) SetAutomaticGcMode(gc bool)

func (*Storage) Usage

func (store *Storage) Usage() StorageUsage

type StorageUsage

type StorageUsage struct {
	JournalCapacity   uint64 `json:"journalcapacity"`
	DataCapacity      uint64 `json:"datacapacity"`
	FileCounts        uint64 `json:"filecounts"`
	DataFreeBytes     uint64 `json:"datafreebytes"`
	JournalUsageBytes uint64 `json:"journalusagebytes"`
	MaxSegmentSize    uint64 `json:"maxsegmentsize"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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