github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/pkg/config/sorter.go (about) 1 // Copyright 2020 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package config 15 16 import ( 17 "math" 18 19 "github.com/pingcap/tiflow/pkg/errors" 20 ) 21 22 // SorterConfig represents sorter config for a changefeed 23 type SorterConfig struct { 24 // the directory used to store the temporary files generated by the sorter 25 SortDir string `toml:"sort-dir" json:"sort-dir"` 26 27 // Cache size of sorter in MB. 28 CacheSizeInMB uint64 `toml:"cache-size-in-mb" json:"cache-size-in-mb"` 29 30 // Deprecated: we don't use this field anymore. 31 MaxMemoryPercentage int `toml:"max-memory-percentage" json:"max-memory-percentage"` 32 // Deprecated: we don't use this field anymore. 33 MaxMemoryConsumption uint64 `toml:"max-memory-consumption" json:"max-memory-consumption"` 34 // Deprecated: we don't use this field anymore. 35 NumWorkerPoolGoroutine int `toml:"num-workerpool-goroutine" json:"num-workerpool-goroutine"` 36 // Deprecated: we don't use this field anymore . 37 NumConcurrentWorker int `toml:"num-concurrent-worker" json:"num-concurrent-worker"` 38 // Deprecated: we don't use this field anymore. 39 ChunkSizeLimit uint64 `toml:"chunk-size-limit" json:"chunk-size-limit"` 40 } 41 42 // ValidateAndAdjust validates and adjusts the sorter configuration 43 func (c *SorterConfig) ValidateAndAdjust() error { 44 if c.CacheSizeInMB < 8 || c.CacheSizeInMB*uint64(1<<20) > uint64(math.MaxInt64) { 45 return errors.ErrIllegalSorterParameter.GenWithStackByArgs("cache-size-in-mb should be greater than 8(MB)") 46 } 47 return nil 48 }