summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorDave Borowitz <dborowitz@google.com>2016-06-01 17:07:19 -0400
committerDave Borowitz <dborowitz@google.com>2016-06-01 17:21:33 -0400
commit0d6ba84065b3281d2e3c3cf8251b7679cbc83488 (patch)
tree5492f830d9a7362ada48755d115cdc28d64201fa /org.eclipse.jgit.test
parent525baa1213097aa8635d846ce024635b1f33931a (diff)
downloadjgit-0d6ba84065b3281d2e3c3cf8251b7679cbc83488.tar.gz
jgit-0d6ba84065b3281d2e3c3cf8251b7679cbc83488.zip
DfsInserter: Optionally disable existing object check
When using a DfsInserter for high-throughput insertion of many objects (analogous to git-fast-import), we don't necessarily want to do a random object lookup for each. It'll be faster from the inserter's perspective to insert the duplicate objects and let a later GC handle the deduplication. Change-Id: Ic97f5f01657b4525f157e6df66023f1f07fc1851
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
index 74790f72c5..b738f7ea74 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/dfs/DfsInserterTest.java
@@ -219,6 +219,37 @@ public class DfsInserterTest {
assertTrue(pack_sources.contains(PackSource.INSERT));
}
+ @Test
+ public void testNoCheckExisting() throws IOException {
+ byte[] contents = Constants.encode("foo");
+ ObjectId fooId;
+ try (ObjectInserter ins = db.newObjectInserter()) {
+ fooId = ins.insert(Constants.OBJ_BLOB, contents);
+ ins.flush();
+ }
+ assertEquals(1, db.getObjectDatabase().listPacks().size());
+
+ try (ObjectInserter ins = db.newObjectInserter()) {
+ ((DfsInserter) ins).checkExisting(false);
+ assertEquals(fooId, ins.insert(Constants.OBJ_BLOB, contents));
+ ins.flush();
+ }
+ assertEquals(2, db.getObjectDatabase().listPacks().size());
+
+ // Verify that we have a foo in both INSERT packs.
+ DfsReader reader = new DfsReader(db.getObjectDatabase());
+ DfsPackFile packs[] = db.getObjectDatabase().getPacks();
+
+ assertEquals(2, packs.length);
+ DfsPackFile p1 = packs[0];
+ assertEquals(PackSource.INSERT, p1.getPackDescription().getPackSource());
+ assertTrue(p1.hasObject(reader, fooId));
+
+ DfsPackFile p2 = packs[1];
+ assertEquals(PackSource.INSERT, p2.getPackDescription().getPackSource());
+ assertTrue(p2.hasObject(reader, fooId));
+ }
+
private static String readString(ObjectLoader loader) throws IOException {
return RawParseUtils.decode(readStream(loader));
}