forked from lomik/go-whisper
-
Notifications
You must be signed in to change notification settings - Fork 10
A whisper of many aggregation policies (with percentiles) #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
67dc1cb
mix: initial supports for a new aggregation policy: mix (with percent…
bom-d-van 4409fc4
mix: add some docs and fix Whisper.bufferSize
bom-d-van 23dc23b
mix: add TestFillCompressedByMix and update comments
bom-d-van 93d9efc
mix: multiple bug fixes and refactorings for both mix or non-mix logics
bom-d-van 6941e73
mix: correct percentile caculation
bom-d-van 8a3bdde
mix: update comments and clean up commented out codes, todos
bom-d-van beabc51
debug: add end_offset in archive header, fix off-by-1 in count output…
bom-d-van f1a7fb0
mix: FetchByAggregation: ignore spec if aggregation method is not mix
bom-d-van 0246244
mix: a bug fix for dynamic read backfilling and a propagation buffer …
bom-d-van 6c5f01b
mix: rename var with a bit of self-explainatory code changes, and bet…
bom-d-van File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "io/ioutil" | ||
| "os" | ||
| "strconv" | ||
| "strings" | ||
|
|
||
| whisper "github.com/go-graphite/go-whisper" | ||
| ) | ||
|
|
||
| func main() { | ||
| var body string | ||
| if len(os.Args) < 2 { | ||
| fmt.Println("write: write data points to a whisper file.\nwrite file.wsp [1572940800:3,1572940801:5]\n") | ||
| os.Exit(1) | ||
| } else if len(os.Args) > 2 { | ||
| body = os.Args[2] | ||
| } else { | ||
| in, err := ioutil.ReadAll(os.Stdin) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| body = string(in) | ||
| } | ||
|
|
||
| db, err := whisper.OpenWithOptions(os.Args[1], &whisper.Options{FLock: true}) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| if err := db.UpdateMany(parse(body)); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| if err := db.Close(); err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| if db.Extended { | ||
| fmt.Println("file is extended.") | ||
| } | ||
| } | ||
|
|
||
| func parse(str string) []*whisper.TimeSeriesPoint { | ||
| var ps []*whisper.TimeSeriesPoint | ||
| for _, p := range strings.Split(str, ",") { | ||
| p = strings.TrimSpace(p) | ||
| if p == "" { | ||
| continue | ||
| } | ||
| pp := strings.Split(p, ":") | ||
| t, err := strconv.Atoi(pp[0]) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| v, err := strconv.ParseFloat(pp[1], 64) | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
| ps = append(ps, &whisper.TimeSeriesPoint{Time: t, Value: v}) | ||
| } | ||
| return ps | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.