MCPcopy
hub / github.com/davyxu/tabtoy / LoadAllTable

Function LoadAllTable

v3/example/golang/main.go:10–36  ·  view source on GitHub ↗

一次性加载所有表

()

Source from the content-addressed store, hash-verified

8
9// 一次性加载所有表
10func LoadAllTable() {
11
12 var Tab = NewTable()
13
14 // 表加载前清除之前的手动索引和表关联数据
15 Tab.RegisterPreEntry(func(tab *Table) error {
16 fmt.Println("tab pre load clear")
17 return nil
18 })
19
20 // 表加载和构建索引后,需要手动处理数据的回调
21 Tab.RegisterPostEntry(func(tab *Table) error {
22 fmt.Println("tab post load done")
23 fmt.Printf("%+v\n", tab.ExampleDataByID[200])
24
25 fmt.Println("KV: ", tab.GetKeyValue_ExampleKV().ServerIP)
26 return nil
27 })
28
29 err := tabtoy.LoadFromFile(Tab, "../json/table_gen.json")
30 if err != nil {
31 fmt.Println(err)
32 os.Exit(1)
33 }
34
35 fmt.Println("")
36}
37
38// 按指定表加载
39func LoadSpecifiedTable() {

Callers 1

mainFunction · 0.70

Calls 5

PrintfMethod · 0.80
NewTableFunction · 0.70
RegisterPreEntryMethod · 0.45
RegisterPostEntryMethod · 0.45
GetKeyValue_ExampleKVMethod · 0.45

Tested by

no test coverage detected