Skip to content

Conversation

@khanhtc1202
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

NONE

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request does not change code coverage.

@pipecd-bot
Copy link
Collaborator

TODO

The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use /todo skip command.

Details

1. Add merge based on UpdatedAt field in case there are multiple parts of object are fetched.

// TODO: Add merge based on UpdatedAt field in case there are multiple parts of object are fetched.
return datastore.ErrUnimplemented
}

This was created by todo plugin since "TODO:" was found in e573321 when #3286 was merged. cc: @khanhtc1202.

@khanhtc1202 khanhtc1202 changed the title [WIP] Implement get interface for filedb Implement get interface for FileDB Feb 18, 2022
@khanhtc1202
Copy link
Member Author

/todo skip

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.33%. This pull request decreases coverage by -0.07%.

File Function Base Head Diff
pkg/datastore/filedb/filedb.go WithLogger -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go NewFileDB -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.fetch -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Find -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Get -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Create -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Update -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Close -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go makeHotStorageFilePath -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go dataTo -- 100.00% +100.00%

}

if len(parts) == 1 {
return dataTo(parts[0], v)
Copy link
Member

Choose a reason for hiding this comment

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

I prefer to avoid using reflect package or copying data from another struct.
So how about unmarshal the data directly to v.
In the case of multiple shards, we can unmarshal the least significant one to v to merge.

Copy link
Member Author

@khanhtc1202 khanhtc1202 Feb 21, 2022

Choose a reason for hiding this comment

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

I feel you, if possible I would like to not use reflect as you said since it's slow and quite dangerous to do. 👍

In the case of multiple shards, we can unmarshal the least significant one to v to merge.

I get your point, but one thing I have to confirm. In case of multiple shards stored object, we may need to unmarshal once to get at least UpdatedAt field to enable comparisons between parts and choice which should be unmarshaled first. In such a case, we may have a flow of: unmarshal => compare => unmarshal again with unmarshaled data. It looks a bit odd but could avoid using reflect, if it is good for you too, I'm happy to adopt your suggestion 👍

Copy link
Member

Choose a reason for hiding this comment

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

I think that UpdatedAt does not matter while merging them. UpdatedAt is for the whole entity, not each field so we can not rely on it to decide the value of which entity should be used.

I think each Collection we will need a Merge(from, to interface{}, fromShard, toShard Shard) function that merges the from one to the to one, the shard name should be passed to that Merge function as well to know the priority of their fields.

Btw, since this PR is only supporting 1 shard currently, so let's use JSON to unmarshal directly v at this time for the sake of simplicity.
And then talk more about the merging problem at another PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Btw, since this PR is only supporting 1 shard currently, so let's use JSON to unmarshal directly v at this time for the sake of simplicity.
And then talk more about the merging problem at another PR.

okay, for sure 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the comment, addressed by a44fd83 🙏

@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.33%. This pull request decreases coverage by -0.07%.

File Function Base Head Diff
pkg/datastore/filedb/filedb.go WithLogger -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go NewFileDB -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.fetch -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Find -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Get -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Create -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Update -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go FileDB.Close -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go makeHotStorageFilePath -- 0.00% +0.00%
pkg/datastore/filedb/filedb.go dataTo -- 100.00% +100.00%

@pipecd-bot pipecd-bot added size/M and removed size/L labels Feb 21, 2022
@pipecd-bot
Copy link
Collaborator

COVERAGE

Code coverage for golang is 32.40%. This pull request does not change code coverage.

@nghialv
Copy link
Member

nghialv commented Feb 21, 2022

Nice.
/lgtm

@knanao
Copy link
Member

knanao commented Feb 21, 2022

Here you go!
/approve

@pipecd-bot
Copy link
Collaborator

APPROVE

This pull request is APPROVED by knanao.

Approvers can cancel the approval by writing /approve cancel in a comment. Any additional commits also will change this pull request to be not-approved.

@pipecd-bot pipecd-bot merged commit fb69555 into master Feb 21, 2022
@pipecd-bot pipecd-bot deleted the implement-get-interface branch February 21, 2022 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants