コード例 #1
0
ファイル: getTimes.go プロジェクト: rhino1998/cluster
func main() {
	
	c := runtime.NumCPU() * 2
	runtime.GOMAXPROCS(1)
	conn := client.MustConn("")
	argsWithoutProg := os.Args[1:]
	var i info
	common.MustJSONDecode([]byte(argsWithoutProg[0]), &i)
	r := everything.RGet(i.rideID)
	fmt.Println(r.Name)
	p, _ := everything.GetG(append([]byte{0},[]byte{0}[0],[]byte{0}[0]))
	count := 0
	t := true
	fmt.Print("[")
	for i := r.CurTrip; i < len(r.Times); i++ {
		if r.Capacity - r.Capacities[i] > 2 {
			a := r.GetTimeRange(i)
			for j := 0; j < len(p.Times); j++ {
				if between(a[0], a[1], p.Times[j][0], p.Times[j][1]) {
					t = false
				}
			}
			if t {
				conn.Put([]byte(strconv.Itoa(i)),common.MustJSONEncode(p.Times[j]))
				conn.Put([]byte(strconv.Itoa(i) + "r"),common.MustJSONEncode(r.K)
				fmt.Print("{" + r.Name + ":" + " [" + getTime(p.Times[j][0]) + "," + getTime(p.Times[j][1]) + "],id:" + strconv.Itoa(i) +  "},")
				count += 1
			}
		}
		if count == 3 { break }
	}
	fmt.Print("]")


}
コード例 #2
0
ファイル: test.go プロジェクト: Smedira/GO-Amusement
func main() {
	// connect to the default local server
	conn := client.MustConn("localhost:9191")
	// create a user

	// try to fetch the user again
	data, _ := conn.Get(murmur.HashString("hi"))
	var found []int
	// to unserialize it
	common.MustJSONDecode(data, &found)
	fmt.Printf("stored and found ", found)
}
コード例 #3
0
ファイル: save.go プロジェクト: rhino1998/cluster
func main() {
	//c := runtime.NumCPU() * 2
	runtime.GOMAXPROCS(1)
	conn := client.MustConn("")
	argsWithoutProg := os.Args[1:]
	var i info
	common.MustJSONDecode([]byte(argsWithoutProg[0]), &i)
	s := strings.Split(string(i.times), "id:")[1]
	s = strings.Split(s, "}")[0]
	var time []int
	v, _ := conn.Get([]byte(s))
	common.MustJSONDecode(v, &time)
	p, _ := everything.GetG(append([]byte{0}, []byte{0}[0], []byte{0}[0]))
	p.Times = append(p.Times, time)

	var ri []byte
	v, _ = conn.Get([]byte(s + "r"))
	common.MustJSONDecode(v, &ri)
	p.AppointRide = append(p.AppointRide, ri)

	p.Save()
}