uengine

package module
v0.0.0-...-1802b4c Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 15 Imported by: 1

README

uengine

storage engine

Documentation

Index

Constants

View Source
const (
	ENGINE_NAMESPACE_SYSTEM = "_sys"  // 系统命名空间
	ENGINE_NAMESPACE_USER   = "_user" // 用户命名空间

	ENGINE_TABLE_NAMESPACES = "_ns"      //系统命名空间表名
	ENGINE_TABLE_TABLES     = "_tab"     //系统表名
	ENGINE_TABLE_PARTITIONS = "_part"    //系统分区表名
	ENGINE_TABLE_CLUSTERS   = "_cluster" //集群信息存储表
	ENGINE_TABLE_METAS      = "_meta"    //系统元数据表名

	ENGINE_KEY_META_STORAGE    = "storage" //存储元数据主键
	ENGINE_KEY_META_PART       = "part"    //分区元数据主键
	ENGINE_KEY_META_REPOSITORY = "repo"    //分区元数据主键
)
View Source
const (
	VERSION = 1
)

Variables

View Source
var (
	ErrPartRingVerifyFailed = errors.New("partition ring verify failed")
	ErrPartNotFound         = errors.New("partition not found")
	ErrPartAllocated        = errors.New("partition has been allocated")
	ErrPartNotAllocate      = errors.New("partition not allocate")
)

database

View Source
var (
	StoreType_Value = map[string]uint8{
		"UDB":     0,
		"BOLG":    1,
		"LEVELDB": 2,
		"BADGER":  3,
	}

	FLAG_META = []byte{'0'}
	FLAG_DATA = []byte{'1'}
)
View Source
var (
	EMPTY_KEY = []byte{}
)
View Source
var (
	ErrDbKeyNotFound = errors.New("db:key not found")
)

Functions

func IdentityDataId

func IdentityDataId(identity Identity) []byte

func IdentityMetaId

func IdentityMetaId(identity Identity) []byte

func IdentityVersionId

func IdentityVersionId(identity Identity, version int32) []byte

func KeyBytes

func KeyBytes(key []byte) []byte

func NsTabBytes

func NsTabBytes(ns, tab int32) []byte

func NsTabKeyBytes

func NsTabKeyBytes(ns, tab int32, key []byte) []byte

Types

type Data

type Data struct {
	Id      Identity
	Content []byte
	Version int32
}

func NewData

func NewData(id Identity, con []byte) *Data

type Engine

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

func NewEngine

func NewEngine(config UEngineConfig) *Engine

func (*Engine) AddPart

func (p *Engine) AddPart(part model.Partition) error

func (*Engine) Close

func (p *Engine) Close()

func (*Engine) GetData

func (p *Engine) GetData(partId int32, id Identity) (*model.DataMeta, *model.DataContent, error)

func (*Engine) GetPart

func (p *Engine) GetPart(partId int32) *model.Partition

func (*Engine) GetPartOfIndex

func (p *Engine) GetPartOfIndex(partIndex int32) *model.Partition

func (*Engine) PartRanges

func (p *Engine) PartRanges() []int

func (*Engine) PartSize

func (p *Engine) PartSize() int

func (*Engine) Parts

func (p *Engine) Parts() []model.Partition

func (*Engine) SetData

func (p *Engine) SetData(partId int32, data Data, incrementVersion bool) error

func (*Engine) SimilarPart

func (p *Engine) SimilarPart(ring int32) *model.Partition

func (*Engine) Table

func (p *Engine) Table() *EngineTable

func (*Engine) ValidatePartition

func (p *Engine) ValidatePartition(nodeId int32) ([]model.Partition, error)

type EngineTable

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

func NewEngineTable

func NewEngineTable(engine *Engine) *EngineTable

func (*EngineTable) AddPartition

func (p *EngineTable) AddPartition(part model.Partition) error

func (*EngineTable) Partition

func (p *EngineTable) Partition(partId int32) *model.Partition

func (*EngineTable) PartitionOfIndex

func (p *EngineTable) PartitionOfIndex(partIndex int32) *model.Partition

func (*EngineTable) Repository

func (p *EngineTable) Repository() *model.Repository

func (*EngineTable) RepositoryUpdate

func (p *EngineTable) RepositoryUpdate(repository model.Repository) error

type Identity

type Identity struct {
	NamespaceId    int32  //命名空间id
	Namespace      string //命名空间名称
	TableId        int32  //表id
	Table          string //表名称
	PartitionIndex int32  //分区索引
	PartitionId    int32  //分区id
	Key            []byte //用户主键
	// contains filtered or unexported fields
}

func NewIdOfData

func NewIdOfData(namespace, table string, key []byte) *Identity

func NewIdOfNs

func NewIdOfNs(key []byte) *Identity

func NewIdOfPart

func NewIdOfPart(key []byte) *Identity

func NewIdOfTab

func NewIdOfTab(namespace string, key []byte) *Identity

func NewIdentity

func NewIdentity(ns, tab string, key []byte) *Identity

func NewIdentityWithValue

func NewIdentityWithValue(idBytes []byte) *Identity

func (Identity) IdBytes

func (v Identity) IdBytes() []byte

func (Identity) Part

func (v Identity) Part(partSize int) int32

type Store

type Store interface {
	Close() error

	Set(key, value []byte) error

	Get(key []byte) ([]byte, error)

	Seek(key []byte, iter StoreIterator) error

	ForEach(iter StoreIterator) error
}

func NewStore

func NewStore(cfg StoreConfig) (s Store)

func OpenStoreBadger

func OpenStoreBadger(cfg StoreConfig) (Store, error)

type StoreBadger

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

func (*StoreBadger) Close

func (p *StoreBadger) Close() error

func (*StoreBadger) ForEach

func (p *StoreBadger) ForEach(iter StoreIterator) (err error)

func (*StoreBadger) Get

func (p *StoreBadger) Get(key []byte) (dat []byte, err error)

func (*StoreBadger) Seek

func (p *StoreBadger) Seek(key []byte, iter StoreIterator) (err error)

func (*StoreBadger) Set

func (p *StoreBadger) Set(key, value []byte) error

type StoreConfig

type StoreConfig struct {
	Path string
	Type StoreType
}

type StoreIterator

type StoreIterator func(key, data []byte) bool

type StoreMetaIterator

type StoreMetaIterator func(key []byte, meta model.DataMeta) bool

type StoreOperator

type StoreOperator interface {
	Close() error

	PartIfAbsent(part model.Partition) (*model.Partition, error)
	Part() *model.Partition

	MetaSeek(identity Identity, iter StoreMetaIterator) error
	MetaForEach(iter StoreMetaIterator) error
	DataSeek(identity Identity, iter StoreIterator) error
	DataForEach(iter StoreIterator) error

	NSs() []model.Namespace
	NS(namespace string) *model.Namespace
	NSValue(namespaceId int32) *model.Namespace
	NSIfAbsent(namespace string) *model.Namespace

	TABs(namespace string) []model.Table
	TAB(namespace, table string) *model.Table
	TABValue(namespace string, tableId int32) *model.Table
	TABIfAbsent(namespace, table string) *model.Table

	SysSet(table, key string, message ggproto.Message) error
	SysGet(table, key string, message ggproto.Message) error

	SetMeta(identity Identity, meta model.DataMeta) error
	GetMeta(identity Identity) (*model.DataMeta, error)
	SetData(data Data, incrementVersion bool) error
	GetData(identity Identity) (*model.DataMeta, *model.DataContent, error)
}

type StoreOperatorKV

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

func NewStoreOperatorKV

func NewStoreOperatorKV(store Store) *StoreOperatorKV

func (*StoreOperatorKV) Close

func (p *StoreOperatorKV) Close() error

func (*StoreOperatorKV) DataForEach

func (p *StoreOperatorKV) DataForEach(iter StoreIterator) error

func (*StoreOperatorKV) DataSeek

func (p *StoreOperatorKV) DataSeek(identity Identity, iter StoreIterator) error

func (*StoreOperatorKV) GetData

func (p *StoreOperatorKV) GetData(identity Identity) (*model.DataMeta, *model.DataContent, error)

func (*StoreOperatorKV) GetMeta

func (p *StoreOperatorKV) GetMeta(dataId Identity) (meta *model.DataMeta, err error)

func (*StoreOperatorKV) MetaForEach

func (p *StoreOperatorKV) MetaForEach(iter StoreMetaIterator) error

func (*StoreOperatorKV) MetaSeek

func (p *StoreOperatorKV) MetaSeek(identity Identity, iter StoreMetaIterator) error

func (*StoreOperatorKV) NS

func (p *StoreOperatorKV) NS(namespace string) *model.Namespace

func (*StoreOperatorKV) NSIfAbsent

func (p *StoreOperatorKV) NSIfAbsent(namespace string) *model.Namespace

func (*StoreOperatorKV) NSValue

func (p *StoreOperatorKV) NSValue(nsId int32) *model.Namespace

func (*StoreOperatorKV) NSs

func (p *StoreOperatorKV) NSs() []model.Namespace

func (*StoreOperatorKV) Part

func (p *StoreOperatorKV) Part() *model.Partition

func (*StoreOperatorKV) PartIfAbsent

func (p *StoreOperatorKV) PartIfAbsent(part model.Partition) (*model.Partition, error)

func (*StoreOperatorKV) SetData

func (p *StoreOperatorKV) SetData(data Data, incrementVersion bool) error

func (*StoreOperatorKV) SetMeta

func (p *StoreOperatorKV) SetMeta(dataId Identity, meta model.DataMeta) error

func (*StoreOperatorKV) SysGet

func (p *StoreOperatorKV) SysGet(table, key string, message ggproto.Message) error

func (*StoreOperatorKV) SysSet

func (p *StoreOperatorKV) SysSet(table, key string, message ggproto.Message) error

func (*StoreOperatorKV) TAB

func (p *StoreOperatorKV) TAB(namespace string, tab string) *model.Table

func (*StoreOperatorKV) TABIfAbsent

func (p *StoreOperatorKV) TABIfAbsent(namespace string, tab string) *model.Table

func (*StoreOperatorKV) TABValue

func (p *StoreOperatorKV) TABValue(namespace string, tabId int32) *model.Table

func (*StoreOperatorKV) TABs

func (p *StoreOperatorKV) TABs(namespace string) []model.Table

type StoreType

type StoreType uint8
const (
	STORE_TYPE_UDB StoreType = iota
	STORE_TYPE_BOLT
	STORE_TYPE_LEVELDB
	STORE_TYPE_BADGER
)

func StoreTypeOfValue

func StoreTypeOfValue(val string) StoreType

type UEngineConfig

type UEngineConfig struct {
	Engine     string   `json:"engine" yaml:"engine"`
	Meta       string   `json:"meta" yaml:"meta"`
	Wal        string   `json:"wal" yaml:"wal"`
	Partitions []string `json:"partitions" yaml:"partitions"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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