Package dovetaildb.bagindex.BlueSteelBagIndex

Examples of dovetaildb.bagindex.BlueSteelBagIndex.MemoryTokenTable


    TokenRec tr;
    Iterator<TokenRec> i;
    Iterator<TokenRec> subi;
   
    ArrayList<TokenRec> tokenRecs = new ArrayList<TokenRec>();
    TokenTable root = new MemoryTokenTable(ArrayBytes.EMPTY_BYTES, tokenRecs);
   
    edits = new ArrayList<EditRec>();
    edits.add(new EditRec(1, bytes("age:13"), false));
    edits.add(new EditRec(1, bytes("name:phil"), false));
View Full Code Here


  }
 
  public void testDescend() {
    List<EditRec> edits;
    ArrayList<TokenRec> tokenRecs = new ArrayList<TokenRec>();
    TokenTable root = new MemoryTokenTable(ArrayBytes.EMPTY_BYTES, tokenRecs);
   
    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);
    assertEquals(3, sb.getSlicePosition());
    assertEquals('o', (char)tr.token);
   
    sb = new SlicedBytes(ArrayBytes.fromString("bro"), 0, 3);
    tr = root.descend(sb);
    assertEquals(3, sb.getSlicePosition());
    assertEquals('o', (char)tr.token);
    assertEquals(0, sb.getLength());
   
    sb = new SlicedBytes(ArrayBytes.fromString(""), 0, 0);
    tr = root.descend(sb);
    assertNull(tr);
    assertEquals(0, sb.getLength());
   
    sb = new SlicedBytes(ArrayBytes.fromString("a"), 0, 1);
    tr = root.descend(sb);
    assertEquals(1, sb.getSlicePosition());
    assertEquals('a', (char)tr.token);
    assertEquals(0, sb.getLength());
   
    sb = new SlicedBytes(ArrayBytes.fromString("brXX"), 0, 4);
    tr = root.descend(sb);
    assertNull(tr);
    assertTrue(sb.getLength() > 0);
   
    sb = new SlicedBytes(ArrayBytes.fromString("aXXX"), 0, 4);
    tr = root.descend(sb);
    assertNull(tr);
    assertTrue(sb.getLength() > 0);
   
    sb = new SlicedBytes(ArrayBytes.fromString("XXXX"), 0, 4);
    tr = root.descend(sb);
    assertNull(tr);
    assertTrue(sb.getLength() > 0);
   
  }
View Full Code Here

TOP

Related Classes of dovetaildb.bagindex.BlueSteelBagIndex.MemoryTokenTable

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.