You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2022/05/22 14:20:29 UTC
[skywalking-banyandb] branch query-top created (now 630354c)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a change to branch query-top
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
at 630354c Rearrage the result of topN
This branch includes the following new commits:
new 630354c Rearrage the result of topN
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[skywalking-banyandb] 01/01: Rearrage the result of topN
Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch query-top
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 630354c9bc7afb989aa3e900280ca747295fef79
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Sun May 22 14:10:02 2022 +0000
Rearrage the result of topN
Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
pkg/query/logical/measure_plan_execution_test.go | 28 ++++++++++++++----------
pkg/query/logical/measure_plan_top.go | 15 +++++--------
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/pkg/query/logical/measure_plan_execution_test.go b/pkg/query/logical/measure_plan_execution_test.go
index aaed872..117382f 100644
--- a/pkg/query/logical/measure_plan_execution_test.go
+++ b/pkg/query/logical/measure_plan_execution_test.go
@@ -109,13 +109,15 @@ func TestMeasurePlanExecution_IndexScan(t *testing.T) {
dataSize := 0
for iter.Next() {
dataPoints := iter.Current()
- for _, dp := range dataPoints {
- dataSize++
- tester.Len(dp.GetFields(), tt.fieldLength)
- tester.Len(dp.GetTagFamilies(), len(tt.tagLength))
- for tagFamilyIdx, tagFamily := range dp.GetTagFamilies() {
- tester.Len(tagFamily.GetTags(), tt.tagLength[tagFamilyIdx])
- }
+ if len(dataPoints) < 1 {
+ continue
+ }
+ dp := dataPoints[0]
+ dataSize++
+ tester.Len(dp.GetFields(), tt.fieldLength)
+ tester.Len(dp.GetTagFamilies(), len(tt.tagLength))
+ for tagFamilyIdx, tagFamily := range dp.GetTagFamilies() {
+ tester.Len(tagFamily.GetTags(), tt.tagLength[tagFamilyIdx])
}
}
tester.Equal(dataSize, tt.wantLength)
@@ -343,11 +345,13 @@ func TestMeasurePlanExecution_Cursor(t *testing.T) {
got := make([]int64, 0)
for iter.Next() {
dataPoints := iter.Current()
- for _, dp := range dataPoints {
- for _, f := range dp.Fields {
- if f.Name == "value" {
- got = append(got, f.Value.GetInt().Value)
- }
+ if len(dataPoints) < 1 {
+ continue
+ }
+ dp := dataPoints[0]
+ for _, f := range dp.Fields {
+ if f.Name == "value" {
+ got = append(got, f.Value.GetInt().Value)
}
}
}
diff --git a/pkg/query/logical/measure_plan_top.go b/pkg/query/logical/measure_plan_top.go
index d250855..cf55dc6 100644
--- a/pkg/query/logical/measure_plan_top.go
+++ b/pkg/query/logical/measure_plan_top.go
@@ -119,28 +119,23 @@ func (g *top) Execute(ec executor.MeasureExecutionContext) (executor.MIterator,
type topMIterator struct {
elements []TopElement
- current []*measurev1.DataPoint
+ index int
}
func newTopMIterator(elements []TopElement) executor.MIterator {
return &topMIterator{
elements: elements,
+ index: -1,
}
}
func (ami *topMIterator) Next() bool {
- if ami.current != nil {
- return false
- }
- ami.current = make([]*measurev1.DataPoint, 0, len(ami.elements))
- for _, tn := range ami.elements {
- ami.current = append(ami.current, tn.dp)
- }
- return true
+ ami.index++
+ return ami.index < len(ami.elements)
}
func (ami *topMIterator) Current() []*measurev1.DataPoint {
- return ami.current
+ return []*measurev1.DataPoint{ami.elements[ami.index].dp}
}
func (ami *topMIterator) Close() error {