summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.test
diff options
context:
space:
mode:
authorChris Aniszczyk <caniszczyk@gmail.com>2010-11-13 12:37:30 -0500
committerCode Review <codereview-daemon@eclipse.org>2010-11-13 12:37:30 -0500
commit1b3abe75f8469402b4a4c7d38dc6930946729d0a (patch)
tree86d89d940b13c882aabc8b1c3eadd42255982137 /org.eclipse.jgit.test
parent9f2bde653ffbbc86351e81c3aaa5b010a71d997a (diff)
parent2b0df15f7f1bdcfc41349c478319fad50158c183 (diff)
downloadjgit-1b3abe75f8469402b4a4c7d38dc6930946729d0a.tar.gz
jgit-1b3abe75f8469402b4a4c7d38dc6930946729d0a.zip
Merge "Split note leaf buckets at 256 elements"
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r--org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
index f22b020989..d740ffaf15 100644
--- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
+++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/notes/NoteMapTest.java
@@ -47,6 +47,7 @@ import java.io.IOException;
import org.eclipse.jgit.junit.TestRepository;
import org.eclipse.jgit.lib.CommitBuilder;
+import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.MutableObjectId;
import org.eclipse.jgit.lib.ObjectInserter;
import org.eclipse.jgit.lib.ObjectReader;
@@ -361,6 +362,46 @@ public class NoteMapTest extends RepositoryTestCase {
.forPath(reader, "zoo-animals.txt", n.getTree()).getObjectId(0));
}
+ public void testLeafSplitsWhenFull() throws Exception {
+ RevBlob data1 = tr.blob("data1");
+ MutableObjectId idBuf = new MutableObjectId();
+
+ RevCommit r = tr.commit() //
+ .add(data1.name(), data1) //
+ .create();
+ tr.parseBody(r);
+
+ NoteMap map = NoteMap.read(reader, r);
+ for (int i = 0; i < 254; i++) {
+ idBuf.setByte(Constants.OBJECT_ID_LENGTH - 1, i);
+ map.set(idBuf, data1);
+ }
+
+ RevCommit n = commitNoteMap(map);
+ TreeWalk tw = new TreeWalk(reader);
+ tw.reset(n.getTree());
+ while (tw.next())
+ assertFalse("no fan-out subtree", tw.isSubtree());
+
+ for (int i = 254; i < 256; i++) {
+ idBuf.setByte(Constants.OBJECT_ID_LENGTH - 1, i);
+ map.set(idBuf, data1);
+ }
+ idBuf.setByte(Constants.OBJECT_ID_LENGTH - 2, 1);
+ map.set(idBuf, data1);
+ n = commitNoteMap(map);
+
+ // The 00 bucket is fully split.
+ String path = fanout(38, idBuf.name());
+ tw = TreeWalk.forPath(reader, path, n.getTree());
+ assertNotNull("has " + path, tw);
+
+ // The other bucket is not.
+ path = fanout(2, data1.name());
+ tw = TreeWalk.forPath(reader, path, n.getTree());
+ assertNotNull("has " + path, tw);
+ }
+
public void testRemoveDeletesTreeFanout2_38() throws Exception {
RevBlob a = tr.blob("a");
RevBlob data1 = tr.blob("data1");