-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for `Serial Diff` It's simply `derivative`, but we calculate `row[i] - row[i - lag]` instead of `row[i] - row[i - 1]` * Unify code for all pipeline aggregations a bit, especially for `serial_diff` and `derivative` as they are almost the same Some screens: <img width="1728" alt="Screenshot 2024-05-20 at 16 53 08" src="https://github.com/QuesmaOrg/quesma/assets/5407146/f7bec1fe-4b3e-4f15-a106-196cf524f92c"> `Serial diff of cumulative sum of Avg bytes` should be exactly the same as simply `Avg bytes`, and it is: <img width="1725" alt="Screenshot 2024-05-20 at 16 53 37" src="https://github.com/QuesmaOrg/quesma/assets/5407146/692563e8-e537-4687-9d33-7319ecb31f5d"> <img width="1728" alt="Screenshot 2024-05-20 at 16 54 57" src="https://github.com/QuesmaOrg/quesma/assets/5407146/d81df69c-65d2-44ea-af26-ee532340a39c">
- Loading branch information
Showing
8 changed files
with
1,068 additions
and
133 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,44 @@ | ||
package pipeline_aggregations | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"mitmproxy/quesma/model" | ||
) | ||
|
||
type SerialDiff struct { | ||
ctx context.Context | ||
Parent string | ||
IsCount bool | ||
lag int | ||
} | ||
|
||
func NewSerialDiff(ctx context.Context, bucketsPath string, lag int) SerialDiff { | ||
isCount := bucketsPath == BucketsPathCount | ||
return SerialDiff{ | ||
ctx: ctx, | ||
Parent: bucketsPath, | ||
IsCount: isCount, | ||
lag: lag, | ||
} | ||
} | ||
|
||
func (query SerialDiff) IsBucketAggregation() bool { | ||
return false | ||
} | ||
|
||
func (query SerialDiff) TranslateSqlResponseToJson(rows []model.QueryResultRow, level int) []model.JsonMap { | ||
return translateSqlResponseToJsonCommon(query.ctx, rows, query.String()) | ||
} | ||
|
||
func (query SerialDiff) CalculateResultWhenMissing(qwa *model.Query, parentRows []model.QueryResultRow) []model.QueryResultRow { | ||
return calculateResultWhenMissingCommonForDiffAggregations(query.ctx, parentRows, query.lag) | ||
} | ||
|
||
func (query SerialDiff) PostprocessResults(rowsFromDB []model.QueryResultRow) []model.QueryResultRow { | ||
return rowsFromDB | ||
} | ||
|
||
func (query SerialDiff) String() string { | ||
return fmt.Sprintf("serial_diff(parent: %s, lag: %d)", query.Parent, query.lag) | ||
} |
This file contains 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
Oops, something went wrong.