From 5e9c3645a2585146811e65131044044f073611a0 Mon Sep 17 00:00:00 2001 From: Quin Lynch <49576606+quinchs@users.noreply.github.com> Date: Tue, 5 Mar 2024 10:30:11 -0400 Subject: [PATCH] Don't parse if no args and result (#30) --- .../driver/binary/builders/CodecBuilder.java | 2 ++ .../protocol/v1/V1ProtocolProvider.java | 20 +++++++++++++++---- .../driver/clients/EdgeDBTCPClient.java | 1 - 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/driver/src/main/java/com/edgedb/driver/binary/builders/CodecBuilder.java b/src/driver/src/main/java/com/edgedb/driver/binary/builders/CodecBuilder.java index 2150b6d..d3d8a69 100644 --- a/src/driver/src/main/java/com/edgedb/driver/binary/builders/CodecBuilder.java +++ b/src/driver/src/main/java/com/edgedb/driver/binary/builders/CodecBuilder.java @@ -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 codecCaches; static { diff --git a/src/driver/src/main/java/com/edgedb/driver/binary/protocol/v1/V1ProtocolProvider.java b/src/driver/src/main/java/com/edgedb/driver/binary/protocol/v1/V1ProtocolProvider.java index aac835f..ae124e6 100644 --- a/src/driver/src/main/java/com/edgedb/driver/binary/protocol/v1/V1ProtocolProvider.java +++ b/src/driver/src/main/java/com/edgedb/driver/binary/protocol/v1/V1ProtocolProvider.java @@ -293,10 +293,6 @@ public ProtocolState(QueryParameters args, ByteBuf stateBuffer, List da @Override public CompletionStage parseQuery(QueryParameters queryParameters) { - var cacheKey = queryParameters.getCacheKey(); - - var cachedCodecs = CodecBuilder.getCachedCodecs(this, cacheKey); - ByteBuf stateBuffer; try { @@ -305,6 +301,22 @@ public CompletionStage 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); diff --git a/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBTCPClient.java b/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBTCPClient.java index bf4ae09..9f0c7a5 100644 --- a/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBTCPClient.java +++ b/src/driver/src/main/java/com/edgedb/driver/clients/EdgeDBTCPClient.java @@ -135,7 +135,6 @@ public TransactionState getTransactionState() { @Override public CompletionStage startTransaction(@NotNull TransactionIsolation isolation, boolean readonly, boolean deferrable) { - String query = "start transaction isolation " + isolation + ", " +