index

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2018 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

package core 这是一个B+树的缓存,底层实现用到了mmap。 如果是使用vagrant或者是虚拟机,数据库文件不能存放到共享目录里面。 https://stackoverflow.com/questions/18420473/invalid-argument-for-read-write-mmap

Package index

Index

Constants

View Source
const (
	ASC  = true
	DESC = false
)

Variables

This section is empty.

Functions

func If added in v1.0.3

func If(expr bool, f1, f2 func() bool) bool

If ... https://my.oschina.net/chai2010/blog/202870

Types

type BTree

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

func NewBTree

func NewBTree(dbpath string) (*BTree, error)

func (*BTree) AddBTree

func (t *BTree) AddBTree(btname []byte) error

func (*BTree) Close

func (t *BTree) Close() error

func (*BTree) Debug

func (t *BTree) Debug(btname []byte)

func (*BTree) Delete

func (t *BTree) Delete(btname, key []byte) error

func (*BTree) DeleteBTree

func (t *BTree) DeleteBTree(btname []byte) error

func (*BTree) GetDB

func (t *BTree) GetDB() *bolt.DB

func (*BTree) Keys

func (t *BTree) Keys(btname []byte, len int) [][]byte

func (*BTree) Len

func (t *BTree) Len(btname []byte) int

func (*BTree) Prefix

func (t *BTree) Prefix(btname []byte, prefix []byte) ([][]byte, [][]byte, bool, error)

func (*BTree) Search

func (t *BTree) Search(btname []byte, key []byte) ([]byte, bool, error)

func (*BTree) Set

func (t *BTree) Set(btname, key []byte, value []byte) error

type Bitmap

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

func NewBitmap

func NewBitmap(btname []byte, btree *BTree) (*Bitmap, error)

func (*Bitmap) Backup

func (b *Bitmap) Backup() error

func (*Bitmap) ClearAll

func (b *Bitmap) ClearAll() error

func (*Bitmap) Close

func (b *Bitmap) Close() error

func (*Bitmap) Len

func (b *Bitmap) Len() uint32

Count() 才是所占位的长度,Len() 是位的总数

func (*Bitmap) NextClear

func (b *Bitmap) NextClear(i uint32) (uint32, bool)

func (*Bitmap) NextSet

func (b *Bitmap) NextSet(i uint32) (uint32, bool)

func (*Bitmap) Set

func (b *Bitmap) Set(i uint32) error

func (*Bitmap) SetTo

func (b *Bitmap) SetTo(i uint32, value bool) error

func (*Bitmap) Test

func (b *Bitmap) Test(i uint32) bool

func (*Bitmap) Uints

func (b *Bitmap) Uints(status bool) []uint32

type Document

type Document struct {
	DocId    uint32   `json:"-"`
	PK       string   `json:"pk"`
	Title    string   `json:"title"`
	PubDate  int64    `json:"pub_date"`
	Brief    string   `json:"brief"`
	FullText string   `json:"full_text"`
	Tags     []string `json:"tags"`
	Category string   `json:"category"`
	Link     string   `json:"link"`
	Figure   string   `json:"figure"`
	PV       int      `json:"pv"`
}

Document ...

type Index

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

func NewIndex

func NewIndex(path string) (*Index, error)

func (*Index) AddDocument

func (index *Index) AddDocument(doc *Document) error

func (*Index) Buckets

func (index *Index) Buckets() (map[string]int, error)

func (*Index) CheckParam

func (index *Index) CheckParam(param *Param)

CheckParam check if param is error. Offset default value is 0. Size default value is 10.

func (*Index) ClearAll

func (index *Index) ClearAll() error

func (*Index) Close

func (index *Index) Close() error

func (*Index) Commit

func (index *Index) Commit() error

func (*Index) GetDB

func (index *Index) GetDB() *bolt.DB

func (*Index) PageSizeDocIds

func (index *Index) PageSizeDocIds(docIds []uint32, offset, size int) []uint32

PageSizeDocIds ...

func (*Index) Search

func (index *Index) Search(pars *Param) (int, []*Document, error)

Search ...

func (*Index) SearchAll added in v1.0.2

func (index *Index) SearchAll(pars *Param) (int, []*Document, error)

SearchAll search status index for all result.

func (*Index) SearchAllDocIds added in v1.0.2

func (index *Index) SearchAllDocIds(status bool) ([]uint32, error)

SearchDocIds ...

func (*Index) SearchCategory

func (index *Index) SearchCategory(category ...string) ([]uint32, error)

SearchCategory ...

func (*Index) SearchDocIds

func (index *Index) SearchDocIds(param *Param) (int, []uint32, error)

SearchDocIds ...

func (*Index) SearchKeyWords

func (index *Index) SearchKeyWords(queries []string) ([]uint32, error)

SearchKeyWords search by keywords. If query is english, it should be lower case.

func (*Index) SearchPks

func (index *Index) SearchPks(pks ...string) ([]uint32, error)

SearchPks ...

func (*Index) SearchTag

func (index *Index) SearchTag(tags ...string) ([]uint32, error)

SearchTag ...

func (*Index) SortDocIds

func (index *Index) SortDocIds(param *Param, docIds []uint32) []uint32

SortDocIds ...

func (*Index) ToDocuments

func (index *Index) ToDocuments(docIds ...uint32) []*Document

ToDocuments ...

type InvertIndex

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

func NewInvertIndex

func NewInvertIndex(btname []byte, btree *BTree) (*InvertIndex, error)

func (*InvertIndex) AppendBytesUints

func (t *InvertIndex) AppendBytesUints(key []byte, value ...uint32) error

func (*InvertIndex) AppendUint64Uints

func (t *InvertIndex) AppendUint64Uints(key uint64, value ...uint32) error

func (*InvertIndex) AppendUintUints

func (t *InvertIndex) AppendUintUints(key uint32, value ...uint32) error

func (*InvertIndex) ClearAll

func (t *InvertIndex) ClearAll() error

func (*InvertIndex) Debug

func (t *InvertIndex) Debug()

func (*InvertIndex) DeleteByKey

func (t *InvertIndex) DeleteByKey(key []byte) error

func (*InvertIndex) DeleteBytesUints

func (t *InvertIndex) DeleteBytesUints(key []byte, value ...uint32) error

func (*InvertIndex) DeleteUIntBytes

func (t *InvertIndex) DeleteUIntBytes(key uint32) error

func (*InvertIndex) DeleteUint

func (t *InvertIndex) DeleteUint(key uint32) error

func (*InvertIndex) DeleteUint64Uints

func (t *InvertIndex) DeleteUint64Uints(key uint64, value ...uint32) error

func (*InvertIndex) DeleteUintUints

func (t *InvertIndex) DeleteUintUints(key uint32, value ...uint32) error

func (*InvertIndex) Keys

func (t *InvertIndex) Keys(len int) [][]byte

func (*InvertIndex) Len

func (t *InvertIndex) Len() int

func (*InvertIndex) PrefixKeys

func (t *InvertIndex) PrefixKeys(pre uint32) ([][]byte, bool, error)

func (*InvertIndex) SearchBytesUints

func (t *InvertIndex) SearchBytesUints(key []byte) ([]uint32, bool, error)

func (*InvertIndex) SearchUIntBytes

func (t *InvertIndex) SearchUIntBytes(key uint32) ([]byte, bool, error)

func (*InvertIndex) SearchUint64Uints

func (t *InvertIndex) SearchUint64Uints(key uint64) ([]uint32, bool, error)

func (*InvertIndex) SearchUintUint

func (t *InvertIndex) SearchUintUint(key uint32) (uint32, bool, error)

func (*InvertIndex) SearchUintUints

func (t *InvertIndex) SearchUintUints(key uint32) ([]uint32, bool, error)

func (*InvertIndex) SearchUintsInt16

func (t *InvertIndex) SearchUintsInt16(key []uint32) (int16, bool, error)

func (*InvertIndex) SetUInt64Uints

func (t *InvertIndex) SetUInt64Uints(key uint64, value ...uint32) error

func (*InvertIndex) SetUIntBytes

func (t *InvertIndex) SetUIntBytes(key uint32, value []byte) error

func (*InvertIndex) SetUIntUint

func (t *InvertIndex) SetUIntUint(key uint32, value uint32) error

func (*InvertIndex) SetUIntUints

func (t *InvertIndex) SetUIntUints(key uint32, value []uint32) error

func (*InvertIndex) SetUIntsInt16

func (t *InvertIndex) SetUIntsInt16(key []uint32, value int16) error

type Param

type Param struct {
	PKs      []string
	Query    string
	Tags     []string
	Category string

	Offset int
	Size   int
	Sort   Sorter
}

Param is search param.

type Sorter added in v1.0.3

type Sorter struct {
	Field string
	Asc   bool
}

Jump to

Keyboard shortcuts

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