Commit ff408ff
authored
refactor: Remove redundant parameters from SnapshotProducer validation methods (#1853)
## Which issue does this PR close?
- Closes #.
## What changes are included in this PR?
## Summary
Refactor `SnapshotProducer` validation methods to use internal state
instead of requiring redundant parameters.
## Problem
I've noticed that while the current **SnapshotProducer** API design
already equips SnapshotProducer with all necessary state, the current
invocations still redundantly pass parameters externally. I believe this
could lead to some issues.
1. **Data mismatch risk**: Callers could pass different data than what's
stored in `SnapshotProducer`, leading to validating one set of files but
committing another
2. **API complexity**: As more validations are added (e.g., delete
files, file existence checks), each method would require additional
parameters, making the API harder to use
3. **Redundant passing**: The same data that was already provided during
construction has to be passed again
## Changes
- Modified `validate_added_data_files()` and
`validate_duplicate_files()` to operate on `self.added_data_files`
directly
- Updated `FastAppendAction::commit()` to call validation methods
without passing `added_data_files` parameter
## Motivation
Previously, `added_data_files` was passed as a parameter to validation
methods even though it was already stored in `SnapshotProducer`:
```rust
// Before
snapshot_producer.validate_added_data_files(&self.added_data_files)?;
// After
snapshot_producer.validate_added_data_files()?;
```
## Benefits
1. Better encapsulation - validation operates on object's own state
2. Safer API - eliminates possibility of data mismatch
3. Simpler interface - no redundant parameters needed
## Discussion
Since **SnapshotProducer** already holds all necessary state, can we
further refine validation by performing it during the **new** function's
execution to improve data consistency and encapsulation?
## Are these changes tested?1 parent 12c4c21 commit ff408ff
2 files changed
+7
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 100 | + | |
103 | 101 | | |
104 | 102 | | |
105 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
| 102 | + | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
131 | 129 | | |
132 | 130 | | |
133 | 131 | | |
| |||
0 commit comments