Documentation
¶
Index ¶
- Constants
- func NewBatch() engine.Batch
- type Collection
- func (collection *Collection) Count(key []byte) (uint32, error)
- func (collection *Collection) DelAll(key []byte, batch engine.Batch) error
- func (collection *Collection) DelRowById(key []byte, id []byte, batch engine.Batch) error
- func (collection *Collection) ExistRowById(key []byte, id []byte) (bool, error)
- func (collection *Collection) GetRowById(key []byte, id []byte) (*Row, error)
- func (collection *Collection) GetRowByIdWithBatch(key []byte, id []byte, batch engine.Batch) (*Row, error)
- func (collection *Collection) IndexPage(key []byte, indexName []byte, offset int32, limit uint32) ([]*Row, error)
- func (collection *Collection) IndexValuePage(key []byte, indexName []byte, indexValue []byte, offset int32, limit uint32) ([]*Row, error)
- func (collection *Collection) Page(key []byte, offset int32, limit uint32) ([]*Row, error)
- func (collection *Collection) PageWithBatch(key []byte, offset int32, limit uint32, batch engine.Batch) ([]*Row, error)
- func (collection *Collection) UpsertRow(row *Row, batch engine.Batch) error
- type Index
- type Row
Constants ¶
const ( PEBBLE string = "pebble" BADGER string = "badger" LEVEL string = "level" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection 是对数据结构的抽象,dataType = List/Set/SortedSet 一个 Collection 对应包含 row 每行 row 以 rowKey 作为唯一值,rowKey = {dataType} + {key} + {id} 联合形成唯一值 每行 row 包含 N 个索引 每个索引以 indexKey 作为唯一值,indexKey = {dataType} + {key} + idx_{indexName} + {indexValue} + {id} 以 ListCollection 为例子,该 List 的 key 为 [l1],假设该 Collection 有 4 行 Row,每行 Row 都有 value 和 score 的索引 那么每行 Row 如下: { {key: l1}, {id: 1.1}, {value: aaa}, {score: 1.1}, indexes: [ {name: "value", value: aaa}, {name: "score", value: 1.1} ] } { {key: l1}, {id: 2.2}, {value: bbb}, {score: 2.2}, indexes: [ {name: "value", value: bbb}, {name: "score", value: 2.2} ] } { {key: l1}, {id: 3.3}, {value: ccc}, {score: 3.3}, indexes: [ {name: "value", value: ccc}, {name: "score", value: 3.3} ] } { {key: l1}, {id: 4.4}, {value: aaa}, {score: 4.4}, indexes: [ {name: "value", value: aaa}, {name: "score", value: 4.4} ] } 以 id = 1.1 的 Row 为例子,rowKey = 1/l1/1.1, valueIndexKey = 1/l1/idx_value/aaa/1.1, scoreIndexKey = 1/l1/idx_score/1.1/1.1 写入的数据为:
rowKey: 1/l1/1.1 -> { {key: l1}, {id: 1.1}, {value: aaa}, {score: 1.1}, indexes: [ {name: "value", value: aaa}, {name: "score", value: 1.1} ] }
valueIndexKey: 1/l1/idx_value/aaa/1.1, -> 1/l1/1.1
scoreIndexKey: 1/l1/idx_score/1.1/1.1 -> 1/l1/1.1
func NewCollection ¶
func NewCollection(dataType pb.DataType) *Collection
NewCollection create collection
func (*Collection) Count ¶
func (collection *Collection) Count(key []byte) (uint32, error)
Count dataType + key
func (*Collection) DelAll ¶
func (collection *Collection) DelAll(key []byte, batch engine.Batch) error
DelAll del all by key
func (*Collection) DelRowById ¶
DelRowById delete row by id
func (*Collection) ExistRowById ¶
func (collection *Collection) ExistRowById(key []byte, id []byte) (bool, error)
ExistRowById check row exist
func (*Collection) GetRowById ¶
func (collection *Collection) GetRowById(key []byte, id []byte) (*Row, error)
GetRowById get row by id
func (*Collection) GetRowByIdWithBatch ¶
func (collection *Collection) GetRowByIdWithBatch(key []byte, id []byte, batch engine.Batch) (*Row, error)
GetRowByIdWithBatch get row by id
func (*Collection) IndexPage ¶
func (collection *Collection) IndexPage(key []byte, indexName []byte, offset int32, limit uint32) ([]*Row, error)
IndexPage page by index name
func (*Collection) IndexValuePage ¶
func (collection *Collection) IndexValuePage(key []byte, indexName []byte, indexValue []byte, offset int32, limit uint32) ([]*Row, error)
IndexValuePage page by index value
func (*Collection) PageWithBatch ¶
func (collection *Collection) PageWithBatch(key []byte, offset int32, limit uint32, batch engine.Batch) ([]*Row, error)
PageWithBatch dataType + key