Skip to content

Write directly to the ODB when possible#724

Merged
nulltoken merged 4 commits intovNextfrom
cmn/write-stream
May 30, 2014
Merged

Write directly to the ODB when possible#724
nulltoken merged 4 commits intovNextfrom
cmn/write-stream

Conversation

@carlosmn
Copy link
Member

While trying to get rid of the uglyness that is git_blob_create_fromchunks(), I realised we can do it bit by bit, so here's the first bit.

If we're given no path (and thus cannot do any filtering) and a size, we know that we can stream the data directly into the database, so let's do that with a git_odb_stream.

This brought up the fact that we expect a short read to succeed, which is only possible because fromchunks waits for an EOF signal from us, which we can simply pass along from Stream.Read(). Trying to keep this behaviour would make it impossible to optimise anything, and it also seems like a great place to introduce subtle bugs, so I've changed the tests to reflect that we need to read that amount of bytes.

This however is still the behaviour for the case when we have a path, since that needs filtering and thus must still rely on fromchunks. This however means that the place where we would raise the exception is beyond a C wall, so that probably wouldn't work without storing the exception somewhere.

Copy link
Member

Choose a reason for hiding this comment

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

CreatingABlob From TooShortAStreamThrows?

@nulltoken nulltoken added this to the v0.18.0 milestone May 29, 2014
@nulltoken
Copy link
Member

Rebased. Ok to merge?

Copy link
Member Author

Choose a reason for hiding this comment

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

there's a word missing here. Either "prior to being stored" or "before storing it" or something work work.

nulltoken and others added 4 commits May 30, 2014 18:36
ObjectDatabase.CreateBlob() accepts a number of bytes to read. It
currently however treats this as a max, rather than a hard size, which
seems ripe for introducing bugs.

Assert that we should throw when asked to read too much from a Stream.
When given a size and no path, we know that we do not need to buffer the
content or apply any filters, so we can create an write-stream into the
object database and put in our content directly, avoiding the temporary
file and callbacks altogether.
@nulltoken nulltoken merged commit f65af84 into vNext May 30, 2014
@nulltoken nulltoken deleted the cmn/write-stream branch May 30, 2014 17:00
@nulltoken
Copy link
Member

💥

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.

2 participants