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

Add large-object support for CopyObject API #644

Closed
wants to merge 1 commit into from

Conversation

donatello
Copy link
Member

This patch is up for early review.

Context of the change is at #617

The byte-range for the source object has been added into CopyConditions type - ideally the CopyConditions type should be called CopySourceInfo and it should have the copy-conditions, copy-source and the optional copy-byte-range. However, the changes in this patch aim to keep backwards compatibility.

The one wrinkle is the NewCopyConditions method - it is now the preferred method to create a CopyConditions{} instance as it initializes the byte-range to -1 (indicating that the byte range is not specified by the user).

This is as yet untested - hoping to get some input about the interface improvement to be done.

@donatello
Copy link
Member Author

API change proposal:

func CopyObject(bucketName, objectName, srcBucket, srcObject string, csi copySourceInfo) error

Providing explicit source bucket and object makes it easier for user to not have to format it as "/bucket/object".

Data type and methods:

// Not exported so that user has to use an initialization function
type copySourceInfo struct {
    copyConditions map[string]string
    byteRangeStart int64
    byteRangeEnd int64
}

// To allocate map and initialize range
func NewCopySourceInfo() copySourceInfo {}

// funcs to set copy conditions.
func (c *copySourceInfo) SetMatchETag(etag string) error {}
func (c *copySourceInfo) SetMatchETagExcept(etag string) error {}
func (c *copySourceInfo) SetUnmodified(modTime time.Time) error {}
func (c *copySourceInfo) SetModified(modTime time.Time) error {}
func (c *copySourceInfo) SetByteRange(start, end int64) error {}

// internal utils
func (c *copySourceInfo) getRangeSize() int64 {}
func (c *copySourceInfo) duplicate() *copySourceInfo {}

@harshavardhana
Copy link
Member

To keep backward compatibility we can introduce a new API, we now have projects dependent on minio-go. So we need to be careful with API changes.

Will discuss this with @abperiasamy and see where we go from there.

return c.byteRangeEnd - c.byteRangeStart + 1
}

func (c *CopyConditions) duplicate() *CopyConditions {
Copy link
Member

Choose a reason for hiding this comment

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

call this clone() or cloneCopyConditions in Go style.

}
return parts[1], parts[2], nil
}

Copy link
Member

Choose a reason for hiding this comment

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

Comment necessary..

@@ -70,3 +102,91 @@ func (c Client) CopyObject(bucketName string, objectName string, objectSource st
// Return nil on success.
return nil
}

func getObjectSource(src string) (bucket string, object string, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Comment necessary.. and a test case..

Copy link
Member

@krisis krisis left a comment

Choose a reason for hiding this comment

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

Minor comments, overall looks good.

if err != nil {
return err
}

Copy link
Member

Choose a reason for hiding this comment

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

Stray newline?

cpCond.byteRangeStart, cpCond.byteRangeEnd, srcInfo.Size))
}

copySize := srcByteRangeSize
Copy link
Member

Choose a reason for hiding this comment

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

A comment explaining how an empty range is interpreted as the entire object would provide context for future.

func (c *CopyConditions) getRangeSize() int64 {
if c.byteRangeStart < 0 {
// only happens if byte-range was not set by user
return 0
Copy link
Member

Choose a reason for hiding this comment

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

Probably it is better to set this to -1 to say unknown. Probably zero is a valid value.

if start < 0 || end < start {
return ErrInvalidArgument("Range start less than 0 or range end less than range start.")
}
if end-start+1 < 1 {
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 this condition is useless,

Here we are already sure that start <= end:

start <= end <=> 0 <= end - start <=> 1 <= end - start + 1,

so we will never have end-start+1 < 1

@harshavardhana harshavardhana changed the title WIP: Add large-object support for CopyObject API Add large-object support for CopyObject API Apr 17, 2017

// Update the source range header value.
headers.Set("x-amz-copy-source-range",
fmt.Sprintf("bytes:%d-%d", pCond.byteRangeStart,
Copy link
Member

Choose a reason for hiding this comment

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

This is wrong btw - it should be bytes=%d-%d

@deekoder
Copy link
Contributor

Is this still blocked?

@harshavardhana
Copy link
Member

Is this still blocked?

Yes not discussed yet.

@harshavardhana
Copy link
Member

@donatello can you update this and incorporate usage of requestHeaders instead of copyConditions . Which would expand the scope of this.

@harshavardhana
Copy link
Member

@donatello can you update this and incorporate usage of requestHeaders instead of copyConditions . Which would expand the scope of this.

@donatello can you incorporate the request-headers.go changes to CopyObject() just like how we did with GetObject() .This would be a breaking change we will bump up the tag so that the users who have referenced using our tags atleast can understand why this change.

@tejaycar
Copy link
Contributor

tejaycar commented Jun 5, 2017

@donatello, @harshavardhana is there anything I can do to help?

@donatello
Copy link
Member Author

@tejaycar We plan to get this resolved by next week. We are busy with the Minio server release at this time.

@tejaycar
Copy link
Contributor

tejaycar commented Jun 8, 2017 via email

@tejaycar
Copy link
Contributor

@donatello I don't mean to bug, but do you have any update to offer on this? I'm not trying to push, just trying to plan accordingly.

@donatello
Copy link
Member Author

@donatello I don't mean to bug, but do you have any update to offer on this? I'm not trying to push, just trying to plan accordingly.

@tejaycar I am actively working on this, and hope to have a PR today. I would venture to say that it might get merged by the end of the week after reviews and testing.

@tejaycar
Copy link
Contributor

tejaycar commented Jun 19, 2017 via email

@donatello
Copy link
Member Author

We are bringing large object copy support via a more flexible ComposeObject API that allows server-side copying of objects to create new objects.

This PR is thus superseded by #715. Closing as obsolete.

@donatello donatello closed this Jun 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants