Skip to content

Commit 8c11aa2

Browse files
committed
Add max_serializable_object_size session property
1 parent 9e202ff commit 8c11aa2

File tree

10 files changed

+66
-6
lines changed

10 files changed

+66
-6
lines changed

presto-hive/src/test/java/com/facebook/presto/hive/AbstractTestHiveClient.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,6 +1250,12 @@ public ConnectorSession forConnectorId(ConnectorId connectorId)
12501250
{
12511251
return this;
12521252
}
1253+
1254+
@Override
1255+
public long getMaxSerializableObjectSize()
1256+
{
1257+
return session.getMaxSerializableObjectSize();
1258+
}
12531259
};
12541260
}
12551261

presto-main-base/src/main/java/com/facebook/presto/FullConnectorSession.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.Optional;
3232
import java.util.Set;
3333

34+
import static com.facebook.presto.SystemSessionProperties.MAX_SERIALIZABLE_OBJECT_SIZE;
3435
import static com.facebook.presto.SystemSessionProperties.isExploitConstraints;
3536
import static com.facebook.presto.spi.StandardErrorCode.INVALID_SESSION_PROPERTY;
3637
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -184,6 +185,7 @@ public String toString()
184185
.add("locale", getLocale())
185186
.add("startTime", getStartTime())
186187
.add("properties", properties)
188+
.add("maxSerializableObjectSize", getMaxSerializableObjectSize())
187189
.omitNullValues()
188190
.toString();
189191
}
@@ -205,4 +207,10 @@ public ConnectorSession forConnectorId(ConnectorId connectorId)
205207
{
206208
return new FullConnectorSession(session, identity);
207209
}
210+
211+
@Override
212+
public long getMaxSerializableObjectSize()
213+
{
214+
return session.getSystemProperty(MAX_SERIALIZABLE_OBJECT_SIZE, Long.class);
215+
}
208216
}

presto-main-base/src/main/java/com/facebook/presto/SystemSessionProperties.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ public final class SystemSessionProperties
338338
public static final String ADD_DISTINCT_BELOW_SEMI_JOIN_BUILD = "add_distinct_below_semi_join_build";
339339
public static final String PUSHDOWN_SUBFIELDS_FOR_MAP_SUBSET = "pushdown_subfields_for_map_subset";
340340
public static final String PUSHDOWN_SUBFIELDS_FOR_MAP_FUNCTIONS = "pushdown_subfields_for_map_functions";
341+
public static final String MAX_SERIALIZABLE_OBJECT_SIZE = "max_serializable_object_size";
341342

342343
// TODO: Native execution related session properties that are temporarily put here. They will be relocated in the future.
343344
public static final String NATIVE_AGGREGATION_SPILL_ALL = "native_aggregation_spill_all";
@@ -1926,6 +1927,10 @@ public SystemSessionProperties(
19261927
"Enable subfield pruning for map functions, currently include map_subset and map_filter",
19271928
featuresConfig.isPushdownSubfieldForMapFunctions(),
19281929
false),
1930+
longProperty(MAX_SERIALIZABLE_OBJECT_SIZE,
1931+
"Configure the maximum byte size of a serializable object in expression interpreters",
1932+
featuresConfig.getMaxSerializableObjectSize(),
1933+
false),
19291934
new PropertyMetadata<>(
19301935
QUERY_CLIENT_TIMEOUT,
19311936
"Configures how long the query runs without contact from the client application, such as the CLI, before it's abandoned",
@@ -3309,4 +3314,9 @@ public static boolean isOptimizeConditionalApproxDistinctEnabled(Session session
33093314
{
33103315
return session.getSystemProperty(OPTIMIZE_CONDITIONAL_CONSTANT_APPROXIMATE_DISTINCT, Boolean.class);
33113316
}
3317+
3318+
public static long getMaxSerializableObjectSize(Session session)
3319+
{
3320+
return session.getSystemProperty(MAX_SERIALIZABLE_OBJECT_SIZE, Long.class);
3321+
}
33123322
}

presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ public class FeaturesConfig
308308
private boolean addExchangeBelowPartialAggregationOverGroupId;
309309
private boolean addDistinctBelowSemiJoinBuild;
310310
private boolean pushdownSubfieldForMapFunctions = true;
311+
private long maxSerializableObjectSize = 1000;
311312

312313
public enum PartitioningPrecisionStrategy
313314
{
@@ -3083,4 +3084,17 @@ public boolean isPushdownSubfieldForMapFunctions()
30833084
{
30843085
return pushdownSubfieldForMapFunctions;
30853086
}
3087+
3088+
@Config("max_serializable_object_size")
3089+
@ConfigDescription("Configure the maximum byte size of a serializable object in expression interpreters")
3090+
public FeaturesConfig setMaxSerializableObjectSize(long maxSerializableObjectSize)
3091+
{
3092+
this.maxSerializableObjectSize = maxSerializableObjectSize;
3093+
return this;
3094+
}
3095+
3096+
public long getMaxSerializableObjectSize()
3097+
{
3098+
return maxSerializableObjectSize;
3099+
}
30863100
}

presto-main-base/src/main/java/com/facebook/presto/sql/planner/ExpressionInterpreter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@
160160
@Deprecated
161161
public class ExpressionInterpreter
162162
{
163-
private static final long MAX_SERIALIZABLE_OBJECT_SIZE = 1000;
164163
private final Expression expression;
165164
private final Metadata metadata;
166165
private final LiteralEncoder literalEncoder;
@@ -1318,7 +1317,7 @@ private boolean isSerializable(Object value, Type type)
13181317
{
13191318
requireNonNull(type, "type is null");
13201319
// If value is already Expression, literal values contained inside should already have been made serializable. Otherwise, we make sure the object is small and serializable.
1321-
return value instanceof Expression || (isSupportedLiteralType(type) && estimatedSizeInBytes(value) <= MAX_SERIALIZABLE_OBJECT_SIZE);
1320+
return value instanceof Expression || (isSupportedLiteralType(type) && estimatedSizeInBytes(value) <= connectorSession.getMaxSerializableObjectSize());
13221321
}
13231322

13241323
private List<Expression> toExpressions(List<Object> values, List<Type> types)

presto-main-base/src/main/java/com/facebook/presto/sql/planner/RowExpressionInterpreter.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122

123123
public class RowExpressionInterpreter
124124
{
125-
private static final long MAX_SERIALIZABLE_OBJECT_SIZE = 1000;
126125
private final RowExpression expression;
127126
private final ConnectorSession session;
128127
private final Level optimizationLevel;
@@ -779,7 +778,7 @@ private RowExpression toRowExpression(Object value, RowExpression originalRowExp
779778
private boolean isSerializable(Object value, Type type)
780779
{
781780
// If value is already RowExpression, constant values contained inside should already have been made serializable. Otherwise, we make sure the object is small and serializable.
782-
return value instanceof RowExpression || (isSupportedLiteralType(type) && estimatedSizeInBytes(value) <= MAX_SERIALIZABLE_OBJECT_SIZE);
781+
return value instanceof RowExpression || (isSupportedLiteralType(type) && estimatedSizeInBytes(value) <= session.getMaxSerializableObjectSize());
783782
}
784783

785784
private SpecialCallResult tryHandleArrayConstructor(CallExpression callExpression, List<Object> argumentValues)

presto-main-base/src/main/java/com/facebook/presto/testing/TestingConnectorSession.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class TestingConnectorSession
6363
private final SqlFunctionProperties sqlFunctionProperties;
6464
private final Optional<String> schema;
6565
private final Map<SqlFunctionId, SqlInvokedFunction> sessionFunctions;
66+
private final long maxSerializableObjectSize;
6667

6768
public TestingConnectorSession(List<PropertyMetadata<?>> properties)
6869
{
@@ -125,6 +126,7 @@ public TestingConnectorSession(
125126
.build();
126127
this.schema = requireNonNull(schema, "schema is null");
127128
this.sessionFunctions = sessionFunctions;
129+
this.maxSerializableObjectSize = 1000;
128130
}
129131

130132
@Override
@@ -245,6 +247,12 @@ public ConnectorSession forConnectorId(ConnectorId connectorId)
245247
sessionFunctions);
246248
}
247249

250+
@Override
251+
public long getMaxSerializableObjectSize()
252+
{
253+
return maxSerializableObjectSize;
254+
}
255+
248256
@Override
249257
public String toString()
250258
{
@@ -258,6 +266,7 @@ public String toString()
258266
.add("sqlFunctionProperties", sqlFunctionProperties)
259267
.add("properties", propertyValues)
260268
.add("clientInfo", clientInfo)
269+
.add("maxSerializableObjectSize", maxSerializableObjectSize)
261270
.omitNullValues()
262271
.toString();
263272
}

presto-main-base/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ public void testDefaults()
265265
.setBroadcastSemiJoinForDelete(true)
266266
.setInEqualityJoinPushdownEnabled(false)
267267
.setRewriteMinMaxByToTopNEnabled(false)
268-
.setPrestoSparkExecutionEnvironment(false));
268+
.setPrestoSparkExecutionEnvironment(false)
269+
.setMaxSerializableObjectSize(1000));
269270
}
270271

271272
@Test
@@ -478,6 +479,7 @@ public void testExplicitPropertyMappings()
478479
.put("optimizer.add-distinct-below-semi-join-build", "true")
479480
.put("optimizer.pushdown-subfield-for-map-functions", "false")
480481
.put("optimizer.add-exchange-below-partial-aggregation-over-group-id", "true")
482+
.put("max_serializable_object_size", "50")
481483
.build();
482484

483485
FeaturesConfig expected = new FeaturesConfig()
@@ -688,7 +690,8 @@ public void testExplicitPropertyMappings()
688690
.setBroadcastSemiJoinForDelete(false)
689691
.setRewriteMinMaxByToTopNEnabled(true)
690692
.setInnerJoinPushdownEnabled(true)
691-
.setPrestoSparkExecutionEnvironment(true);
693+
.setPrestoSparkExecutionEnvironment(true)
694+
.setMaxSerializableObjectSize(50);
692695
assertFullMapping(properties, expected);
693696
}
694697

presto-spi/src/main/java/com/facebook/presto/spi/ConnectorSession.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ default boolean isReadConstraints()
7272
* @return
7373
*/
7474
ConnectorSession forConnectorId(ConnectorId connectorId);
75+
76+
/**
77+
* returns the max size of a serializable object in bytes
78+
* @return
79+
*/
80+
long getMaxSerializableObjectSize();
7581
}

presto-spi/src/test/java/com/facebook/presto/spi/TestingSession.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ public ConnectorSession forConnectorId(ConnectorId connectorId)
136136
{
137137
return this;
138138
}
139+
140+
@Override
141+
public long getMaxSerializableObjectSize()
142+
{
143+
return 1000;
144+
}
139145
};
140146

141147
private TestingSession() {}

0 commit comments

Comments
 (0)