driver

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: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes2String

func Bytes2String(v []byte) string

func Bytes2Uint64

func Bytes2Uint64(v []byte) (b uint64, err error)

func DecodeIndex

func DecodeIndex(data []byte) (aoe.IndexInfo, error)

func DecodeTable

func DecodeTable(data []byte) (aoe.TableInfo, error)

func EncodeIndex

func EncodeIndex(idx aoe.IndexInfo) ([]byte, error)

func EncodeKey

func EncodeKey(ks ...interface{}) []byte

func EncodeTable

func EncodeTable(tbl aoe.TableInfo) ([]byte, error)

func String2Bytes

func String2Bytes(v string) []byte

func Uint642Bytes

func Uint642Bytes(v uint64) []byte

Types

type CubeDriver

type CubeDriver interface {
	// Start the driver.
	Start() error
	// Close close the driver.
	Close()
	// GetShardPool return ShardsPool instance.
	GetShardPool() raftstore.ShardsPool
	// Set set key value.
	Set([]byte, []byte) error
	// SetWithGroup set key value in specific group.
	SetWithGroup([]byte, []byte, pb.Group) error
	// Set async set key value.
	AsyncSet([]byte, []byte, func(CustomRequest, []byte, error), interface{})
	TpeAsyncSetKeysValuesInbatch(shardID uint64, keys [][]byte, values [][]byte, timeout time.Duration, cb func(CustomRequest, []byte, error))
	TpeAsyncSet([]byte, []byte, int, time.Duration, func(CustomRequest, []byte, error), interface{})
	// AsyncSetIfNotExist async set key value if key not exists.
	AsyncSetIfNotExist([]byte, []byte, func(CustomRequest, []byte, error), interface{})
	// Set async set key value in specific group.
	AsyncSetWithGroup([]byte, []byte, pb.Group, func(CustomRequest, []byte, error), interface{})
	// SetIfNotExist set key value if key not exists.
	SetIfNotExist([]byte, []byte) error
	// Get returns the value of key.
	Get([]byte) ([]byte, error)
	// GetWithGroup returns the value of key from specific group.
	GetWithGroup([]byte, pb.Group) ([]byte, error)
	// Delete remove the key from the store.
	Delete([]byte) error
	// DeleteIfExist remove the key from the store if key exists.
	DeleteIfExist([]byte) error
	// TpeDeleteBatch deletes keys in the parameter.
	TpeDeleteBatch(keys [][]byte) error
	// TpeDeleteBatchWithRange deletes keys in the range [startKey,endKey)
	TpeDeleteBatchWithRange([]byte, []byte) error
	// Scan scan [start,end) data
	Scan([]byte, []byte, uint64) ([][]byte, error)
	// ScanWithGroup scan [start,end) data in specific group.
	ScanWithGroup([]byte, []byte, uint64, pb.Group) ([][]byte, error)
	// TpeScan gets the keys in the range [startKey,endKey), return keys/values.
	//a. startKey maybe nil.
	//b. endKey maybe nil.
	//c. limit: if it is the math.MaxUint64,
	//	        it means there is not limitation on the count of keys.
	//d. needKey: if it is true, the keys and the values are returned.
	//			  if it is false, the keys are returned only.
	//return parameters:
	//[][]byte : return keys
	//[][]byte : return values
	//bool: true - the scanner accomplished in all shards.
	//[]byte : the start key for the next scan. If last parameter is false, this parameter is nil.
	TpeScan(startKey, endKey, prefix []byte, limit uint64, needKey bool, tryCount int, timeout time.Duration) ([][]byte, [][]byte, bool, []byte, error)
	// TpeCheckKeysExist checks the shard has keys.
	// return the index of the key that existed in the shard.
	TpeAsyncCheckKeysExist(shardID uint64, keys [][]byte, timeout time.Duration, cb func(CustomRequest, []byte, error))
	// PrefixScan scan k-vs which k starts with prefix.
	PrefixScan([]byte, uint64) ([][]byte, error)
	// PrefixScanWithGroup scan k-vs which k starts with prefix
	PrefixScanWithGroup([]byte, uint64, pb.Group) ([][]byte, error)
	// TpePrefixScan gets the values of the prefix with limit.
	//a. startKeyOrPrefix : When we invoke TpePrefixScan several times,
	//	the startKeyOrPrefix is the real prefix in the first time.
	//	But from the second time, the startKeyOrPrefix is the next scan key
	//	that generated from results in the previous TpePrefixScan.
	//b. prefixLength : it denotes startKeyOrPrefix[:prefixLength] is the real prefix.
	//c. prefixEnd : the next key of the keys started with the prefix
	//d. needKeyOnly: only return the keys without theirs values
	//e. limit: if it is the math.MaxUint64,
	//	        it means there is not limitation on the count of keys.
	//return parameters:
	//[][]byte : return keys
	//[][]byte : return values
	//bool: true - the scanner accomplished in all shards.
	//[]byte : the start key for the next scan. If last parameter is false, this parameter is nil.
	TpePrefixScan(startKeyOrPrefix []byte, prefixLength int, prefixEnd []byte, needKeyOnly bool, limit uint64, tryCount int, timeout time.Duration) ([][]byte, [][]byte, bool, []byte, error)
	// PrefixScan returns the values whose key starts with prefix.
	PrefixKeys([]byte, uint64) ([][]byte, error)
	// PrefixKeysWithGroup scans prefix with specific group.
	PrefixKeysWithGroup([]byte, uint64, pb.Group) ([][]byte, error)
	// AllocID allocs id.
	AllocID([]byte, uint64) (uint64, error)
	// AsyncAllocID async alloc id.
	AsyncAllocID([]byte, uint64, func(CustomRequest, []byte, error), interface{})
	// Append appends the data in the table
	Append(string, uint64, []byte) error
	//GetSnapshot gets the snapshot from the table.
	//If there's no segment, it returns an empty snapshot.
	GetSnapshot(dbi.GetSnapshotCtx) (*handle.Snapshot, error)
	//GetSegmentIds returns the ids of segments of the table.
	GetSegmentIds(string, uint64) (dbi.IDS, error)
	//GetSegmentedId returns the smallest segmente id among the tables with the shard.
	GetSegmentedId(uint64) (uint64, error)
	//CreateTablet creates a table in the storage.
	CreateTablet(name string, shardId uint64, tbl *aoe.TableInfo) error
	//DropTablet drops the table in the storage.
	DropTablet(string, uint64) (uint64, error)
	//CreateIndex creates an index
	CreateIndex(tableName string, indexInfo *aoe.IndexInfo, toShard uint64) error
	//DropIndex drops an index
	DropIndex(tableName, indexName string, toShard uint64) error
	// TabletIDs returns the ids of all the tables in the storage.
	TabletIDs() ([]uint64, error)
	// TabletNames returns the names of all the tables in the storage.
	TabletNames(uint64) ([]string, error)
	// Exec exec command
	Exec(cmd interface{}) ([]byte, error)
	// AsyncExec async exec command
	AsyncExec(interface{}, func(CustomRequest, []byte, error), interface{})
	// ExecWithGroup exec command with group
	ExecWithGroup(interface{}, pb.Group) ([]byte, error)
	TpeExecWithGroup(interface{}, pb.Group, int, time.Duration) ([]byte, error)
	// AsyncExecWithGroup async exec command with group
	AsyncExecWithGroup(interface{}, pb.Group, func(CustomRequest, []byte, error), interface{})
	TpeAsyncExecWithGroup(interface{}, pb.Group, time.Duration, func(CustomRequest, []byte, error), interface{})
	// RaftStore returns the raft store
	RaftStore() raftstore.Store
	//AOEStore returns h.aoeDB
	AOEStore() *aoedb.DB
	//AddLabelToShard add a label to the shard
	AddLabelToShard(shardID uint64, name, value string) error
	AddSchedulingRule(ruleName string, groupByLabel string) error
}

CubeDriver implements distributed kv and aoe.

func ErrorResp1

func ErrorResp1(err error, infos string) (CubeDriver, []byte)

func NewCubeDriver

func NewCubeDriver(
	kvDataStorage cstorage.DataStorage,
	aoeDataStorage cstorage.DataStorage) (CubeDriver, error)

NewCubeDriver returns a aoe request handler

func NewCubeDriverWithFactory

func NewCubeDriverWithFactory(
	kvDataStorage cstorage.DataStorage,
	aoeDataStorage cstorage.DataStorage,
	c *config.Config,
	raftStoreFactory func(*cConfig.Config) (raftstore.Store, error)) (CubeDriver, error)

NewCubeDriverWithFactory creates the cube driver with raftstore factory

func NewCubeDriverWithOptions

func NewCubeDriverWithOptions(
	kvDataStorage cstorage.DataStorage,
	aoeDataStorage cstorage.DataStorage,
	c *config.Config) (CubeDriver, error)

NewCubeDriverWithOptions returns an aoe request handler

type CustomRequest

type CustomRequest struct {
	// Group used to indicate which group of Shards to send
	Group uint64
	// Key the key used to indicate which shard to send
	Key []byte
	// ToShard if the field is specified, Key are disabled
	ToShard uint64
	// CustomType type of custom request
	CustomType uint64
	// Cmd serialized custom request content
	Cmd []byte
	// Read read request
	Read bool
	// Write write request
	Write bool
}

CustomRequest custom request

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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