Documentation ¶
Index ¶
- Constants
- type AddIndex
- type CompareAble
- type Ele
- type F64CompareAble
- type Indexer
- type IndexerHash
- type M
- type Node
- type OneIndexer
- type Operation
- type PointersIndex
- type QueryBuilder
- type QueryBuilders
- type Queue
- type RdbNode
- type SelectIndex
- type SkipList
- type SortedSet
- func (z *SortedSet) ZAdd(key string, score CompareAble, member string)
- func (z *SortedSet) ZCard(key string) int
- func (z *SortedSet) ZClear(key string)
- func (z *SortedSet) ZGetByRank(key string, rank int) (val []interface{})
- func (z *SortedSet) ZKeyExists(key string) bool
- func (z *SortedSet) ZRange(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRangeWithScores(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRank(key, member string) int64
- func (z *SortedSet) ZRem(key, member string) bool
- func (z *SortedSet) ZRevGetByRank(key string, rank int) (val []interface{})
- func (z *SortedSet) ZRevRange(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRevRangeWithScores(key string, start, stop int) []interface{}
- func (z *SortedSet) ZRevRank(key, member string) int64
- func (z *SortedSet) ZRevScoreRange(key string, max, min CompareAble) (val []interface{})
- func (z *SortedSet) ZScore(key string, member string) (ok bool, score CompareAble)
- func (z *SortedSet) ZScoreRange(key string, min, max CompareAble) (val []interface{})
- type SortedSetNode
- type StrCompareAble
Constants ¶
const ( IndexTypeHash = iota IndexTypeRedBlackTree )
const ( P = 0.25 MaxLevel = 32 )
const ( OperationAnd = iota OperationOr )
const ( Red = true Black = false )
const ( EQ = iota LIKE )
const ( INT = iota FLOAT STRING TIME )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompareAble ¶
type CompareAble interface {
CompareTo(CompareAble) (int, error)
}
type Ele ¶
type Ele struct { Score CompareAble Value interface{} // 根? RootEl bool // 到下一个的节点数量 Span int // 记录属于哪一个节点的 Node *Node NextEle *Ele PreEle *Ele }
Ele 设计为双向链表
type F64CompareAble ¶
type F64CompareAble struct {
// contains filtered or unexported fields
}
func NewF64CompareAble ¶
func NewF64CompareAble(f64 float64) F64CompareAble
func (F64CompareAble) CompareTo ¶
func (f F64CompareAble) CompareTo(f64 CompareAble) (int, error)
type Indexer ¶
type Indexer struct { // 字段的名称 ColumnValue interface{} // 字段所对应的 结构体的指针 Pointers []*PointersIndex }
Indexer 实现了从sort set value中提取字段作为索引
type IndexerHash ¶
type IndexerHash struct {
IdxHash map[string]*OneIndexer
}
func NewIndexerHash ¶
func NewIndexerHash() *IndexerHash
type M ¶
type M struct { Score CompareAble Member interface{} AddIndexes []*AddIndex }
type OneIndexer ¶
type OneIndexer struct { IndexType int FullIndexer []*Indexer // contains filtered or unexported fields }
OneIndexer 一条索引的全部记录
func NewOneIndexer ¶
func NewOneIndexer() *OneIndexer
func (*OneIndexer) GetMemberLikeByStr ¶
func (o *OneIndexer) GetMemberLikeByStr(likeStr string) canCompareRanElements
GetMemberLikeByStr 模糊搜索
func (*OneIndexer) StoreColumnValueExit ¶
func (o *OneIndexer) StoreColumnValueExit(check interface{}) int
func (*OneIndexer) ZipperAdd ¶
func (o *OneIndexer) ZipperAdd(columnValues, pointer interface{}, rank int64)
type PointersIndex ¶
type PointersIndex struct { Pointer interface{} Rank int64 // 再sortSet中的排序 }
PointersIndex 索引的Pointers的再sortSet中的排名
type QueryBuilder ¶
type QueryBuilder struct { filter.Filter Level int // 层级 InnerBuilders []*QueryBuilder FatherBuilder *QueryBuilder // 上级节点 }
QueryBuilder 构建一颗查询的多叉树
type QueryBuilders ¶
type QueryBuilders struct { QueryBuilders []*QueryBuilder MaxLevel int // 当前树有几层 }
func (*QueryBuilders) LevelBfs ¶
func (q *QueryBuilders) LevelBfs() [][]*QueryBuilder
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue represents a single instance of the queue data structure.
func (*Queue) Add ¶
func (q *Queue) Add(elem *QueryBuilder)
Add puts an element on the end of the queue.
func (*Queue) Get ¶
func (q *Queue) Get(i int) *QueryBuilder
Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.
func (*Queue) Peek ¶
func (q *Queue) Peek() *QueryBuilder
Peek returns the element at the head of the queue. This call panics if the queue is empty.
func (*Queue) Remove ¶
func (q *Queue) Remove() *QueryBuilder
Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.
type RdbNode ¶
func NewRdbNode ¶
type SelectIndex ¶
type SelectIndex struct { ColumnName string // 列名称 Operation int // 操作 EQ LIKE ... SearchVal interface{} // 查找的列的值 ColumnType int // 列的值的类型 支持 INT FLOAT STRING TIME }
SelectIndex 搜索索引条件
func NewSelectIndex ¶
func NewSelectIndex() *SelectIndex
type SkipList ¶
type SkipList struct { Nodes []*Node // contains filtered or unexported fields }
func (SkipList) Get ¶
func (s SkipList) Get(score CompareAble) interface{}
func (*SkipList) Insert ¶
func (s *SkipList) Insert(score CompareAble, value interface{}) *Ele
type SortedSet ¶
type SortedSet struct {
// contains filtered or unexported fields
}
SortedSet sorted set struct
func (*SortedSet) ZAdd ¶
func (z *SortedSet) ZAdd(key string, score CompareAble, member string)
ZAdd Adds the specified member with the specified score to the sorted set stored at key.
func (*SortedSet) ZCard ¶
ZCard returns the sorted set cardinality (number of elements) of the sorted set stored at key.
func (*SortedSet) ZGetByRank ¶
ZGetByRank 根据排名获取member及分值信息,从小到大排列遍历,即分值最低排名为0,依次类推 Get the member at key by rank, the rank is ordered from lowest to highest. The rank of lowest is 0 and so on.
func (*SortedSet) ZKeyExists ¶
ZKeyExists check if the key exists in zset.
func (*SortedSet) ZRange ¶
ZRange returns the specified range of elements in the sorted set stored at <key>.
func (*SortedSet) ZRangeWithScores ¶
ZRangeWithScores returns the specified range of elements in the sorted set stored at <key>.
func (*SortedSet) ZRank ¶
ZRank returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0.
func (*SortedSet) ZRem ¶
ZRem removes the specified members from the sorted set stored at key. Non existing members are ignored. An error is returned when key exists and does not hold a sorted set.
func (*SortedSet) ZRevGetByRank ¶
ZRevGetByRank get the member at key by rank, the rank is ordered from highest to lowest. The rank of highest is 0 and so on.
func (*SortedSet) ZRevRange ¶
ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
func (*SortedSet) ZRevRangeWithScores ¶
ZRevRange returns the specified range of elements in the sorted set stored at key. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score.
func (*SortedSet) ZRevRank ¶
ZRevRank returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.
func (*SortedSet) ZRevScoreRange ¶
func (z *SortedSet) ZRevScoreRange(key string, max, min CompareAble) (val []interface{})
ZRevScoreRange returns all the elements in the sorted set at key with a score between max and min (including elements with score equal to max or min). In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered from high to low scores.
func (*SortedSet) ZScore ¶
func (z *SortedSet) ZScore(key string, member string) (ok bool, score CompareAble)
ZScore returns the score of member in the sorted set at key.
func (*SortedSet) ZScoreRange ¶
func (z *SortedSet) ZScoreRange(key string, min, max CompareAble) (val []interface{})
ZScoreRange returns all the elements in the sorted set at key with a score between min and max (including elements with score equal to min or max). The elements are considered to be ordered from low to high scores.
type SortedSetNode ¶
type SortedSetNode struct { Lock sync.Mutex Indexers *IndexerHash // contains filtered or unexported fields }
SortedSetNode node of sorted set
func NewSortSet ¶
func NewSortSet() *SortedSetNode
func (*SortedSetNode) Add ¶
func (s *SortedSetNode) Add(score CompareAble, value interface{}, indexers []*AddIndex)
Add score 分值,value 保存的对象, indexers map 的key 保存的列名称,也就是value对象里面的某个字段的名称 map 的 value 保存的value对象里面 key 对应的值。 这里让用户手动添加indexers 而不是利用反射是为了提高性能。减少反射所耗费的性能。 TODO: 提供一个自动检查的方法。利用Tag标记。
func (*SortedSetNode) GetByIndex ¶
func (s *SortedSetNode) GetByIndex(selectIndexers []*SelectIndex, start, stop int64) []interface{}
GetByIndex 传入搜索条件,查询指定key的结果。返回顺序按照此key的 score 排列
type StrCompareAble ¶
type StrCompareAble struct {
// contains filtered or unexported fields
}
func NewStrCompareAble ¶
func NewStrCompareAble(str string) StrCompareAble
func (StrCompareAble) CompareTo ¶
func (s StrCompareAble) CompareTo(str CompareAble) (int, error)