Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions datafusion/core/benches/map_query_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use std::collections::HashSet;
use std::sync::Arc;

use arrow::array::{ArrayRef, Int32Array, RecordBatch};
Expand All @@ -33,8 +34,15 @@ mod data_utils;

fn build_keys(rng: &mut ThreadRng) -> Vec<String> {
let mut keys = vec![];
for _ in 0..1000 {
keys.push(rng.random_range(0..9999).to_string());
let mut seen = HashSet::with_capacity(1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also make keys a HashSet and just keep inserting into it until it reaches 1000 instead of having both keys and seen

// Generate unique keys by tracking seen keys
while keys.len() < 1000 {
let key = rng.random_range(0..9999).to_string();
if seen.insert(key.clone()) {
// Only push if it's a new unique key
keys.push(key);
}
// If key was already in set, skip it and generate another
}
keys
}
Expand Down