worryg0d commented on code in PR #1822:
URL:
https://github.com/apache/cassandra-gocql-driver/pull/1822#discussion_r1812558391
##########
compressor.go:
##########
@@ -32,6 +32,7 @@ type Compressor interface {
Name() string
Encode(data []byte) ([]byte, error)
Decode(data []byte) ([]byte, error)
+ DecodeSized(data []byte, size uint32) ([]byte, error)
Review Comment:
Then we should agree on the API.
We could adjust the current API to
[this](https://github.com/worryg0d/gocql/commit/b4e0322e2af541fa0a3b7c467802e20cfa691ef6):
```go
type Compressor interface {
Name() string
Encode(dst, data []byte) ([]byte, error)
Decode(dst, data []byte) ([]byte, error)
// DecodeSized decodes the encoded bytes and appends them to dst.
// decodeSize is the size of data after decompression.
DecodeSized(dst, encoded []byte, decodedSize uint32) ([]byte, error)
}
```
As another solution, we could change the API to this:
```go
type Compressor interface {
Name() string
// EncodeWithSize encodes data bytes, appends the size of the data
// to dst and appends encoded bytes.
// It returns encoded data length.
EncodeWithSize(dst, data []byte) (n int, err error)
// DecodeWithSize reads size of uncompressed data from the encoded data,
// decodes the encoded bytes and appends them to dst.
// It returns decoded data length.
DecodeWithSize(dst, encoded []byte) (n int, err error)
// Encode encodes data bytes and appends them to dst.
// It returns encoded data length.
Encode(dst, data []byte) (n int, err error)
// Decode decodes the encoded bytes and appends them to dst.
// It returns decoded data length.
Decode(dst, encoded []byte) (n int, err error)
}
```
The second provides distinguishing methods for:
* **frame body** encoding/decoding `EncodeWithSize` and `DecodeWithSize`
* **segment payload** processing `Encode` and `Decode`.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]