-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
FeaturesConfig.java
299 lines (252 loc) · 8.57 KB
/
FeaturesConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.presto.sql.analyzer;
import com.google.common.collect.ImmutableList;
import io.airlift.configuration.Config;
import io.airlift.configuration.ConfigDescription;
import io.airlift.configuration.DefunctConfig;
import io.airlift.configuration.LegacyConfig;
import io.airlift.units.DataSize;
import javax.validation.constraints.Min;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import static com.facebook.presto.sql.analyzer.RegexLibrary.JONI;
@DefunctConfig("resource-group-manager")
public class FeaturesConfig
{
public static class ProcessingOptimization
{
public static final String DISABLED = "disabled";
public static final String COLUMNAR = "columnar";
public static final String COLUMNAR_DICTIONARY = "columnar_dictionary";
public static final List<String> AVAILABLE_OPTIONS = ImmutableList.of(DISABLED, COLUMNAR, COLUMNAR_DICTIONARY);
}
private boolean experimentalSyntaxEnabled;
private boolean distributedIndexJoinsEnabled;
private boolean distributedJoinsEnabled = true;
private boolean colocatedJoinsEnabled;
private boolean redistributeWrites = true;
private boolean optimizeMetadataQueries;
private boolean optimizeHashGeneration = true;
private boolean optimizeSingleDistinct = true;
private boolean pushTableWriteThroughUnion = true;
private boolean legacyArrayAgg;
private String processingOptimization = ProcessingOptimization.DISABLED;
private boolean dictionaryAggregation;
private boolean resourceGroups;
private int re2JDfaStatesLimit = Integer.MAX_VALUE;
private int re2JDfaRetries = 5;
private RegexLibrary regexLibrary = JONI;
private boolean spillEnabled;
private DataSize operatorMemoryLimitBeforeSpill = new DataSize(4, DataSize.Unit.MEGABYTE);
private Path spillerSpillPath = Paths.get(System.getProperty("java.io.tmpdir"), "presto", "spills");
public boolean isResourceGroupsEnabled()
{
return resourceGroups;
}
@Config("experimental.resource-groups-enabled")
public FeaturesConfig setResourceGroupsEnabled(boolean enabled)
{
resourceGroups = enabled;
return this;
}
public boolean isExperimentalSyntaxEnabled()
{
return experimentalSyntaxEnabled;
}
@LegacyConfig("analyzer.experimental-syntax-enabled")
@Config("experimental-syntax-enabled")
public FeaturesConfig setExperimentalSyntaxEnabled(boolean enabled)
{
experimentalSyntaxEnabled = enabled;
return this;
}
public boolean isDistributedIndexJoinsEnabled()
{
return distributedIndexJoinsEnabled;
}
@Config("distributed-index-joins-enabled")
public FeaturesConfig setDistributedIndexJoinsEnabled(boolean distributedIndexJoinsEnabled)
{
this.distributedIndexJoinsEnabled = distributedIndexJoinsEnabled;
return this;
}
public boolean isDistributedJoinsEnabled()
{
return distributedJoinsEnabled;
}
@Config("deprecated.legacy-array-agg")
public FeaturesConfig setLegacyArrayAgg(boolean legacyArrayAgg)
{
this.legacyArrayAgg = legacyArrayAgg;
return this;
}
public boolean isLegacyArrayAgg()
{
return legacyArrayAgg;
}
@Config("distributed-joins-enabled")
public FeaturesConfig setDistributedJoinsEnabled(boolean distributedJoinsEnabled)
{
this.distributedJoinsEnabled = distributedJoinsEnabled;
return this;
}
public boolean isColocatedJoinsEnabled()
{
return colocatedJoinsEnabled;
}
@Config("colocated-joins-enabled")
@ConfigDescription("Experimental: Use a colocated join when possible")
public FeaturesConfig setColocatedJoinsEnabled(boolean colocatedJoinsEnabled)
{
this.colocatedJoinsEnabled = colocatedJoinsEnabled;
return this;
}
public boolean isRedistributeWrites()
{
return redistributeWrites;
}
@Config("redistribute-writes")
public FeaturesConfig setRedistributeWrites(boolean redistributeWrites)
{
this.redistributeWrites = redistributeWrites;
return this;
}
public boolean isOptimizeMetadataQueries()
{
return optimizeMetadataQueries;
}
@Config("optimizer.optimize-metadata-queries")
public FeaturesConfig setOptimizeMetadataQueries(boolean optimizeMetadataQueries)
{
this.optimizeMetadataQueries = optimizeMetadataQueries;
return this;
}
public boolean isOptimizeHashGeneration()
{
return optimizeHashGeneration;
}
@Config("optimizer.optimize-hash-generation")
public FeaturesConfig setOptimizeHashGeneration(boolean optimizeHashGeneration)
{
this.optimizeHashGeneration = optimizeHashGeneration;
return this;
}
public boolean isOptimizeSingleDistinct()
{
return optimizeSingleDistinct;
}
@Config("optimizer.optimize-single-distinct")
public FeaturesConfig setOptimizeSingleDistinct(boolean optimizeSingleDistinct)
{
this.optimizeSingleDistinct = optimizeSingleDistinct;
return this;
}
public boolean isPushTableWriteThroughUnion()
{
return pushTableWriteThroughUnion;
}
@Config("optimizer.push-table-write-through-union")
public FeaturesConfig setPushTableWriteThroughUnion(boolean pushTableWriteThroughUnion)
{
this.pushTableWriteThroughUnion = pushTableWriteThroughUnion;
return this;
}
public String getProcessingOptimization()
{
return processingOptimization;
}
@Config("optimizer.processing-optimization")
public FeaturesConfig setProcessingOptimization(String processingOptimization)
{
if (!ProcessingOptimization.AVAILABLE_OPTIONS.contains(processingOptimization)) {
throw new IllegalStateException(String.format("Value %s is not valid for processingOptimization.", processingOptimization));
}
this.processingOptimization = processingOptimization;
return this;
}
public boolean isDictionaryAggregation()
{
return dictionaryAggregation;
}
@Config("optimizer.dictionary-aggregation")
public FeaturesConfig setDictionaryAggregation(boolean dictionaryAggregation)
{
this.dictionaryAggregation = dictionaryAggregation;
return this;
}
@Min(2)
public int getRe2JDfaStatesLimit()
{
return re2JDfaStatesLimit;
}
@Config("re2j.dfa-states-limit")
public FeaturesConfig setRe2JDfaStatesLimit(int re2JDfaStatesLimit)
{
this.re2JDfaStatesLimit = re2JDfaStatesLimit;
return this;
}
@Min(0)
public int getRe2JDfaRetries()
{
return re2JDfaRetries;
}
@Config("re2j.dfa-retries")
public FeaturesConfig setRe2JDfaRetries(int re2JDfaRetries)
{
this.re2JDfaRetries = re2JDfaRetries;
return this;
}
public RegexLibrary getRegexLibrary()
{
return regexLibrary;
}
@Config("regex-library")
public FeaturesConfig setRegexLibrary(RegexLibrary regexLibrary)
{
this.regexLibrary = regexLibrary;
return this;
}
public boolean isSpillEnabled()
{
return spillEnabled;
}
@Config("experimental.spill-enabled")
public FeaturesConfig setSpillEnabled(boolean spillEnabled)
{
this.spillEnabled = spillEnabled;
return this;
}
public DataSize getOperatorMemoryLimitBeforeSpill()
{
return operatorMemoryLimitBeforeSpill;
}
@Config("experimental.operator-memory-limit-before-spill")
public FeaturesConfig setOperatorMemoryLimitBeforeSpill(DataSize operatorMemoryLimitBeforeSpill)
{
this.operatorMemoryLimitBeforeSpill = operatorMemoryLimitBeforeSpill;
return this;
}
public Path getSpillerSpillPath()
{
return spillerSpillPath;
}
@Config("experimental.spiller-spill-path")
public FeaturesConfig setSpillerSpillPath(String spillPath)
{
this.spillerSpillPath = Paths.get(spillPath);
return this;
}
}