https://slatedb.io logo
I've been thinking about how to support
# general
s
I've been thinking about how to support custom validation rules for different compaction scheduling strategies. This would also be useful for the compaction validations we plan to add with compaction persistence workflow. To address this, I suggest we introduce a
validate_compaction
method to the scheduler's interface. This would serve as a dedicated hook for compaction schedulers to verify compaction scheduled by them. Here are a couple of implementation ideas: 1. Provide a default implementation within the current compaction_scheduler trait. This would be easy to adopt and wouldn't require changes to existing compaction schedulers.
Copy code
Rust
// Default implementation returns Ok
pub trait CompactionScheduler: Send + Sync {
    fn maybe_schedule_compaction(&self, state: &CompactorState) -> Vec<Compaction>;
    fn validate_compaction(...) -> Result<(), SlateDBError> { Ok(()) }
}
2. Use a separate CompactionValidator trait. This would cleanly separate the validation concern from scheduling logic. Thoughts on the above☝️ . Curious to hear other perspectives.
r
Let's just add it to the
CompactionScheduler
trait. Validation is coupled pretty tightly to the scheduling logic
s
Yes. I was thinking of having it there as well. I will use the
validate_compaction
in compaction_state.rs method trait method implementation by size_tiered compaction. Does that seem fine?
I will create a PR for it.
@Rohan I see the scope of the SlateDBError is at the crate level. Should I make the above
validate_compaction
boolean?
r
yeah that seems fine
maybe a
Result<(), String>
so there can be some error msg
c
left comments!
s
Responded.
This refactoring aims to bundle a compaction strategy's scheduling logic and its validation logic together, much like a Codec pairs encoding with decoding.
c
👍 responded