hanahmily commented on code in PR #521: URL: https://github.com/apache/skywalking-banyandb/pull/521#discussion_r1735464067
########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { Review Comment: According to Go’s philosophy, if any type name should not include the package’s name. ```suggestion type Input interface { ``` ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} Review Comment: What’s the Void used for? Would you show me some examples? ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { + Void | ~string | ~int64 | ~float64 | ~[]string | ~[]int64 +} + +// MAFKeep represents the only two types of value hold by MAF. +type MAFKeep interface { + ~int64 | ~float64 +} + +var errFieldValueType = fmt.Errorf("unsupported input value type on this field") + +// MAFArguments represents the argument array, with at most three arguments. +type MAFArguments[A, B, C MAFInput] struct { Review Comment: ```suggestion type Arguments[A, B, C MAFInput] struct { ``` ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { + Void | ~string | ~int64 | ~float64 | ~[]string | ~[]int64 +} + +// MAFKeep represents the only two types of value hold by MAF. +type MAFKeep interface { Review Comment: ```suggestion type Output interface { ``` ########## banyand/measure/aggregate/avg_test.go: ########## @@ -0,0 +1,39 @@ +// 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. + +package aggregate Review Comment: ```suggestion package aggregate_test ``` ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { + Void | ~string | ~int64 | ~float64 | ~[]string | ~[]int64 +} + +// MAFKeep represents the only two types of value hold by MAF. +type MAFKeep interface { + ~int64 | ~float64 +} + +var errFieldValueType = fmt.Errorf("unsupported input value type on this field") + +// MAFArguments represents the argument array, with at most three arguments. +type MAFArguments[A, B, C MAFInput] struct { + arg0 []A + arg1 []B + arg2 []C +} + +// MAF describes two stages of aggregation. +type MAF[A, B, C MAFInput, K MAFKeep] interface { Review Comment: ```suggestion type Function[A, B, C MAFInput, K MAFKeep] interface { ``` ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { + Void | ~string | ~int64 | ~float64 | ~[]string | ~[]int64 +} + +// MAFKeep represents the only two types of value hold by MAF. +type MAFKeep interface { + ~int64 | ~float64 Review Comment: Please make sure to include the string type since the input supports it. ########## banyand/measure/aggregate/aggregate_function.go: ########## @@ -0,0 +1,92 @@ +// 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. + +// Package aggregate for measure aggregate function. +package aggregate + +import ( + "fmt" + "math" + + modelv1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/model/v1" +) + +// Void type contains nothing. It works as a placeholder for type parameter. +type Void struct{} + +// MAFInput synchronizes with `pbv1.ValueType`, excluding `ValueTypeUnknown` +// and `ValueTypeBinaryData`. +type MAFInput interface { + Void | ~string | ~int64 | ~float64 | ~[]string | ~[]int64 +} + +// MAFKeep represents the only two types of value hold by MAF. +type MAFKeep interface { + ~int64 | ~float64 +} + +var errFieldValueType = fmt.Errorf("unsupported input value type on this field") + +// MAFArguments represents the argument array, with at most three arguments. +type MAFArguments[A, B, C MAFInput] struct { + arg0 []A + arg1 []B + arg2 []C Review Comment: Is their type different? Do you have any examples? ########## banyand/measure/aggregate/avg.go: ########## Review Comment: Add a “NewAvgArg” to create a argument for Avg’s Input -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
