Ejemplo n.º 1
0
 /** ************************ TEST MUTATION ******************************************* */
 @Test
 public void testOversizedMiddleInsert() {
   TreeSet<Integer> canon = new TreeSet<>();
   for (int i = 0; i < 10000000; i++) canon.add(i);
   Object[] btree =
       BTree.build(Arrays.asList(Integer.MIN_VALUE, Integer.MAX_VALUE), UpdateFunction.noOp());
   btree = BTree.update(btree, naturalOrder(), canon, UpdateFunction.<Integer>noOp());
   canon.add(Integer.MIN_VALUE);
   canon.add(Integer.MAX_VALUE);
   assertTrue(BTree.isWellFormed(btree, naturalOrder()));
   testEqual("Oversize", BTree.iterator(btree), canon.iterator());
 }
Ejemplo n.º 2
0
 @Test
 public void testSlicingAllSmallTrees() throws ExecutionException, InterruptedException {
   Object[] cur = BTree.empty();
   TreeSet<Integer> canon = new TreeSet<>();
   // we set FAN_FACTOR to 4, so 128 items is four levels deep, three fully populated
   for (int i = 0; i < 128; i++) {
     String id = String.format("[0..%d)", canon.size());
     log("Testing " + id);
     Futures.allAsList(testAllSlices(id, cur, canon)).get();
     Object[] next = null;
     while (next == null)
       next = BTree.update(cur, naturalOrder(), Arrays.asList(i), SPORADIC_ABORT);
     cur = next;
     canon.add(i);
   }
 }
Ejemplo n.º 3
0
 private static void log(String formatstr, Object... args) {
   args = Arrays.copyOf(args, args.length + 1);
   System.arraycopy(args, 0, args, 1, args.length - 1);
   args[0] = System.currentTimeMillis();
   System.out.printf("%tT: " + formatstr + "\n", args);
 }