common

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxUint8  = ^uint8(0)
	MaxUint16 = ^uint16(0)
	MaxUint32 = ^uint32(0)
	MaxUint64 = ^uint64(0)
)
View Source
const (
	TmpSuffix  = ".tmp"
	TBlkSuffix = ".tblk"
	BlkSuffix  = ".blk"
	SegSuffix  = ".seg"
	LockSuffix = ".lock"
	NodeSuffix = ".nod"
	BSISuffix  = ".bsi"
	BBSISuffix = ".bbsi"

	SpillDirName = "spill"
	TempDirName  = "temp"
	DataDirName  = "data"
	MetaDirName  = "meta"
)
View Source
const (
	K uint64 = 1024
	M uint64 = 1024 * 1024
	G        = K * M
)
View Source
const (
	TRANSIENT_TABLE_START_ID uint64 = ^(uint64(0)) / 2
)
View Source
const (
	UNLIMIT uint64 = ^uint64(0)
)

Variables

View Source
var (
	ErrParseBlockFileName   = errors.New("aoe: parse block file name")
	ErrParseTBlockFileName  = errors.New("aoe: parse tblock file name")
	ErrParseSegmentFileName = errors.New("aoe: parse segment file name")
)
View Source
var (
	ErrRangeNotContinous = errors.New("aoe: range not continuous")
	ErrRangeInvalid      = errors.New("aoe: invalid range")
)
View Source
var (
	GlobalSeqNum uint64 = 0
)
View Source
var (
	PageSizes = []uint64{
		64,
		128,
		256,
		512,
		1 * K,
		4 * K,
		8 * K,
		16 * K,
		32 * K,
		64 * K,
		128 * K,
		256 * K,
		512 * K,
		M,
	}
)

Here we defined different page sizes, and each size has a certain pool managing all pages in that size.

Functions

func CompareInterface

func CompareInterface(a, b interface{}) int64

func FilenameFromTmpfile

func FilenameFromTmpfile(tmpFile string) (fname string, err error)

func GetGlobalSeqNum

func GetGlobalSeqNum() uint64

func IsBlockFile

func IsBlockFile(name string) bool

func IsSegmentFile

func IsSegmentFile(name string) bool

func IsTBlockFile

func IsTBlockFile(name string) bool

func IsTempFile

func IsTempFile(name string) bool

func MakeBitSlicedIndexFileName

func MakeBitSlicedIndexFileName(version, tid, sid uint64, col uint16) string

func MakeBlockBitSlicedIndexFileName

func MakeBlockBitSlicedIndexFileName(version, tid, sid, bid uint64, col uint16) string

func MakeBlockFileName

func MakeBlockFileName(dirname, name string, tableID uint64, isTmp bool) string

func MakeDataDir

func MakeDataDir(dirname string) string

func MakeFilename

func MakeFilename(dirname string, ft FileT, name string, isTmp bool) string

func MakeLockFileName

func MakeLockFileName(dirname, name string) string

func MakeMetaDir

func MakeMetaDir(dirname string) string

func MakeSegmentFileName

func MakeSegmentFileName(dirname, name string, tableID uint64, isTmp bool) string

func MakeSpillDir

func MakeSpillDir(dirname string) string

func MakeTBlockFileName

func MakeTBlockFileName(dirname, name string, isTmp bool) string

func MakeTempDir

func MakeTempDir(dirname string) string

func NextGlobalSeqNum

func NextGlobalSeqNum() uint64

func ParseBitSlicedIndexFileName

func ParseBitSlicedIndexFileName(filename string) (name string, ok bool)

func ParseBitSlicedIndexFileNameToInfo

func ParseBitSlicedIndexFileNameToInfo(filename string) (version, tblID, segID uint64, colIdx uint16, ok bool)

func ParseBlockBitSlicedIndexFileName

func ParseBlockBitSlicedIndexFileName(filename string) (name string, ok bool)

func ParseBlockBitSlicedIndexFileNameToInfo

func ParseBlockBitSlicedIndexFileNameToInfo(filename string) (version, tblID, segID, blkID uint64, colIdx uint16, ok bool)

func ParseBlockfileName

func ParseBlockfileName(filename string) (name string, ok bool)

func ParseSegmentFileName

func ParseSegmentFileName(filename string) (name string, ok bool)

func ParseTBlockfileName

func ParseTBlockfileName(filename string) (name string, ok bool)

func ToH

func ToH(size uint64) string

Types

type BaseMvcc

type BaseMvcc struct {
	PrevVer   *interface{}
	NextVer   *interface{}
	Pin       PinFunc
	Unpin     UnpinFunc
	GetObject GetObjectFunc
}

func (*BaseMvcc) GetNextVersion

func (mvcc *BaseMvcc) GetNextVersion() interface{}

func (*BaseMvcc) GetPrevVersion

func (mvcc *BaseMvcc) GetPrevVersion() interface{}

func (*BaseMvcc) Object

func (mvcc *BaseMvcc) Object() interface{}

func (*BaseMvcc) OnVersionStale

func (mvcc *BaseMvcc) OnVersionStale()

func (*BaseMvcc) SetNextVersion

func (mvcc *BaseMvcc) SetNextVersion(next interface{})

func (*BaseMvcc) SetPrevVersion

func (mvcc *BaseMvcc) SetPrevVersion(prev interface{})

type FileInfo

type FileInfo interface {
	Name() string
	Size() int64
	OriginSize() int64
	CompressAlgo() int
}

FileInfo contains the basic info for a file.

type FileT

type FileT int
const (
	FTLock FileT = iota
	FTTBlock
	FTBlock
	FTSegment
	FTTransientNode
)

type FileType

type FileType uint8
const (
	InvalidFile FileType = iota
	MemFile
	DiskFile
)

type GetObjectFunc

type GetObjectFunc func() interface{}

type ID

type ID struct {
	// Internal table id
	TableID uint64
	// Internal segment id
	SegmentID uint64
	// Internal block id
	BlockID uint64
	// Internal column part id
	PartID uint32
	// Column index for the column part above
	Idx uint16
	// Iter is used for MVCC
	Iter uint8
}

ID is the general identifier type shared by different types like table, segment, block, etc.

We could wrap info from upper level via ID, for instance, get the table id, segment id, and the block id for one block by ID.AsBlockID, which made the resource management easier.

func NewTransientID

func NewTransientID() *ID

func ParseBlkNameToID

func ParseBlkNameToID(name string) (ID, error)

func ParseSegmentNameToID

func ParseSegmentNameToID(name string) (ID, error)

func ParseTBlkName

func ParseTBlkName(name string) (id ID, tag string, err error)

func (*ID) AsBlockID

func (id *ID) AsBlockID() ID

func (*ID) AsSegmentID

func (id *ID) AsSegmentID() ID

func (*ID) BlockString

func (id *ID) BlockString() string

func (*ID) IsSameBlock

func (id *ID) IsSameBlock(o ID) bool

func (*ID) IsSameSegment

func (id *ID) IsSameSegment(o ID) bool

func (*ID) IsTransient

func (id *ID) IsTransient() bool

func (*ID) Next

func (id *ID) Next() *ID

func (*ID) NextBlock

func (id *ID) NextBlock() ID

func (*ID) NextIter

func (id *ID) NextIter() ID

func (*ID) NextPart

func (id *ID) NextPart() ID

func (*ID) NextSegment

func (id *ID) NextSegment() ID

func (*ID) SegmentString

func (id *ID) SegmentString() string

func (*ID) String

func (id *ID) String() string

func (*ID) TableString

func (id *ID) TableString() string

func (*ID) ToBlockFileName

func (id *ID) ToBlockFileName() string

func (*ID) ToBlockFilePath

func (id *ID) ToBlockFilePath() string

func (*ID) ToPartFileName

func (id *ID) ToPartFileName() string

func (*ID) ToPartFilePath

func (id *ID) ToPartFilePath() string

func (*ID) ToSegmentFileName

func (id *ID) ToSegmentFileName() string

func (*ID) ToSegmentFilePath

func (id *ID) ToSegmentFilePath() string

func (*ID) ToTBlockFileName

func (id *ID) ToTBlockFileName(name string) string

type IDAlloctor

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

func NewIdAlloctor

func NewIdAlloctor(from uint64) *IDAlloctor

func (*IDAlloctor) Alloc

func (alloc *IDAlloctor) Alloc() uint64

func (*IDAlloctor) Get

func (alloc *IDAlloctor) Get() uint64

func (*IDAlloctor) SetStart

func (alloc *IDAlloctor) SetStart(start uint64)

type IRef

type IRef interface {
	RefCount() int64
	Ref()
	Unref()
}

IRef is the general representation of the resources that should be managed with a reference count. Once the reference count reached 0, the OnZeroCB would be called.

type ISLLNode

type ISLLNode interface {
	IRef
}

type ISSLLNode

type ISSLLNode interface {
	Insert(ISSLLNode)
	GetNext() ISSLLNode
	SetNext(ISSLLNode)
	ReleaseNextNode() ISSLLNode
	ReleaseFollowing() ISSLLNode
}

type IVFile

type IVFile interface {
	io.Reader
	Ref()
	Unref()
	RefCount() int64
	Stat() FileInfo
	GetFileType() FileType
}

IVFile is the general in-memory representation of resources like segment, block, index, column part, etc. that managed by buffer manager.

func MockCompressedFile

func MockCompressedFile(size int64, osize int64) IVFile

func NewMemFile

func NewMemFile(size int64) IVFile

type MVCC

type MVCC interface {
	GetPrevVersion() interface{}
	SetPrevVersion(interface{})
	GetNextVersion() interface{}
	SetNextVersion(interface{})
	Object() interface{}
}

MVCC offers some basic methods related to MVCC. Every type expected to have multiple physical versions should implement this.

type MemNode

type MemNode struct {
	Buf []byte
	// contains filtered or unexported fields
}

func (*MemNode) IsQuota

func (n *MemNode) IsQuota() bool

func (*MemNode) PageIdx

func (n *MemNode) PageIdx() int

func (*MemNode) Size

func (n *MemNode) Size() int

type Mempool

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

Mempool wraps an easy-to-use memory pool for the AOE storage.

It manages memory through different granularity.

var (
	// GPool is the global mem pool used by AOE storage.
	// It's initialized automatically during init phase.
	GPool *Mempool
)

func NewMempool

func NewMempool(capacity uint64) *Mempool

func (*Mempool) Alloc

func (mp *Mempool) Alloc(size uint64) *MemNode

func (*Mempool) ApplyQuota

func (mp *Mempool) ApplyQuota(size uint64) *MemNode

func (*Mempool) Capacity

func (mp *Mempool) Capacity() uint64

func (*Mempool) Free

func (mp *Mempool) Free(n *MemNode)

func (*Mempool) String

func (mp *Mempool) String() string

func (*Mempool) Usage

func (mp *Mempool) Usage() uint64

type OnZeroCB

type OnZeroCB func()

type PinFunc

type PinFunc func(interface{})

type Range

type Range struct {
	Left  uint64 `json:"l"`
	Right uint64 `json:"r"`
}

func (*Range) Append

func (r *Range) Append(right uint64) error

func (*Range) CanCover

func (r *Range) CanCover(o *Range) bool

func (*Range) ClosedIn

func (r *Range) ClosedIn(id uint64) bool

func (*Range) CommitLeft

func (r *Range) CommitLeft(left uint64) bool

func (*Range) GT

func (r *Range) GT(id uint64) bool

func (*Range) LT

func (r *Range) LT(id uint64) bool

func (*Range) String

func (r *Range) String() string

func (*Range) Union

func (r *Range) Union(o *Range) error

func (*Range) Valid

func (r *Range) Valid() bool

type RefHelper

type RefHelper struct {
	Refs     int64
	OnZeroCB OnZeroCB
}

func (*RefHelper) Ref

func (helper *RefHelper) Ref()

func (*RefHelper) RefCount

func (helper *RefHelper) RefCount() int64

func (*RefHelper) Unref

func (helper *RefHelper) Unref()

type SLLNode

type SLLNode struct {
	RefHelper
	*sync.RWMutex
	Next ISLLNode
}

SLLNode represent a single node in linked list. It is thread-safe.

func NewSLLNode

func NewSLLNode(mu *sync.RWMutex) *SLLNode

func (*SLLNode) GetNextNode

func (l *SLLNode) GetNextNode() ISLLNode

func (*SLLNode) Insert

func (l *SLLNode) Insert(n ISLLNode)

func (*SLLNode) ReleaseNextNode

func (l *SLLNode) ReleaseNextNode()

func (*SLLNode) SetNextNode

func (l *SLLNode) SetNextNode(next ISLLNode)

func (*SLLNode) SetNextNodeNoLock

func (l *SLLNode) SetNextNodeNoLock(next ISLLNode)

type SSLLNode

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

func NewSSLLNode

func NewSSLLNode() *SSLLNode

func (*SSLLNode) GetNext

func (n *SSLLNode) GetNext() ISSLLNode

func (*SSLLNode) Insert

func (n *SSLLNode) Insert(nn ISSLLNode)

func (*SSLLNode) ReleaseFollowing

func (n *SSLLNode) ReleaseFollowing() ISSLLNode

func (*SSLLNode) ReleaseNextNode

func (n *SSLLNode) ReleaseNextNode() ISSLLNode

func (*SSLLNode) SetNext

func (n *SSLLNode) SetNext(next ISSLLNode)

type UnpinFunc

type UnpinFunc func(interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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