Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Nov 16, 2023
1 parent 5d34e37 commit 52eb141
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,16 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
*/
<T> Stream<T> findInRange(long offset, long limit, Sort sort, Class<T> 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.
*/
<T> Stream<T> findUsingQueryWithoutPostProcessing(Class<?> entityClass, Class<T> targetClass, Query query);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ private <T> Stream<T> findUsingQueryWithPostProcessing(String setName, Class<T>
return applyPostProcessingOnResults(results, query);
}

@Override
public <T> Stream<T> findUsingQueryWithoutPostProcessing(Class<?> entityClass, Class<T> targetClass, Query query) {
verifyUnsortedWithOffset(query.getSort(), query.getOffset());
return findUsingQueryWithDistinctPredicate(getSetName(entityClass), targetClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,6 +868,16 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
*/
<T, S> Flux<S> findInRange(long offset, long limit, Sort sort, Class<T> entityClass, Class<S> 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.
*/
<T> Flux<T> findUsingQueryWithoutPostProcessing(Class<?> entityClass, Class<T> targetClass, Query query);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,7 @@ private <T> Flux<T> findUsingQueryWithPostProcessing(String setName, Class<T> ta
return results;
}

@Override
public <T> Flux<T> findUsingQueryWithoutPostProcessing(Class<?> entityClass, Class<T> targetClass, Query query) {
verifyUnsortedWithOffset(query.getSort(), query.getOffset());
return findUsingQueryWithDistinctPredicate(getSetName(entityClass), targetClass,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -113,12 +116,4 @@ private Mono<KeyRecord> 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;
}
}

0 comments on commit 52eb141

Please sign in to comment.