package com.github.davidmoten.logan;

import java.io.File;

import org.junit.Test;

import com.github.davidmoten.bplustree.BPlusTree;

public class DataPersisted2Test {

    @Test
    public void test() {
        BPlusTree<IntWithTimestamp, PropertyWithTimestamp> tree = create();
        tree.insert(new IntWithTimestamp("hello".hashCode(), 100L),
                new PropertyWithTimestamp("hello", 1.1, 100L));
        tree.insert(new IntWithTimestamp("there".hashCode(), 200L),
                new PropertyWithTimestamp("there", 1.2, 200L));
        tree.insert(new IntWithTimestamp("hello2".hashCode(), 300L),
                new PropertyWithTimestamp("hello2", 1.3, 300L));
        tree.print();
        Iterable<PropertyWithTimestamp> it = tree.find(new IntWithTimestamp("hello".hashCode(), 0),
                new IntWithTimestamp("hello".hashCode(), 1000));
        it.forEach(System.out::println);

    }

    private BPlusTree<IntWithTimestamp, PropertyWithTimestamp> create() {
        new File("target/testbp").mkdirs();
        return BPlusTree.file() //
                .directory("target/testbp") //
                .maxKeys(12) //
                .segmentSizeMB(1) //
                .keySerializer(IntWithTimestamp.SERIALIZER) //
                .valueSerializer(PropertyWithTimestamp.SERIALIZER) //
                .naturalOrder();
    }

}
@@ -42,20 +42,163 @@
 ort 
-java.io.File
+static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0A%0Aimport java.io.File;%0Aimport java.util.Iterator;%0Aimport java.util.TreeSet
 ;%0A%0Ai
@@ -854,11 +854,11 @@
 tera
-ble
+tor
 %3CPro
@@ -892,16 +892,36 @@
 ee.find(
+ //%0A                
 new IntW
@@ -956,16 +956,19 @@
 e(), 0),
+ //
 %0A       
@@ -1027,20 +1027,530 @@
 00))
-;%0A        it
+ //%0A                .iterator();%0A        assertEquals(100L, it.next().time);%0A        assertEquals(200L, it.next().time);%0A        assertEquals(300L, it.next().time);%0A        assertFalse(it.hasNext());%0A    %7D%0A%0A    @Test%0A    public void testTreeSet() %7B%0A        TreeSet%3CIntWithTimestamp%3E set = new TreeSet%3C%3E();%0A        set.add(new IntWithTimestamp(%22hello%22.hashCode(), 100L));%0A        set.add(new IntWithTimestamp(%22there%22.hashCode(), 200L));%0A        set.add(new IntWithTimestamp(%22hello2%22.hashCode(), 300L));%0A        set.stream()
 .for
@@ -1576,17 +1576,16 @@
 intln);%0A
-%0A
     %7D%0A%0A 

add tests