feat(fileindex): add file index top dependencies
This commit is contained in:
parent
0962ddb57c
commit
24f1516fd5
4 changed files with 39 additions and 0 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/ihexxa/quickshare/src/idgen"
|
||||
"github.com/ihexxa/quickshare/src/iolimiter"
|
||||
"github.com/ihexxa/quickshare/src/kvstore"
|
||||
"github.com/ihexxa/quickshare/src/search/fileindex"
|
||||
"github.com/ihexxa/quickshare/src/worker"
|
||||
)
|
||||
|
||||
|
@ -38,6 +39,7 @@ type Deps struct {
|
|||
workers worker.IWorkerPool
|
||||
boltStore *boltstore.BoltStore
|
||||
cron cron.ICron
|
||||
fileIndex fileindex.IFileIndex
|
||||
}
|
||||
|
||||
func NewDeps(cfg gocfg.ICfg) *Deps {
|
||||
|
@ -139,3 +141,11 @@ func (deps *Deps) Cron() cron.ICron {
|
|||
func (deps *Deps) SetCron(cronImp cron.ICron) {
|
||||
deps.cron = cronImp
|
||||
}
|
||||
|
||||
func (deps *Deps) FileIndex() fileindex.IFileIndex {
|
||||
return deps.fileIndex
|
||||
}
|
||||
|
||||
func (deps *Deps) SetFileIndex(fileIndex fileindex.IFileIndex) {
|
||||
deps.fileIndex = fileIndex
|
||||
}
|
||||
|
|
26
src/search/fileindex/trie_tree.go
Normal file
26
src/search/fileindex/trie_tree.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package fileindex
|
||||
|
||||
import (
|
||||
qradix "github.com/ihexxa/q-radix/v3"
|
||||
)
|
||||
|
||||
type FileTreeIndex struct {
|
||||
*qradix.RTree
|
||||
}
|
||||
|
||||
func NewFileTreeIndex() *FileTreeIndex {
|
||||
return &FileTreeIndex{
|
||||
RTree: qradix.NewRTree(),
|
||||
}
|
||||
}
|
||||
|
||||
type IFileIndex interface {
|
||||
FromString(input chan string) error
|
||||
Get(key string) (interface{}, error)
|
||||
GetAllPrefixMatches(key string) map[string]interface{}
|
||||
GetBestMatch(key string) (string, interface{}, bool)
|
||||
Insert(key string, val interface{}) (interface{}, error)
|
||||
Remove(key string) bool
|
||||
Size() int
|
||||
String() chan string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue