This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch entity_match in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/entity_match by this push: new 1b08432e Improve test cases 1b08432e is described below commit 1b08432ee81dbbfc1692b8955fe9ea72541ad408 Author: Gao Hongtao <hanahm...@gmail.com> AuthorDate: Fri Sep 20 15:20:32 2024 +0800 Improve test cases Signed-off-by: Gao Hongtao <hanahm...@gmail.com> --- pkg/index/inverted/inverted_series.go | 16 +++++++---- test/cases/measure/data/input/entity_match.yaml | 2 +- .../measure/data/testdata/endpoint_traffic.json | 8 +++--- test/cases/measure/data/want/entity_match.yaml | 33 ++++++++-------------- test/cases/measure/measure.go | 2 +- 5 files changed, 28 insertions(+), 33 deletions(-) diff --git a/pkg/index/inverted/inverted_series.go b/pkg/index/inverted/inverted_series.go index 074e30c2..11ee28b3 100644 --- a/pkg/index/inverted/inverted_series.go +++ b/pkg/index/inverted/inverted_series.go @@ -40,7 +40,7 @@ func (s *store) BuildQuery(seriesMatchers []index.SeriesMatcher, secondaryQuery } qs := make([]bluge.Query, len(seriesMatchers)) - primaryNode := newShouldNode() + nodes := make([]node, len(seriesMatchers)) for i := range seriesMatchers { switch seriesMatchers[i].Type { case index.SeriesMatcherTypeExact: @@ -48,36 +48,42 @@ func (s *store) BuildQuery(seriesMatchers []index.SeriesMatcher, secondaryQuery q := bluge.NewTermQuery(match) q.SetField(entityField) qs[i] = q - primaryNode.Append(newTermNode(match, nil)) + nodes = append(nodes, newTermNode(match, nil)) case index.SeriesMatcherTypePrefix: match := convert.BytesToString(seriesMatchers[i].Match) q := bluge.NewPrefixQuery(match) q.SetField(entityField) qs[i] = q - primaryNode.Append(newPrefixNode(match)) + nodes = append(nodes, newPrefixNode(match)) case index.SeriesMatcherTypeWildcard: match := convert.BytesToString(seriesMatchers[i].Match) q := bluge.NewWildcardQuery(match) q.SetField(entityField) qs[i] = q - primaryNode.Append(newWildcardNode(match)) + nodes = append(nodes, newWildcardNode(match)) default: return nil, errors.Errorf("unsupported series matcher type: %v", seriesMatchers[i].Type) } } var primaryQuery bluge.Query + var n node if len(qs) > 1 { bq := bluge.NewBooleanQuery() bq.AddShould(qs...) bq.SetMinShould(1) primaryQuery = bq + n = newShouldNode() + for i := range nodes { + n.(*shouldNode).Append(nodes[i]) + } } else { primaryQuery = qs[0] + n = nodes[0] } query := bluge.NewBooleanQuery().AddMust(primaryQuery) node := newMustNode() - node.Append(primaryNode) + node.Append(n) if secondaryQuery != nil && secondaryQuery.(*queryNode).query != nil { query.AddMust(secondaryQuery.(*queryNode).query) node.Append(secondaryQuery.(*queryNode).node) diff --git a/test/cases/measure/data/input/entity_match.yaml b/test/cases/measure/data/input/entity_match.yaml index 28c14edc..ce37d3cc 100644 --- a/test/cases/measure/data/input/entity_match.yaml +++ b/test/cases/measure/data/input/entity_match.yaml @@ -30,7 +30,7 @@ criteria: op: "BINARY_OP_MATCH" value: str: - value: "endpoint1" + value: "foo" left: condition: name: "service_id" diff --git a/test/cases/measure/data/testdata/endpoint_traffic.json b/test/cases/measure/data/testdata/endpoint_traffic.json index 0a098c72..bf43fb9d 100644 --- a/test/cases/measure/data/testdata/endpoint_traffic.json +++ b/test/cases/measure/data/testdata/endpoint_traffic.json @@ -10,7 +10,7 @@ }, { "str": { - "value": "/api/v1/endpoint1" + "value": "/api/v1/foo" } } ] @@ -28,7 +28,7 @@ }, { "str": { - "value": "/api/v1/endpoint2" + "value": "/api/v1/bar" } } ] @@ -46,7 +46,7 @@ }, { "str": { - "value": "/api/v1/endpoint1" + "value": "/api/v1/foo" } } ] @@ -64,7 +64,7 @@ }, { "str": { - "value": "/api/v1/endpoint2" + "value": "/api/v1/bar" } } ] diff --git a/test/cases/measure/data/want/entity_match.yaml b/test/cases/measure/data/want/entity_match.yaml index 73ba584e..ccd79306 100644 --- a/test/cases/measure/data/want/entity_match.yaml +++ b/test/cases/measure/data/want/entity_match.yaml @@ -16,25 +16,14 @@ # under the License. dataPoints: -- tagFamilies: - - name: default - tags: - - key: name - value: - str: - value: service_name_1 - - key: short_name - value: - str: - value: service_short_name_1 -- tagFamilies: - - name: default - tags: - - key: name - value: - str: - value: service_name_2 - - key: short_name - value: - str: - value: service_short_name_2 + - tagFamilies: + - name: default + tags: + - key: service_id + value: + str: + value: service_1 + - key: endpoint_name + value: + str: + value: /api/v1/foo diff --git a/test/cases/measure/measure.go b/test/cases/measure/measure.go index 53b6a6c7..8f843105 100644 --- a/test/cases/measure/measure.go +++ b/test/cases/measure/measure.go @@ -71,5 +71,5 @@ var _ = g.DescribeTable("Scanning Measures", verify, g.Entry("float64 aggregation:min", helpers.Args{Input: "float_agg_min", Duration: 25 * time.Minute, Offset: -20 * time.Minute}), g.Entry("all_latency", helpers.Args{Input: "all_latency", Duration: 25 * time.Minute, Offset: -20 * time.Minute}), g.Entry("duplicated in a part", helpers.Args{Input: "duplicated_part", Duration: 25 * time.Minute, Offset: -20 * time.Minute}), - g.FEntry("match a tag belongs to the entity", helpers.Args{Input: "entity_match", Duration: 25 * time.Minute, Offset: -20 * time.Minute}), + g.Entry("match a tag belongs to the entity", helpers.Args{Input: "entity_match", Duration: 25 * time.Minute, Offset: -20 * time.Minute}), )