Exemplo n.º 1
0
func network_test() {
	listen_addr := os.Args[1]
	server_addr := ""
	if len(os.Args) > 2 {
		server_addr = os.Args[2]
	}

	server := tnydb.NewServer("Filesystem", listen_addr, server_addr)
	server.Serve()
}
Exemplo 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")
}
Exemplo n.º 3
0
func server_read_test() {

	fmt.Printf("\n\nReading...\n")
	server := tnydb.NewServer("Filesystem", os.Args[1], os.Args[2])

	db, _ := server.LoadDatabase("tester")

	fmt.Printf("Distributing pages...\n")
	server.DistributePages()

	fmt.Printf("Rows: %d, querying:\n", db.Tables["quotes"].Rows())

	// db.Tables["quotes"].Print(100)

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

}
Exemplo n.º 4
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))

}