#pragma once #include "helpers.h" #include #include namespace NErasure { template class TReedSolomonBase : public ICodec { public: static constexpr ui64 RequiredDataAlignment = alignof(ui64); bool CanRepair(const TPartIndexList& erasedIndices) const final { return erasedIndices.size() <= ParityPartCount; } bool CanRepair(const TPartIndexSet& erasedIndices) const final { return erasedIndices.count() <= static_cast(ParityPartCount); } std::optional GetRepairIndices(const TPartIndexList& erasedIndices) const final { if (erasedIndices.empty()) { return TPartIndexList(); } TPartIndexList indices = erasedIndices; std::sort(indices.begin(), indices.end()); indices.erase(std::unique(indices.begin(), indices.end()), indices.end()); if (indices.size() > static_cast(ParityPartCount)) { return std::nullopt; } return Difference(0, DataPartCount + ParityPartCount, indices); } int GetDataPartCount() const final { return DataPartCount; } int GetParityPartCount() const final { return ParityPartCount; } int GetGuaranteedRepairablePartCount() const final { return ParityPartCount; } int GetWordSize() const final { return WordSize * sizeof(long); } virtual ~TReedSolomonBase() = default; }; } // namespace NErasure