mirror of
https://github.com/versity/scoutfs-go.git
synced 2026-01-05 11:24:54 +00:00
add query totals by group
This commit is contained in:
@@ -4,6 +4,14 @@
|
||||
// that can be found in the LICENSE file in the root of the source
|
||||
// tree.
|
||||
|
||||
// This example returns the values of a "group" of totl counts/values
|
||||
// given a 2 uint64 id group tuple. Or it will return the single value
|
||||
// for a unique 3 uint64 id triple.
|
||||
|
||||
// id1 id2 id3
|
||||
// |--group--|
|
||||
// |--specific id---|
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
@@ -16,8 +24,9 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) != 5 || os.Args[1] == "-h" {
|
||||
fmt.Fprintln(os.Stderr, "usage:", os.Args[0], "<scoutfs mount point> <id1> <id2> <id3>")
|
||||
if (len(os.Args) != 4 && len(os.Args) != 5) || os.Args[1] == "-h" {
|
||||
fmt.Fprintln(os.Stderr, "usage:", os.Args[0],
|
||||
"<scoutfs mount point> <id1> <id2> or <scoutfs mount point> <id1> <id2> <id3>")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -35,16 +44,33 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatalln("error parsing id2:", err)
|
||||
}
|
||||
|
||||
if len(os.Args) == 4 {
|
||||
tg := scoutfs.NewTotalsGroup(f, u1, u2, 10)
|
||||
for {
|
||||
ttls, err := tg.Next()
|
||||
if err != nil {
|
||||
log.Fatalln("error read totals:", err)
|
||||
}
|
||||
if ttls == nil {
|
||||
break
|
||||
}
|
||||
for _, t := range ttls {
|
||||
fmt.Println("id:", t.ID[2], "xattrs match:", t.Count, "total value:", t.Total)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
u3, err := strconv.ParseUint(os.Args[4], 10, 64)
|
||||
if err != nil {
|
||||
log.Fatalln("error parsing id3:", err)
|
||||
log.Fatalln("error parsing id2:", err)
|
||||
}
|
||||
|
||||
t, err := scoutfs.ReadXattrTotals(f, u1, u2, u3)
|
||||
if err != nil {
|
||||
log.Fatalln("error read totals:", err)
|
||||
log.Fatalln("error reading totals:", err)
|
||||
}
|
||||
|
||||
fmt.Println("xattrs match: ", t.Count)
|
||||
fmt.Println("total value : ", t.Total)
|
||||
fmt.Println("Count", t.Count)
|
||||
fmt.Println("Total", t.Total)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user