public void test_onePrefix(){
  final BTree btree;
{
    IndexMetadata md=new IndexMetadata(UUID.randomUUID());
    md.setTupleSerializer(tupleSer);
    btree=BTree.create(new SimpleMemoryRawStore(),md);
  }
  btree.insert("Bryan","Bryan");
  btree.insert("Bryan Thompson","Bryan Thompson");
  btree.insert("Mike","Mike");
  btree.insert("Mike Personick","Mike Personick");
  btree.insert("Michael","Michael");
  btree.insert("Michael Personick","Michael Personick");
  btree.dump(Level.DEBUG,System.err);
{
    final ITupleIterator<String> itr=btree.rangeIterator(null,null,0,IRangeQuery.DEFAULT | IRangeQuery.CURSOR,new PrefixFilter<String>(asPrefixKey("Mike")));
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Mike"),itr.next());
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Mike Personick"),itr.next());
    assertFalse(itr.hasNext());
  }
{
    final ITupleIterator<String> itr=btree.rangeIterator(null,null,0,IRangeQuery.DEFAULT | IRangeQuery.CURSOR,new PrefixFilter<String>(asPrefixKey("Bryan")));
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Bryan"),itr.next());
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Bryan Thompson"),itr.next());
    assertFalse(itr.hasNext());
  }
{
    final ITupleIterator<String> itr=btree.rangeIterator(null,null,0,IRangeQuery.DEFAULT | IRangeQuery.CURSOR,new PrefixFilter<String>(asPrefixKey("Mi")));
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Michael"),itr.next());
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Michael Personick"),itr.next());
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Mike"),itr.next());
    assertTrue(itr.hasNext());
    AbstractTupleCursorTestCase.assertEquals(newTestTuple("Mike Personick"),itr.next());
    assertFalse(itr.hasNext());
  }
{
    final ITupleIterator<String> itr=btree.rangeIterator(null,null,0,IRangeQuery.DEFAULT | IRangeQuery.CURSOR,new PrefixFilter<String>(asPrefixKey("Ma")));
    assertFalse(itr.hasNext());
  }
}

public void test_onePrefix ( ) { final BTree btree ; { IndexMetadata md = new IndexMetadata ( UUID . randomUUID ( ) ) ; md . setTupleSerializer ( tupleSer ) ; btree = BTree . create ( new SimpleMemoryRawStore ( ) , md ) ; } btree . insert ( "Bryan" , "Bryan" ) ; btree . insert ( "Bryan Thompson" , "Bryan Thompson" ) ; btree . insert ( "Mike" , "Mike" ) ; btree . insert ( "Mike Personick" , "Mike Personick" ) ; btree . insert ( "Michael" , "Michael" ) ; btree . insert ( "Michael Personick" , "Michael Personick" ) ; btree . dump ( Level . DEBUG , System . err ) ; { final ITupleIterator < String > itr = btree . rangeIterator ( null , null , 0 , IRangeQuery . DEFAULT | IRangeQuery . CURSOR , new PrefixFilter < String > ( asPrefixKey ( "Mike" ) ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Mike" ) , itr . next ( ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Mike Personick" ) , itr . next ( ) ) ; assertFalse ( itr . hasNext ( ) ) ; } { final ITupleIterator < String > itr = btree . rangeIterator ( null , null , 0 , IRangeQuery . DEFAULT | IRangeQuery . CURSOR , new PrefixFilter < String > ( asPrefixKey ( "Bryan" ) ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Bryan" ) , itr . next ( ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Bryan Thompson" ) , itr . next ( ) ) ; assertFalse ( itr . hasNext ( ) ) ; } { final ITupleIterator < String > itr = btree . rangeIterator ( null , null , 0 , IRangeQuery . DEFAULT | IRangeQuery . CURSOR , new PrefixFilter < String > ( asPrefixKey ( "Mi" ) ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Michael" ) , itr . next ( ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Michael Personick" ) , itr . next ( ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Mike" ) , itr . next ( ) ) ; assertTrue ( itr . hasNext ( ) ) ; AbstractTupleCursorTestCase . assertEquals ( newTestTuple ( "Mike Personick" ) , itr . next ( ) ) ; assertFalse ( itr . hasNext ( ) ) ; } { final ITupleIterator < String > itr = btree . rangeIterator ( null , null , 0 , IRangeQuery . DEFAULT | IRangeQuery . CURSOR , new PrefixFilter < String > ( asPrefixKey ( "Ma" ) ) ) ; assertFalse ( itr . hasNext ( ) ) ; } }
unit tests with a single prefix .
