コード例 #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
ファイル: getRides.go プロジェクト: rhino1998/cluster
func main() {
	//c := runtime.NumCPU() * 2
	runtime.GOMAXPROCS(1)

	p, _ := everything.GetG(append([]byte{0}, []byte{0}[0], []byte{0}[0]))
	fmt.Print("[")
	for i := 0; i < len(p.Times); i++ {
		r := everything.RGet(p.AppointRide[i])
		a1 := getTime(p.Times[i][0])
		b1 := getTime(p.Times[i][1])
		s1 := "{" + r.Name + ": ["
		s2 := a1 + ","
		s3 := b1 + "]},"
		fmt.Print(s1 + s2 + s3)
	}
	fmt.Print("]")
}