Skip to content

Commit

Permalink
Use the corret iterator to order tag
Browse files Browse the repository at this point in the history
Signed-off-by: Gao Hongtao <[email protected]>
  • Loading branch information
hanahmily committed Jun 26, 2023
1 parent c8b2967 commit 856cfed
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 1 deletion.
2 changes: 1 addition & 1 deletion banyand/tsdb/seriesdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ func (s *seriesDB) Search(ctx context.Context, path Path, filter index.Filter, o
continue
}
pIter := pv.Iterator()
for iter.Next() {
for pIter.Next() {
var series Series
if series, err = s.GetByID(common.SeriesID(pIter.Current())); err != nil {
return nil, multierr.Append(err, pIter.Close())
Expand Down
29 changes: 29 additions & 0 deletions test/cases/measure/data/input/order_tag_asc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

metadata:
name: "service_cpm_minute"
group: "sw_metric"
tagProjection:
tagFamilies:
- name: "default"
tags: ["id"]
fieldProjection:
names: ["total", "value"]
orderBy:
sort: "SORT_ASC"
indexRuleName: "id"
29 changes: 29 additions & 0 deletions test/cases/measure/data/input/order_tag_desc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

metadata:
name: "service_cpm_minute"
group: "sw_metric"
tagProjection:
tagFamilies:
- name: "default"
tags: ["id"]
fieldProjection:
names: ["total", "value"]
orderBy:
sort: "SORT_DESC"
indexRuleName: "id"
120 changes: 120 additions & 0 deletions test/cases/measure/data/want/order_tag_asc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

dataPoints:
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "1"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:41:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "2"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:42:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "3"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:43:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "5"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc2
timestamp: "2023-06-26T12:44:00Z"
- fields:
- name: total
value:
int:
value: "50"
- name: value
value:
int:
value: "4"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc2
timestamp: "2023-06-26T12:45:00Z"
- fields:
- name: total
value:
int:
value: "300"
- name: value
value:
int:
value: "6"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc3
timestamp: "2023-06-26T12:46:00Z"
120 changes: 120 additions & 0 deletions test/cases/measure/data/want/order_tag_desc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

dataPoints:
- fields:
- name: total
value:
int:
value: "300"
- name: value
value:
int:
value: "6"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc3
timestamp: "2023-06-26T12:47:00Z"
- fields:
- name: total
value:
int:
value: "50"
- name: value
value:
int:
value: "4"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc2
timestamp: "2023-06-26T12:46:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "5"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc2
timestamp: "2023-06-26T12:45:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "3"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:44:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "2"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:43:00Z"
- fields:
- name: total
value:
int:
value: "100"
- name: value
value:
int:
value: "1"
tagFamilies:
- name: default
tags:
- key: id
value:
str:
value: svc1
timestamp: "2023-06-26T12:42:00Z"
2 changes: 2 additions & 0 deletions test/cases/measure/measure.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ var _ = g.DescribeTable("Scanning Measures", verify,
g.Entry("bottom 2", helpers.Args{Input: "bottom", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("order by time asc", helpers.Args{Input: "order_asc", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("order by time desc", helpers.Args{Input: "order_desc", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("order by tag asc", helpers.Args{Input: "order_tag_asc", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("order by tag desc", helpers.Args{Input: "order_tag_desc", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("limit 3,2", helpers.Args{Input: "limit", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("match a node", helpers.Args{Input: "match_node", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
g.Entry("match nodes", helpers.Args{Input: "match_nodes", Duration: 25 * time.Minute, Offset: -20 * time.Minute}),
Expand Down

0 comments on commit 856cfed

Please sign in to comment.