From 06f7ed102c11c89a8f5beb54798f6771fdbe10dd Mon Sep 17 00:00:00 2001 From: agrgr Date: Wed, 8 Jan 2025 18:27:47 +0200 Subject: [PATCH] add byte[] support in CDT containing filter operation, cleanup --- src/main/asciidoc/reference/configuration.adoc | 4 ++-- .../data/aerospike/query/FilterOperation.java | 3 ++- .../data/aerospike/query/QueryEngine.java | 10 ++++------ .../data/aerospike/query/ReactorQueryEngine.java | 3 ++- .../repository/query/blocking/delete/EqualsTests.java | 2 +- .../data/aerospike/sample/PersonRepository.java | 5 +++++ 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/asciidoc/reference/configuration.adoc b/src/main/asciidoc/reference/configuration.adoc index ccdccac9..337d5190 100644 --- a/src/main/asciidoc/reference/configuration.adoc +++ b/src/main/asciidoc/reference/configuration.adoc @@ -1,8 +1,8 @@ [[configuration]] = Configuration -Configuration parameters can be set in a standard `application.properties` file using `spring.data.aerospike*` prefix -or by overriding configuration from `AbstractAerospikeDataConfiguration` class. +Configuration parameters can be set in a standard `application.properties` file using `spring.aerospike*` +and `spring.data.aerospike*` prefixes or by overriding configuration from `AbstractAerospikeDataConfiguration` class. [[configuration.application-properties]] == Application.properties diff --git a/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java b/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java index 35d9aa16..c85c3013 100644 --- a/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java +++ b/src/main/java/org/springframework/data/aerospike/query/FilterOperation.java @@ -1989,11 +1989,12 @@ protected Filter cdtContains(IndexCollectionType collectionType, Map Filter.contains(getBinName(qualifierMap), collectionType, val.toLong(), getCtxArr(qualifierMap)); case STRING -> Filter.contains(getBinName(qualifierMap), collectionType, val.toString(), getCtxArr(qualifierMap)); + case BLOB -> Filter.contains(getBinName(qualifierMap), collectionType, (byte[]) val.getObject(), + getCtxArr(qualifierMap)); default -> null; }; } diff --git a/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java b/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java index 6b77fec4..45fac812 100644 --- a/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java +++ b/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java @@ -27,8 +27,6 @@ import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.data.aerospike.config.AerospikeDataSettings; import org.springframework.data.aerospike.query.qualifier.Qualifier; import org.springframework.data.aerospike.repository.query.Query; @@ -53,10 +51,9 @@ @Slf4j public class QueryEngine { - private static final Logger logger = LoggerFactory.getLogger(QueryEngine.class); public static final String SCANS_DISABLED_MESSAGE = - "Query without a filter will initiate a scan. Since scans are potentially dangerous operations, they are " + - "disabled by default in spring-data-aerospike. " + + "Query without a secondary index filter will initiate a scan. Since scans are potentially dangerous operations," + + " they are disabled by default in spring-data-aerospike. " + "If you still need to use them, enable them via `scans-enabled` property."; public static final List SEC_INDEX_ERROR_RESULT_CODES = List.of( INDEX_NOTFOUND, INDEX_OOM, INDEX_NOTREADABLE, INDEX_GENERIC, INDEX_NAME_MAXLEN, INDEX_MAXCOUNT); @@ -128,7 +125,8 @@ public KeyRecordIterator select(String namespace, String set, String[] binNames, return new KeyRecordIterator(namespace, rs); } catch (AerospikeException e) { if (statement.getFilter() != null && SEC_INDEX_ERROR_RESULT_CODES.contains(e.getResultCode())) { - log.warn("Got secondary index related exception (resultCode: {}), retrying with filter expression only", + log.warn("Got secondary index related exception (resultCode: {}), " + + "retrying with filter expression only (scan operation)", e.getResultCode()); return retryWithFilterExpression(namespace, qualifier, statement); } diff --git a/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java b/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java index c796bbcd..af22179e 100644 --- a/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java +++ b/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java @@ -115,7 +115,8 @@ public Flux select(String namespace, String set, String[] binNames, @ && SEC_INDEX_ERROR_RESULT_CODES.contains(ae.getResultCode())) { log.warn( - "Got secondary index related exception (resultCode: {}), retrying with filter expression only", + "Got secondary index related exception (resultCode: {}), " + + "retrying with filter expression only (scan operation)", ae.getResultCode()); return retryWithFilterExpression(qualifier, statement); } diff --git a/src/test/java/org/springframework/data/aerospike/repository/query/blocking/delete/EqualsTests.java b/src/test/java/org/springframework/data/aerospike/repository/query/blocking/delete/EqualsTests.java index 2b7ff921..2bb448c3 100644 --- a/src/test/java/org/springframework/data/aerospike/repository/query/blocking/delete/EqualsTests.java +++ b/src/test/java/org/springframework/data/aerospike/repository/query/blocking/delete/EqualsTests.java @@ -16,7 +16,7 @@ public class EqualsTests extends PersonRepositoryQueryTests { @Test void deleteBySimplePropertyEquals_String() { - assertThat(repository.findByFirstName("Leroi")).isNotEmpty(); + assertThat(repository.findByFirstName("Leroi")).isNotEmpty().hasSize(2); repository.deleteByFirstName("Leroi"); assertThat(repository.findByFirstName("Leroi")).isEmpty(); diff --git a/src/test/java/org/springframework/data/aerospike/sample/PersonRepository.java b/src/test/java/org/springframework/data/aerospike/sample/PersonRepository.java index c5e6576b..6c3ff30b 100644 --- a/src/test/java/org/springframework/data/aerospike/sample/PersonRepository.java +++ b/src/test/java/org/springframework/data/aerospike/sample/PersonRepository.java @@ -1573,6 +1573,11 @@ List

findByFriendStringMapNotContaining(AerospikeQueryCriterion criterion, long countByFirstName(String name); + /** + * Delete all entities with the given first name + * + * @param name First name to match + */ void deleteByFirstName(String name); List

readByFirstName(String name);