-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sharding optimizations I: AST mapping (#1846)
* [wip] sharding evaluator/ast * [wip] continues experimenting with ast mapping * refactoring in preparation for binops * evaluators can pass state to other evaluators * compiler alignment * Evaluator method renamed to StepEvaluator * chained evaluator impl * tidying up sharding code * handling for ConcatSampleExpr * downstream iterator * structure for downstreaming asts * outlines sharding optimizations * work on sharding mapper * ast sharding optimizations * test for different logrange positions * shard mapper tests * stronger ast sharding & tests * shardmapper tests for string->string * removes sharding evaluator code * removes unused ctx arg * Update pkg/logql/evaluator.go Co-Authored-By: Cyril Tovena <cyril.tovena@gmail.com> Co-authored-by: Cyril Tovena <cyril.tovena@gmail.com>
- Loading branch information
1 parent
b7e868a
commit 7effeec
Showing
9 changed files
with
1,379 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package logql | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/pkg/errors" | ||
) | ||
|
||
// ASTMapper is the exported interface for mapping between multiple AST representations | ||
type ASTMapper interface { | ||
Map(Expr) (Expr, error) | ||
} | ||
|
||
// CloneExpr is a helper function to clone a node. | ||
func CloneExpr(expr Expr) (Expr, error) { | ||
return ParseExpr(expr.String()) | ||
} | ||
|
||
func badASTMapping(expected string, got Expr) error { | ||
return fmt.Errorf("Bad AST mapping: expected one type (%s), but got (%T)", expected, got) | ||
} | ||
|
||
// MapperUnsuportedType is a helper for signaling that an evaluator does not support an Expr type | ||
func MapperUnsupportedType(expr Expr, m ASTMapper) error { | ||
return errors.Errorf("unexpected expr type (%T) for ASTMapper type (%T) ", expr, m) | ||
} |
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
Oops, something went wrong.