From 52eb141322c7429dae23e076a78cdae04e73d232 Mon Sep 17 00:00:00 2001 From: agrgr Date: Thu, 16 Nov 2023 12:17:21 +0200 Subject: [PATCH] cleanup --- .../data/aerospike/core/AerospikeOperations.java | 10 ++++++++++ .../data/aerospike/core/AerospikeTemplate.java | 1 + .../core/ReactiveAerospikeOperations.java | 10 ++++++++++ .../aerospike/core/ReactiveAerospikeTemplate.java | 1 + .../data/aerospike/query/QueryEngine.java | 15 +++++---------- .../data/aerospike/query/ReactorQueryEngine.java | 15 +++++---------- 6 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/springframework/data/aerospike/core/AerospikeOperations.java b/src/main/java/org/springframework/data/aerospike/core/AerospikeOperations.java index 8cc36d48c..945f3ce5e 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeOperations.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeOperations.java @@ -896,6 +896,16 @@ List findByIdsUsingQuery(Collection ids, Class entityClass, Clas */ Stream findInRange(long offset, long limit, Sort sort, Class targetClass, String setName); + /** + * Find documents in the given entityClass's set using a query and map them to the given target class type. If the + * query has pagination and/or sorting, post-processing must be applied separately. + * + * @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}. + * @param targetClass The class to map the document to. + * @param query The {@link Query} to filter results. + * @return A Stream of all matching documents regardless of pagination/sorting, returned documents will be mapped to + * targetClass's type. + */ Stream findUsingQueryWithoutPostProcessing(Class entityClass, Class targetClass, Query query); /** 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 04ba1e299..eb7e81a52 100644 --- a/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/AerospikeTemplate.java @@ -944,6 +944,7 @@ private Stream findUsingQueryWithPostProcessing(String setName, Class return applyPostProcessingOnResults(results, query); } + @Override public Stream findUsingQueryWithoutPostProcessing(Class entityClass, Class targetClass, Query query) { verifyUnsortedWithOffset(query.getSort(), query.getOffset()); return findUsingQueryWithDistinctPredicate(getSetName(entityClass), targetClass, diff --git a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeOperations.java b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeOperations.java index 89964c46f..9eaf4fbe4 100644 --- a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeOperations.java +++ b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeOperations.java @@ -868,6 +868,16 @@ Flux findByIdsUsingQuery(Collection ids, Class entityClass, Clas */ Flux findInRange(long offset, long limit, Sort sort, Class entityClass, Class targetClass); + /** + * Reactively find documents in the given entityClass's set using a query and map them to the given target class + * type. If the query has pagination and/or sorting, post-processing must be applied separately. + * + * @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}. + * @param targetClass The class to map the document to. + * @param query The {@link Query} to filter results. + * @return A Flux of all matching documents regardless of pagination/sorting, returned documents will be mapped to + * targetClass's type. + */ Flux findUsingQueryWithoutPostProcessing(Class entityClass, Class targetClass, Query query); /** 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 eea0e8e70..57d4dc1ca 100644 --- a/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java +++ b/src/main/java/org/springframework/data/aerospike/core/ReactiveAerospikeTemplate.java @@ -1177,6 +1177,7 @@ private Flux findUsingQueryWithPostProcessing(String setName, Class ta return results; } + @Override public Flux findUsingQueryWithoutPostProcessing(Class entityClass, Class targetClass, Query query) { verifyUnsortedWithOffset(query.getSort(), query.getOffset()); return findUsingQueryWithDistinctPredicate(getSetName(entityClass), targetClass, 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 c1bf8f5f2..ae551438c 100644 --- a/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java +++ b/src/main/java/org/springframework/data/aerospike/query/QueryEngine.java @@ -25,6 +25,7 @@ import com.aerospike.client.query.RecordSet; import com.aerospike.client.query.Statement; import lombok.Getter; +import lombok.Setter; import org.springframework.data.aerospike.repository.query.Query; import org.springframework.lang.Nullable; @@ -53,8 +54,10 @@ public class QueryEngine { * Scans can potentially slow down Aerospike server, so we are disabling them by default. If you still need to use * scans, set this property to true. */ - private boolean scansEnabled = false; - private int queryMaxRecords = 100000; + @Setter + private boolean scansEnabled; + @Setter + private int queryMaxRecords; public QueryEngine(IAerospikeClient client, StatementBuilder statementBuilder, FilterExpressionsBuilder filterExpressionsBuilder, QueryPolicy queryPolicy) { @@ -126,14 +129,6 @@ private Record getRecord(Policy policy, Key key, String[] binNames) { return client.get(policy, key, binNames); } - public void setScansEnabled(boolean scansEnabled) { - this.scansEnabled = scansEnabled; - } - - public void setQueryMaxRecords(int queryMaxRecords) { - this.queryMaxRecords = queryMaxRecords; - } - @Deprecated(since = "4.6.0", forRemoval = true) public enum Meta { KEY, 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 565bec56b..6474bd862 100644 --- a/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java +++ b/src/main/java/org/springframework/data/aerospike/query/ReactorQueryEngine.java @@ -23,6 +23,7 @@ import com.aerospike.client.query.Statement; import com.aerospike.client.reactor.IAerospikeReactorClient; import lombok.Getter; +import lombok.Setter; import org.springframework.data.aerospike.repository.query.Query; import org.springframework.lang.Nullable; import reactor.core.publisher.Flux; @@ -49,8 +50,10 @@ public class ReactorQueryEngine { * Scans can potentially slow down Aerospike server, so we are disabling them by default. If you still need to use * scans, set this property to true. */ - private boolean scansEnabled = false; - private int queryMaxRecords = 100000; + @Setter + private boolean scansEnabled; + @Setter + private int queryMaxRecords; public ReactorQueryEngine(IAerospikeReactorClient client, StatementBuilder statementBuilder, FilterExpressionsBuilder filterExpressionsBuilder, QueryPolicy queryPolicy) { @@ -113,12 +116,4 @@ private Mono getRecord(Policy policy, Key key, String[] binNames) { } return client.get(policy, key, binNames); } - - public void setScansEnabled(boolean scansEnabled) { - this.scansEnabled = scansEnabled; - } - - public void setQueryMaxRecords(int queryMaxRecords) { - this.queryMaxRecords = queryMaxRecords; - } }