diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-06-25 18:23:44 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-06-25 23:26:19 -0700 |
commit | 6fc3ecac848b357891da8a9749d35090dbb0ace3 (patch) | |
tree | ff8d697329494019bdc3dcd95f03a26a4c8d4a97 /org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java | |
parent | a2208be6aaf4a3763beb1b6e0ef374d77570a165 (diff) | |
download | jgit-6fc3ecac848b357891da8a9749d35090dbb0ace3.tar.gz jgit-6fc3ecac848b357891da8a9749d35090dbb0ace3.zip |
Extract PackFile specific code to ObjectToPack subclass
The ObjectReader class is dual-purposed into being a factory for the
ObjectToPack, permitting specific ObjectDatabase implementations
to override the method and offer their own custom subclass of the
generic ObjectToPack class. By allowing them to directly extend the
type, each implementation can add custom fields to support tracking
where an object is stored, without incurring any additional penalties
like a parallel Map<ObjectId,Object> would cost.
The reader was chosen to act as a factory rather than the database,
as the reader will eventually be tied more tightly with the
ObjectWalk and TreeWalk. During object enumeration the reader
would have had to load the object for the RevWalk, and may chose
to cache object position data internally so it can later be reused
and fed into the ObjectToPack instance supplied to the PackWriter.
Since a reader is not thread-safe, and is scoped to this PackWriter
and its internal ObjectWalk, its a great place for the database to
perform caching, if any.
Right now this change goes a bit backwards by changing what should
be generic ObjectToPack references inside of PackWriter to the very
PackFile specific LocalObjectToPack subclass. We will correct these
in a later commit as we start to refine what the ObjectToPack API
will eventually look like in order to better support the PackWriter.
Change-Id: I9f047d26b97e46dee3bc0ccb4060bbebedbe8ea9
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java index afc7f7186a..cf5bce73c0 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/WindowCursor.java @@ -50,6 +50,7 @@ import java.util.zip.DataFormatException; import java.util.zip.Inflater; import org.eclipse.jgit.errors.MissingObjectException; +import org.eclipse.jgit.revwalk.RevObject; /** Active handle to a ByteWindow. */ final class WindowCursor extends ObjectReader { @@ -81,6 +82,11 @@ final class WindowCursor extends ObjectReader { return ldr; } + @Override + public LocalObjectToPack newObjectToPack(RevObject obj) { + return new LocalObjectToPack(obj); + } + void openObjectInAllPacks(AnyObjectId otp, Collection<PackedObjectLoader> reuseLoaders) throws IOException { db.openObjectInAllPacks(reuseLoaders, this, otp); |