Skip to content

Commit

Permalink
Make default target result size configurable in ExecutingStatementRes…
Browse files Browse the repository at this point in the history
…ource
  • Loading branch information
tooptoop4 committed Mar 10, 2020
1 parent a0bfef8 commit 0c04d84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
import io.airlift.configuration.ConfigDescription;
import io.airlift.units.DataSize;

import static com.google.common.base.Preconditions.checkArgument;
import static io.airlift.units.DataSize.Unit.MEGABYTE;

public class ExecutingStatementResourceConfig
{
private DataSize serverTargetResultSize = DataSize.of(1, MEGABYTE);
private static final DataSize MIN_TARGET_RESULT_SIZE = DataSize.of(1, MEGABYTE);
private static final DataSize MAX_TARGET_RESULT_SIZE = DataSize.of(128, MEGABYTE);

public DataSize getServerTargetResultSize()
{
Expand All @@ -32,6 +35,10 @@ public DataSize getServerTargetResultSize()
@ConfigDescription("Chunk size for query results in JSON responses sent to client")
public ExecutingStatementResourceConfig setServerTargetResultSize(DataSize targetResultSize)
{
if (targetResultSize != null) {
checkArgument(targetResultSize.compareTo(MIN_TARGET_RESULT_SIZE) >= 0, "targetResultSize must be greater than or equal to %s", MIN_TARGET_RESULT_SIZE.toString());
checkArgument(targetResultSize.compareTo(MAX_TARGET_RESULT_SIZE) <= 0, "targetResultSize must be less than or equal to %s", MAX_TARGET_RESULT_SIZE.toString());
}
this.serverTargetResultSize = targetResultSize;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public ExecutingStatementResource(
BlockEncodingSerde blockEncodingSerde,
@ForStatementResource BoundedExecutor responseExecutor,
@ForStatementResource ScheduledExecutorService timeoutExecutor,
ExecutingStatementResourceConfig executingStatementResourceConfig)
ExecutingStatementResourceConfig executingStatementResourceConfig)
{
this.queryManager = requireNonNull(queryManager, "queryManager is null");
this.exchangeClientSupplier = requireNonNull(exchangeClientSupplier, "exchangeClientSupplier is null");
Expand Down

0 comments on commit 0c04d84

Please sign in to comment.