Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

Support offset and size for read #157

Merged
merged 4 commits into from
Jul 22, 2021
Merged

Conversation

zhaohuxing
Copy link
Contributor

No description provided.

storage.go Outdated
@@ -473,6 +473,7 @@ func (s *Storage) read(ctx context.Context, path string, w io.Writer, opt pairSt
input := &s3.GetObjectInput{
Bucket: aws.String(s.name),
Key: aws.String(rp),
Range: aws.String(fmt.Sprintf("bytes=%d-%d", opt.Offset, opt.Offset+opt.Size)),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Range is [a, b], maybe we need to use opt.Offset+opt.Size-1 for end?

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, we need to check offset and size before we use them.

  • What if the offset is missing?
  • What if the size is missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Range is [a, b], maybe we need to use opt.Offset+opt.Size-1 for end?
Got

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BTW, we need to check offset and size before we use them.

  • What if the offset is missing?
  • What if the size is missing?

Both offset and size are not pointer types, so we have to check whether size is greater than 0

storage.go Outdated
@@ -474,6 +474,9 @@ func (s *Storage) read(ctx context.Context, path string, w io.Writer, opt pairSt
Bucket: aws.String(s.name),
Key: aws.String(rp),
}
if opt.Size > 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use opt.HasXxxx to check size and offset.

It's OK to eliminate the check for offset, but please fill comments here for the reason.

Copy link
Contributor Author

@zhaohuxing zhaohuxing Jul 22, 2021

Choose a reason for hiding this comment

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

Modified, Please Review.

storage.go Show resolved Hide resolved
@Xuanwo Xuanwo merged commit 8fb8864 into beyondstorage:master Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants