tarantool / cartridge-springdata

Spring Data Tarantool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Remove unnecessary select in update operation

ArtDu opened this issue · comments

protected <T> List<T> update(Conditions query, TupleOperations updateOperations, Class<T> entityClass) {
Assert.notNull(query, "Conditions must not be null!");
Assert.notNull(updateOperations, "Update operations must not be null!");
Assert.notNull(entityClass, "Entity class must not be null!");
TarantoolPersistentEntity<?> entityMetadata = mappingContext.getRequiredPersistentEntity(entityClass);
TarantoolResult<TarantoolTuple> tuplesForUpdate = executeSync(() ->
tarantoolClient.space(entityMetadata.getSpaceName()).select(query)
);
List<CompletableFuture<TarantoolResult<TarantoolTuple>>> futures = tuplesForUpdate.stream()
.map(tuple -> tarantoolClient.space(entityMetadata.getSpaceName())
.update(idQueryFromTuple(tuple, entityMetadata), updateOperations))
.collect(Collectors.toList());
return getFutureValue(queryExecutors.submit(
() -> futures.stream().parallel()
.map(this::getFutureValue)
.map(tuples -> mapFirstToEntity(tuples, entityClass))
.collect(Collectors.toList())
));
}

Git blame points at you @akudiyar. May you remember why it's done this way?

This update implementation was really non-optimal and I did a quick solution for fulfilling the client's requirements at that time. Maybe some comments on this are in the git history. The biggest problem was that tarantool/crud did not support update operation.