Skip to content

Commit

Permalink
add byte[] support in CDT containing filter operation, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Jan 8, 2025
1 parent 667e06c commit 06f7ed1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/asciidoc/reference/configuration.adoc
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1989,11 +1989,12 @@ protected Filter cdtContains(IndexCollectionType collectionType, Map<QualifierKe
qualifierMap.put(CTX_ARRAY, resolveCtxList(ctxList));
}
return switch (valType) {
// TODO: Add Bytes and Double Support (will fail on old mode - no results)
case INTEGER -> 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;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Integer> SEC_INDEX_ERROR_RESULT_CODES = List.of(
INDEX_NOTFOUND, INDEX_OOM, INDEX_NOTREADABLE, INDEX_GENERIC, INDEX_NAME_MAXLEN, INDEX_MAXCOUNT);
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ public Flux<KeyRecord> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1573,6 +1573,11 @@ List<P> 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<P> readByFirstName(String name);
Expand Down

0 comments on commit 06f7ed1

Please sign in to comment.