Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Oct 11, 2023
1 parent c9f9fb6 commit 46e7738
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import com.aerospike.client.reactor.IAerospikeReactorClient;
import org.springframework.data.aerospike.core.model.GroupedEntities;
import org.springframework.data.aerospike.core.model.GroupedKeys;
import org.springframework.data.aerospike.query.FilterOperation;
import org.springframework.data.aerospike.repository.query.CriteriaDefinition;
import org.springframework.data.aerospike.repository.query.Query;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.context.MappingContext;
Expand Down Expand Up @@ -519,15 +517,4 @@ <T> Mono<Void> createIndex(Class<T> entityClass, String indexName, String binNam
* @return true if exists.
*/
Mono<Boolean> indexExists(String indexName);

/**
* Find entities that have the given metadata field with the operation applied to its value.
*
* @param metadataFieldName Metadata field name.
* @param operation Operation to be applied.
* @param value Numerical value of the metadata field.
* @return Entities that satisfy the applied operation
*/
<T> Flux<T> findByMetadata(CriteriaDefinition.AerospikeMetadata metadataFieldName, FilterOperation operation,
long value, Class<T> entityClass);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,9 @@
import org.springframework.data.aerospike.mapping.AerospikeMappingContext;
import org.springframework.data.aerospike.mapping.AerospikePersistentEntity;
import org.springframework.data.aerospike.mapping.AerospikePersistentProperty;
import org.springframework.data.aerospike.query.FilterOperation;
import org.springframework.data.aerospike.query.Qualifier;
import org.springframework.data.aerospike.query.ReactorQueryEngine;
import org.springframework.data.aerospike.query.cache.ReactorIndexRefresher;
import org.springframework.data.aerospike.repository.query.AerospikeCriteria;
import org.springframework.data.aerospike.repository.query.CriteriaDefinition;
import org.springframework.data.aerospike.repository.query.Query;
import org.springframework.data.aerospike.utility.Utils;
import org.springframework.data.domain.Sort;
Expand Down Expand Up @@ -831,17 +828,6 @@ public Mono<Boolean> indexExists(String indexName) {
return Mono.just(false);
}

@Override
public <T> Flux<T> findByMetadata(CriteriaDefinition.AerospikeMetadata metadataFieldName, FilterOperation operation, long value, Class<T> entityClass) {
AerospikeCriteria criteria = new AerospikeCriteria(new Qualifier.QualifierBuilder()
.setMetadataField(metadataFieldName)
.setFilterOperation(operation)
.setValue1(Value.get(value)));
Query query = new Query(criteria);

return find(query, entityClass);
}

@Override
public IAerospikeReactorClient getAerospikeReactorClient() {
return reactorClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,14 +1309,11 @@ private static Optional<Exp> getMetadataExp(Map<String, Object> qualifierMap) {

// expecting value1 always be of type Long
private static Long getValue1AsLongOrFail(Object value1) {
Long longValue1;
try {
longValue1 = (Long) value1;
return (Long) value1;
} catch (Exception e) {
throw new IllegalArgumentException("Expecting value1 to be of type Long");
}

return longValue1;
}

private static Exp mapMetadataExp(CriteriaDefinition.AerospikeMetadata metadataField) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,6 @@ public Object execute(Object[] parameters) {
excludeIdQualifier(qualifiers));
}
}
//
// // queries that include metadata have their own processing flow
// if (parameters != null && parameters.length > 0) {
// AerospikeCriteria criteria = query.getAerospikeCriteria();
// if (isMetadataQuery(criteria)) {
// return runMetadataQuery(criteria, entityClass);
// }
// }
//
//
return findByQuery(query, targetClass);
}

Expand All @@ -91,9 +81,4 @@ protected Object findByIds(Iterable<?> iterable, Class<?> sourceClass, Class<?>
return internalOperations.findByIdsInternal(IterableConverter.toList(iterable), sourceClass, targetClass,
qualifiers);
}

protected Object runMetadataQuery(AerospikeCriteria criteria, Class<?> entityClass) {
return operations.findByMetadata(criteria.getMetadataField(), criteria.getOperation(),
criteria.getValue1().toLong(), entityClass);
}
}

0 comments on commit 46e7738

Please sign in to comment.