mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 01:24:05 +08:00
fix grows
This commit is contained in:
parent
d044f2266e
commit
92ad44769e
@ -21,7 +21,7 @@ var Index = &ice.Context{Name: "wiki", Help: "文档中心",
|
|||||||
"path", "",
|
"path", "",
|
||||||
"head", "time size line path",
|
"head", "time size line path",
|
||||||
"alias", map[string]interface{}{
|
"alias", map[string]interface{}{
|
||||||
"block": []interface{}{"chart", "block"},
|
"label": []interface{}{"chart", "block"},
|
||||||
"chain": []interface{}{"chart", "chain"},
|
"chain": []interface{}{"chart", "chain"},
|
||||||
|
|
||||||
"chapter": []interface{}{"title", "chapter"},
|
"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("spark", ice.Meta("template")), m.Option("name"))
|
||||||
m.Render(m.Conf("shell", ice.Meta("template")))
|
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) {
|
"spark": {Name: "spark name text", Help: "参考", Hand: func(m *ice.Message, c *ice.Context, key string, arg ...string) {
|
||||||
m.Option("type", "refer")
|
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)
|
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)
|
|
||||||
}},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
miss/miss.md
19
miss/miss.md
@ -1,10 +1,29 @@
|
|||||||
# miss
|
# miss
|
||||||
|
|
||||||
|
{{label "图谱" `
|
||||||
|
模块化 集群化 自动化
|
||||||
|
配置化 服务化 场景化
|
||||||
|
命令化 组件化 个性化
|
||||||
|
`}}
|
||||||
|
|
||||||
{{table "图谱" `
|
{{table "图谱" `
|
||||||
code wiki chat team mall
|
code wiki chat team mall
|
||||||
linux nginx golang redis mysql
|
linux nginx golang redis mysql
|
||||||
zsh tmux docker git vim
|
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" `
|
{{stack "hi" `
|
||||||
hi
|
hi
|
||||||
hello
|
hello
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
_ "github.com/shylinux/icebergs/core"
|
_ "github.com/shylinux/icebergs/core"
|
||||||
_ "github.com/shylinux/icebergs/misc"
|
_ "github.com/shylinux/icebergs/misc"
|
||||||
|
|
||||||
|
_ "github.com/shylinux/icebergs/misc/alpha"
|
||||||
_ "github.com/shylinux/icebergs/misc/lark"
|
_ "github.com/shylinux/icebergs/misc/lark"
|
||||||
_ "github.com/shylinux/icebergs/misc/mp"
|
_ "github.com/shylinux/icebergs/misc/mp"
|
||||||
_ "github.com/shylinux/icebergs/misc/pi"
|
_ "github.com/shylinux/icebergs/misc/pi"
|
||||||
|
51
type.go
51
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"))
|
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)
|
f, e := os.OpenFile(name, os.O_RDWR|os.O_APPEND|os.O_CREATE, 0666)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
f, _, e = kit.Create(name)
|
f, _, e = kit.Create(name)
|
||||||
@ -1136,9 +1141,9 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin
|
|||||||
match, value = "", ""
|
match, value = "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
data := make([]interface{}, 0, limit)
|
order := 0
|
||||||
if begin < current {
|
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{})
|
store, _ := meta["record"].([]interface{})
|
||||||
for s := len(store) - 1; s > -1; s-- {
|
for s := len(store) - 1; s > -1; s-- {
|
||||||
item, _ := store[s].(map[string]interface{})
|
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 {
|
if begin >= end {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
item, _ := store[s].(map[string]interface{})
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := kit.Format(item["file"])
|
m.Log(LOG_IMPORT, "load history %v %v %v", s, offset, item)
|
||||||
pos := kit.Int(item["position"])
|
|
||||||
line := kit.Int(item["offset"])
|
|
||||||
m.Log(LOG_INFO, "load history %v %v %v", s, line, item)
|
|
||||||
if f, e := os.Open(name); m.Assert(e) {
|
if f, e := os.Open(name); m.Assert(e) {
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
r := csv.NewReader(f)
|
r := csv.NewReader(f)
|
||||||
heads, _ := r.Read()
|
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)
|
f.Seek(int64(pos), os.SEEK_SET)
|
||||||
r = csv.NewReader(f)
|
r = csv.NewReader(f)
|
||||||
for i := line; i < end; i++ {
|
for i := offset; i < end; i++ {
|
||||||
lines, e := r.Read()
|
lines, e := r.Read()
|
||||||
if e != nil {
|
if e != nil {
|
||||||
|
m.Log(LOG_IMPORT, "load head %v", e)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1180,9 +1188,18 @@ func (m *Message) Grows(key string, chain interface{}, match string, value strin
|
|||||||
for i := range heads {
|
for i := range heads {
|
||||||
item[heads[i]] = lines[i]
|
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) {
|
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
|
begin = i + 1
|
||||||
} else {
|
} 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++ {
|
for i := begin - current; i < end-current; i++ {
|
||||||
if match == "" || strings.Contains(kit.Format(kit.Value(list[i], match)), value) {
|
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
|
return meta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user