Esempio n. 1
0
func join_test() {
	server := tnydb.NewServer("filesystem", os.Args[1], os.Args[2])
	db := server.NewDatabase("tester")

	a, err := tnydb.ReadCSV(db, "simple_test.csv", "a", 1000000)

	if err == nil {
		b, err := tnydb.ReadCSV(db, "simple_test_2.csv", "b", 1000000)
		if err == nil {
			tnydb.ProcessJoin(db, a, b, a.ColumnsMap["Code"], b.ColumnsMap["Code"]).Print(100)
		}
	}

	fmt.Println("===========WRITE TEST===============")

	page := a.Columns[0].Pages[0]
	fmt.Println(page.BitString(10))

	// Write the first page of data from simple_test
	pageDef := tnydb.TnyPageDefinition{DataPath: "output.page", Loaded: false}
	fo, err := os.Create(pageDef.DataPath)
	if err != nil {
		panic(err)
	}

	writer := bufio.NewWriter(fo)
	page.WritePage(writer)
	writer.Flush()
	fo.Close()

	// Now lets jsut see if we can actually read it yeah?

	fmt.Println("===========READ TEST===============")
	fi, err := os.Open("output.page")
	reader := bufio.NewReader(fi)

	readPage := tnydb.ReadPage(reader, a.Columns[0], &pageDef)

	fmt.Println(readPage.BitString(10))

}
Esempio n. 2
0
func server_write_test() {

	filename := "/home/tez/data/tnydb/quotes.csv"
	server := tnydb.NewServer("Filesystem", os.Args[1], os.Args[2])
	db := server.NewDatabase("tester")

	tnydb.ReadCSV(db, filename, "quotes", -1)

	db.WriteDefinition()
	db.WriteDirtyPages()

	sexp_test(db, "quotes[Date=\"2012-03-21\"]|SUM(Volume),Code")
}