Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Oct 12, 2023
1 parent b120f67 commit e515305
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public Qualifier[] getQualifiers() {
return (Qualifier[]) internalMap.get(QUALIFIERS);
}

public boolean hasQualifiers() {
return internalMap.get(QUALIFIERS) != null;
}

public Value getValue1() {
return (Value) internalMap.get(VALUE1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.springframework.util.Assert;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -164,13 +163,19 @@ public boolean indexExists(String indexName) {
@Override
public Iterable<T> findByQualifiers(Qualifier... qualifiers) {
Assert.notNull(qualifiers, "Qualifiers must not be null");
validateQualifiers(qualifiers);
return operations.findAllUsingQuery(entityInformation.getJavaType(), null, qualifiers).toList();
}

Arrays.stream(qualifiers).forEach(qualifier -> {
// not to build secondary index filter based on this qualifier
// as it might conflict with a combination of other qualifiers
qualifier.setExcludeFilter(true);
public static void validateQualifiers(Qualifier... qualifiers) {
boolean haveInternalQualifiers = qualifiers.length > 1;
for (Qualifier qualifier : qualifiers) {
Qualifier.validate(qualifier);
});
return operations.findAllUsingQuery(entityInformation.getJavaType(), null, qualifiers).toList();
haveInternalQualifiers = haveInternalQualifiers || qualifier.hasQualifiers();
// 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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.Arrays;
import static org.springframework.data.aerospike.repository.support.SimpleAerospikeRepository.validateQualifiers;

/**
* Stub implementation of {@link ReactiveAerospikeRepository}.
Expand Down Expand Up @@ -158,13 +158,7 @@ public void deleteIndex(Class<T> domainType, String indexName) {
@Override
public Flux<T> findByQualifiers(Qualifier... qualifiers) {
Assert.notNull(qualifiers, "Qualifiers must not be null");

Arrays.stream(qualifiers).forEach(qualifier -> {
// not to build secondary index filter based on this qualifier
// as it might conflict with a combination of other qualifiers
qualifier.setExcludeFilter(true);
Qualifier.validate(qualifier);
});
validateQualifiers(qualifiers);
return operations.findAllUsingQuery(entityInformation.getJavaType(), null, qualifiers);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public void findAllUsingQuery_shouldRunWithDifferentArgumentsCombinations() {
// no secondary index filter and no qualifiers
Stream<SampleClasses.CustomCollectionClass> result4 =
template.findAllUsingQuery(SampleClasses.CustomCollectionClass.class, null);
assertThat(result4).containsOnly(doc1, doc2);
assertThat(result4).contains(doc1, doc2);

additionalAerospikeTestOperations.dropIndex(SampleClasses.CustomCollectionClass.class,
"CustomCollectionClass_field"); // cleanup
Expand Down

0 comments on commit e515305

Please sign in to comment.