Browse Source

Match Go EC locate: subtract 1 from shard size and use datFileSize override

Go's LocateEcShardNeedleInterval passes shard.ecdFileSize-1 to
LocateData (shards are padded, -1 avoids overcounting large block
rows). When datFileSize is known, Go uses datFileSize/DataShards
instead. Rust was passing the raw shard file size without adjustment.
rust-volume-server
Chris Lu 3 days ago
parent
commit
fbcedba68b
  1. 10
      seaweed-volume/src/storage/erasure_coding/ec_volume.rs

10
seaweed-volume/src/storage/erasure_coding/ec_volume.rs

@ -329,7 +329,15 @@ impl EcVolume {
return Ok(None);
}
let shard_size = self.shard_file_size();
// Match Go's LocateEcShardNeedleInterval: shardSize = shard.ecdFileSize - 1
// Shards are usually padded to ErasureCodingSmallBlockSize, so subtract 1
// to avoid off-by-one in large block row count calculation.
// If datFileSize is known, use datFileSize / DataShards instead.
let shard_size = if self.dat_file_size > 0 {
self.dat_file_size / self.data_shards as i64
} else {
self.shard_file_size() - 1
};
// Pass the actual on-disk size (header+body+checksum+timestamp+padding)
// to locate_data, matching Go: types.Size(needle.GetActualSize(size, version))
let actual = get_actual_size(size, self.version);

Loading…
Cancel
Save