meta

package
v0.0.0-...-959c02d Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CurrentMagicByteVer is the current magic byte version, used for future meta compatibility.
	CurrentMagicByteVer byte = 0x00

	// MaxInt48 is the max value of int48.
	MaxInt48 = 0x0000FFFFFFFFFFFF
	// MaxGlobalID reserves 1000 IDs. Use MaxInt48 to reserves the high 2 bytes to compatible with Multi-tenancy.
	MaxGlobalID = MaxInt48 - 1000
)

Variables

View Source
var (
	// ErrGraphExists is the error for db exists.
	ErrGraphExists = errors.New("graph exists")
	// ErrGraphNotExists is the error for db not exists.
	ErrGraphNotExists    = errors.New("graph not exists")
	ErrInvalidString     = errors.New("invalid string")
	ErrLabelExists       = errors.New("label exists")
	ErrLabelNotExists    = errors.New("label not exists")
	ErrIndexExists       = errors.New("index exists")
	ErrIndexNotExists    = errors.New("index not exists")
	ErrPropertyExists    = errors.New("property exists")
	ErrPropertyNotExists = errors.New("property not exists")
	ErrNoGraphSelected   = errors.New("no graph selected")
)

Functions

func GraphKey

func GraphKey(id int64) []byte

GraphKey encodes the graph identifier into graph key.

func IsLabelKey

func IsLabelKey(labelKey []byte) bool

IsLabelKey checks whether the label key comes from LabelKey().

func IsPropertyKey

func IsPropertyKey(propertyKey []byte) bool

IsPropertyKey checks whether the property key comes from PropertyKey().

func LabelKey

func LabelKey(labelID int64) []byte

LabelKey encodes the labelID into label key.

func ParseLabelKey

func ParseLabelKey(labelKey []byte) (int64, error)

ParseLabelKey decodes the label key to get label id.

func ParsePropertyKey

func ParsePropertyKey(propertyKey []byte) (int64, error)

ParsePropertyKey decodes the property key to get property id.

func PropertyKey

func PropertyKey(propertyID uint16) []byte

PropertyKey encodes the propertyID into property key.

Types

type Meta

type Meta struct {
	StartVer kv.Version
	// contains filtered or unexported fields
}

Meta is for handling meta information in a transaction.

func New

func New(txn kv.Transaction) *Meta

New returns a new instance of meta API object.

func NewSnapshot

func NewSnapshot(snap kv.Snapshot) *Meta

NewSnapshot returns a read-only new instance of meta API object.

func (*Meta) AdvanceGlobalID

func (m *Meta) AdvanceGlobalID(n int) (int64, error)

AdvanceGlobalID advances the global ID by n. return the old global ID.

func (*Meta) AdvanceID

func (m *Meta) AdvanceID(graphID int64, n int) (int64, error)

AdvanceID advances the local ID allocator by n, and return the old global ID. NOTE: It's better to call graph.MDLock() to reduce transaction conflicts.

func (*Meta) CreateGraph

func (m *Meta) CreateGraph(info *model.GraphInfo) error

CreateGraph creates a graph.

func (*Meta) CreateLabel

func (m *Meta) CreateLabel(graphID int64, labelInfo *model.LabelInfo) error

CreateLabel creates a label.

func (*Meta) CreateProperty

func (m *Meta) CreateProperty(graphID int64, propertyInfo *model.PropertyInfo) error

CreateProperty creates a property.

func (*Meta) DropGraph

func (m *Meta) DropGraph(graphID int64) error

DropGraph drops whole graph.

func (*Meta) DropLabel

func (m *Meta) DropLabel(graphID int64, labelID int64) error

DropLabel drops label in graph.

func (*Meta) DropProperty

func (m *Meta) DropProperty(graphID int64, propertyID uint16) error

DropProperty drops property in graph.

func (*Meta) GenGlobalIDs

func (m *Meta) GenGlobalIDs(n int) ([]int64, error)

GenGlobalIDs generates the next n global IDs.

func (*Meta) GetGraph

func (m *Meta) GetGraph(graphID int64) (*model.GraphInfo, error)

GetGraph gets the database value with ID.

func (*Meta) GetLabel

func (m *Meta) GetLabel(graphID int64, labelID int64) (*model.LabelInfo, error)

GetLabel gets the label value in a graph.

func (*Meta) GetProperty

func (m *Meta) GetProperty(graphID int64, propertyID uint16) (*model.PropertyInfo, error)

GetProperty gets the property value in a graph.

func (*Meta) GlobalID

func (m *Meta) GlobalID() (int64, error)

GlobalID gets current global id.

func (*Meta) ListGraphs

func (m *Meta) ListGraphs() ([]*model.GraphInfo, error)

ListGraphs shows all graphs.

func (*Meta) ListLabels

func (m *Meta) ListLabels(graphID int64) ([]*model.LabelInfo, error)

ListLabels shows all labels in a graph.

func (*Meta) ListProperties

func (m *Meta) ListProperties(graphID int64) ([]*model.PropertyInfo, error)

ListProperties shows all properties in a graph.

func (*Meta) NextGlobalID

func (m *Meta) NextGlobalID() (int64, error)

NextGlobalID generates next id globally.

func (*Meta) UpdateGraph

func (m *Meta) UpdateGraph(info *model.GraphInfo) error

UpdateGraph updates a graph.

func (*Meta) UpdateLabel

func (m *Meta) UpdateLabel(graphID int64, labelInfo *model.LabelInfo) error

UpdateLabel updates the label.

func (*Meta) UpdateProperty

func (m *Meta) UpdateProperty(graphID int64, propertyInfo *model.PropertyInfo) error

UpdateProperty updates the property.

Jump to

Keyboard shortcuts

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