Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Commit e67e2a9

Browse files
committed
WIP
1 parent 38b6652 commit e67e2a9

File tree

1 file changed

+33
-16
lines changed

1 file changed

+33
-16
lines changed

platform/optimize/pipeline.go

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package optimize
55
import (
66
"github.com/QuesmaOrg/quesma/platform/config"
77
"github.com/QuesmaOrg/quesma/platform/model"
8+
"log"
89
"strings"
910
"time"
1011
)
@@ -23,24 +24,40 @@ type OptimizePipeline struct {
2324
optimizations []OptimizeTransformer
2425
}
2526

27+
func checkIfOptimizerIsEnabled(config *config.QuesmaConfiguration, name string) bool {
28+
29+
if c, ok := config.DefaultQueryOptimizers[name]; ok {
30+
return !c.Disabled
31+
}
32+
return true // default is enabled
33+
34+
}
35+
2636
func NewOptimizePipeline(config *config.QuesmaConfiguration) model.QueryTransformer {
27-
// TODO remove this line when splitTimeRange is removed
28-
// this is just to satisfy the linter
29-
_ = &splitTimeRange{}
37+
38+
var optimizations []OptimizeTransformer
39+
40+
if checkIfOptimizerIsEnabled(config, "truncateDate") {
41+
optimizations = append(optimizations, &truncateDate{truncateTo: 5 * time.Minute})
42+
}
43+
44+
if checkIfOptimizerIsEnabled(config, "cacheQueries") {
45+
optimizations = append(optimizations, &cacheQueries{})
46+
}
47+
48+
if checkIfOptimizerIsEnabled(config, "materializedViewReplace") {
49+
optimizations = append(optimizations, &materializedViewReplace{})
50+
}
51+
52+
if checkIfOptimizerIsEnabled(config, "splitTimeRangeExt") {
53+
optimizations = append(optimizations, &splitTimeRangeExt{})
54+
}
55+
56+
log.Println("OptimizePipeline: enabled optimizations:", optimizations)
57+
3058
return &OptimizePipeline{
31-
config: config,
32-
optimizations: []OptimizeTransformer{
33-
&truncateDate{truncateTo: 5 * time.Minute},
34-
&cacheQueries{},
35-
&materializedViewReplace{},
36-
// TODO finally remove this transformer
37-
// commenting out splitTimeRange for now
38-
// as we have splitTimeRangeExt that uses novel approach
39-
// of splitting queries based on time range
40-
// executing them in parallel and finally merging results
41-
// &splitTimeRange{},
42-
&splitTimeRangeExt{},
43-
},
59+
config: config,
60+
optimizations: optimizations,
4461
}
4562
}
4663

0 commit comments

Comments
 (0)