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

feat: support return RedundancyType #16

Merged
merged 3 commits into from
Mar 27, 2023
Merged

feat: support return RedundancyType #16

merged 3 commits into from
Mar 27, 2023

Conversation

flywukong
Copy link
Collaborator

Description

support return RedundancyType in computing hash function

Rationale

createObject need to pass the right RedundancyType with this function

Example

NA

Changes

Notable changes:

  • return RedundancyType of EC

@flywukong flywukong force-pushed the dev-redundancy branch 2 times, most recently from f22f523 to 0260e3b Compare March 24, 2023 07:40
@flywukong flywukong changed the title support return RedundancyType feat: support return RedundancyType Mar 24, 2023
@flywukong flywukong closed this Mar 24, 2023
@flywukong flywukong reopened this Mar 24, 2023
@flywukong flywukong force-pushed the dev-redundancy branch 2 times, most recently from 878f529 to 437af93 Compare March 25, 2023 13:16
@flywukong flywukong changed the base branch from develop to master March 26, 2023 12:39
@flywukong flywukong changed the base branch from master to develop March 26, 2023 13:52
go/hash/hash.go Outdated
}

// ComputerHashFromFile open a local file and compute hash result and size
func ComputerHashFromFile(filePath string, segmentSize int64, dataShards, parityShards int) ([][]byte, int64, error) {
func ComputerHashFromFile(filePath string, segmentSize int64, dataShards, parityShards int) ([][]byte, int64, storageTypes.RedundancyType, error) {
f, err := os.Open(filePath)
if err != nil {
log.Error().Msg("open file fail:" + err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

failed open file:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

@@ -24,25 +25,28 @@ func TestHash(t *testing.T) {
contentToHash := createTestData(length)
start := time.Now()

hashResult, size, err := ComputeIntegrityHash(contentToHash, int64(segmentSize), redundancy.DataBlocks, redundancy.ParityBlocks)
hashResult, size, redundnacyType, err := ComputeIntegrityHash(contentToHash, int64(segmentSize), redundancy.DataBlocks, redundancy.ParityBlocks)
Copy link
Contributor

Choose a reason for hiding this comment

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

fix redundnacyType to redundancyType

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

if err != nil {
t.Errorf(err.Error())
}
fmt.Println("hash cost time:", time.Since(start).Milliseconds(), "ms")
if size != length {
t.Errorf("compute size error")
}
if redundnacyType != types.REDUNDANCY_EC_TYPE {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

go/hash/hash.go Outdated
f, err := os.Open(filePath)
if err != nil {
log.Error().Msg("open file fail:" + err.Error())
return nil, 0, err
log.Error().Msg("failed open file:" + err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to open

go/hash/hash.go Outdated
@@ -30,7 +32,7 @@ func ComputeIntegrityHash(reader io.Reader, segmentSize int64, dataShards, parit
if err != nil {
if err != io.EOF {
log.Error().Msg("content read failed:" + err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

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

failed to read content

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated

Copy link
Contributor

@sysvm sysvm left a comment

Choose a reason for hiding this comment

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

LGTM

@flywukong flywukong merged commit a9a3727 into develop Mar 27, 2023
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.

3 participants