diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-07-08 17:14:45 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-07-09 15:17:26 -0700 |
commit | 2f93a09dd10696b6388a0fcb4099341ccef05169 (patch) | |
tree | e118e14e88eb9afeb22384f9f91d2b6819c098a7 | |
parent | c20daa73146a3c385f4fed237708c4a7d28d8745 (diff) | |
download | jgit-2f93a09dd10696b6388a0fcb4099341ccef05169.tar.gz jgit-2f93a09dd10696b6388a0fcb4099341ccef05169.zip |
Save object path hash codes during packing
We need to remember these so we can later cluster objects that
have similar file paths near each other as we search for deltas
between them.
Change-Id: I52cb1e4ca15c9c267a2dbf51dd0d795f885f4cf8
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java | 11 | ||||
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java | 24 |
2 files changed, 30 insertions, 5 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java index 773ce44fd5..cad3aaeec7 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/ObjectToPack.java @@ -83,6 +83,9 @@ public class ObjectToPack extends PackedObjectInfo { */ private int flags; + /** Hash of the object's tree path. */ + private int pathHash; + /** * Construct for the specified object id. * @@ -222,6 +225,14 @@ public class ObjectToPack extends PackedObjectInfo { setCRC(weight); } + int getPathHash() { + return pathHash; + } + + void setPathHash(int hc) { + pathHash = hc; + } + /** * Remember a specific representation for reuse at a later time. * <p> diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java index 2fecc68758..5ecef832a9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/pack/PackWriter.java @@ -181,7 +181,7 @@ public class PackWriter { private final ObjectIdSubclassMap<ObjectToPack> objectsMap = new ObjectIdSubclassMap<ObjectToPack>(); // edge objects for thin packs - private final ObjectIdSubclassMap<ObjectId> edgeObjects = new ObjectIdSubclassMap<ObjectId>(); + private final ObjectIdSubclassMap<ObjectToPack> edgeObjects = new ObjectIdSubclassMap<ObjectToPack>(); private int compressionLevel; @@ -813,11 +813,11 @@ public class PackWriter { RevObject o; while ((o = walker.next()) != null) { - addObject(o); + addObject(o, 0); countingMonitor.update(1); } while ((o = walker.nextObject()) != null) { - addObject(o); + addObject(o, walker.getPathHashCode()); countingMonitor.update(1); } countingMonitor.endTask(); @@ -837,9 +837,21 @@ public class PackWriter { */ public void addObject(final RevObject object) throws IncorrectObjectTypeException { + addObject(object, 0); + } + + private void addObject(final RevObject object, final int pathHashCode) + throws IncorrectObjectTypeException { if (object.has(RevFlag.UNINTERESTING)) { - edgeObjects.add(object); - thin = true; + switch (object.getType()) { + case Constants.OBJ_TREE: + case Constants.OBJ_BLOB: + ObjectToPack otp = new ObjectToPack(object); + otp.setPathHash(pathHashCode); + edgeObjects.add(otp); + thin = true; + break; + } return; } @@ -848,6 +860,8 @@ public class PackWriter { otp = reuseSupport.newObjectToPack(object); else otp = new ObjectToPack(object); + otp.setPathHash(pathHashCode); + try { objectsLists[object.getType()].add(otp); } catch (ArrayIndexOutOfBoundsException x) { |