Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize JSON directly from Pages #23975

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import io.trino.client.Column;
import io.trino.client.JsonCodec;
import io.trino.client.QueryResults;
import io.trino.client.RawQueryData;
import io.trino.client.StatementStats;
import io.trino.client.TypedQueryData;
import io.trino.client.uri.PropertyName;
import io.trino.client.uri.TrinoUri;
import okhttp3.mockwebserver.MockResponse;
Expand Down Expand Up @@ -136,7 +136,7 @@ static String createResults(MockWebServer server)
null,
null,
ImmutableList.of(new Column("_col0", BIGINT, new ClientTypeSignature(BIGINT))),
RawQueryData.of(ImmutableList.of(ImmutableList.of(123))),
TypedQueryData.of(ImmutableList.of(ImmutableList.of(123))),
StatementStats.builder()
.setState("FINISHED")
.setProgressPercentage(OptionalDouble.empty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public ResultRows toRows(List<Column> columns, QueryData data)
}

verify(columns != null && !columns.isEmpty(), "Columns must be set when decoding data");
if (data instanceof RawQueryData) {
RawQueryData rawData = (RawQueryData) data;
if (data instanceof TypedQueryData) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we short circuit it?

if (data instanceof TypedQueryData rawData) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. This is client so JDK 8

TypedQueryData rawData = (TypedQueryData) data;
if (rawData.isNull()) {
return NULL_ROWS; // for backward compatibility instead of null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
* Class represents QueryData of already typed values
*
*/
public class RawQueryData
public class TypedQueryData
implements QueryData
{
private final Iterable<List<Object>> iterable;

private RawQueryData(Iterable<List<Object>> values)
private TypedQueryData(Iterable<List<Object>> values)
{
this.iterable = values == null ? null : unmodifiableIterable(values);
}
Expand All @@ -42,7 +42,7 @@ public Iterable<List<Object>> getIterable()

public static QueryData of(@Nullable Iterable<List<Object>> values)
{
return new RawQueryData(values);
return new TypedQueryData(values);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private String newQueryResults(MockWebServer server)
Stream.of(new Column("id", INTEGER, new ClientTypeSignature("integer")),
new Column("name", VARCHAR, new ClientTypeSignature("varchar")))
.collect(toList()),
RawQueryData.of(IntStream.range(0, numRecords)
TypedQueryData.of(IntStream.range(0, numRecords)
.mapToObj(index -> Stream.of((Object) index, "a").collect(toList()))
.collect(toList())),
StatementStats.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private String newQueryResults(String state)
Stream.of(new Column("id", INTEGER, new ClientTypeSignature("integer")),
new Column("name", VARCHAR, new ClientTypeSignature("varchar")))
.collect(toList()),
RawQueryData.of(IntStream.range(0, numRecords)
TypedQueryData.of(IntStream.range(0, numRecords)
.mapToObj(index -> Stream.of((Object) index, "a").collect(toList()))
.collect(toList())),
new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import io.trino.client.ClientTypeSignature;
import io.trino.client.Column;
import io.trino.client.QueryResults;
import io.trino.client.RawQueryData;
import io.trino.client.StatementStats;
import io.trino.client.TypedQueryData;
import io.trino.server.protocol.spooling.QueryDataJacksonModule;
import io.trino.spi.type.StandardTypes;
import okhttp3.mockwebserver.MockResponse;
Expand Down Expand Up @@ -98,7 +98,7 @@ private String newQueryResults(Integer partialCancelId, Integer nextUriId, List<
partialCancelId == null ? null : server.url(format("/v1/statement/partialCancel/%s.%s", queryId, partialCancelId)).uri(),
nextUriId == null ? null : server.url(format("/v1/statement/%s/%s", queryId, nextUriId)).uri(),
responseColumns,
RawQueryData.of(data),
TypedQueryData.of(data),
new StatementStats(state, state.equals("QUEUED"), true, OptionalDouble.of(0), OptionalDouble.of(0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null),
null,
ImmutableList.of(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import io.opentelemetry.api.trace.Tracer;
import io.trino.client.QueryError;
import io.trino.client.QueryResults;
import io.trino.client.RawQueryData;
import io.trino.client.StatementStats;
import io.trino.client.TypedQueryData;
import io.trino.execution.ExecutionFailureInfo;
import io.trino.execution.QueryManagerConfig;
import io.trino.execution.QueryState;
Expand Down Expand Up @@ -281,7 +281,7 @@ private static QueryResults createQueryResults(
null,
nextUri,
null,
RawQueryData.of(null),
TypedQueryData.of(null),
StatementStats.builder()
.setState(state.toString())
.setQueued(state == QUEUED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import io.trino.server.ServerConfig;
import io.trino.server.protocol.spooling.QueryDataEncoder;
import io.trino.server.protocol.spooling.QueryDataEncoders;
import io.trino.server.protocol.spooling.RawQueryDataProducer;
import io.trino.server.protocol.spooling.SpooledQueryDataProducer;
import io.trino.server.security.ResourceSecurity;
import io.trino.spi.QueryId;
Expand Down Expand Up @@ -207,7 +206,7 @@ protected Query getQuery(QueryId queryId, String slug, long token)
queryManager,
encoderFactory
.map(SpooledQueryDataProducer::createSpooledQueryDataProducer)
.orElseGet(RawQueryDataProducer::new),
.orElseGet(JsonBytesQueryDataProducer::new),
queryInfoUrlFactory.getQueryInfoUrl(queryId),
directExchangeClientSupplier,
exchangeManagerRegistry,
Expand Down

This file was deleted.

Loading