Skip to content

Commit

Permalink
Add comments and fix multiErr.
Browse files Browse the repository at this point in the history
  • Loading branch information
notbdu committed Feb 11, 2019
1 parent d568781 commit 6395be1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions values/decoding/dictionary_based_string_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
// dictionaryBasedStringIterator iterates over a
// dict encoded stream of string data.
type dictionaryBasedStringIterator struct {
reader xio.SimpleReadCloser
byteReader io.ByteReader // Same as `reader` but has the proper type to save interface conversions in `Next`
reader xio.SimpleReadCloser // `reader`is used to `Close` the underlying reader and allow for resource clean up.
byteReader io.ByteReader // Same as `reader` but has the proper type to save interface conversions in `Next`
// extDict is passed externally from the string decoder
// and should not be mutated during iteration.
extDict []string
Expand Down
4 changes: 2 additions & 2 deletions values/decoding/varint_int_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
// varintIntIterator iterates over a stream of
// varint encoded int data.
type varintIntIterator struct {
reader xio.SimpleReadCloser
byteReader io.ByteReader // Same as `reader` but has the proper type to save interface conversions in `Next`
reader xio.SimpleReadCloser // `reader`is used to `Close` the underlying reader and allow for resource clean up.
byteReader io.ByteReader // Same as `reader` but has the proper type to save interface conversions in `Next`

closed bool
curr int
Expand Down
9 changes: 5 additions & 4 deletions values/encoding/string_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,19 @@ func (enc *stringEncoder) Encode(strVals values.StringValues, writer io.Writer)
var multiErr xerrors.MultiError
switch metaProto.Encoding {
case encodingpb.EncodingType_RAW_SIZE:
multiErr.Add(enc.rawSizeEncode(valuesIt, writer))
err = enc.rawSizeEncode(valuesIt, writer)
case encodingpb.EncodingType_DICTIONARY:
multiErr.Add(enc.dictionaryEncode(valuesIt, dictionary, writer))
err = enc.dictionaryEncode(valuesIt, dictionary, writer)
default:
multiErr.Add(fmt.Errorf("invalid encoding type: %v", metaProto.Encoding))
err = fmt.Errorf("invalid encoding type: %v", metaProto.Encoding)
}
multiErr = multiErr.Add(err)

// Close the compressWriter if its present.
if compressWriter != nil {
// NB(xichen): Close flushes and closes the compressed writer but doesn't
// close the writer wrapped by the compressed writer.
multiErr.Add(compressWriter.Close())
multiErr = multiErr.Add(compressWriter.Close())
}

return multiErr.FinalError()
Expand Down

0 comments on commit 6395be1

Please sign in to comment.