types

package
v2.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 5

Documentation

Overview

Package types implement @Description:

Index

Constants

This section is empty.

Variables

View Source
var SHARD_COUNT = 32

nolint

Functions

func BatchToIndexPairs added in v2.3.4

func BatchToIndexPairs(batch *UpdateBatch) []*tbf.IndexPair

BatchToIndexPairs convert updateBatch kvs to index pairs @Description: @param blkBatch @return []*tbf.IndexPair

func IndexPairsToBatch added in v2.3.4

func IndexPairsToBatch(kvPairs []*tbf.IndexPair, batch protocol.StoreBatcher,
	logger protocol.Logger) protocol.StoreBatcher

IndexPairsToBatch convert index pairs to updateBatch kvs @Description: @param blkBatch @return []*tbf.IndexPair

func NewSyncPoolUpdateBatch added in v2.3.4

func NewSyncPoolUpdateBatch() *sync.Pool

NewSyncPoolUpdateBatch init a sync.Pool to spools then return it @Description: @param batchPool @return *sync.Pool

func NewUpdateBatch

func NewUpdateBatch() protocol.StoreBatcher

NewUpdateBatch constructs an instance of a Batch @Description: @return protocol.StoreBatcher

Types

type BlockGetter added in v2.2.0

type BlockGetter interface {

	// GetTxInfoOnly add next time
	// @Description:
	// @param txId
	// @return *storePb.TransactionStoreInfo
	// @return error
	GetTxInfoOnly(txId string) (*storePb.TransactionStoreInfo, error)
}

BlockGetter add next time @Description:

type ConcurrentMap added in v2.2.0

type ConcurrentMap []*ConcurrentMapShared

ConcurrentMap A "thread" safe map of type string:Anything. To avoid lock bottlenecks this map is dived to several (SHARD_COUNT) map shards.

func New added in v2.2.0

func New() ConcurrentMap

New Creates a new concurrent map. @Description: @return ConcurrentMap

func (ConcurrentMap) Clear added in v2.2.0

func (m ConcurrentMap) Clear()

Clear removes all items from map. @Description: @receiver m

func (ConcurrentMap) Count added in v2.2.0

func (m ConcurrentMap) Count() int

Count returns the number of elements within the map. @Description: @receiver m @return int

func (ConcurrentMap) Get added in v2.2.0

func (m ConcurrentMap) Get(key string) (interface{}, bool)

Get retrieves an element from map under given key. @Description: @receiver m @param key @return interface{} @return bool

func (ConcurrentMap) GetShard added in v2.2.0

func (m ConcurrentMap) GetShard(key string) *ConcurrentMapShared

GetShard returns shard under given key @Description: @receiver m @param key @return *ConcurrentMapShared

func (ConcurrentMap) Has added in v2.2.0

func (m ConcurrentMap) Has(key string) bool

Has Looks up an item under specified key @Description: @receiver m @param key @return bool

func (ConcurrentMap) IsEmpty added in v2.2.0

func (m ConcurrentMap) IsEmpty() bool

IsEmpty checks if map is empty. @Description: @receiver m @return bool

func (ConcurrentMap) Items added in v2.2.0

func (m ConcurrentMap) Items() map[string]interface{}

Items returns all items as map[string]interface{} @Description: @receiver m @return map[string]interface{}

func (ConcurrentMap) Iter added in v2.2.0

func (m ConcurrentMap) Iter() <-chan Tuple

Iter returns an iterator which could be used in a for range loop. @Description: Deprecated: using IterBuffered() will get a better performance @receiver m @return <-chan

func (ConcurrentMap) IterBuffered added in v2.2.0

func (m ConcurrentMap) IterBuffered() <-chan Tuple

IterBuffered returns a buffered iterator which could be used in a for range loop. @Description: @receiver m @return <-chan

func (ConcurrentMap) IterCb added in v2.2.0

func (m ConcurrentMap) IterCb(fn IterCb)

IterCb Callback based iterator, cheapest way to read @Description: all elements in a map. @receiver m @param fn

func (ConcurrentMap) Keys added in v2.2.0

func (m ConcurrentMap) Keys() []string

Keys returns all keys as []string @Description: @receiver m @return []string

func (ConcurrentMap) MSet added in v2.2.0

func (m ConcurrentMap) MSet(data map[string]interface{})

MSet add next time @Description: @receiver m @param data

func (ConcurrentMap) MarshalJSON added in v2.2.0

func (m ConcurrentMap) MarshalJSON() ([]byte, error)

MarshalJSON Reviles ConcurrentMap "private" variables to json marshal. @Description: @receiver m @return []byte @return error

func (ConcurrentMap) Pop added in v2.2.0

func (m ConcurrentMap) Pop(key string) (v interface{}, exists bool)

Pop removes an element from the map and returns it @Description: @receiver m @param key @return v @return exists

func (ConcurrentMap) Remove added in v2.2.0

func (m ConcurrentMap) Remove(key string)

Remove removes an element from the map. @Description: @receiver m @param key

func (ConcurrentMap) RemoveCb added in v2.2.0

func (m ConcurrentMap) RemoveCb(key string, cb RemoveCb) bool

RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map) @Description: @receiver m @param key @param cb @return bool

func (ConcurrentMap) Set added in v2.2.0

func (m ConcurrentMap) Set(key string, value interface{})

Set Sets the given value under the specified key. @Description: @receiver m @param key @param value

func (ConcurrentMap) SetIfAbsent added in v2.2.0

func (m ConcurrentMap) SetIfAbsent(key string, value interface{}) bool

SetIfAbsent Sets the given value under the specified key if no value was associated with it. @Description: @receiver m @param key @param value @return bool

func (ConcurrentMap) Upsert added in v2.2.0

func (m ConcurrentMap) Upsert(key string, value interface{}, cb UpsertCb) (res interface{})

Upsert Insert or Update - updates existing element or inserts a new one using UpsertCb @Description: @receiver m @param key @param value @param cb @return res

type ConcurrentMapShared added in v2.2.0

type ConcurrentMapShared struct {
	sync.RWMutex // Read Write mutex, guards access to internal map.
	// contains filtered or unexported fields
}

ConcurrentMapShared A "thread" safe string to anything map. @Description:

type ConnectionPoolDBHandle added in v2.2.0

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

ConnectionPoolDBHandle encapsulate lru cache,and logger @Description:

func NewConnectionPoolDBHandle added in v2.2.0

func NewConnectionPoolDBHandle(size int, log protocol.Logger) *ConnectionPoolDBHandle

NewConnectionPoolDBHandle construct ConnectionPoolDBHandle @Description: @param size @param log @return *ConnectionPoolDBHandle

func (*ConnectionPoolDBHandle) Clear added in v2.2.0

func (c *ConnectionPoolDBHandle) Clear()

Clear clear the cache @Description: @receiver c

func (*ConnectionPoolDBHandle) GetDBHandle added in v2.2.0

func (c *ConnectionPoolDBHandle) GetDBHandle(contractName string) (protocol.SqlDBHandle, bool)

GetDBHandle retrieve db handler from cache @Description: @receiver c @param contractName @return protocol.SqlDBHandle @return bool

func (*ConnectionPoolDBHandle) SetDBHandle added in v2.2.0

func (c *ConnectionPoolDBHandle) SetDBHandle(contractName string, handle protocol.SqlDBHandle)

SetDBHandle add db handler to cache @Description: @receiver c @param contractName @param handle

type EngineType

type EngineType int32

EngineType database type

const (
	UnknownDb EngineType = 0
	LevelDb   EngineType = 1
	TikvDb    EngineType = 2
	MySQL     EngineType = 3
	Sqlite    EngineType = 4
	BadgerDb  EngineType = 5
)

nolint

func (EngineType) LowerString

func (t EngineType) LowerString() string

LowerString lower sql type @Description: @receiver t @return string

func (EngineType) String

func (t EngineType) String() string

String return db type @Description: @receiver t @return string

type HistoryIteratorImpl

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

HistoryIteratorImpl add next time @Description:

func NewHistoryIterator

func NewHistoryIterator(contractName string, key []byte, dbItr historydb.HistoryIterator,
	resultStore resultdb.ResultDB, blockStore BlockGetter) *HistoryIteratorImpl

NewHistoryIterator add next time @Description: @param contractName @param key @param dbItr @param resultStore @param blockStore @return *HistoryIteratorImpl

func (*HistoryIteratorImpl) Next

func (hs *HistoryIteratorImpl) Next() bool

Next add next time @Description: @receiver hs @return bool

func (*HistoryIteratorImpl) Release

func (hs *HistoryIteratorImpl) Release()

Release add next time @Description: @receiver hs

func (*HistoryIteratorImpl) Value

Value add next time @Description: @receiver hs @return *storePb.KeyModification @return error

type IterCb added in v2.2.0

type IterCb func(key string, v interface{})

IterCb Iterator callback,called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sess consistent view of a shard, but not across the shards

type RemoveCb added in v2.2.0

type RemoveCb func(key string, v interface{}, exists bool) bool

RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map

type SavePoint

type SavePoint struct {
	BlockHeight uint64 `gorm:"primarykey"`
}

SavePoint add next time @Description:

func (*SavePoint) GetCountSql

func (b *SavePoint) GetCountSql() (string, []interface{})

GetCountSql 获得 得到数据总行数 sql 语句 @Description: @receiver b @return string @return []interface{}

func (*SavePoint) GetCreateTableSql

func (b *SavePoint) GetCreateTableSql(dbType string) string

GetCreateTableSql 获得创建table的ddl语句 @Description: @receiver b @param dbType @return string

func (*SavePoint) GetInsertSql

func (b *SavePoint) GetInsertSql(dbType string) (string, []interface{})

GetInsertSql 获得 insert sql 语句 @Description: @receiver b @param dbType @return string @return []interface{}

func (*SavePoint) GetSaveSql added in v2.3.0

func (b *SavePoint) GetSaveSql(_ string) (string, []interface{})

GetSaveSql 获得Replace into SQL @param _ @return string @return []interface{}

func (*SavePoint) GetTableName

func (b *SavePoint) GetTableName() string

GetTableName 获得table name @Description: @receiver b @return string

func (*SavePoint) GetUpdateSql

func (b *SavePoint) GetUpdateSql() (string, []interface{})

GetUpdateSql 获得 update sql 语句 @Description: @receiver b @return string @return []interface{}

type SqlVerifyPass

type SqlVerifyPass struct {
}

SqlVerifyPass 用于测试场景,不对SQL语句进行检查,任意SQL检查都通过 @Description:

func (*SqlVerifyPass) VerifyDDLSql

func (s *SqlVerifyPass) VerifyDDLSql(sql string) error

VerifyDDLSql 校验ddl语句 @Description: @receiver s @param sql @return error

func (*SqlVerifyPass) VerifyDMLSql

func (s *SqlVerifyPass) VerifyDMLSql(sql string) error

VerifyDMLSql 校验dml语句 @Description: @receiver s @param sql @return error

func (*SqlVerifyPass) VerifyDQLSql

func (s *SqlVerifyPass) VerifyDQLSql(sql string) error

VerifyDQLSql 校验dql语句 @Description: @receiver s @param sql @return error

type StandardSqlVerify

type StandardSqlVerify struct {
}

StandardSqlVerify StandardSqlVerify 如果状态数据库是标准SQL语句,对标准SQL的SQL语句进行语法检查,不关心具体的SQL DB类型的语法差异 @Description:

func (*StandardSqlVerify) VerifyDDLSql

func (s *StandardSqlVerify) VerifyDDLSql(sql string) error

VerifyDDLSql 校验ddl 语句是否合法 @Description: @receiver s @param sql @return error

func (*StandardSqlVerify) VerifyDMLSql

func (s *StandardSqlVerify) VerifyDMLSql(sql string) error

VerifyDMLSql 校验 dml语句是否合法 @Description: @receiver s @param sql @return error

func (*StandardSqlVerify) VerifyDQLSql

func (s *StandardSqlVerify) VerifyDQLSql(sql string) error

VerifyDQLSql 校验 dql语句是否合法 @Description: @receiver s @param sql @return error

type Tuple added in v2.2.0

type Tuple struct {
	Key string
	Val interface{}
}

Tuple Used by the Iter & IterBuffered functions to wrap two variables together over a channel, @Description:

type TxHistoryIteratorImpl

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

TxHistoryIteratorImpl add next time @Description:

func NewTxHistoryIterator

func NewTxHistoryIterator(dbItr historydb.HistoryIterator, blockStore BlockGetter) *TxHistoryIteratorImpl

NewTxHistoryIterator add next time @Description: @param dbItr @param blockStore @return *TxHistoryIteratorImpl

func (*TxHistoryIteratorImpl) Next

func (hs *TxHistoryIteratorImpl) Next() bool

Next add next time @Description: @receiver hs @return bool

func (*TxHistoryIteratorImpl) Release

func (hs *TxHistoryIteratorImpl) Release()

Release add next time @Description: @receiver hs

func (*TxHistoryIteratorImpl) Value

func (hs *TxHistoryIteratorImpl) Value() (*storePb.TxHistory, error)

Value add next time @Description: @receiver hs @return *storePb.TxHistory @return error

type UpdateBatch

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

UpdateBatch encloses the details of multiple `updates` @Description:

func (*UpdateBatch) Delete

func (batch *UpdateBatch) Delete(key []byte)

Delete deletes a Key and associated value,set value to nil @Description: @receiver batch @param key

func (*UpdateBatch) Get added in v2.1.1

func (batch *UpdateBatch) Get(key []byte) ([]byte, error)

Get 根据key,返回value @Description: @receiver batch @param key @return []byte @return error

func (*UpdateBatch) Has added in v2.1.1

func (batch *UpdateBatch) Has(key []byte) bool

Has 判断key是否存在 @Description: @receiver batch @param key @return bool

func (*UpdateBatch) KVs

func (batch *UpdateBatch) KVs() map[string][]byte

KVs return map, only read @Description: @receiver batch @return map[string][]byte

func (*UpdateBatch) Keys added in v2.2.0

func (batch *UpdateBatch) Keys() []string

Keys keys in map @Description: @receiver batch @return []string

func (*UpdateBatch) Len

func (batch *UpdateBatch) Len() int

Len returns the number of entries in the batch @Description: @receiver batch @return int

func (*UpdateBatch) Merge

func (batch *UpdateBatch) Merge(u protocol.StoreBatcher)

Merge merges other kvs to this updateBatch @Description: @receiver batch @param u

func (*UpdateBatch) Put

func (batch *UpdateBatch) Put(key []byte, value []byte)

Put adds a KV @Description: @receiver batch @param key @param value

func (*UpdateBatch) ReSet added in v2.2.0

func (batch *UpdateBatch) ReSet()

ReSet return map, only read @Description: @receiver batch

func (*UpdateBatch) Remove added in v2.3.3

func (batch *UpdateBatch) Remove(key []byte)

Remove removes a Key and associated value @Description: @receiver batch @param key

func (*UpdateBatch) SplitBatch

func (batch *UpdateBatch) SplitBatch(batchCnt uint64) []protocol.StoreBatcher

SplitBatch split other kvs to more updateBatchs division by batchCnt @Description: batchCnt: 拆分后,每个子batch,最多包含多少个k/v @receiver batch @param batchCnt @return []protocol.StoreBatcher

type UpsertCb added in v2.2.0

type UpsertCb func(exist bool, valueInMap interface{}, newValue interface{}) interface{}

UpsertCb Callback to return new element to be inserted into the map It is called while lock is held, therefore it MUST NOT try to access other keys in same map, as it can lead to deadlock since Go sync.RWLock is not reentrant

Directories

Path Synopsis
Package blockfile package
Package blockfile package

Jump to

Keyboard shortcuts

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