2021-05-20 18:38:45 +08:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
|
|
//
|
|
|
|
// Licensed 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 storage
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2021-10-13 10:22:33 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/common"
|
|
|
|
"github.com/milvus-io/milvus/internal/rootcoord"
|
2021-05-20 18:38:45 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
2021-09-09 17:12:55 +08:00
|
|
|
func TestStatsWriter_StatsInt64(t *testing.T) {
|
2021-05-20 18:38:45 +08:00
|
|
|
data := []int64{1, 2, 3, 4, 5, 6, 7, 8, 9}
|
|
|
|
sw := &StatsWriter{}
|
2021-10-19 20:18:47 +08:00
|
|
|
err := sw.StatsInt64(common.RowIDField, true, data)
|
2021-05-20 18:38:45 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
b := sw.GetBuffer()
|
|
|
|
|
|
|
|
sr := &StatsReader{}
|
|
|
|
sr.SetBuffer(b)
|
2021-10-13 10:22:33 +08:00
|
|
|
stats, err := sr.GetInt64Stats()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, stats.Max, int64(9))
|
|
|
|
assert.Equal(t, stats.Min, int64(1))
|
|
|
|
buffer := make([]byte, 8)
|
|
|
|
for _, id := range data {
|
2021-11-02 18:16:32 +08:00
|
|
|
common.Endian.PutUint64(buffer, uint64(id))
|
2021-10-13 10:22:33 +08:00
|
|
|
assert.True(t, stats.BF.Test(buffer))
|
2021-05-20 18:38:45 +08:00
|
|
|
}
|
2021-09-09 17:12:55 +08:00
|
|
|
|
|
|
|
msgs := []int64{}
|
2021-10-19 20:18:47 +08:00
|
|
|
err = sw.StatsInt64(rootcoord.RowIDField, true, msgs)
|
2021-09-09 17:12:55 +08:00
|
|
|
assert.Nil(t, err)
|
2021-05-20 18:38:45 +08:00
|
|
|
}
|