Repository navigation
split data more than 2M - #572
Merged
Merged
Conversation
redHJ
force-pushed
the
pdr-6528
branch
4 times, most recently
from
June 26, 2018 13:49
5c88c45 to
81123f9
Compare
wonderflow
reviewed
Jun 27, 2018
| } | ||
| } | ||
|
|
||
| func splitData(data interface{}) (valArray []string) { |
wonderflow
reviewed
Jun 27, 2018
| data := make([]Data, 1) | ||
| byteData, err := json.Marshal(failCtx.Datas[0]) | ||
| if err != nil { | ||
| log.Warnf("Runner[%v] marshal data to string error %v", ft.runnerName, err) |
Contributor
There was a problem hiding this comment.
如果这里marshel出错,Data还是要全部返还回去,不能丢数据
Collaborator
Author
There was a problem hiding this comment.
这边会返回过去,再后面几行,只是不放在pandora_stash,原样返回回去,看375行
redHJ
force-pushed
the
pdr-6528
branch
4 times, most recently
from
June 27, 2018 11:34
130d591 to
5079d95
Compare
unknwon
suggested changes
Jun 27, 2018
| "github.com/qiniu/log" | ||
| "github.com/qiniu/pandora-go-sdk/base/reqerr" | ||
|
|
||
| "strings" |
|
|
||
| end := lenData * splitSize | ||
| valArray = append(valArray, strData[end:]) | ||
| return valArray |
Contributor
There was a problem hiding this comment.
其实可以直接 return append(valArray, strData[end:])
wonderflow
reviewed
Jun 28, 2018
| // 此处将 data 改为 raw 放在 pandora_stash 中 | ||
| if _, ok := failCtxData[KeyPandoraStash]; !ok { | ||
| log.Infof("Runner[%v] Sender[%v] try to convert data to string", ft.runnerName, ft.innerSender.Name()) | ||
| data := make([]Data, 1) |
wonderflow
reviewed
Jun 28, 2018
| @@ -226,9 +226,9 @@ func NewSender(conf conf.MapConf) (pandoraSender sender.Sender, err error) { | |||
| // 当 schema free 为 false 时,需要自动创建 pandora_stash 字段 | |||
wonderflow
reviewed
Jun 28, 2018
|
|
||
| func (s *mock_pandora) PostRepos_Data() echo.HandlerFunc { | ||
| return func(c echo.Context) error { | ||
| log.Println("PostRepos_Data request") |
wonderflow
reviewed
Jun 28, 2018
| } | ||
| } | ||
|
|
||
| func Test_SplitData(t *testing.T) { |
wonderflow
reviewed
Jun 28, 2018
| } | ||
| } | ||
|
|
||
| func SplitData(data interface{}) (valArray []string) { |
Contributor
There was a problem hiding this comment.
splitSize作为参数传入SplitData函数
redHJ
force-pushed
the
pdr-6528
branch
3 times, most recently
from
June 28, 2018 08:47
8faac4f to
405f9cc
Compare
redHJ
force-pushed
the
pdr-6528
branch
2 times, most recently
from
June 28, 2018 09:12
798cd82 to
88bb6e3
Compare
wonderflow
reviewed
Jun 28, 2018
| } | ||
|
|
||
| if ft.opt.longDataDiscard { | ||
| return |
wonderflow
reviewed
Jun 28, 2018
| } | ||
|
|
||
| // failCtxData 的 key value 中找到 string 类型的 value 大于 2M,进行切片 | ||
| if separateData != nil { |
wonderflow
reviewed
Jun 28, 2018
| for k, v := range separateData { | ||
| strVal, ok := v.(string) | ||
| if !ok { | ||
| return |
wonderflow
reviewed
Jun 28, 2018
| valArray = append(valArray, string(dataConverse[start:end])) | ||
| } | ||
|
|
||
| end := lenData * splitSize |
Contributor
There was a problem hiding this comment.
end == len(dataConverse)
wonderflow
reviewed
Jun 28, 2018
| return | ||
| } | ||
| valArray := SplitData(strVal, int64(DefaultSplitSize)) | ||
| if len(valArray) == 0 { |
wonderflow
reviewed
Jun 28, 2018
| } | ||
| } | ||
|
|
||
| func SplitData(data string, splitSize int64) (valArray []string) { |
Contributor
There was a problem hiding this comment.
加个检查,如果splitSIze <=0 的话,返回 valArrary = []string{data}
wonderflow
reviewed
Jun 28, 2018
| retData[k] = v | ||
| } | ||
| retData[KeyPandoraSeparateId] = separateId + "_" + k + "_" + strconv.Itoa(idx) | ||
| retData[k] = val |
wonderflow
reviewed
Jun 28, 2018
| newFailCtx := new(datasContext) | ||
| for idx, val := range valArray { | ||
| data := Data{ | ||
| KeyPandoraStash + "_" + strconv.Itoa(idx): val, |
Contributor
There was a problem hiding this comment.
这种case也要PandoraSeparateId呀,为什么这里就不加了?
Collaborator
Author
|
修过了 |
unknwon
approved these changes
Jun 28, 2018
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.
@wonderflow