Skip to content

Commit

Permalink
fix the nil reference issue, just add the error handle logic (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
alonlong authored May 18, 2021
1 parent 555f765 commit fc9e25b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pkg/convert/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (

// format is a Serialized trie (see transporttrie.Serialize implementation)
func ParseTrie(r io.Reader, cb func(name []byte, val int)) error {
t, _ := transporttrie.Deserialize(r)
t, err := transporttrie.Deserialize(r)
if err != nil {
return err
}
t.Iterate(func(name []byte, val uint64) {
cb(name, int(val))
})
Expand Down
6 changes: 4 additions & 2 deletions pkg/server/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ type ingestParams struct {
func wrapConvertFunction(convertFunc func(r io.Reader, cb func(name []byte, val int)) error) func(io.Reader) (*tree.Tree, error) {
return func(r io.Reader) (*tree.Tree, error) {
t := tree.New()
convertFunc(r, func(k []byte, v int) {
if err := convertFunc(r, func(k []byte, v int) {
t.Insert(k, uint64(v))
})
}); err != nil {
return nil, err
}

return t, nil
}
Expand Down

0 comments on commit fc9e25b

Please sign in to comment.