mirror of https://github.com/milvus-io/milvus.git
Rename param names (#10853)
* Rename param names Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com> * Rename configs Signed-off-by: xiaofan-luan <xiaofan.luan@zilliz.com>pull/10858/head
parent
21959bc7bc
commit
93f205b49e
|
@ -14,7 +14,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
datacoord:
|
||||
dataCoord:
|
||||
segment:
|
||||
maxSize: 512 # Maximum size of a segment in MB
|
||||
sealProportion: 0.75 # It's the minimum proportion for a segment which can be sealed
|
||||
|
|
|
@ -182,15 +182,15 @@ func (p *ParamTable) initCollectionBinlogSubPath() {
|
|||
}
|
||||
|
||||
func (p *ParamTable) initSegmentMaxSize() {
|
||||
p.SegmentMaxSize = p.ParseFloat("datacoord.segment.maxSize")
|
||||
p.SegmentMaxSize = p.ParseFloatWithDefault("dataCoord.segment.maxSize", 512.0)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initSegmentSealProportion() {
|
||||
p.SegmentSealProportion = p.ParseFloat("datacoord.segment.sealProportion")
|
||||
p.SegmentSealProportion = p.ParseFloatWithDefault("dataCoord.segment.sealProportion", 0.75)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initSegAssignmentExpiration() {
|
||||
p.SegAssignmentExpiration = p.ParseInt64("datacoord.segment.assignmentExpiration")
|
||||
p.SegAssignmentExpiration = p.ParseInt64WithDefault("dataCoord.segment.assignmentExpiration", 2000)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initClusterMsgChannelPrefix() {
|
||||
|
|
|
@ -172,16 +172,7 @@ func (pt *ParamTable) initRoleName() {
|
|||
}
|
||||
|
||||
func (pt *ParamTable) initKnowhereSimdType() {
|
||||
simdType, err := pt.LoadWithDefault("knowhere.simdType", "auto")
|
||||
if err != nil {
|
||||
log.Error("failed to initialize the simd type",
|
||||
zap.Error(err))
|
||||
|
||||
panic(err)
|
||||
}
|
||||
|
||||
simdType := pt.LoadWithDefault("knowhere.simdType", "auto")
|
||||
pt.SimdType = simdType
|
||||
|
||||
log.Debug("initialize the knowhere simd type",
|
||||
zap.String("simd_type", pt.SimdType))
|
||||
log.Debug("initialize the knowhere simd type", zap.String("simd_type", pt.SimdType))
|
||||
}
|
||||
|
|
|
@ -50,15 +50,15 @@ func (kv *MemoryKV) Load(key string) (string, error) {
|
|||
return item.(memoryKVItem).value, nil
|
||||
}
|
||||
|
||||
func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) (string, error) {
|
||||
func (kv *MemoryKV) LoadWithDefault(key, defaultValue string) string {
|
||||
kv.RLock()
|
||||
defer kv.RUnlock()
|
||||
item := kv.tree.Get(memoryKVItem{key, ""})
|
||||
|
||||
if item == nil {
|
||||
return defaultValue, nil
|
||||
return defaultValue
|
||||
}
|
||||
return item.(memoryKVItem).value, nil
|
||||
return item.(memoryKVItem).value
|
||||
}
|
||||
|
||||
func (kv *MemoryKV) LoadRange(key, endKey string, limit int) ([]string, []string, error) {
|
||||
|
|
|
@ -335,11 +335,9 @@ func (p *ParamTable) initSegcoreChunkRows() {
|
|||
}
|
||||
|
||||
func (p *ParamTable) initKnowhereSimdType() {
|
||||
simdType, err := p.LoadWithDefault("knowhere.simdType", "auto")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
simdType := p.LoadWithDefault("knowhere.simdType", "auto")
|
||||
p.SimdType = simdType
|
||||
log.Debug("initialize the knowhere simd type", zap.String("simd_type", p.SimdType))
|
||||
}
|
||||
|
||||
func (p *ParamTable) initRoleName() {
|
||||
|
|
|
@ -179,15 +179,15 @@ func (p *ParamTable) initDmlChannelName() {
|
|||
}
|
||||
|
||||
func (p *ParamTable) initDmlChannelNum() {
|
||||
p.DmlChannelNum = p.ParseInt64("rootcoord.dmlChannelNum")
|
||||
p.DmlChannelNum = p.ParseInt64WithDefault("rootCoord.dmlChannelNum", 256)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initMaxPartitionNum() {
|
||||
p.MaxPartitionNum = p.ParseInt64("rootcoord.maxPartitionNum")
|
||||
p.MaxPartitionNum = p.ParseInt64WithDefault("rootCoord.maxPartitionNum", 4096)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initMinSegmentSizeToEnableIndex() {
|
||||
p.MinSegmentSizeToEnableIndex = p.ParseInt64("rootcoord.minSegmentSizeToEnableIndex")
|
||||
p.MinSegmentSizeToEnableIndex = p.ParseInt64WithDefault("rootCoord.minSegmentSizeToEnableIndex", 1024)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initDefaultPartitionName() {
|
||||
|
@ -207,11 +207,11 @@ func (p *ParamTable) initDefaultIndexName() {
|
|||
}
|
||||
|
||||
func (p *ParamTable) initTimeout() {
|
||||
p.Timeout = p.ParseInt("rootcoord.timeout")
|
||||
p.Timeout = p.ParseIntWithDefault("rootCoord.timeout", 3600)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initTimeTickInterval() {
|
||||
p.TimeTickInterval = p.ParseInt("rootcoord.timeTickInterval")
|
||||
p.TimeTickInterval = p.ParseIntWithDefault("rootCoord.timeTickInterval", 200)
|
||||
}
|
||||
|
||||
func (p *ParamTable) initRoleName() {
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
package paramtable
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
|
@ -312,7 +313,7 @@ func (gp *BaseTable) Load(key string) (string, error) {
|
|||
return gp.params.Load(strings.ToLower(key))
|
||||
}
|
||||
|
||||
func (gp *BaseTable) LoadWithDefault(key string, defaultValue string) (string, error) {
|
||||
func (gp *BaseTable) LoadWithDefault(key string, defaultValue string) string {
|
||||
return gp.params.LoadWithDefault(strings.ToLower(key), defaultValue)
|
||||
}
|
||||
|
||||
|
@ -374,10 +375,7 @@ func (gp *BaseTable) Save(key, value string) error {
|
|||
}
|
||||
|
||||
func (gp *BaseTable) ParseBool(key string, defaultValue bool) bool {
|
||||
valueStr, err := gp.LoadWithDefault(key, strconv.FormatBool(defaultValue))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
valueStr := gp.LoadWithDefault(key, strconv.FormatBool(defaultValue))
|
||||
value, err := strconv.ParseBool(valueStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
@ -397,6 +395,15 @@ func (gp *BaseTable) ParseFloat(key string) float64 {
|
|||
return value
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseFloatWithDefault(key string, defaultValue float64) float64 {
|
||||
valueStr := gp.LoadWithDefault(key, fmt.Sprintf("%f", defaultValue))
|
||||
value, err := strconv.ParseFloat(valueStr, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseInt64(key string) int64 {
|
||||
valueStr, err := gp.Load(key)
|
||||
if err != nil {
|
||||
|
@ -409,6 +416,15 @@ func (gp *BaseTable) ParseInt64(key string) int64 {
|
|||
return value
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseInt64WithDefault(key string, defaultValue int64) int64 {
|
||||
valueStr := gp.LoadWithDefault(key, strconv.FormatInt(defaultValue, 10))
|
||||
value, err := strconv.ParseInt(valueStr, 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseInt32(key string) int32 {
|
||||
valueStr, err := gp.Load(key)
|
||||
if err != nil {
|
||||
|
@ -421,6 +437,15 @@ func (gp *BaseTable) ParseInt32(key string) int32 {
|
|||
return int32(value)
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseInt32WithDefault(key string, defaultValue int32) int32 {
|
||||
valueStr := gp.LoadWithDefault(key, strconv.FormatInt(int64(defaultValue), 10))
|
||||
value, err := strconv.ParseInt(valueStr, 10, 32)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return int32(value)
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseInt(key string) int {
|
||||
valueStr, err := gp.Load(key)
|
||||
if err != nil {
|
||||
|
@ -433,6 +458,15 @@ func (gp *BaseTable) ParseInt(key string) int {
|
|||
return value
|
||||
}
|
||||
|
||||
func (gp *BaseTable) ParseIntWithDefault(key string, defaultValue int) int {
|
||||
valueStr := gp.LoadWithDefault(key, strconv.FormatInt(int64(defaultValue), 10))
|
||||
value, err := strconv.Atoi(valueStr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// package methods
|
||||
|
||||
func ConvertRangeToIntRange(rangeStr, sep string) []int {
|
||||
|
|
|
@ -185,6 +185,15 @@ func TestBaseTable_Parse(t *testing.T) {
|
|||
assert.Panics(t, func() { baseParams.ParseFloat("key") })
|
||||
})
|
||||
|
||||
t.Run("ParseFloatWithDefault", func(t *testing.T) {
|
||||
baseParams.Remove("key")
|
||||
assert.Equal(t, float64(0.0), baseParams.ParseFloatWithDefault("key", 0.0))
|
||||
assert.Equal(t, float64(3.14), baseParams.ParseFloatWithDefault("key", 3.14))
|
||||
|
||||
assert.Nil(t, baseParams.Save("key", "2"))
|
||||
assert.Equal(t, float64(2.0), baseParams.ParseFloatWithDefault("key", 3.14))
|
||||
})
|
||||
|
||||
t.Run("ParseInt32", func(t *testing.T) {
|
||||
assert.Nil(t, baseParams.Save("key", "0"))
|
||||
assert.Equal(t, int32(0), baseParams.ParseInt32("key"))
|
||||
|
@ -197,6 +206,13 @@ func TestBaseTable_Parse(t *testing.T) {
|
|||
assert.Panics(t, func() { baseParams.ParseInt32("key") })
|
||||
})
|
||||
|
||||
t.Run("ParseInt32WithDefault", func(t *testing.T) {
|
||||
baseParams.Remove("key")
|
||||
assert.Equal(t, int32(1), baseParams.ParseInt32WithDefault("key", 1))
|
||||
assert.Nil(t, baseParams.Save("key", "2"))
|
||||
assert.Equal(t, int32(2), baseParams.ParseInt32WithDefault("key", 1))
|
||||
})
|
||||
|
||||
t.Run("ParseInt64", func(t *testing.T) {
|
||||
assert.Nil(t, baseParams.Save("key", "0"))
|
||||
assert.Equal(t, int64(0), baseParams.ParseInt64("key"))
|
||||
|
@ -208,6 +224,20 @@ func TestBaseTable_Parse(t *testing.T) {
|
|||
assert.Nil(t, baseParams.Save("key", "abc"))
|
||||
assert.Panics(t, func() { baseParams.ParseInt64("key") })
|
||||
})
|
||||
|
||||
t.Run("ParseInt64WithDefault", func(t *testing.T) {
|
||||
baseParams.Remove("key")
|
||||
assert.Equal(t, int64(1), baseParams.ParseInt64WithDefault("key", 1))
|
||||
assert.Nil(t, baseParams.Save("key", "2"))
|
||||
assert.Equal(t, int64(2), baseParams.ParseInt64WithDefault("key", 1))
|
||||
})
|
||||
|
||||
t.Run("ParseIntWithDefault", func(t *testing.T) {
|
||||
baseParams.Remove("key")
|
||||
assert.Equal(t, int(1), baseParams.ParseIntWithDefault("key", 1))
|
||||
assert.Nil(t, baseParams.Save("key", "2"))
|
||||
assert.Equal(t, int(2), baseParams.ParseIntWithDefault("key", 1))
|
||||
})
|
||||
}
|
||||
|
||||
func Test_ConvertRangeToIntSlice(t *testing.T) {
|
||||
|
|
|
@ -80,18 +80,12 @@ func (p *BaseParamTable) initUseEmbedEtcd() {
|
|||
}
|
||||
|
||||
func (p *BaseParamTable) initConfigPath() {
|
||||
addr, err := p.LoadWithDefault("etcd.config.path", "")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
addr := p.LoadWithDefault("etcd.config.path", "")
|
||||
p.EtcdConfigPath = addr
|
||||
}
|
||||
|
||||
func (p *BaseParamTable) initEtcdDataDir() {
|
||||
addr, err := p.LoadWithDefault("etcd.data.dir", "default.etcd")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
addr := p.LoadWithDefault("etcd.data.dir", "default.etcd")
|
||||
p.EtcdDataDir = addr
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue