hanahmily commented on code in PR #861:
URL: 
https://github.com/apache/skywalking-banyandb/pull/861#discussion_r2570387685


##########
banyand/property/db.go:
##########


Review Comment:
   `database.query` should sort properties from several shards.
   
   ```
   func (db *database) query(ctx context.Context, req *propertyv1.QueryRequest) 
([]*queryProperty, error) {
        iq, err := inverted.BuildPropertyQuery(req, groupField, entityID)
        if err != nil {
                return nil, err
        }
        sLst := db.sLst.Load()
        if sLst == nil {
                return nil, nil
        }
        var res []*queryProperty
        for _, s := range *sLst {
                r, err := s.search(ctx, iq, int(req.Limit))
                if err != nil {
                        return nil, err
                }
                res = append(res, r...)
        }
        return res, nil
   }
   ```



##########
banyand/liaison/grpc/property.go:
##########
@@ -762,3 +784,38 @@ type repairInProcessKey struct {
        entity  string
        modTime int64
 }
+
+// sortPropertiesWithSortedValues sorts properties using pre-extracted 
sortedValue bytes.
+func sortPropertiesWithSortedValues(

Review Comment:
   To optimize efficiency in the merging process, consider implementing merge 
sorting, which can leverage already-sorted sub-property lists. 
   
   For more information on the merge sort algorithm, visit the [Wikipedia 
page](https://en.wikipedia.org/wiki/Merge_sort).



##########
pkg/index/inverted/query.go:
##########
@@ -634,8 +634,29 @@ func (t *timeRangeNode) String() string {
        return convert.JSONToString(t)
 }
 
+// PropertyQuery support query property with order.
+type PropertyQuery struct {
+       Query      index.Query
+       Order      *index.OrderBy
+       orderField string
+}

Review Comment:
   ```suggestion
   ```
   
   The query should not include fields relevant to ordering. Internally, 
Bluge's sorting system operates as a separate data structure that is not 
accessible through the query tree. For this reason, sorting is not supported 
within the query itself. Therefore, the sorting operation should only be 
handled in the `property` package.



##########
test/cases/property/data/input/order_by_asc.yaml:
##########
@@ -0,0 +1,26 @@
+# 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.
+
+name: "ui_menu"
+groups: ["sw"]
+tag_projection:
+  - menu_name
+  - configuration
+  - update_time

Review Comment:
   Add a case like
   
   ```yaml
   tag_projection:
     - menu_name
     - configuration
   order_by:
     tag_name: "update_time"
   ```
   To verify that the sorted tag is not in the projection list.



-- 
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]

Reply via email to