Fix reduce range bug

This commit is contained in:
Andrea Cavalli 2024-10-24 00:26:00 +02:00
parent dd11e24351
commit fbf17c8650

View File

@ -469,23 +469,22 @@ public class GrpcServer extends Server {
@Override @Override
public Mono<FirstAndLast> reduceRangeFirstAndLast(GetRangeRequest request) { public Mono<FirstAndLast> reduceRangeFirstAndLast(GetRangeRequest request) {
return executeSync(() -> { var arena = Arena.ofAuto();
try (var arena = Arena.ofConfined()) { return Mono.fromFuture(() -> asyncApi.reduceRangeAsync(arena, request.getTransactionId(), request.getColumnId(),
it.cavallium.rockserver.core.common.FirstAndLast<it.cavallium.rockserver.core.common.KV> firstAndLast
= api.reduceRange(arena,
request.getTransactionId(),
request.getColumnId(),
mapKeys(arena, request.getStartKeysInclusiveCount(), request::getStartKeysInclusive), mapKeys(arena, request.getStartKeysInclusiveCount(), request::getStartKeysInclusive),
mapKeys(arena, request.getEndKeysExclusiveCount(), request::getEndKeysExclusive), mapKeys(arena, request.getEndKeysExclusiveCount(), request::getEndKeysExclusive),
request.getReverse(), request.getReverse(),
RequestType.firstAndLast(), RequestType.firstAndLast(),
request.getTimeoutMs() request.getTimeoutMs()
); )).map(firstAndLast -> {
return FirstAndLast.newBuilder() var resultBuilder = FirstAndLast.newBuilder();
.setFirst(unmapKV(firstAndLast.first())) if (firstAndLast.first() != null) {
.setLast(unmapKV(firstAndLast.last())) resultBuilder.setFirst(unmapKV(firstAndLast.first()));
.build();
} }
if (firstAndLast.last() != null) {
resultBuilder.setLast(unmapKV(firstAndLast.last()));
}
return resultBuilder.build();
}); });
} }