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

Commit 8e18e9e

Browse files
authored
Remove quesma/query_processor (move to quesma/model) (#1026)
Single-file module which was depending only on `model` Related: #1017
1 parent 642dee3 commit 8e18e9e

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

quesma/model/pipeline_aggregations/average_bucket.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"quesma/logger"
99
"quesma/model"
10-
"quesma/queryprocessor"
1110
"quesma/util"
1211
)
1312

@@ -32,7 +31,7 @@ func (query AverageBucket) CalculateResultWhenMissing(parentRows []model.QueryRe
3231
if len(parentRows) == 0 {
3332
return resultRows // maybe null?
3433
}
35-
qp := queryprocessor.NewQueryProcessor(query.ctx)
34+
qp := model.NewQueryProcessor(query.ctx)
3635
parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value]
3736
// in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols
3837
// so we need to split into buckets based on parent_cols

quesma/model/pipeline_aggregations/max_bucket.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"quesma/logger"
99
"quesma/model"
10-
"quesma/queryprocessor"
1110
"quesma/util"
1211
)
1312

@@ -47,7 +46,7 @@ func (query MaxBucket) CalculateResultWhenMissing(parentRows []model.QueryResult
4746
if len(parentRows) == 0 {
4847
return resultRows // maybe null?
4948
}
50-
qp := queryprocessor.NewQueryProcessor(query.ctx)
49+
qp := model.NewQueryProcessor(query.ctx)
5150
parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value]
5251
// in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols
5352
// so we need to split into buckets based on parent_cols

quesma/model/pipeline_aggregations/min_bucket.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"quesma/logger"
99
"quesma/model"
10-
"quesma/queryprocessor"
1110
"quesma/util"
1211
)
1312

@@ -43,7 +42,7 @@ func (query MinBucket) CalculateResultWhenMissing(parentRows []model.QueryResult
4342
if len(parentRows) == 0 {
4443
return resultRows // maybe null?
4544
}
46-
qp := queryprocessor.NewQueryProcessor(query.ctx)
45+
qp := model.NewQueryProcessor(query.ctx)
4746
parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value]
4847
// in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols
4948
// so we need to split into buckets based on parent_cols

quesma/model/pipeline_aggregations/sum_bucket.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"quesma/logger"
99
"quesma/model"
10-
"quesma/queryprocessor"
1110
"quesma/util"
1211
"time"
1312
)
@@ -44,7 +43,7 @@ func (query SumBucket) CalculateResultWhenMissing(parentRows []model.QueryResult
4443
if len(parentRows) == 0 {
4544
return resultRows // maybe null?
4645
}
47-
qp := queryprocessor.NewQueryProcessor(query.ctx)
46+
qp := model.NewQueryProcessor(query.ctx)
4847
parentFieldsCnt := len(parentRows[0].Cols) - 2 // -2, because row is [parent_cols..., current_key, current_value]
4948
// in calculateSingleAvgBucket we calculate avg all current_keys with the same parent_cols
5049
// so we need to split into buckets based on parent_cols

quesma/queryprocessor/query_processor.go renamed to quesma/model/query_processor.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// Copyright Quesma, licensed under the Elastic License 2.0.
22
// SPDX-License-Identifier: Elastic-2.0
3-
package queryprocessor
3+
package model
44

55
import (
66
"context"
7-
"quesma/model"
87
"reflect"
98
)
109

@@ -17,7 +16,7 @@ func NewQueryProcessor(ctx context.Context) QueryProcessor {
1716
}
1817

1918
// Returns if row1 and row2 have the same values for the first level fields
20-
func (qp *QueryProcessor) sameGroupByFields(row1, row2 model.QueryResultRow, level int) bool {
19+
func (qp *QueryProcessor) sameGroupByFields(row1, row2 QueryResultRow, level int) bool {
2120

2221
isArray := func(val interface{}) bool {
2322
if val == nil {
@@ -49,18 +48,18 @@ func (qp *QueryProcessor) sameGroupByFields(row1, row2 model.QueryResultRow, lev
4948
// Splits ResultSet into buckets, based on the first level fields
5049
// E.g. if level == 0, we split into buckets based on the first field,
5150
// e.g. [row(1, ...), row(1, ...), row(2, ...), row(2, ...), row(3, ...)] -> [[row(1, ...), row(1, ...)], [row(2, ...), row(2, ...)], [row(3, ...)]]
52-
func (qp *QueryProcessor) SplitResultSetIntoBuckets(ResultSet []model.QueryResultRow, level int) [][]model.QueryResultRow {
51+
func (qp *QueryProcessor) SplitResultSetIntoBuckets(ResultSet []QueryResultRow, level int) [][]QueryResultRow {
5352
if len(ResultSet) == 0 {
54-
return [][]model.QueryResultRow{{}}
53+
return [][]QueryResultRow{{}}
5554
}
5655

5756
lastRow := ResultSet[0]
58-
buckets := [][]model.QueryResultRow{{lastRow}}
57+
buckets := [][]QueryResultRow{{lastRow}}
5958
for _, row := range ResultSet[1:] {
6059
if qp.sameGroupByFields(row, lastRow, level) {
6160
buckets[len(buckets)-1] = append(buckets[len(buckets)-1], row)
6261
} else {
63-
buckets = append(buckets, []model.QueryResultRow{row})
62+
buckets = append(buckets, []QueryResultRow{row})
6463
}
6564
lastRow = row
6665
}

0 commit comments

Comments
 (0)