예제 #1
0
func BenchmarkBPlusTree(b *testing.B) {
	t := bplus.NewTree(bytes.Compare)
	for i := 0; i < b.N; i++ {
		x := bpt.UUID()
		t.Set(x, x)
	}
}
예제 #2
0
func main() {

	bpt := bplus.NewTree(cmp)
	defer bpt.Close()

	bpt.Set([]byte("foo"), []byte("bar"))
	fmt.Println("Tree size:", bpt.Len())

	fmt.Print("\n\nPress any key to continue...")
	bufio.NewReader(os.Stdin).ReadBytes('\n')

}
예제 #3
0
func main() {

	bpt := bplus.NewTree(cmp)
	defer bpt.Close()

	fmt.Printf("adding %d entries to btree...\n", count)
	ts := time.Now().Unix()
	for i := 0; i < count; i++ {
		bpt.Set(makeBytes(10), makeBytes(50))
	}
	fmt.Printf("Finished adding %d entries. Took %dms\n", count, (time.Now().Unix() - ts))
	fmt.Println("B+Tree count:", bpt.Len())

	/*
		fmt.Println("Clearing tree, adding a few entries, and seeking first...")
		bpt.Clear()
		bpt.Set([]byte("g"), []byte("gg"))
		bpt.Set([]byte("h"), []byte("hh"))
		bpt.Set([]byte("i"), []byte("ii"))
		bpt.Set([]byte("a"), []byte("aa"))
		bpt.Set([]byte("f"), []byte("ff"))
		bpt.Set([]byte("k"), []byte("kk"))
		bpt.Set([]byte("j"), []byte("jj"))
		bpt.Set([]byte("a"), []byte("second a"))
		bpt.Set([]byte("e"), []byte("ee"))
		bpt.Set([]byte("b"), []byte("bb"))
		bpt.Set([]byte("1"), []byte("one"))
		bpt.Set([]byte("d"), []byte("dd"))
		bpt.Set([]byte("c"), []byte("cc"))
		enum, err := bpt.SeekFirst()
		defer enum.Close()
		if err != nil {
			log.Fatal(err)
		}
		fmt.Println("Enumerating leaf nodes in lexigraphical order...")
		for {
			k, v, err := enum.Next()
			if err != nil {
				break
			}
			fmt.Printf("Key: %s, Val: %s\n", k, v)
		}
		fmt.Println("Done")
	*/

	fmt.Print("\n\nPress any key to continue...")
	bufio.NewReader(os.Stdin).ReadBytes('\n')

}