Skip to content

Introduce ObjectDatabase.Write(Stream...) #1518

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

Merged
merged 3 commits into from
Nov 27, 2017
Merged

Conversation

ethomson
Copy link
Member

Introduce ObjectDatabase.Write(Stream...) to write directly to the object database (without creating the subsequent Blob) and without having to load the entire blob into memory. See #1515

@@ -187,6 +187,45 @@ public int Provider(IntPtr content, int max_length, IntPtr data)
return Proxy.git_odb_write(handle, data, GitObject.TypeToKindMap[typeof(T)]);
}

/// <summary>
/// Write an object to the object database
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick, but this should be "Writes" instead of "Write" to be consistent with other comments.

Also, all of these should have a period at the end.

Copy link
Member Author

Choose a reason for hiding this comment

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

To be fair, it's not that consistent, seeing as I copied and pasted the documentation from the other Write method above it. 😝

Updated them both, in any case.

@carlosmn
Copy link
Member

If we're fixing the API, we should make the Write call return something that implements (or inherits from, in this language) Stream.

This API comes from when we had the scatter-gather pull mechanism in libgit2 for writing to the objectdb. We kept the API for compat when we let you push data into libgit2, but any new code should ideally not use that.

@ethomson
Copy link
Member Author

Why would we return a Stream?

@ethomson
Copy link
Member Author

Right, I understand what you're saying now, @carlosmn: instead of taking a Stream that CanRead and pulling the contents out of it and into the ODB, we could return a Stream that CanWrite and people can write to it at their leisure and we will put the contents into the ODB.

I think that moving towards that API might make sense. At the moment, though, this API matches our existing APIs and unblocks some scenarios.

@ethomson ethomson force-pushed the ethomson/odb_write_stream branch from 5a7243d to f324390 Compare November 25, 2017 16:35
Update the method documentation for `ObjectDatabase.Write` to be
consistent with the other methods.
Test that we can `ObjectDatabase.Write` a blob.
Provide a mechanism to write a stream directly to an object database.
@ethomson ethomson force-pushed the ethomson/odb_write_stream branch from f324390 to 1abf368 Compare November 25, 2017 16:36
@ethomson ethomson merged commit 2a8af3a into master Nov 27, 2017
@ethomson ethomson deleted the ethomson/odb_write_stream branch February 15, 2019 09:08
alex-weaver pushed a commit to alex-weaver/libgit2sharp that referenced this pull request Mar 23, 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