diff --git a/core/wiki/wiki.go b/core/wiki/wiki.go index 16d8def6..6ff1b188 100644 --- a/core/wiki/wiki.go +++ b/core/wiki/wiki.go @@ -21,7 +21,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心", "path", "", "head", "time size line path", "alias", map[string]interface{}{ - "block": []interface{}{"chart", "block"}, + "label": []interface{}{"chart", "block"}, "chain": []interface{}{"chart", "chain"}, "chapter": []interface{}{"title", "chapter"}, @@ -117,6 +117,9 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心", m.Render(m.Conf("spark", ice.Meta("template")), m.Option("name")) m.Render(m.Conf("shell", ice.Meta("template"))) }}, + "index": {Name: "index hash", Help: "索引", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { + m.Cmd(ice.WEB_STORY, "index", arg) + }}, "spark": {Name: "spark name text", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { m.Option("type", "refer") @@ -240,9 +243,6 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心", } m.Cmdy(kit.Select("_tree", "_text", len(arg) > 0 && strings.HasSuffix(arg[0], ".md")), arg) }}, - "index": {Name: "index hash", Help: "索引", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) { - m.Cmd(ice.WEB_STORY, "index", arg) - }}, }, } diff --git a/miss/miss.md b/miss/miss.md index 48b08c1d..3fc9dee0 100644 --- a/miss/miss.md +++ b/miss/miss.md @@ -1,10 +1,29 @@ # miss +{{label "图谱" ` +模块化 集群化 自动化 +配置化 服务化 场景化 +命令化 组件化 个性化 +`}} + {{table "图谱" ` code wiki chat team mall linux nginx golang redis mysql zsh tmux docker git vim `}} + +{{table "图谱" ` +ctx cli aaa web +lex yac log gdb +tcp nfs ssh mdb +`}} + +{{table "图谱" ` +spide serve space dream +favor cache story share +route proxy group label +`}} + {{stack "hi" ` hi hello diff --git a/miss/src/main.go b/miss/src/main.go index 37ce09d3..afcf936f 100644 --- a/miss/src/main.go +++ b/miss/src/main.go @@ -6,6 +6,7 @@ import ( _ "github.com/shylinux/icebergs/core" _ "github.com/shylinux/icebergs/misc" + _ "github.com/shylinux/icebergs/misc/alpha" _ "github.com/shylinux/icebergs/misc/lark" _ "github.com/shylinux/icebergs/misc/mp" _ "github.com/shylinux/icebergs/misc/pi" diff --git a/type.go b/type.go index e7507292..da45f608 100644 --- a/type.go +++ b/type.go @@ -1048,6 +1048,11 @@ func (m *Message) Grow(key string, chain interface{}, data interface{}) int { // 创建文件 name := path.Join(kit.Select(m.Conf(WEB_CACHE, Meta("store")), meta["store"]), kit.Keys(key, chain, "csv")) + if s, e := os.Stat(name); e == nil { + if s.Size() > 100000 { + name = strings.Replace(name, ".csv", fmt.Sprintf("_%d.csv", kit.Int(meta["offset"])), -1) + } + } f, e := os.OpenFile(name, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666) if e != nil { f, _, e = kit.Create(name) @@ -1136,9 +1141,9 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin match, value = "", "" } - data := make([]interface{}, 0, limit) + order := 0 if begin < current { - m.Log(LOG_INFO, "%s.%s read %v-%v from %v-%v", key, chain, begin, end, current, current+len(list)) + m.Log(LOG_INFO, "%s.%v read %v-%v from %v-%v", key, chain, begin, end, current, current+len(list)) store, _ := meta["record"].([]interface{}) for s := len(store) - 1; s > -1; s-- { item, _ := store[s].(map[string]interface{}) @@ -1152,26 +1157,29 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin if begin >= end { break } + item, _ := store[s].(map[string]interface{}) - if line+kit.Int(item["count"]) < begin { + name := kit.Format(item["file"]) + pos := kit.Int(item["position"]) + offset := kit.Int(item["offset"]) + if offset+kit.Int(item["count"]) <= begin { + m.Log(LOG_INFO, "skip store %v %d", item, begin) continue } - name := kit.Format(item["file"]) - pos := kit.Int(item["position"]) - line := kit.Int(item["offset"]) - m.Log(LOG_INFO, "load history %v %v %v", s, line, item) + m.Log(LOG_IMPORT, "load history %v %v %v", s, offset, item) if f, e := os.Open(name); m.Assert(e) { defer f.Close() r := csv.NewReader(f) heads, _ := r.Read() - m.Log(LOG_INFO, "load head %v", heads) + m.Log(LOG_IMPORT, "load head %v", heads) f.Seek(int64(pos), os.SEEK_SET) r = csv.NewReader(f) - for i := line; i < end; i++ { + for i := offset; i < end; i++ { lines, e := r.Read() if e != nil { + m.Log(LOG_IMPORT, "load head %v", e) break } @@ -1180,9 +1188,18 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin for i := range heads { item[heads[i]] = lines[i] } - m.Log(LOG_INFO, "load line %v %v %v", i, len(data), item) + m.Log(LOG_INFO, "load line %v %v %v", i, order, item) if match == "" || strings.Contains(kit.Format(item[match]), value) { - data = append(data, item) + // 读取文件 + switch cb := cb.(type) { + case func(int, map[string]interface{}): + cb(order, item) + case func(int, map[string]interface{}) bool: + if cb(order, item) { + return meta + } + } + order++ } begin = i + 1 } else { @@ -1200,10 +1217,18 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin } for i := begin - current; i < end-current; i++ { if match == "" || strings.Contains(kit.Format(kit.Value(list[i], match)), value) { - data = append(data, list[i]) + // 读取缓存 + switch cb := cb.(type) { + case func(int, map[string]interface{}): + cb(order, list[i].(map[string]interface{})) + case func(int, map[string]interface{}) bool: + if cb(order, list[i].(map[string]interface{})) { + return meta + } + } + order++ } } - kit.Fetch(data, cb) return meta }