Skip to content

Commit

Permalink
Dedup IN values
Browse files Browse the repository at this point in the history
  • Loading branch information
Julius de Bruijn committed Mar 16, 2020
1 parent 7406ee9 commit 0cce28f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions query-engine/connectors/query-connector/src/filter/scalar.rs
@@ -1,7 +1,7 @@
use super::Filter;
use crate::compare::ScalarCompare;
use prisma_models::{DataSourceFieldRef, ModelProjection, PrismaListValue, PrismaValue};
use std::sync::Arc;
use std::{collections::BTreeSet, sync::Arc};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ScalarProjection {
Expand Down Expand Up @@ -31,11 +31,12 @@ impl ScalarFilter {
}

pub fn batched(self) -> Vec<ScalarFilter> {
fn inner(list: PrismaListValue) -> Vec<PrismaListValue> {
fn inner(mut list: PrismaListValue) -> Vec<PrismaListValue> {
let dedup_list: BTreeSet<_> = list.drain(..).collect();
let mut batches = Vec::with_capacity(list.len() % BATCH_SIZE + 1);
batches.push(Vec::with_capacity(BATCH_SIZE));

for (idx, item) in list.into_iter().enumerate() {
for (idx, item) in dedup_list.into_iter().enumerate() {
if idx != 0 && idx % BATCH_SIZE == 0 {
batches.push(Vec::with_capacity(BATCH_SIZE));
}
Expand Down

0 comments on commit 0cce28f

Please sign in to comment.