summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-11-01 18:20:54 -0700
committerJonathan Tan <jonathantanmy@google.com>2017-11-10 15:41:31 -0800
commitc9d25505d835e073f35d4ba305346aca134e3d6b (patch)
tree0e4f32c4895b81c5e7957e57d703627b0b6a50bf
parentd3021788d25d9a6f88006238c7399c78314da2fb (diff)
downloadjgit-c9d25505d835e073f35d4ba305346aca134e3d6b.tar.gz
jgit-c9d25505d835e073f35d4ba305346aca134e3d6b.zip
BitmapWalker: do not revisit objects in bitmap
Currently, BitmapWalker walks through every object returned by the internal ObjectWalk, regardless of whether that object has already been marked in the bitmap. Set an object filter to ensure that only bitmap-unmarked objects are walked through. Change-Id: I22a8874b1e571df3c33643b365036d95f52fe7c7 Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java23
1 files changed, 22 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
index 787cf3588e..4f4de540ba 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/revwalk/BitmapWalker.java
@@ -50,12 +50,14 @@ import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.internal.revwalk.AddToBitmapFilter;
import org.eclipse.jgit.internal.revwalk.AddUnseenToBitmapFilter;
+import org.eclipse.jgit.lib.AnyObjectId;
+import org.eclipse.jgit.lib.BitmapIndex;
import org.eclipse.jgit.lib.BitmapIndex.Bitmap;
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder;
-import org.eclipse.jgit.lib.BitmapIndex;
import org.eclipse.jgit.lib.NullProgressMonitor;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.ProgressMonitor;
+import org.eclipse.jgit.revwalk.filter.ObjectFilter;
/**
* Helper class to do ObjectWalks with pack index bitmaps.
@@ -200,6 +202,7 @@ public final class BitmapWalker {
walker.setRevFilter(
new AddUnseenToBitmapFilter(seen, bitmapResult));
}
+ walker.setObjectFilter(new BitmapObjectFilter(bitmapResult));
while (walker.next() != null) {
// Iterate through all of the commits. The BitmapRevFilter does
@@ -224,4 +227,22 @@ public final class BitmapWalker {
return bitmapResult;
}
+
+ /**
+ * Filter that excludes objects already in the given bitmap.
+ */
+ static class BitmapObjectFilter extends ObjectFilter {
+ private final BitmapBuilder bitmap;
+
+ BitmapObjectFilter(BitmapBuilder bitmap) {
+ this.bitmap = bitmap;
+ }
+
+ @Override
+ public final boolean include(ObjectWalk walker, AnyObjectId objid)
+ throws MissingObjectException, IncorrectObjectTypeException,
+ IOException {
+ return !bitmap.contains(objid);
+ }
+ }
}