Package dovetaildb.bagindex.BlueSteelBagIndex

Examples of dovetaildb.bagindex.BlueSteelBagIndex.ProbabilisticBalancingPolicy


    nodes.add(new MemoryPostingNode(7L, new ArrayBytes(new byte[]{77})));
    nodes.add(new MemoryPostingNode(8L, new ArrayBytes(new byte[]{88})));
    nodes.add(new MemoryPostingNode(9L, new ArrayBytes(new byte[]{99})));
    nodes.add(new MemoryPostingNode(10L,new ArrayBytes(new byte[]{00})));
    SegmentPush push = new SegmentPush(nodes);
    o=BlueSteelBagIndex.balanceSegmentPush(push, new ProbabilisticBalancingPolicy(4, 0.5f, 0.0f));
    compareSegments(o, new long[]{1,2,3,4,5,6,7,8,9,10});
    assertEquals(10, o.getCount());
    assertEquals(3, o.getTopLevelCount());
    o=BlueSteelBagIndex.balanceSegmentPush(push, new ProbabilisticBalancingPolicy(2, 0.5f, 0.0f));
    compareSegments(o, new long[]{1,2,3,4,5,6,7,8,9,10});
    assertEquals(10, o.getCount());
    assertEquals(2, o.getTopLevelCount());
  }
View Full Code Here


    SegmentPush push = new SegmentPush(nodes);
    ArrayList<EditRec> edits = new ArrayList<EditRec>();
    edits.add(new EditRec(2L, new ArrayBytes(new byte[]{22})));
    push = BlueSteelBagIndex.spliceEditsIntoSegmentPush(edits, push);
    push.getTextDisplay();
    push = BlueSteelBagIndex.balanceSegmentPush(push, new ProbabilisticBalancingPolicy(5, 0.5f, 0.0f));
    push.getTextDisplay();
    push.getTextDisplay();
  }
View Full Code Here

   
    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());
View Full Code Here

    edits = new ArrayList<EditRec>();
    edits.add(new EditRec(1, bytes("a"), false));
    edits.add(new EditRec(1, bytes("brother:yes"), false));
    edits.add(new EditRec(1, bytes("name:phil"), false));

    root=BlueSteelBagIndex.applyEditsToTokenTable(edits, root, new ProbabilisticBalancingPolicy(10, 0.5f, 0.0f), 2); // "2" here means we get three tiers

    SlicedBytes sb;
    TokenRec tr;
    sb = new SlicedBytes(ArrayBytes.fromString("brot"), 0, 4);
    tr = root.descend(sb);
View Full Code Here

TOP

Related Classes of dovetaildb.bagindex.BlueSteelBagIndex.ProbabilisticBalancingPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.