journal

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: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TAG_END_OF_RECORDS byte = 0
	TAG_GO_TO_FRONT    byte = 1
	TAG_PUT            byte = 3
	TAG_EMBED          byte = 4
	TAG_DELETE         byte = 5
	TAG_DELETE_RANGE   byte = 6
)
View Source
const (
	RECORD_HEADER_SIZE   = 1 + 4 // TAG size + Checksum size
	LUMPID_SIZE          = 8
	LENGTH_SIZE          = 2
	PORTION_SIZE         = 5
	END_OF_RECORDS_SIZE  = 1 + 4 //Tag Size + Checksum size //GO_TO_FRONT and END_OF_RECORD
	EMBEDDED_DATA_OFFSET = RECORD_HEADER_SIZE + LUMPID_SIZE + LENGTH_SIZE
)
View Source
const (
	GC_COUNT_IN_SIDE_JOB = 64
	//performance related
	GC_QUEUE_SIZE = 0x2000
	SYNC_INTERVAL = 0x2000
)

Variables

This section is empty.

Functions

func InitialJournalRegion

func InitialJournalRegion(writer io.Writer, sector block.BlockSize)

Types

type BufferedIter

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

Use buffer and update tail

func (BufferedIter) Close

func (iter BufferedIter) Close()

func (BufferedIter) PopFront

func (iter BufferedIter) PopFront() (entry JournalEntry, err error)

Update the ring.tail

type DeleteRange

type DeleteRange struct {
	Start lump.LumpId
	End   lump.LumpId
}

func (DeleteRange) CheckSum

func (record DeleteRange) CheckSum() uint32

func (DeleteRange) ExternalSize

func (record DeleteRange) ExternalSize() uint32

func (DeleteRange) Tag

func (record DeleteRange) Tag() byte

func (DeleteRange) WriteTo

func (record DeleteRange) WriteTo(w io.Writer) error

type DeleteRecord

type DeleteRecord struct {
	LumpID lump.LumpId
}

func (DeleteRecord) CheckSum

func (record DeleteRecord) CheckSum() uint32

func (DeleteRecord) ExternalSize

func (record DeleteRecord) ExternalSize() uint32

func (DeleteRecord) Tag

func (record DeleteRecord) Tag() byte

func (DeleteRecord) WriteTo

func (record DeleteRecord) WriteTo(writer io.Writer) error

type DequeueIter

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

No buffer and update head

func (DequeueIter) PopFront

func (iter DequeueIter) PopFront() (entry JournalEntry, err error)

type EmbedRecord

type EmbedRecord struct {
	LumpID lump.LumpId
	Data   []byte
}

func (EmbedRecord) CheckSum

func (record EmbedRecord) CheckSum() uint32

func (EmbedRecord) ExternalSize

func (record EmbedRecord) ExternalSize() uint32

func (EmbedRecord) Tag

func (record EmbedRecord) Tag() byte

func (EmbedRecord) WriteTo

func (record EmbedRecord) WriteTo(w io.Writer) error

type EndOfRecords

type EndOfRecords struct{}

func (EndOfRecords) CheckSum

func (record EndOfRecords) CheckSum() uint32

func (EndOfRecords) ExternalSize

func (record EndOfRecords) ExternalSize() uint32

func (EndOfRecords) Tag

func (record EndOfRecords) Tag() byte

func (EndOfRecords) WriteTo

func (record EndOfRecords) WriteTo(writer io.Writer) (err error)

type GoToFront

type GoToFront struct{}

func (GoToFront) CheckSum

func (record GoToFront) CheckSum() uint32

func (GoToFront) ExternalSize

func (record GoToFront) ExternalSize() uint32

func (GoToFront) Tag

func (record GoToFront) Tag() byte

func (GoToFront) WriteTo

func (record GoToFront) WriteTo(writer io.Writer) error

type JournalEntry

type JournalEntry struct {
	Start  address.Address
	Record JournalRecord
}

func (JournalEntry) End

func (entry JournalEntry) End() uint64

type JournalHeaderRegion

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

func NewJournalHeadRegion

func NewJournalHeadRegion(nvm nvm.NonVolatileMemory) *JournalHeaderRegion

func (*JournalHeaderRegion) ReadFrom

func (headerRegion *JournalHeaderRegion) ReadFrom() (head uint64, err error)

func (*JournalHeaderRegion) WriteTo

func (headerRegion *JournalHeaderRegion) WriteTo(head uint64) (err error)

type JournalNvmBuffer

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

func NewJournalNvmBuffer

func NewJournalNvmBuffer(nvm nvm.NonVolatileMemory) *JournalNvmBuffer

func (*JournalNvmBuffer) BlockSize

func (jb *JournalNvmBuffer) BlockSize() block.BlockSize

func (*JournalNvmBuffer) Capacity

func (jb *JournalNvmBuffer) Capacity() uint64

func (*JournalNvmBuffer) Close

func (jb *JournalNvmBuffer) Close() error

func (*JournalNvmBuffer) Flush

func (jb *JournalNvmBuffer) Flush() error

func (*JournalNvmBuffer) Position

func (jb *JournalNvmBuffer) Position() uint64

func (*JournalNvmBuffer) RawSize

func (jb *JournalNvmBuffer) RawSize() int64

func (*JournalNvmBuffer) Read

func (jb *JournalNvmBuffer) Read(buf []byte) (n int, err error)

Direct Read

func (*JournalNvmBuffer) Seek

func (jb *JournalNvmBuffer) Seek(offset int64, whence int) (int64, error)

func (*JournalNvmBuffer) Split

func (*JournalNvmBuffer) Sync

func (jb *JournalNvmBuffer) Sync() error

implement NonVolatileNVM interface

func (*JournalNvmBuffer) Write

func (jb *JournalNvmBuffer) Write(buf []byte) (n int, err error)

Writeback

type JournalRecord

type JournalRecord interface {
	WriteTo(io.Writer) error
	ExternalSize() uint32
	CheckSum() uint32
	Tag() byte
}

func ReadRecordFrom

func ReadRecordFrom(reader io.Reader) (JournalRecord, error)

All the io.Read() should be io.ReadExact(), which means in parser, we expect read up 10 bytes, It must return 10 bytes, no more no less.

type JournalRegion

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

func OpenJournalRegion

func OpenJournalRegion(nvm nvm.NonVolatileMemory) (*JournalRegion, error)

func (*JournalRegion) GcAllEntries

func (journal *JournalRegion) GcAllEntries(index *lumpindex.LumpIndex)

maybe sync

func (*JournalRegion) GetEmbededData

func (journal *JournalRegion) GetEmbededData(embeded portion.JournalPortion) (buf []byte, err error)

func (*JournalRegion) JournalEntries

func (journal *JournalRegion) JournalEntries() (uint64, uint64, uint64, []JournalEntry)

func (*JournalRegion) RecordDelete

func (journal *JournalRegion) RecordDelete(index *lumpindex.LumpIndex, id lump.LumpId) error

func (*JournalRegion) RecordDeleteRange

func (journal *JournalRegion) RecordDeleteRange(index *lumpindex.LumpIndex, start, end lump.LumpId) error

func (*JournalRegion) RecordEmbed

func (journal *JournalRegion) RecordEmbed(index *lumpindex.LumpIndex, id lump.LumpId, data []byte) error

WARNING: this will update the INDEX

func (*JournalRegion) RecordPut

func (journal *JournalRegion) RecordPut(index *lumpindex.LumpIndex, id lump.LumpId, data portion.DataPortion) error

Write Journal, Update Index

func (*JournalRegion) RestoreIndex

func (journal *JournalRegion) RestoreIndex(index *lumpindex.LumpIndex)

func (*JournalRegion) RunSideJobOnce

func (journal *JournalRegion) RunSideJobOnce(index *lumpindex.LumpIndex)

func (*JournalRegion) SetAutomaticGcMode

func (journal *JournalRegion) SetAutomaticGcMode(gc bool)

func (*JournalRegion) Sync

func (journal *JournalRegion) Sync()

func (*JournalRegion) Usage

func (Journal *JournalRegion) Usage() uint64

thread safe

type JournalRingBuffer

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

func NewJournalRingBuffer

func NewJournalRingBuffer(nvm *JournalNvmBuffer, head uint64) *JournalRingBuffer

func (*JournalRingBuffer) BufferedIter

func (ring *JournalRingBuffer) BufferedIter() BufferedIter

Use Buffer and update tail

func (*JournalRingBuffer) Capacity

func (ring *JournalRingBuffer) Capacity() uint64

func (*JournalRingBuffer) DequeueIter

func (ring *JournalRingBuffer) DequeueIter() DequeueIter

User Buffer and update head

func (*JournalRingBuffer) DoStoreUsage

func (ring *JournalRingBuffer) DoStoreUsage()

unsafe

func (*JournalRingBuffer) Enqueue

func (ring *JournalRingBuffer) Enqueue(record JournalRecord) (jportion portion.JournalPortion, err error)

only return embeded JournalPortion

func (*JournalRingBuffer) Flush

func (ring *JournalRingBuffer) Flush() error

func (*JournalRingBuffer) Head

func (ring *JournalRingBuffer) Head() uint64

func (*JournalRingBuffer) ReadEmbededBuffer

func (ring *JournalRingBuffer) ReadEmbededBuffer(position uint64, data []byte) (err error)

func (*JournalRingBuffer) ReadIter

func (ring *JournalRingBuffer) ReadIter() ReadIter

No buffer and update nothing

func (*JournalRingBuffer) ReleaseBytesUntil

func (ring *JournalRingBuffer) ReleaseBytesUntil(head uint64)

func (*JournalRingBuffer) Sync

func (ring *JournalRingBuffer) Sync() error

func (*JournalRingBuffer) Tail

func (ring *JournalRingBuffer) Tail() uint64

func (*JournalRingBuffer) Usage

func (ring *JournalRingBuffer) Usage() uint64

go routine safe

type PutRecord

type PutRecord struct {
	LumpID      lump.LumpId
	DataPortion portion.DataPortion
}

func (PutRecord) CheckSum

func (record PutRecord) CheckSum() uint32

func (PutRecord) ExternalSize

func (record PutRecord) ExternalSize() uint32

func (PutRecord) Tag

func (record PutRecord) Tag() byte

func (PutRecord) WriteTo

func (record PutRecord) WriteTo(writer io.Writer) error

type ReadIter

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

No buffer and update nothing

func (ReadIter) PopFront

func (iter ReadIter) PopFront() (entry JournalEntry, err error)

No buffer and update nothing

type SeekableReader

type SeekableReader struct {
	*bufio.Reader
	// contains filtered or unexported fields
}

func (*SeekableReader) Seek

func (r *SeekableReader) Seek(offset int64, whence int) (off int64, err error)

Jump to

Keyboard shortcuts

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