Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf!: Changed tuplelist deserialization. #76

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

sbckr
Copy link
Member

@sbckr sbckr commented Sep 5, 2024

No description provided.

- fake castor client always returned empty byte array;
- removed unused functions

Signed-off-by: Alwin Zomotor <[email protected]>
Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.02%. Comparing base (7ce9f83) to head (0511e55).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
- Coverage   82.29%   82.02%   -0.28%     
==========================================
  Files          29       29              
  Lines        3158     3138      -20     
==========================================
- Hits         2599     2574      -25     
- Misses        485      488       +3     
- Partials       74       76       +2     
Flag Coverage Δ
service 82.02% <ø> (-0.28%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ce9f83...0511e55. Read the comment docs.

@CRAlwin CRAlwin marked this pull request as ready for review September 10, 2024 21:34
@CRAlwin CRAlwin requested a review from a team as a code owner September 10, 2024 21:34
Copy link
Member Author

@sbckr sbckr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add yourself to the NOTICE.md file

Requires Changes

if err != nil {
return nil, err
}
ts.logger.Debugw("Fetched new tuples from Castor", "RequestID", requestID)
tupleData, err := ts.tupleListToByteArray(tupleList)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should at least check whether received data fits to the requested tuple parameters (length of array equals number of requested tuples x length of requested tuple type, or sth like that)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

must be part of the client if GetTuples returns a Reader as proposed above

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Copyright header

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Copyright header

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Copyright header

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update Copyright header

@@ -66,17 +66,16 @@ func (c *Client) GetTuples(count int32, tt TupleType, requestID uuid.UUID) (*Tup
if err != nil {
return nil, fmt.Errorf("communication with castor failed: %s", err)
}
bodyBytes, err := ioutil.ReadAll(resp.Body)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the byte[] to is later written to a pipe (file) consumed by the MPC runtime, wouldn't it make sense to return the Body (ReadCloser) directly. This would eliminate the intermediate step of "chaching" as a byte[] first.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

possibly as an additional asStream / asReader method

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one could utilize io.Copy for implementation

if err != nil {
return nil, err
}
return nil, fmt.Errorf("getting tuples failed for \"%s\" with response code #%d: %s", req.URL, resp.StatusCode, string(bodyBytes))
}
tuples := &TupleList{}
err = json.NewDecoder(resp.Body).Decode(tuples)
if err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's unnecessary code now, isn't it?

"github.com/asaskevich/govalidator"
)

// AbstractClient is an interface for castor tuple client.
type AbstractClient interface {
GetTuples(tupleCount int32, tupleType TupleType, requestID uuid.UUID) (*TupleList, error)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is TupleList still used at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants