func Load(N, M0, M1 int) HiddenMM { pool := dbconn.Pool connection := pool.Get() A := make([][]float64, N, N) for i := range A { loadedA, err := redis.Values(connection.Do("LRANGE", DBA+Int2Str(i), 0, -1)) if err != nil { fmt.Println("Error while reading A[", i, "]") os.Exit(1) } A[i] = make([]float64, N, N) for j := range A[i] { A[i][j], _ = redis.Float64(loadedA[j], err) } } B := make([][][]float64, N, N) for i := range B { B[i] = make([][]float64, M0, M0) for j := range B[i] { loadedB, err := redis.Values(connection.Do("LRANGE", DBB+Int2Str(i)+FS+Int2Str(j), 0, -1)) if err != nil { fmt.Println("Error while reading B[", i, "][", j, "]") os.Exit(1) } B[i][j] = make([]float64, M1, M1) for k := range B[i][j] { B[i][j][k], _ = redis.Float64(loadedB[j], err) } } } loadedPi, err := redis.Values(connection.Do("LRANGE", DBPI, 0, -1)) if err != nil { fmt.Println("Error while reading Pi") os.Exit(1) } Pi := make([]float64, N, N) for i := range Pi { Pi[i], _ = redis.Float64(loadedPi[i], err) } connection.Close() return HiddenMM{N, M0, M1, A, B, Pi} }
func GetWordCount(word string) int { pool := dbconn.Pool connection := pool.Get() reply, err := redis.Values(connection.Do("GET", DBDICTPREFIX+word)) if err != nil { fmt.Println("DB: Error reading word", word) os.Exit(1) } connection.Close() count, _ := redis.Int(reply, err) return count }