Browse Source

refactor: move MaxShardCount constant to ec_encoder.go

Moved MaxShardCount from ec_volume_info.go to ec_encoder.go to group it
with other shard count constants (DataShardsCount, ParityShardsCount,
TotalShardsCount). This improves code organization and makes it easier
to understand the relationship between these constants.

Location: ec_encoder.go line 22, between TotalShardsCount and MinTotalDisks
pull/7396/head
chrislu 1 month ago
parent
commit
c4f970bfa6
  1. 5
      weed/storage/erasure_coding/ec_encoder.go
  2. 4
      weed/storage/erasure_coding/ec_volume_info.go

5
weed/storage/erasure_coding/ec_encoder.go

@ -19,6 +19,7 @@ const (
DataShardsCount = 10
ParityShardsCount = 4
TotalShardsCount = DataShardsCount + ParityShardsCount
MaxShardCount = 32 // Maximum number of shards since ShardBits is uint32 (bits 0-31)
MinTotalDisks = TotalShardsCount/ParityShardsCount + 1
ErasureCodingLargeBlockSize = 1024 * 1024 * 1024 // 1GB
ErasureCodingSmallBlockSize = 1024 * 1024 // 1MB
@ -72,7 +73,7 @@ func RebuildEcFiles(baseFileName string) ([]uint32, error) {
if volumeInfo, _, found, _ := volume_info.MaybeLoadVolumeInfo(baseFileName + ".vif"); found && volumeInfo.EcShardConfig != nil {
ds := int(volumeInfo.EcShardConfig.DataShards)
ps := int(volumeInfo.EcShardConfig.ParityShards)
// Validate EC config before using it
if ds > 0 && ps > 0 && ds+ps <= MaxShardCount {
ctx = &ECContext{
@ -88,7 +89,7 @@ func RebuildEcFiles(baseFileName string) ([]uint32, error) {
glog.V(0).Infof("Rebuilding EC files for %s with default config", baseFileName)
ctx = NewDefaultECContext("", 0)
}
return RebuildEcFilesWithContext(baseFileName, ctx)
}

4
weed/storage/erasure_coding/ec_volume_info.go

@ -118,10 +118,6 @@ func (ecInfo *EcVolumeInfo) ToVolumeEcShardInformationMessage() (ret *master_pb.
type ShardBits uint32 // use bits to indicate the shard id, use 32 bits just for possible future extension
const (
MaxShardCount = 32 // Maximum number of shards since ShardBits is uint32 (bits 0-31)
)
func (b ShardBits) AddShardId(id ShardId) ShardBits {
return b | (1 << id)
}

Loading…
Cancel
Save