zeroshade commented on code in PR #1050:
URL: https://github.com/apache/arrow-go/pull/1050#discussion_r3722369188
##########
parquet/internal/thrift/helpers.go:
##########
@@ -76,12 +76,23 @@ func (t *Serializer) Serialize(msg thrift.TStruct, w
io.Writer, enc encryption.E
}
if enc == nil {
- return w.Write(b)
+ n, err := w.Write(b)
+ if err != nil {
+ return n, err
+ }
+ if n != len(b) {
+ return n, io.ErrShortWrite
+ }
+ return n, nil
}
var cipherBuf bytes.Buffer
cipherBuf.Grow(enc.CiphertextSizeDelta() + len(b))
enc.Encrypt(&cipherBuf, b)
+ expected := cipherBuf.Len()
n, err := cipherBuf.WriteTo(w)
+ if err == nil && int(n) != expected {
+ err = io.ErrShortWrite
+ }
Review Comment:
same as above, err will be non-nil on a short write, so you don't need to do
this
##########
parquet/file/page_writer.go:
##########
@@ -400,7 +400,13 @@ func (pw *serializedPageWriter) WriteDataPage(page
DataPage) (int64, error) {
if err != nil {
return int64(written), err
}
+ if written != len(data) {
+ return int64(written), io.ErrShortWrite
+ }
Review Comment:
same comment as above, err will always be non-nil if written < len(data)
##########
parquet/file/page_writer.go:
##########
@@ -337,8 +334,14 @@ func (pw *serializedPageWriter) WriteDictionaryPage(page
*DictionaryPage) (int64
if err != nil {
return 0, err
}
+ if written != len(data) {
+ return int64(written), io.ErrShortWrite
+ }
Review Comment:
this is unnecessary, Write will always return a non-nil error if `written <
len(data)`
##########
parquet/internal/thrift/helpers.go:
##########
@@ -76,12 +76,23 @@ func (t *Serializer) Serialize(msg thrift.TStruct, w
io.Writer, enc encryption.E
}
if enc == nil {
- return w.Write(b)
+ n, err := w.Write(b)
+ if err != nil {
+ return n, err
+ }
+ if n != len(b) {
+ return n, io.ErrShortWrite
+ }
Review Comment:
same comment as above, this isn't necessary since Write will return a
non-nil error on a short write
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]