Documentation ¶
Overview ¶
Package riot is riot engine
Package riot full text search engine
Index ¶
- Constants
- Variables
- func CPUInfo(args ...int) (string, error)
- func CPUPercent() ([]float64, error)
- func DiskFree() (uint64, error)
- func DiskPercent() (string, error)
- func DiskTotal() (uint64, error)
- func DiskUsed() (uint64, error)
- func GetVersion() string
- func KernelVer() (string, error)
- func MemFree() (uint64, error)
- func MemPercent() (string, error)
- func MemTotal() (uint64, error)
- func MemUsed() (uint64, error)
- func Platform() (string, error)
- func PlatformInfo() (platform, family, osVersion string, err error)
- func ToGB(data uint64) uint64
- func ToKB(data uint64) uint64
- func ToMB(data uint64) uint64
- func Try(fun func(), handler func(interface{}))
- func Uptime() (uptime uint64, err error)
- type Engine
- func (engine *Engine) CheckMem()
- func (engine *Engine) Close()
- func (engine *Engine) Flush()
- func (engine *Engine) FlushIndex()
- func (engine *Engine) ForSplitData(strData []string, num int) (TMap, int)
- func (engine *Engine) GetAllDocIds() []uint64
- func (engine *Engine) GetDBAllDocs() (docsId []uint64, docsData []types.DocData)
- func (engine *Engine) GetDBAllIds() []uint64
- func (engine *Engine) HasDoc(docId uint64) bool
- func (engine *Engine) HasDocDB(docId uint64) bool
- func (engine *Engine) Index(docId uint64, data types.DocData, forceUpdate ...bool)
- func (engine *Engine) IndexDoc(docId uint64, data types.DocData, forceUpdate ...bool)
- func (engine *Engine) Indexer(options types.EngineOpts)
- func (engine *Engine) Init(options types.EngineOpts)
- func (engine *Engine) InitStore()
- func (engine *Engine) NumDocsIndexed() uint64
- func (engine *Engine) NumDocsRemoved() uint64
- func (engine *Engine) NumTokenIndexAdded() uint64
- func (engine *Engine) PinYin(hans string) []string
- func (engine *Engine) RankId(request types.SearchReq, RankOpts types.RankOpts, tokens []string, ...) (output types.SearchResp)
- func (engine *Engine) Ranker(options types.EngineOpts)
- func (engine *Engine) Ranks(request types.SearchReq, RankOpts types.RankOpts, tokens []string, ...) (output types.SearchResp)
- func (engine *Engine) RemoveDoc(docId uint64, forceUpdate ...bool)
- func (engine *Engine) Search(request types.SearchReq) (output types.SearchResp)
- func (engine *Engine) Segment(content string) (keywords []string)
- func (engine *Engine) Store()
- func (engine *Engine) Tokens(request types.SearchReq) (tokens []string)
- func (engine *Engine) UsedDisk() (uint64, error)
- func (engine *Engine) UsedMem() (uint64, error)
- func (engine *Engine) WithGse(segmenter gse.Segmenter) *Engine
- type StopTokens
- type TMap
Constants ¶
const ( // Version get the riot version Version string = "v0.10.0.425, Danube River!" // NumNanosecondsInAMillisecond nano-seconds in a milli-second num NumNanosecondsInAMillisecond = 1000000 // StoreFilePrefix persistent store file prefix StoreFilePrefix = "riot" // DefaultPath default db path DefaultPath = "./riot-index" )
Variables ¶
var ( // InitMemUsed init mem used InitMemUsed uint64 // InitDiskUsed init disk used InitDiskUsed uint64 )
Functions ¶
func CPUPercent ¶
CPUPercent returns the amount of use cpu in percent.
func DiskPercent ¶
DiskPercent returns the amount of use disk in percent.
func MemPercent ¶
MemPercent returns the amount of use memory in percent.
func PlatformInfo ¶
PlatformInfo fetches system platform information.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine initialize the engine
func (*Engine) CheckMem ¶
func (engine *Engine) CheckMem()
CheckMem check the memory when the memory is larger than 99.99% using the store
func (*Engine) Flush ¶
func (engine *Engine) Flush()
Flush block wait until all indexes are added 阻塞等待直到所有索引添加完毕
func (*Engine) FlushIndex ¶
func (engine *Engine) FlushIndex()
FlushIndex block wait until all indexes are added 阻塞等待直到所有索引添加完毕
func (*Engine) ForSplitData ¶
ForSplitData for split segment's data, segspl
func (*Engine) GetAllDocIds ¶
GetAllDocIds get all the DocId from the storage database and return 从数据库遍历所有的 DocId, 并返回
func (*Engine) GetDBAllDocs ¶
GetDBAllDocs get the db all docs
func (*Engine) GetDBAllIds ¶
GetDBAllIds get all the DocId from the storage database and return 从数据库遍历所有的 DocId, 并返回
func (*Engine) IndexDoc ¶
IndexDoc add the document to the index 将文档加入索引
输入参数:
docId 标识文档编号,必须唯一,docId == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 data 见 DocIndexData 注释 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快添加到索引,否则等待 cache 满之后一次全量添加
注意:
- 这个函数是线程安全的,请尽可能并发调用以提高索引速度
- 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用Search可能无法查询到这个文档。强制刷新索引请调用FlushIndex函数。
func (*Engine) Indexer ¶
func (engine *Engine) Indexer(options types.EngineOpts)
Indexer initialize the indexer channel
func (*Engine) Init ¶
func (engine *Engine) Init(options types.EngineOpts)
Init initialize the engine
func (*Engine) InitStore ¶
func (engine *Engine) InitStore()
InitStore initialize the persistent store channel
func (*Engine) NumDocsIndexed ¶
NumDocsIndexed documents indexed number
func (*Engine) NumDocsRemoved ¶
NumDocsRemoved documents removed number
func (*Engine) NumTokenIndexAdded ¶
NumTokenIndexAdded added token index number
func (*Engine) RankId ¶
func (engine *Engine) RankId(request types.SearchReq, RankOpts types.RankOpts, tokens []string, rankerReturnChan chan rankerReturnReq) ( output types.SearchResp)
RankId rank docs by types.ScoredIDs
func (*Engine) Ranker ¶
func (engine *Engine) Ranker(options types.EngineOpts)
Ranker initialize the ranker channel
func (*Engine) Ranks ¶
func (engine *Engine) Ranks(request types.SearchReq, RankOpts types.RankOpts, tokens []string, rankerReturnChan chan rankerReturnReq) ( output types.SearchResp)
Ranks rank docs by types.ScoredDocs
func (*Engine) RemoveDoc ¶
RemoveDoc remove the document from the index 将文档从索引中删除
输入参数:
docId 标识文档编号,必须唯一,docId == 0 表示非法文档(用于强制刷新索引),[1, +oo) 表示合法文档 forceUpdate 是否强制刷新 cache,如果设为 true,则尽快删除索引,否则等待 cache 满之后一次全量删除
注意:
- 这个函数是线程安全的,请尽可能并发调用以提高索引速度
- 这个函数调用是非同步的,也就是说在函数返回时有可能文档还没有加入索引中,因此 如果立刻调用 Search 可能无法查询到这个文档。强制刷新索引请调用 FlushIndex 函数。
func (*Engine) Search ¶
func (engine *Engine) Search(request types.SearchReq) (output types.SearchResp)
Search find the document that satisfies the search criteria. This function is thread safe 查找满足搜索条件的文档,此函数线程安全
func (*Engine) Store ¶
func (engine *Engine) Store()
Store start the persistent store work connection
type StopTokens ¶
type StopTokens struct {
// contains filtered or unexported fields
}
StopTokens stop tokens map
func (*StopTokens) Init ¶
func (st *StopTokens) Init(stopTokenFile string)
Init 从 stopTokenFile 中读入停用词,一个词一行 文档索引建立时会跳过这些停用词
func (*StopTokens) IsStopToken ¶
func (st *StopTokens) IsStopToken(token string) bool
IsStopToken to determine whether to stop token
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package core is riot core
|
Package core is riot core |
Package engine is riot engine
|
Package engine is riot engine |
examples
|
|
benchmark
riot 性能测试
|
riot 性能测试 |
codelab
一个微博搜索的例子。
|
一个微博搜索的例子。 |
pinyin_weibo
一个微博 pinyin 搜索的例子。
|
一个微博 pinyin 搜索的例子。 |
Package net is riot net
|
Package net is riot net |
Package types is riot types
|
Package types is riot types |