Skip to content

Commit

Permalink
limit SELECT FilterValue size to < 20000 as big values cause memory i…
Browse files Browse the repository at this point in the history
…ssues
  • Loading branch information
awildturtok committed Jul 3, 2023
1 parent a60bff3 commit eb16224
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.bakdata.conquery.models.identifiable.ids.specific.FilterId;
import com.bakdata.conquery.models.query.QueryResolveContext;
import com.bakdata.conquery.models.query.queryplan.filter.FilterNode;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
Expand All @@ -27,6 +28,7 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
import io.dropwizard.validation.ValidationMethod;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -44,6 +46,10 @@
@EqualsAndHashCode
@ToString(of = "value")
public abstract class FilterValue<VALUE> {
/**
* Very large SELECT FilterValues can cause issues, so we just limit it to large but not gigantic quantities.
*/
private static final int MAX_NUMBER_FILTER_VALUES = 20_000;
@NotNull
@Nonnull
@NsIdRef
Expand All @@ -68,6 +74,12 @@ public static class CQMultiSelectFilter extends FilterValue<String[]> {
public CQMultiSelectFilter(@NsIdRef Filter<String[]> filter, String[] value) {
super(filter, value);
}

@ValidationMethod(message = "Too many values selected.")
@JsonIgnore
public boolean isSaneAmountOfFilterValues() {
return getValue().length < MAX_NUMBER_FILTER_VALUES;
}
}

@NoArgsConstructor
Expand All @@ -77,6 +89,12 @@ public static class CQBigMultiSelectFilter extends FilterValue<String[]> {
public CQBigMultiSelectFilter(@NsIdRef Filter<String[]> filter, String[] value) {
super(filter, value);
}

@ValidationMethod(message = "Too many values selected.")
@JsonIgnore
public boolean isSaneAmountOfFilterValues() {
return getValue().length < MAX_NUMBER_FILTER_VALUES;
}
}

@NoArgsConstructor
Expand Down

0 comments on commit eb16224

Please sign in to comment.