-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
f22f523
to
0260e3b
Compare
878f529
to
437af93
Compare
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed open file:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
go/hash/hash_test.go
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix redundnacyType to redundancyType
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
go/hash/hash_test.go
Outdated
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
9ed1461
to
c6369a4
Compare
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()) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
failed to read content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
d31e674
to
a113b16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
support return RedundancyType in computing hash function
Rationale
createObject need to pass the right RedundancyType with this function
Example
NA
Changes
Notable changes: