Repository navigation
Ip库增加mmdb格式支持 - #653
Merged
Merged
Ip库增加mmdb格式支持#653
Conversation
wangqiang-qiniu
force-pushed
the
ipmmdb
branch
4 times, most recently
from
July 26, 2018 01:45
2511621 to
6cc95e4
Compare
wonderflow
reviewed
Jul 26, 2018
| } | ||
|
|
||
| func (loc *datLocator) Close() error { | ||
| return nil |
wonderflow
reviewed
Jul 26, 2018
|
|
||
| func (loc *mmdbLocator) Close() error { | ||
| if loc.reader != nil { | ||
| locatorStore.Remove(loc.path) |
Contributor
There was a problem hiding this comment.
这样直接remove可能不合适,因为别的tranformer或者runner也会用
unknwon
suggested changes
Jul 26, 2018
| if err := loc.init(data); err != nil { | ||
| return nil, err | ||
| } | ||
| return loc, nil |
Contributor
There was a problem hiding this comment.
应该改造 newDatLocatorWithData 支持接收一个文件名参数
| indexData2 []int | ||
| indexData3 []int | ||
| index []int | ||
| path string |
|
|
||
| func (loc *datLocator) Close() error { | ||
| if loc.index != nil && len(loc.index) > 0 { | ||
| locatorStore.Remove(loc.path) |
Contributor
There was a problem hiding this comment.
这里已经调用 Remove 之后,就没有地方引用这个 loc 了,会被 GC 收掉的,所以这行之后的内容应该是没有必要的
| if err != nil { | ||
| loc := new(datxLocator) | ||
| loc.path = dataFile | ||
| if err := loc.init(data); err != nil { |
Contributor
There was a problem hiding this comment.
应该改造 newDatxLocatorWithData 支持接收一个文件名参数
|
|
||
| func (loc *datxLocator) Close() error { | ||
| if loc.index != nil && len(loc.index) > 0 { | ||
| locatorStore.Remove(loc.path) |
Contributor
There was a problem hiding this comment.
这里已经调用 Remove 之后,就没有地方引用这个 loc 了,会被 GC 收掉的,所以这行之后的内容应该是没有必要的
| assert.Len(t, locatorStore.locators, 2) | ||
| assert.Equal(t, expe6, ipt.stats) | ||
| assert.Equal(t, ipt.Stage(), transforms.StageAfterParser) | ||
| // 确保多个 transformer 只有两个 Locator 产生 |
Contributor
There was a problem hiding this comment.
这行注释的位置不对吧,原来判断是紧接着上一部分测试结果的,新添加的部分可以重新判断但是原来的还是不要移动
| } | ||
|
|
||
| // 将指定路径删除 | ||
| func (s *LocatorStore) Remove(fpath string) { |
Contributor
There was a problem hiding this comment.
// Remove 将指定路径的 Locator 引用计数减 1 并在为零时从 Store 中移除
| } | ||
|
|
||
| // Get 返回对应路径的 Locator,如果 Locator 不存在则返回 nil | ||
| func (s *LocatorStore) Get(fpath string) Locator { |
Contributor
There was a problem hiding this comment.
// Get 返回对应路径的 Locator 并将其引用计数加 1,如果 Locator 不存在则返回 nil
| type Closer interface { | ||
| Close() error | ||
| } | ||
|
|
Contributor
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes [PDR-6915]
Changes
Reviewers
Wiki Changes
Checklist