git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Steven E. Harris" <seh@panix.com>
To: git@vger.kernel.org
Subject: Re: Confused over packfile and index design
Date: Sat, 09 Apr 2011 10:30:26 -0400	[thread overview]
Message-ID: <m28vvj7b0d.fsf@Spindle.sehlabs.com> (raw)
In-Reply-To: BANLkTikXcvRf1bLJXFOHBcGcN-B0m_xSnw@mail.gmail.com

Shawn Pearce <spearce@spearce.org> writes:

> Then remaining bytes are shoved into a libz inflate() routine until
> libz says the stream is over. As Peff mentioned elsewhere in the
> thread, libz maintains its own markers and checksum to know when the
> object's stream is over.

Ah, so even though you as the caller don't know how much data to feed to
libz, so long as you continue feeding it until it signals completion, it
will figure it out and tell you how much data it needed after all.

> As a safety measure, the inflated length from the object header is
> checked against the number of bytes returned by libz.  Any remaining
> data that libz didn't consume is the next object's header and data.

I see. This means that it's the packed object's "job" -- or, rather, the
job of the parser for the packed object -- to determine the payload
length. If the data was not compressed, then perhaps the deflated size
indicated in the header could provide sufficient framing, but for now we
don't need to worry about such flexibility.

[...]

> Its meant to tell us how many bytes to malloc() in order to hold the
> result of the libz inflate() call when the object is being read from
> the packfile. That way we don't under or over allocate the result
> buffer.

Does Git always inflate the objects into an in-memory buffer? As the
size of these objects can be very large (given the variable-length size
encoding), is there any provision to inflate the object to a temporary
file?

-- 
Steven E. Harris

  reply	other threads:[~2011-04-09 14:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-08 23:58 Confused over packfile and index design Steven E. Harris
2011-04-09  0:20 ` Jeff King
2011-04-09  2:07 ` Shawn Pearce
2011-04-09 14:30   ` Steven E. Harris [this message]
2011-04-09 14:45     ` Shawn Pearce
2011-04-10  2:08 ` Nicolas Pitre
2011-04-10 20:10   ` Steven E. Harris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m28vvj7b0d.fsf@Spindle.sehlabs.com \
    --to=seh@panix.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).