From 6efb948b44cc44d5d39b800805baf11df4eb489f Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sun, 8 Mar 2026 10:31:34 -0700 Subject: [PATCH] fix(ec): use constants for default EC shard counts and resolve compiler error --- .../src/storage/erasure_coding/ec_volume.rs | 4 ++-- seaweed-volume/src/storage/volume.rs | 24 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs index 63436c9f2..5eccc4f27 100644 --- a/seaweed-volume/src/storage/erasure_coding/ec_volume.rs +++ b/seaweed-volume/src/storage/erasure_coding/ec_volume.rs @@ -28,8 +28,8 @@ pub struct EcVolume { } pub fn read_ec_shard_config(dir: &str, volume_id: VolumeId) -> (u32, u32) { - let mut data_shards = 10; - let mut parity_shards = 4; + let mut data_shards = crate::storage::erasure_coding::ec_shard::DATA_SHARDS_COUNT as u32; + let mut parity_shards = crate::storage::erasure_coding::ec_shard::PARITY_SHARDS_COUNT as u32; let vif_path = format!("{}/{}.vif", dir, volume_id.0); if let Ok(vif_content) = std::fs::read_to_string(&vif_path) { if let Ok(vif_info) = serde_json::from_str::(&vif_content) { diff --git a/seaweed-volume/src/storage/volume.rs b/seaweed-volume/src/storage/volume.rs index 72a97af06..7e02dc98e 100644 --- a/seaweed-volume/src/storage/volume.rs +++ b/seaweed-volume/src/storage/volume.rs @@ -173,13 +173,15 @@ pub struct VifEcShardConfig { pub struct VifVolumeInfo { #[serde(default)] pub files: Vec, + #[serde(default)] pub version: u32, - pub collection: String, - pub replica_placement: u32, - pub ttl: String, - #[serde(default, rename = "datFileSize")] - pub dat_file_size: u64, - #[serde(default, rename = "expireAtSec")] + #[serde(default)] + pub replication: String, + #[serde(default, rename = "bytesOffset")] + pub bytes_offset: u32, + #[serde(default, rename = "datFileSize", with = "string_or_i64")] + pub dat_file_size: i64, + #[serde(default, rename = "expireAtSec", with = "string_or_u64")] pub expire_at_sec: u64, #[serde(default, rename = "readOnly")] pub read_only: bool, @@ -205,9 +207,8 @@ impl VifVolumeInfo { }) .collect(), version: pb.version, - collection: pb.collection.clone(), - replica_placement: pb.replica_placement, - ttl: pb.ttl.clone(), + replication: pb.replication.clone(), + bytes_offset: pb.bytes_offset, dat_file_size: pb.dat_file_size, expire_at_sec: pb.expire_at_sec, read_only: pb.read_only, @@ -235,9 +236,8 @@ impl VifVolumeInfo { }) .collect(), version: self.version, - collection: self.collection.clone(), - replica_placement: self.replica_placement, - ttl: self.ttl.clone(), + replication: self.replication.clone(), + bytes_offset: self.bytes_offset, dat_file_size: self.dat_file_size, expire_at_sec: self.expire_at_sec, read_only: self.read_only,