Skip to content

Commit

Permalink
Don't parse if no args and result (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
quinchs authored Mar 5, 2024
1 parent 5fb9a14 commit 5e9c364
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ private CodecCache(ProtocolVersion version) {
public static final UUID NULL_CODEC_ID = new UUID(0L, 0L);
public static final UUID INVALID_CODEC_ID = new UUID(Long.MAX_VALUE, Long.MAX_VALUE);

public static final NullCodec NULL_CODEC = new NullCodec();

private static final ConcurrentMap<ProtocolVersion, CodecCache> codecCaches;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,6 @@ public ProtocolState(QueryParameters args, ByteBuf stateBuffer, List<ByteBuf> da

@Override
public CompletionStage<ParseResult> parseQuery(QueryParameters queryParameters) {
var cacheKey = queryParameters.getCacheKey();

var cachedCodecs = CodecBuilder.getCachedCodecs(this, cacheKey);

ByteBuf stateBuffer;

try {
Expand All @@ -305,6 +301,22 @@ public CompletionStage<ParseResult> parseQuery(QueryParameters queryParameters)
return CompletableFuture.failedFuture(e);
}

if(queryParameters.format == IOFormat.NONE && (queryParameters.arguments == null || queryParameters.arguments.isEmpty())) {
return CompletableFuture.completedFuture(new ParseResult(
CodecBuilder.NULL_CODEC,
CodecBuilder.NULL_CODEC,
CodecBuilder.NULL_CODEC_ID,
CodecBuilder.NULL_CODEC_ID,
stateBuffer,
queryParameters.capabilities,
queryParameters.cardinality
));
}

var cacheKey = queryParameters.getCacheKey();

var cachedCodecs = CodecBuilder.getCachedCodecs(this, cacheKey);

if(cachedCodecs == null) {
ProtocolState parseState = new ProtocolState(queryParameters, stateBuffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ public TransactionState getTransactionState() {

@Override
public CompletionStage<Void> startTransaction(@NotNull TransactionIsolation isolation, boolean readonly, boolean deferrable) {

String query = "start transaction isolation " +
isolation +
", " +
Expand Down

0 comments on commit 5e9c364

Please sign in to comment.