Untitled conversation
- Usercode
#[derive(Debug, Clone)] struct Video { id: u32, path: String, size: u64, width: u16, height: u16, duration: f32, bitrate: u32, codec: String, valid_frames: f32, black_frames: f32, bad_frames: f32, timeout_frames: f32, checksum: String, phash: Vec<u64>, } #[derive(Debug, Clone)] struct Phash { video_id: u32, phash: u64, neighbors: HashSet<usize>, } fn find_duplicates(videos: HashMap<u32, Video>) { let mut phashes = Vec::new(); for (video_id, video) in videos.clone() { for phash in video.phash { phashes.push(Phash { video_id: video_id, phash: phash, neighbors: HashSet::new() }); } } let max_distance: u32 = 6; let mut curr_video_id: u32 = u32::MAX; // TODO: Use rayon to parallelize this for i in 0..phashes.len() { let query = phashes[i].clone(); for j in 0..phashes.len() { let item = phashes[j].clone(); if i == j { continue; } if query.neighbors.contains(&j) { continue; } if query.video_id == item.video_id { continue; } let distance = (query.phash ^ item.phash).count_ones(); if distance <= max_distance { phashes.index_mut(i).neighbors.insert(j); phashes.index_mut(j).neighbors.insert(i); } } } }Please use rayon to parallelize
find_duplicates - Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.