Skip to content

Commit d66cc88

Browse files
committed
Refactor
1 parent d2c3d84 commit d66cc88

File tree

15 files changed

+302
-431
lines changed

15 files changed

+302
-431
lines changed

src/indexer/init.go

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ import (
77
"github.com/triole/logseal"
88
)
99

10-
type Indexer struct {
11-
JI JoinerIndex
12-
Conf conf.Conf
13-
Util util.Util
14-
Lg logseal.Logseal
15-
}
16-
1710
var (
18-
ut util.Util
19-
idx Indexer
11+
ut util.Util
2012
)
2113

22-
func Init(conf conf.Conf, util util.Util, lg logseal.Logseal) Indexer {
23-
ut = util
14+
type Indexer struct {
15+
TapIndex TapIndex
16+
DataSources DataSources
17+
Conf conf.Conf
18+
Util util.Util
19+
Lg logseal.Logseal
20+
}
21+
22+
func Init(conf conf.Conf, util util.Util, lg logseal.Logseal) (idx Indexer) {
2423
idx = Indexer{
2524
Conf: conf,
2625
Util: util,

src/indexer/ji.go

Lines changed: 0 additions & 165 deletions
This file was deleted.

src/indexer/ji_test.go

Lines changed: 0 additions & 129 deletions
This file was deleted.

src/indexer/mapval.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,35 @@ import (
44
"strings"
55
)
66

7-
func (ji JoinerIndex) getContentVal(key interface{}, content FileContent) (s []string) {
8-
keypath := ji.splitKey(key)
7+
func (ti TapIndex) getContentVal(key interface{}, content FileContent) (s []string) {
8+
keypath := ti.splitKey(key)
99
if len(keypath) > 0 {
1010
switch keypath[0] {
1111
case "front_matter":
12-
s = ji.getMapVal(keypath[1:], content.FrontMatter)
12+
s = ti.getMapVal(keypath[1:], content.FrontMatter)
1313
case "body":
14-
s = ji.getMapVal(keypath[1:], content.Body)
14+
s = ti.getMapVal(keypath[1:], content.Body)
1515
default:
16-
s = ji.getMapVal(keypath, content.Body)
16+
s = ti.getMapVal(keypath, content.Body)
1717
}
1818
}
1919
return
2020
}
2121

22-
func (ji JoinerIndex) getMapVal(keypath []string, itf interface{}) (s []string) {
22+
func (ti TapIndex) getMapVal(keypath []string, itf interface{}) (s []string) {
2323
switch val := itf.(type) {
2424
case map[string]interface{}:
25-
val = ji.keyToLower(val)
25+
val = ti.keyToLower(val)
2626
if len(keypath) > 0 {
2727
if dictval, ok := val[keypath[0]]; ok {
28-
s = ji.getMapVal(keypath[1:], dictval)
28+
s = ti.getMapVal(keypath[1:], dictval)
2929
}
3030
}
3131
case []interface{}:
3232
for _, x := range val {
3333
switch val2 := x.(type) {
3434
case map[string]interface{}:
35-
t := ji.getMapVal(keypath, val2)
35+
t := ti.getMapVal(keypath, val2)
3636
if len(t) > 0 {
3737
s = t
3838
}
@@ -50,15 +50,15 @@ func (ji JoinerIndex) getMapVal(keypath []string, itf interface{}) (s []string)
5050
return
5151
}
5252

53-
func (ji JoinerIndex) keyToLower(dict map[string]interface{}) (r map[string]interface{}) {
53+
func (ti TapIndex) keyToLower(dict map[string]interface{}) (r map[string]interface{}) {
5454
r = make(map[string]interface{})
5555
for key, val := range dict {
5656
r[strings.ToLower(key)] = val
5757
}
5858
return
5959
}
6060

61-
func (ji JoinerIndex) splitKey(key interface{}) (arr []string) {
61+
func (ti TapIndex) splitKey(key interface{}) (arr []string) {
6262
var tmp []string
6363
switch val := key.(type) {
6464
case string:

0 commit comments

Comments
 (0)