Skip to content

Commit c944bfd

Browse files
fix[benchmark]: random access validate format (#6396)
Signed-off-by: Joe Isaacs <[email protected]>
1 parent 0fc32ff commit c944bfd

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎benchmarks/random-access-bench/src/main.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ struct Args {
158158
#[arg(
159159
long,
160160
value_delimiter = ',',
161-
value_enum,
162-
default_values_t = vec![Format::Parquet, Format::OnDiskVortex]
161+
value_parser = Format::parse_allowed,
162+
default_values_t = vec![Format::Parquet, Format::OnDiskVortex, Format::Lance]
163163
)]
164164
formats: Vec<Format>,
165165
/// Time limit in seconds for each benchmark target (e.g., 10 for 10 seconds).

‎vortex-bench/src/lib.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,24 @@ impl Display for Format {
151151
}
152152
}
153153

154+
/// Allowed formats for benchmark CLI arguments.
155+
pub const ALLOWED_FORMATS: &[Format] = &[Format::Parquet, Format::OnDiskVortex, Format::Lance];
156+
154157
impl Format {
158+
/// Clap value parser that only accepts parquet, vortex, and lance.
159+
pub fn parse_allowed(s: &str) -> Result<Format, String> {
160+
let format = Format::from_str(s, true)?;
161+
if ALLOWED_FORMATS.contains(&format) {
162+
Ok(format)
163+
} else {
164+
Err(format!(
165+
"invalid format '{}': allowed values are [{}]",
166+
s,
167+
ALLOWED_FORMATS.iter().map(|f| f.to_string()).join(", "),
168+
))
169+
}
170+
}
171+
155172
pub fn name(&self) -> &'static str {
156173
match self {
157174
Format::Csv => "csv",

0 commit comments

Comments
 (0)