Fix put atomicity

This commit is contained in:
Andrea Cavalli 2024-03-29 19:42:02 +01:00
parent b3de83c4da
commit 5851c233b1
3 changed files with 1694 additions and 220 deletions

View File

@ -22,6 +22,7 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.List;
import java.util.function.BiConsumer;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.transport.TNonblockingServerSocket;
@ -119,7 +120,8 @@ public class ThriftServer extends Server {
}
private static OptionalBinary mapResult(MemorySegment memorySegment) {
return memorySegment != null ? new OptionalBinary().setValue(memorySegment.asByteBuffer()) : null;
var result = new OptionalBinary();
return memorySegment != null ? result.setValue(memorySegment.asByteBuffer()) : result;
}
private static UpdateBegin mapResult(UpdateContext<MemorySegment> context) {
@ -177,6 +179,15 @@ public class ThriftServer extends Server {
client.getAsyncApi().getColumnIdAsync(name).whenComplete(handleResult(resultHandler));
}
@Override
public void putFast(long transactionOrUpdateId,
long columnId,
List<ByteBuffer> keys,
ByteBuffer value,
AsyncMethodCallback<Void> resultHandler) {
this.put(transactionOrUpdateId, columnId, keys, value, resultHandler);
}
@Override
public void put(long transactionOrUpdateId,
long columnId,

View File

@ -52,7 +52,9 @@ service RocksDB {
i64 getColumnId(1: required string name),
oneway void put(1: required i64 transactionOrUpdateId, 2: required i64 columnId, 3: required list<binary> keys, 4: required binary value),
oneway void putFast(1: required i64 transactionOrUpdateId, 2: required i64 columnId, 3: required list<binary> keys, 4: required binary value),
void put(1: required i64 transactionOrUpdateId, 2: required i64 columnId, 3: required list<binary> keys, 4: required binary value),
OptionalBinary putGetPrevious(1: required i64 transactionOrUpdateId, 2: required i64 columnId, 3: required list<binary> keys, 4: required binary value),
@ -74,7 +76,7 @@ service RocksDB {
void seekTo(1: required i64 iterationId, 2: required list<binary> keys),
oneway void subsequent(1: required i64 iterationId, 2: required i64 skipCount, 3: required i64 takeCount),
void subsequent(1: required i64 iterationId, 2: required i64 skipCount, 3: required i64 takeCount),
bool subsequentExists(1: required i64 iterationId, 2: required i64 skipCount, 3: required i64 takeCount),