Skip to content

Commit

Permalink
Make configuration and session property names consistent
Browse files Browse the repository at this point in the history
It makes it easier to reason about which session property maps to which configuration property.
  • Loading branch information
wendigo committed Jan 23, 2025
1 parent 6f64088 commit 5916ea5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@
import static io.trino.server.protocol.spooling.SpooledBlock.SPOOLING_METADATA_TYPE;
import static io.trino.server.protocol.spooling.SpooledBlock.createNonSpooledPage;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getInitialSegmentSize;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getMaxInlinedRows;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getMaxInlinedSize;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getInliningMaxRows;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getInliningMaxSize;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.getMaxSegmentSize;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.isAllowInlining;
import static io.trino.server.protocol.spooling.SpoolingSessionProperties.isInliningEnabled;
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
Expand Down Expand Up @@ -162,9 +162,9 @@ public OutputSpoolingOperator(OperatorContext operatorContext, QueryDataEncoder
{
this.operatorContext = requireNonNull(operatorContext, "operatorContext is null");
this.controller = new OutputSpoolingController(
isAllowInlining(operatorContext.getSession()),
getMaxInlinedRows(operatorContext.getSession()),
getMaxInlinedSize(operatorContext.getSession()).toBytes(),
isInliningEnabled(operatorContext.getSession()),
getInliningMaxRows(operatorContext.getSession()),
getInliningMaxSize(operatorContext.getSession()).toBytes(),
getInitialSegmentSize(operatorContext.getSession()).toBytes(),
getMaxSegmentSize(operatorContext.getSession()).toBytes());
this.userMemoryContext = operatorContext.newLocalUserMemoryContext(OutputSpoolingOperator.class.getSimpleName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;
import io.airlift.configuration.ConfigSecuritySensitive;
import io.airlift.configuration.LegacyConfig;
import io.airlift.units.DataSize;
import io.airlift.units.MaxDataSize;
import io.airlift.units.MinDataSize;
Expand All @@ -38,9 +39,9 @@ public class SpoolingConfig
private Optional<SecretKey> sharedSecretKey = Optional.empty();
private SegmentRetrievalMode retrievalMode = SegmentRetrievalMode.STORAGE;

private boolean allowInlining = true;
private long maximumInlinedRows = 1000;
private DataSize maximumInlinedSize = DataSize.of(128, KILOBYTE);
private boolean inliningEnabled = true;
private long inliningMaxRows = 1000;
private DataSize inliningMaxSize = DataSize.of(128, KILOBYTE);
private DataSize initialSegmentSize = DataSize.of(8, MEGABYTE);
private DataSize maximumSegmentSize = DataSize.of(16, MEGABYTE);

Expand Down Expand Up @@ -94,54 +95,55 @@ public DataSize getMaximumSegmentSize()
return maximumSegmentSize;
}

@Config("protocol.spooling.maximum-segment-size")
@LegacyConfig("protocol.spooling.maximum-segment-size")
@Config("protocol.spooling.max-segment-size")
@ConfigDescription("Maximum size of the spooled segments in bytes")
public SpoolingConfig setMaximumSegmentSize(DataSize maximumSegmentSize)
{
this.maximumSegmentSize = maximumSegmentSize;
return this;
}

public boolean isAllowInlining()
public boolean isInliningEnabled()
{
return allowInlining;
return inliningEnabled;
}

@ConfigDescription("Allow spooling protocol to inline data")
@Config("protocol.spooling.inlining.enabled")
public SpoolingConfig setAllowInlining(boolean allowInlining)
public SpoolingConfig setInliningEnabled(boolean inliningEnabled)
{
this.allowInlining = allowInlining;
this.inliningEnabled = inliningEnabled;
return this;
}

@Min(1)
@Max(1_000_000)
public long getMaximumInlinedRows()
public long getInliningMaxRows()
{
return maximumInlinedRows;
return inliningMaxRows;
}

@Config("protocol.spooling.inlining.max-rows")
@ConfigDescription("Maximum number of rows that are allowed to be inlined per worker")
public SpoolingConfig setMaximumInlinedRows(long maximumInlinedRows)
public SpoolingConfig setInliningMaxRows(long inliningMaxRows)
{
this.maximumInlinedRows = maximumInlinedRows;
this.inliningMaxRows = inliningMaxRows;
return this;
}

@MinDataSize("1kB")
@MaxDataSize("1MB")
public DataSize getMaximumInlinedSize()
public DataSize getInliningMaxSize()
{
return maximumInlinedSize;
return inliningMaxSize;
}

@Config("protocol.spooling.inlining.max-size")
@ConfigDescription("Maximum size of rows that are allowed to be inlined per worker")
public SpoolingConfig setMaximumInlinedSize(DataSize maximumInlinedSize)
public SpoolingConfig setInliningMaxSize(DataSize inliningMaxSize)
{
this.maximumInlinedSize = maximumInlinedSize;
this.inliningMaxSize = inliningMaxSize;
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class SpoolingSessionProperties
public static final String MAX_SEGMENT_SIZE = "spooling_max_segment_size";

// Inlined segments
public static final String ALLOW_INLINING = "spooling_inlining_enabled";
public static final String MAX_INLINED_SIZE = "spooling_max_inlined_size";
public static final String MAX_INLINED_ROWS = "spooling_max_inlined_rows";
public static final String INLINING_ENABLED = "spooling_inlining_enabled";
public static final String INLINING_MAX_SIZE = "spooling_inlining_max_size";
public static final String INLINING_MAX_ROWS = "spooling_inlining_max_rows";

private final List<PropertyMetadata<?>> sessionProperties;

Expand All @@ -62,20 +62,20 @@ public SpoolingSessionProperties(SpoolingConfig spoolingConfig)
isDataSizeBetween(MAX_SEGMENT_SIZE, DataSize.of(1, KILOBYTE), DataSize.of(128, MEGABYTE)),
false))
.add(booleanProperty(
ALLOW_INLINING,
INLINING_ENABLED,
"Allow inlining initial rows",
spoolingConfig.isAllowInlining(),
spoolingConfig.isInliningEnabled(),
false))
.add(dataSizeProperty(
MAX_INLINED_SIZE,
INLINING_MAX_SIZE,
"Maximum size of inlined data",
spoolingConfig.getMaximumInlinedSize(),
isDataSizeBetween(MAX_INLINED_SIZE, DataSize.of(1, KILOBYTE), DataSize.of(1, MEGABYTE)),
spoolingConfig.getInliningMaxSize(),
isDataSizeBetween(INLINING_MAX_SIZE, DataSize.of(1, KILOBYTE), DataSize.of(1, MEGABYTE)),
false))
.add(longProperty(
MAX_INLINED_ROWS,
INLINING_MAX_ROWS,
"Maximum number of rows that are allowed to be inlined per worker",
spoolingConfig.getMaximumInlinedRows(),
spoolingConfig.getInliningMaxRows(),
false))
.build();
}
Expand Down Expand Up @@ -103,19 +103,19 @@ public static DataSize getMaxSegmentSize(Session session)
return session.getSystemProperty(MAX_SEGMENT_SIZE, DataSize.class);
}

public static boolean isAllowInlining(Session session)
public static boolean isInliningEnabled(Session session)
{
return session.getSystemProperty(ALLOW_INLINING, Boolean.class);
return session.getSystemProperty(INLINING_ENABLED, Boolean.class);
}

public static DataSize getMaxInlinedSize(Session session)
public static DataSize getInliningMaxSize(Session session)
{
return session.getSystemProperty(MAX_INLINED_SIZE, DataSize.class);
return session.getSystemProperty(INLINING_MAX_SIZE, DataSize.class);
}

public static long getMaxInlinedRows(Session session)
public static long getInliningMaxRows(Session session)
{
return session.getSystemProperty(MAX_INLINED_ROWS, Long.class);
return session.getSystemProperty(INLINING_MAX_ROWS, Long.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public void testDefaults()
.setRetrievalMode(STORAGE)
.setInitialSegmentSize(DataSize.of(8, MEGABYTE))
.setMaximumSegmentSize(DataSize.of(16, MEGABYTE))
.setMaximumInlinedRows(1000)
.setMaximumInlinedSize(DataSize.of(128, KILOBYTE))
.setAllowInlining(true));
.setInliningMaxRows(1000)
.setInliningMaxSize(DataSize.of(128, KILOBYTE))
.setInliningEnabled(true));
}

@Test
Expand All @@ -54,7 +54,7 @@ public void testExplicitPropertyMappings()
.put("protocol.spooling.retrieval-mode", "coordinator_storage_redirect")
.put("protocol.spooling.inlining.enabled", "false")
.put("protocol.spooling.initial-segment-size", "1kB")
.put("protocol.spooling.maximum-segment-size", "8kB")
.put("protocol.spooling.max-segment-size", "8kB")
.put("protocol.spooling.inlining.max-rows", "1024")
.put("protocol.spooling.inlining.max-size", "1MB")
.buildOrThrow();
Expand All @@ -64,9 +64,9 @@ public void testExplicitPropertyMappings()
.setSharedSecretKey(randomAesEncryptionKey)
.setInitialSegmentSize(DataSize.of(1, KILOBYTE))
.setMaximumSegmentSize(DataSize.of(8, KILOBYTE))
.setMaximumInlinedRows(1024)
.setMaximumInlinedSize(DataSize.of(1, MEGABYTE))
.setAllowInlining(false);
.setInliningMaxRows(1024)
.setInliningMaxSize(DataSize.of(1, MEGABYTE))
.setInliningEnabled(false);

assertFullMapping(properties, expected);
}
Expand Down

0 comments on commit 5916ea5

Please sign in to comment.