├── README.md ├── core ├── lookup_service.go ├── metric.go ├── search_tag_option.go ├── search_users.go ├── stats.go ├── tag_whitelist.go └── utils.go ├── data ├── empty.txt ├── tag_option.csv └── whitelist.csv ├── json_service ├── json_service.go ├── metric_service.go ├── option_service.go ├── stats.go ├── tag_service.go └── utils.go ├── static ├── bootstrap │ ├── css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ └── bootstrap.min.css │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ └── npm.js ├── computing.js ├── d3.min.js ├── draw_bar_chart.js ├── index.html ├── jquery.ba-hashchange.min.js ├── jquery.min.js ├── oneGroup.html ├── select2.min.css ├── select2.min.js └── twoGroups.html ├── testdata └── data.txt └── tools ├── benchmark.go └── lookup_server.go /README.md: -------------------------------------------------------------------------------- 1 | Ad Hoc Analytics 2 | == 3 | 4 | 高性能即席分析引擎:每秒处理TB量级消费者画像数据 5 | 6 | 使用方法: 7 | 8 | ``` 9 | cd tools 10 | go run lookup_server.go --data_files data.csv --tag_option_file tag_option.csv 11 | ``` 12 | 13 | 其中 data.csv 的格式为(参见testdata/data.txt) 14 | 15 | ``` 16 | 日期,用户id,tag1:option1,tag2:option2,... 17 | ``` 18 | 19 | 其中日期为数据采集的日期,用户 id 为 uint64 整数,tag和 option 也都是整数 20 | 21 | tag_option.csv 格式为(参见 data/tag_option.csv ) 22 | 23 | ``` 24 | tag id,tag name,option id,option name,category name 25 | ``` 26 | 27 | category, tag, option 的关系如下 28 | 29 | ``` 30 | category 1: 31 | tag 1: option 1 32 | tag 1: option 2 33 | tag 2: option 3 34 | tag 3: option 4 35 | category 2: 36 | tag 4: option 5 37 | tag 4: option 6 38 | ``` 39 | 40 | 其中跨 category 的 tag id 不会发生重复,跨 tag 的 option id 不会发生重复。 41 | -------------------------------------------------------------------------------- /core/lookup_service.go: -------------------------------------------------------------------------------- 1 | package core 2 | 3 | import ( 4 | "flag" 5 | "github.com/huichen/wukong/engine" 6 | "github.com/huichen/wukong/types" 7 | "runtime" 8 | ) 9 | 10 | var ( 11 | dataFiles = flag.String("data_files", "", "包含用户属性的数据文件,支持wildcard") 12 | emptyFile = flag.String("empty_file", "../data/empty.txt", "空文件,用于启动tag搜索引擎") 13 | tagOptionFile = flag.String("tag_option_file", "../data/tag_option.csv", "从哪个日期的数据中搜索") 14 | ) 15 | 16 | type LookupService struct { 17 | searcher engine.Engine // 用于搜索人群 18 | userIds []uint64 // 全部人群的ID 19 | 20 | optionInfos map[string]OptionInfo // 快速查找option节点信息,key为: