edits = new ArrayList<EditRec>();
edits.add(new EditRec(1, bytes("age:13"), false));
edits.add(new EditRec(1, bytes("name:phil"), false));
o=BlueSteelBagIndex.applyEditsToTokenTable(edits, root, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 0);
i=o.getTokenRecs();
assertTrue(i.hasNext());
tr = i.next();
assertEquals('a', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1});
assertTrue(i.hasNext());
tr = i.next();
assertEquals('n', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1});
assertFalse(i.hasNext());
edits = new ArrayList<EditRec>();
edits.add(new EditRec(2, bytes("age:14"), false));
edits.add(new EditRec(2, bytes("name:joe"), false));
o=BlueSteelBagIndex.applyEditsToTokenTable(edits, o, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 0);
// System.out.println(o);
i=o.getTokenRecs();
assertTrue(i.hasNext());
tr = i.next();
assertEquals('a', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1,2});
assertTrue(i.hasNext());
tr = i.next();
assertEquals('n', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1,2});
assertFalse(i.hasNext());
// test mutilevel stuff
edits = new ArrayList<EditRec>();
edits.add(new EditRec(3, bytes("age:14"), false));
edits.add(new EditRec(3, bytes("foo:yes"), false));
o=BlueSteelBagIndex.applyEditsToTokenTable(edits, o, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 1);
i=o.getTokenRecs();
assertTrue(i.hasNext());
tr = i.next();
assertEquals('a', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1,2,3});
subi = tr.tokenTable.getTokenRecs();
assertTrue(subi.hasNext());
tr = subi.next();
assertFalse(subi.hasNext());
assertEquals('g', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{3});
assertNull(tr.tokenTable);
assertTrue(i.hasNext());
tr = i.next();
assertEquals('f', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{3});
subi = tr.tokenTable.getTokenRecs();
assertTrue(subi.hasNext());
tr = subi.next();
assertFalse(subi.hasNext());
assertEquals('o', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{3});
assertNull(tr.tokenTable);
assertTrue(i.hasNext());
tr = i.next();
assertEquals('n', tr.getToken());
compareSegments(tr.getSegmentPush(), new long[]{1,2});
assertNull(tr.tokenTable);
assertFalse(i.hasNext());
// test deletions
edits = new ArrayList<EditRec>();
edits.add(new EditRec(1, bytes("age:13"), true));
edits.add(new EditRec(3, bytes("age:14"), true));
edits.add(new EditRec(3, bytes("foo:yes"), true));
o=BlueSteelBagIndex.applyEditsToTokenTable(edits, o, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 1);
i=o.getTokenRecs();
assertTrue(i.hasNext());
tr = i.next();
assertEquals('a', tr.getToken());