Grouping + Aggregation

This commit is contained in:
cdricms
2024-04-28 21:05:13 +02:00
parent e43c4b129c
commit 081a914560
2 changed files with 168 additions and 15 deletions

36
main.go
View File

@@ -1,12 +1,9 @@
package main
import (
// "encoding/csv"
"fmt"
// "os"
"git.cems.dev/cdricms/bdooc/proto"
// "git.cems.dev/cdricms/bdooc/parsing"
)
func main() {
@@ -25,20 +22,31 @@ func main() {
// }
// data := parsing.MapToProto(employees)
// data.SaveToFile("employee_data.bin")
// data.SaveToFile("employee_data.bin")
// fmt.Println(employees[:10])
data, err := proto.LoadFromFile("employee_data.bin")
if err != nil {
fmt.Println(err)
}
data, err := proto.LoadFromFile("employee_data.bin")
if err != nil {
fmt.Println(err)
}
result, err := data.QueryEmployeesByColumn(proto.FieldYearsOfService, "2.48")
if err != nil {
fmt.Println(err)
}
// fmt.Println('F')
fmt.Println(result, len(result))
// _, err = data.QueryEmployeesByColumn(proto.FieldGender, "70")
// if err != nil {
// fmt.Println(err)
// }
r := proto.AggregateByColumn(data, proto.FieldRegion, func(ep proto.EmployeePList) float64 {
return proto.Max(ep, proto.FieldSalary)
})
fmt.Println(r)
r = proto.AggregateByColumn(data, proto.FieldRegion, func(ep proto.EmployeePList) float64 {
return proto.Min(ep, proto.FieldSalary)
})
fmt.Println(r)
// for key := range result {
// fmt.Println(key)
// }
}