From 2127cb5567bb486805a373a9c7cdb270c3b4508d Mon Sep 17 00:00:00 2001 From: agrgr Date: Thu, 9 Nov 2023 09:41:51 +0200 Subject: [PATCH] remove EXCLUDE_FILTER in Qualifier --- .../aerospike/core/AerospikeTemplate.java | 3 -- .../core/ReactiveAerospikeTemplate.java | 3 -- .../data/aerospike/query/Qualifier.java | 9 ---- .../data/aerospike/query/QualifierUtils.java | 53 +++---------------- .../aerospike/query/StatementBuilder.java | 2 +- 5 files changed, 8 insertions(+), 62 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java index 22d517027..6374eee22 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java @@ -73,7 +73,6 @@ import static org.springframework.data.aerospike.core.TemplateUtils.getIdValue; import static org.springframework.data.aerospike.query.QualifierUtils.getOneIdQualifier; import static org.springframework.data.aerospike.query.QualifierUtils.queryCriteriaIsNotNull; -import static org.springframework.data.aerospike.query.QualifierUtils.validateQualifiers; /** * Primary implementation of {@link AerospikeOperations}. @@ -1276,8 +1275,6 @@ private Stream applyPostProcessingOnResults(Stream results, Sort sort, private Stream findRecordsUsingQuery(String setName, Class targetClass, Query query) { Qualifier qualifier = queryCriteriaIsNotNull(query) ? query.getCriteria().getCriteriaObject() : null; if (qualifier != null) { - validateQualifiers(qualifier); - Qualifier idQualifier = getOneIdQualifier(qualifier); if (idQualifier != null) { // a special flow if there is id given diff --git a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java index 1d92fab9d..cec4bd2a2 100644 --- a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java @@ -69,7 +69,6 @@ import static org.springframework.data.aerospike.core.TemplateUtils.getIdValue; import static org.springframework.data.aerospike.query.QualifierUtils.getOneIdQualifier; import static org.springframework.data.aerospike.query.QualifierUtils.queryCriteriaIsNotNull; -import static org.springframework.data.aerospike.query.QualifierUtils.validateQualifiers; /** * Primary implementation of {@link ReactiveAerospikeOperations}. @@ -1232,8 +1231,6 @@ private Flux findUsingQueryWithDistinctPredicate(String setName, Class private Flux findRecordsUsingQuery(String setName, Class targetClass, Query query) { Qualifier qualifier = queryCriteriaIsNotNull(query) ? query.getCriteria().getCriteriaObject() : null; if (qualifier != null) { - validateQualifiers(qualifier); - Qualifier idQualifier = getOneIdQualifier(qualifier); if (idQualifier != null) { // a special flow if there is id given diff --git a/src/main/java/org/springframework/data/aerospike/query/Qualifier.java b/src/main/java/org/springframework/data/aerospike/query/Qualifier.java index 4a0739b0e..4dbbfb8d4 100644 --- a/src/main/java/org/springframework/data/aerospike/query/Qualifier.java +++ b/src/main/java/org/springframework/data/aerospike/query/Qualifier.java @@ -55,7 +55,6 @@ public class Qualifier implements CriteriaDefinition, Map, Seria protected static final String QUALIFIERS = "qualifiers"; protected static final String OPERATION = "operation"; protected static final String AS_FILTER = "queryAsFilter"; - protected static final String EXCLUDE_FILTER = "excludeFilter"; @Serial private static final long serialVersionUID = -2689196529952712849L; protected final Map internalMap = new HashMap<>(); @@ -114,14 +113,6 @@ public Boolean queryAsFilter() { return internalMap.containsKey(AS_FILTER) && (Boolean) internalMap.get(AS_FILTER); } - public boolean getExcludeFilter() { - return internalMap.containsKey(EXCLUDE_FILTER) && (Boolean) internalMap.get(EXCLUDE_FILTER); - } - - public void setExcludeFilter(boolean excludeFilter) { - internalMap.put(EXCLUDE_FILTER, excludeFilter); - } - public boolean hasQualifiers() { return internalMap.get(QUALIFIERS) != null; } diff --git a/src/main/java/org/springframework/data/aerospike/query/QualifierUtils.java b/src/main/java/org/springframework/data/aerospike/query/QualifierUtils.java index 35717f334..ea1a09251 100644 --- a/src/main/java/org/springframework/data/aerospike/query/QualifierUtils.java +++ b/src/main/java/org/springframework/data/aerospike/query/QualifierUtils.java @@ -1,7 +1,6 @@ package org.springframework.data.aerospike.query; import lombok.experimental.UtilityClass; -import org.springframework.data.aerospike.repository.query.AerospikeCriteria; import org.springframework.data.aerospike.repository.query.Query; import java.util.ArrayList; @@ -10,58 +9,20 @@ @UtilityClass public class QualifierUtils { - @Deprecated(since = "4.6.0", forRemoval = true) - public static Qualifier getIdQualifier(AerospikeCriteria criteria) { - Object qualifiers = getQualifiers(criteria); - return getOneIdQualifier((Qualifier[]) qualifiers); - } - - public static Qualifier getIdQualifier(Qualifier criteria) { - Object qualifiers = getQualifiers(criteria); - return getOneIdQualifier((Qualifier[]) qualifiers); - } - - @Deprecated(since = "4.6.0", forRemoval = true) - public static Qualifier[] getQualifiers(AerospikeCriteria criteria) { - if (criteria == null) { - return null; - } else if (criteria.getQualifiers() == null) { - return new Qualifier[]{(criteria)}; - } - return criteria.getQualifiers(); - } - - public static Qualifier[] getQualifiers(Qualifier criteria) { - if (criteria == null) { - return null; - } else if (criteria.getQualifiers() == null) { - return new Qualifier[]{criteria}; - } - return criteria.getQualifiers(); - } - - public static void validateQualifiers(Qualifier... qualifiers) { - boolean haveInternalQualifiers = qualifiers.length > 1; - for (Qualifier qualifier : qualifiers) { - haveInternalQualifiers = haveInternalQualifiers || qualifier.hasQualifiers(); - // excludeFilter in the upmost parent qualifier is set to true - // if there are multiple qualifiers - // must not build secondary index filter based on any of them - // as it might conflict with the combination of qualifiers - qualifier.setExcludeFilter(haveInternalQualifiers); - } + public static Qualifier getIdQualifier(Qualifier qualifier) { + return getOneIdQualifier(qualifier); } /** * Find id qualifier. * - * @param qualifiers Qualifiers to search through - * @return The only id qualifier or null. + * @param qualifier {@link Qualifier} to search through + * @return The only id qualifier or null * @throws IllegalArgumentException if more than one id qualifier given */ - public static Qualifier getOneIdQualifier(Qualifier... qualifiers) { - if (qualifiers != null && qualifiers.length > 0) { - List idQualifiers = getIdQualifiers(qualifiers); + public static Qualifier getOneIdQualifier(Qualifier qualifier) { + if (qualifier != null) { + List idQualifiers = getIdQualifiers(new Qualifier[]{qualifier}); if (idQualifiers.size() > 1) { throw new IllegalArgumentException("Expecting not more than one id qualifier in qualifiers array," + " got " + idQualifiers.size()); diff --git a/src/main/java/org/springframework/data/aerospike/query/StatementBuilder.java b/src/main/java/org/springframework/data/aerospike/query/StatementBuilder.java index 7a1575987..d6dca3447 100644 --- a/src/main/java/org/springframework/data/aerospike/query/StatementBuilder.java +++ b/src/main/java/org/springframework/data/aerospike/query/StatementBuilder.java @@ -62,7 +62,7 @@ private void setStatementFilterFromQualifiers(Statement stmt, Qualifier qualifie /* * query with qualifier */ - if (qualifier == null || qualifier.getExcludeFilter()) return; + if (qualifier == null) return; if (qualifier.getOperation() == FilterOperation.AND) { // no sense to use secondary index in case of OR // as it requires to enlarge selection to more than 1 field