This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch vectorized-query
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit 11d0f9884e712ddf8062a43ef4e42f6506a057a1
Author: Hongtao Gao <[email protected]>
AuthorDate: Mon May 4 11:16:40 2026 +0000

    chore: fix lint issues in vectorized/measure operators
    
    - aggregation.go: govet fieldalignment (aggGroup field reorder); exhaustive
      AggFunc switch in aggOutputType (add Sum/Min/Max case)
    - serialize.go: exhaustive ColumnRole switch (add metadata-role no-op case;
      metadata is handled before the loop)
    - serialize_test.go: drop unparam ver argument from mkSerializeRow (always 
1)
    - top.go: misspell (initialises -> initializes)
---
 pkg/query/vectorized/measure/aggregation.go    |  7 ++++---
 pkg/query/vectorized/measure/serialize.go      |  4 ++++
 pkg/query/vectorized/measure/serialize_test.go | 18 ++++++++++--------
 pkg/query/vectorized/measure/top.go            |  2 +-
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/pkg/query/vectorized/measure/aggregation.go 
b/pkg/query/vectorized/measure/aggregation.go
index 4a6f5f4c7..587daba17 100644
--- a/pkg/query/vectorized/measure/aggregation.go
+++ b/pkg/query/vectorized/measure/aggregation.go
@@ -91,9 +91,9 @@ type BatchAggregation struct {
 
 // aggGroup carries one bucket's reduction state plus a copy of its key column 
values.
 type aggGroup struct {
-       keyCols []vectorized.Column // each holds exactly one row — the 
representative key
-       slots   []aggSlot           // one per AggSpec
        key     string
+       keyCols []vectorized.Column
+       slots   []aggSlot
 }
 
 // aggSlot holds an aggregation.Map of either int64 or float64. Whether int or
@@ -363,7 +363,8 @@ func aggOutputType(in vectorized.ColumnType, fn AggFunc) 
vectorized.ColumnType {
                return vectorized.ColumnTypeInt64
        case AggMean:
                return vectorized.ColumnTypeFloat64
+       case AggSum, AggMin, AggMax:
+               return in
        }
        return in
 }
-
diff --git a/pkg/query/vectorized/measure/serialize.go 
b/pkg/query/vectorized/measure/serialize.go
index 7bb6d5aba..6a20c0fee 100644
--- a/pkg/query/vectorized/measure/serialize.go
+++ b/pkg/query/vectorized/measure/serialize.go
@@ -85,6 +85,10 @@ func buildDataPoint(b *vectorized.RecordBatch, schema 
*vectorized.BatchSchema, r
                                Name:  def.Name,
                                Value: 
columnValueToFieldValue(b.Columns[colIdx], rowIdx),
                        })
+               case vectorized.RoleTimestamp, vectorized.RoleVersion,
+                       vectorized.RoleSeriesID, vectorized.RoleShardID:
+                       // Metadata roles are handled before the loop 
(Timestamp/Version/Sid)
+                       // or via the InternalDataPoint wrapper (ShardId). Skip 
here.
                }
        }
        return dp
diff --git a/pkg/query/vectorized/measure/serialize_test.go 
b/pkg/query/vectorized/measure/serialize_test.go
index ced5be7a2..242ae2639 100644
--- a/pkg/query/vectorized/measure/serialize_test.go
+++ b/pkg/query/vectorized/measure/serialize_test.go
@@ -42,11 +42,13 @@ func serializeFullSchema() *vectorized.BatchSchema {
        })
 }
 
-func mkSerializeRow(b *vectorized.RecordBatch, ts, ver, sid int64, svc string,
+// mkSerializeRow builds one row in the serializeFullSchema layout. Version is
+// pinned to 1 — tests don't exercise version-specific behavior.
+func mkSerializeRow(b *vectorized.RecordBatch, ts, sid int64, svc string,
        vInt int64, vFloat float64, vStr string, vBytes []byte,
 ) {
        b.Columns[0].(*vectorized.TypedColumn[int64]).Append(ts)
-       b.Columns[1].(*vectorized.TypedColumn[int64]).Append(ver)
+       b.Columns[1].(*vectorized.TypedColumn[int64]).Append(1)
        b.Columns[2].(*vectorized.TypedColumn[int64]).Append(sid)
        b.Columns[3].(*vectorized.TypedColumn[string]).Append(svc)
        b.Columns[4].(*vectorized.TypedColumn[int64]).Append(vInt)
@@ -59,7 +61,7 @@ func mkSerializeRow(b *vectorized.RecordBatch, ts, ver, sid 
int64, svc string,
 func TestSerializeBatchToProto_RoundTrips_AllScalarVariants(t *testing.T) {
        s := serializeFullSchema()
        b := vectorized.NewRecordBatch(s, 2)
-       mkSerializeRow(b, 100, 1, 7, "svcA", 42, 3.14, "hello", []byte("xyz"))
+       mkSerializeRow(b, 100, 7, "svcA", 42, 3.14, "hello", []byte("xyz"))
 
        out := serializeBatchToProto(b, nil)
        if len(out) != 1 {
@@ -98,9 +100,9 @@ func 
TestSerializeBatchToProto_RoundTrips_AllScalarVariants(t *testing.T) {
 func TestSerializeBatchToProto_RespectsSelectionVector(t *testing.T) {
        s := serializeFullSchema()
        b := vectorized.NewRecordBatch(s, 4)
-       mkSerializeRow(b, 100, 1, 1, "a", 10, 1.0, "", nil)
-       mkSerializeRow(b, 200, 1, 2, "b", 20, 2.0, "", nil)
-       mkSerializeRow(b, 300, 1, 3, "c", 30, 3.0, "", nil)
+       mkSerializeRow(b, 100, 1, "a", 10, 1.0, "", nil)
+       mkSerializeRow(b, 200, 2, "b", 20, 2.0, "", nil)
+       mkSerializeRow(b, 300, 3, "c", 30, 3.0, "", nil)
        b.Selection = []uint16{0, 2} // only rows 0 and 2 are active
 
        out := serializeBatchToProto(b, nil)
@@ -143,7 +145,7 @@ func TestSerializeBatchToProto_RowOrderMatchesRowPath(t 
*testing.T) {
        s := serializeFullSchema()
        b := vectorized.NewRecordBatch(s, 5)
        for i := range 5 {
-               mkSerializeRow(b, int64(i*100), 1, int64(i+1), "svc", 0, 0, "", 
nil)
+               mkSerializeRow(b, int64(i*100), int64(i+1), "svc", 0, 0, "", 
nil)
        }
 
        out := serializeBatchToProto(b, nil)
@@ -158,7 +160,7 @@ func TestSerializeBatchToProto_RowOrderMatchesRowPath(t 
*testing.T) {
 func TestSerializeBatchToProto_ReusesDestinationSlice(t *testing.T) {
        s := serializeFullSchema()
        b := vectorized.NewRecordBatch(s, 1)
-       mkSerializeRow(b, 100, 1, 7, "x", 0, 0, "", nil)
+       mkSerializeRow(b, 100, 7, "x", 0, 0, "", nil)
 
        dst := make([]*measurev1.InternalDataPoint, 0, 16)
        beforeCap := cap(dst)
diff --git a/pkg/query/vectorized/measure/top.go 
b/pkg/query/vectorized/measure/top.go
index 191724715..4bf63e0ba 100644
--- a/pkg/query/vectorized/measure/top.go
+++ b/pkg/query/vectorized/measure/top.go
@@ -129,7 +129,7 @@ func NewBatchTop(schema *vectorized.BatchSchema, fieldCol, 
n int, asc bool, batc
        }
 }
 
-// Init initialises the heap.
+// Init initializes the heap.
 func (t *BatchTop) Init(_ context.Context) error {
        t.heapState = &topHeap{asc: t.asc}
        return nil

Reply via email to