Skip to content

Commit c997854

Browse files
comments
1 parent 839bd57 commit c997854

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

parquet-variant/benches/variant_builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,9 @@ fn bench_iteration_performance(c: &mut Criterion) {
496496
}
497497

498498
fn bench_extend_metadata_builder(c: &mut Criterion) {
499-
let list = (0..u32::MAX).map(|i| format!("id_{i}")).collect::<Vec<_>>();
499+
let list = (0..400_000).map(|i| format!("id_{i}")).collect::<Vec<_>>();
500500

501-
c.bench_function("bench_validate_large_nested_list", |b| {
501+
c.bench_function("bench_extend_metadata_builder", |b| {
502502
b.iter(|| {
503503
std::hint::black_box(
504504
VariantBuilder::new().with_field_names(list.iter().map(|s| s.as_str())),

parquet-variant/src/builder.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ impl<S: AsRef<str>> FromIterator<S> for MetadataBuilder {
403403
impl<S: AsRef<str>> Extend<S> for MetadataBuilder {
404404
fn extend<T: IntoIterator<Item = S>>(&mut self, iter: T) {
405405
let iter = iter.into_iter();
406-
let (min, max) = iter.size_hint();
406+
let (min, _) = iter.size_hint();
407407

408-
self.field_names.reserve(max.unwrap_or(min));
408+
self.field_names.reserve(min);
409409

410410
for field_name in iter {
411411
self.upsert_field_name(field_name.as_ref());
@@ -768,10 +768,8 @@ impl VariantBuilder {
768768
/// This method reserves capacity for field names in the Variant metadata,
769769
/// which can improve performance when you know the approximate number of unique field
770770
/// names that will be used across all objects in the [`Variant`].
771-
pub fn with_field_name_capacity(mut self, capacity: usize) -> Self {
771+
pub fn reserve(&mut self, capacity: usize) {
772772
self.metadata_builder.field_names.reserve(capacity);
773-
774-
self
775773
}
776774

777775
/// Adds a single field name to the field name directory in the Variant metadata.

0 commit comments

Comments
 (0)