manlge commented on a change in pull request #14:
URL: https://github.com/apache/iotdb-client-go/pull/14#discussion_r579751337



##########
File path: client/tablet.go
##########
@@ -209,31 +209,77 @@ func (t *Tablet) getValuesBytes() ([]byte, error) {
 }
 
 func (t *Tablet) Sort() error {

Review comment:
       ```suggestion
   func (t *Tablet) Sort() error {
   
   func (t *Tablet) Sort() error {
        for i, schema := range t.measurementSchemas {
                timestamps := make([]int64, len(t.timestamps))
                copy(timestamps, t.timestamps)
                sortFunc := func(i int, j int) bool {
                        b := timestamps[i] < timestamps[j]
                        if b {
                                timestamps[i], timestamps[j] = timestamps[j], 
timestamps[i]
                        }
                        return b
                }
                switch schema.DataType {
                case BOOLEAN:
                        sort.Slice(t.values[i].([]bool), sortFunc)
                case INT32:
                        sort.Slice(t.values[i].([]int32), sortFunc)
                case INT64:
                        sort.Slice(t.values[i].([]int64), sortFunc)
                case FLOAT:
                        sort.Slice(t.values[i].([]float32), sortFunc)
                case DOUBLE:
                        sort.Slice(t.values[i].([]float64), sortFunc)
                case TEXT:
                        sort.Slice(t.values[i].([]string), sortFunc)
                default:
                        return fmt.Errorf("Illegal datatype %v", 
schema.DataType)
                }
        }
        sort.Slice(t.timestamps, func(i int, j int) bool {
                return t.timestamps[i] < t.timestamps[j]
        })
        return nil
   }
   ```




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to