Completed
Push — master ( 5e2cd7...799fe9 )
by Teye
04:24
created

QueryContext::setParallelMergeInitialYieldRows()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Context;
5
6
/**
7
 * Class QueryContext
8
 *
9
 * The query context is used for various query configuration parameters. The following parameters apply to all queries.
10
 *
11
 * @package Level23\Druid\Context
12
 */
13
class QueryContext extends Context implements ContextInterface
14
{
15
    /**
16
     * Query timeout in millis, beyond which unfinished queries will be cancelled. 0 timeout means no timeout. To set
17
     * the default timeout, see Broker configuration
18
     *
19
     * @param int $timeout
20
     *
21
     * @return $this;
22
     */
23 8
    public function setTimeout(int $timeout)
24
    {
25 8
        $this->properties['timeout'] = $timeout;
26
27 8
        return $this;
28
    }
29
30
    /**
31
     * Query Priority. Queries with higher priority get precedence for computational resources.
32
     *
33
     * @param int $priority
34
     *
35
     * @return $this;
36
     */
37 11
    public function setPriority(int $priority)
38
    {
39 11
        $this->properties['priority'] = $priority;
40
41 11
        return $this;
42
    }
43
44
    /**
45
     * Unique identifier given to this query. If a query ID is set or known, this can be used to cancel the query
46
     *
47
     * @param string $queryId
48
     *
49
     * @return $this;
50
     */
51 5
    public function setQueryId(string $queryId)
52
    {
53 5
        $this->properties['queryId'] = $queryId;
54
55 5
        return $this;
56
    }
57
58
    /**
59
     * Flag indicating whether to leverage the query cache for this query. When set to false, it disables reading from
60
     * the query cache for this query. When set to true, Apache Druid (incubating) uses druid.broker.cache.useCache or
61
     * druid.historical.cache.useCache to determine whether or not to read from the query cache
62
     *
63
     * @param bool $useCache
64
     *
65
     * @return $this;
66
     */
67 5
    public function setUseCache(bool $useCache)
68
    {
69 5
        $this->properties['useCache'] = $useCache;
70
71 5
        return $this;
72
    }
73
74
    /**
75
     * Flag indicating whether to save the results of the query to the query cache. Primarily used for debugging. When
76
     * set to false, it disables saving the results of this query to the query cache. When set to true, Druid uses
77
     * druid.broker.cache.populateCache or druid.historical.cache.populateCache to determine whether or not to save the
78
     * results of this query to the query cache
79
     *
80
     * @param bool $populateCache
81
     *
82
     * @return $this;
83
     */
84 5
    public function setPopulateCache(bool $populateCache)
85
    {
86 5
        $this->properties['populateCache'] = $populateCache;
87
88 5
        return $this;
89
    }
90
91
    /**
92
     * Flag indicating whether to leverage the result level cache for this query. When set to false, it disables
93
     * reading from the query cache for this query. When set to true, Druid uses druid.broker.cache.useResultLevelCache
94
     * to determine whether or not to read from the result-level query cache
95
     *
96
     * @param bool $useResultLevelCache
97
     *
98
     * @return $this;
99
     */
100 5
    public function setUseResultLevelCache(bool $useResultLevelCache)
101
    {
102 5
        $this->properties['useResultLevelCache'] = $useResultLevelCache;
103
104 5
        return $this;
105
    }
106
107
    /**
108
     * Flag indicating whether to save the results of the query to the result level cache. Primarily used for
109
     * debugging. When set to false, it disables saving the results of this query to the query cache. When set to true,
110
     * Druid uses druid.broker.cache.populateResultLevelCache to determine whether or not to save the results of this
111
     * query to the result-level query cache
112
     *
113
     * @param bool $populateResultLevelCache
114
     *
115
     * @return $this;
116
     */
117 5
    public function setPopulateResultLevelCache(bool $populateResultLevelCache)
118
    {
119 5
        $this->properties['populateResultLevelCache'] = $populateResultLevelCache;
120
121 5
        return $this;
122
    }
123
124
    /**
125
     * Return "by segment" results. Primarily used for debugging, setting it to true returns results associated with
126
     * the data segment they came from
127
     *
128
     * @param bool $bySegment
129
     *
130
     * @return $this;
131
     */
132 5
    public function setBySegment(bool $bySegment)
133
    {
134 5
        $this->properties['bySegment'] = $bySegment;
135
136 5
        return $this;
137
    }
138
139
    /**
140
     * Flag indicating whether to "finalize" aggregation results. Primarily used for debugging. For instance, the
141
     * hyperUnique aggregator will return the full HyperLogLog sketch instead of the estimated cardinality when this
142
     * flag is set to false
143
     *
144
     * @param bool $finalize
145
     *
146
     * @return $this;
147
     */
148 9
    public function setFinalize(bool $finalize)
149
    {
150 9
        $this->properties['finalize'] = $finalize;
151
152 9
        return $this;
153
    }
154
155
    /**
156
     * At the Broker process level, long interval queries (of any type) may be broken into shorter interval queries to
157
     * parallelize merging more than normal. Broken up queries will use a larger share of cluster resources, but, if
158
     * you use groupBy "v1, it may be able to complete faster as a result. Use ISO 8601 periods. For example, if this
159
     * property is set to P1M (one month), then a query covering a year would be broken into 12 smaller queries. The
160
     * broker uses its query processing executor service to initiate processing for query chunks, so make sure
161
     * "druid.processing.numThreads" is configured appropriately on the broker. groupBy queries do not support
162
     * chunkPeriod by default, although they do if using the legacy "v1" engine. This context is deprecated since it's
163
     * only useful for groupBy "v1", and will be removed in the future releases.
164
     *
165
     * @param string $chunkPeriod
166
     *
167
     * @return $this;
168
     */
169 5
    public function setChunkPeriod(string $chunkPeriod)
170
    {
171 5
        $this->properties['chunkPeriod'] = $chunkPeriod;
172
173 5
        return $this;
174
    }
175
176
    /**
177
     * Maximum number of bytes gathered from data processes such as historicals and realtime processes to execute a
178
     * query. This parameter can be used to further reduce maxScatterGatherBytes limit at query time. See Broker
179
     * configuration for more details.
180
     *
181
     * @param int $maxScatterGatherBytes
182
     *
183
     * @return $this;
184
     */
185 5
    public function setMaxScatterGatherBytes(int $maxScatterGatherBytes)
186
    {
187 5
        $this->properties['maxScatterGatherBytes'] = $maxScatterGatherBytes;
188
189 5
        return $this;
190
    }
191
192
    /**
193
     * Maximum number of bytes queued per query before exerting back pressure on the channel to the data server. Similar
194
     * to maxScatterGatherBytes, except unlike that configuration, this one will trigger back pressure rather than query
195
     * failure. Zero means disabled.
196
     *
197
     * @param int $maxQueuedBytes
198
     *
199
     * @return $this;
200
     */
201 5
    public function setMaxQueuedBytes(int $maxQueuedBytes)
202
    {
203 5
        $this->properties['maxQueuedBytes'] = $maxQueuedBytes;
204
205 5
        return $this;
206
    }
207
208
    /**
209
     * If true, DateTime is serialized as long in the result returned by Broker and the data transportation between
210
     * Broker and compute process
211
     *
212
     * @param bool $serializeDateTimeAsLong
213
     *
214
     * @return $this;
215
     */
216 5
    public function setSerializeDateTimeAsLong(bool $serializeDateTimeAsLong)
217
    {
218 5
        $this->properties['serializeDateTimeAsLong'] = $serializeDateTimeAsLong;
219
220 5
        return $this;
221
    }
222
223
    /**
224
     * If true, DateTime is serialized as long in the data transportation between Broker and compute process
225
     *
226
     * @param bool $serializeDateTimeAsLongInner
227
     *
228
     * @return $this;
229
     */
230 5
    public function setSerializeDateTimeAsLongInner(bool $serializeDateTimeAsLongInner)
231
    {
232 5
        $this->properties['serializeDateTimeAsLongInner'] = $serializeDateTimeAsLongInner;
233
234 5
        return $this;
235
    }
236
237
    /**
238
     * Enable parallel result merging on the Broker.
239
     * Note that druid.processing.merge.useParallelMergePool must be enabled for this setting to be
240
     * set to true. See Broker configuration for more details.
241
     *
242
     * @param bool $enableParallelMerge
243
     *
244
     * @return $this
245
     */
246 5
    public function setEnableParallelMerge(bool $enableParallelMerge)
247
    {
248 5
        $this->properties['enableParallelMerge'] = $enableParallelMerge;
249
250 5
        return $this;
251
    }
252
253
    /**
254
     * Maximum number of parallel threads to use for parallel result merging on the Broker.
255
     * See Broker configuration for more details.
256
     *
257
     * @param int $parallelMergeParallelism
258
     *
259
     * @return $this
260
     */
261 5
    public function setParallelMergeParallelism(int $parallelMergeParallelism)
262
    {
263 5
        $this->properties['parallelMergeParallelism'] = $parallelMergeParallelism;
264
265 5
        return $this;
266
    }
267
268
    /**
269
     * Number of rows to yield per ForkJoinPool merge task for parallel result merging on the Broker,
270
     * before forking off a new task to continue merging sequences.
271
     * See Broker configuration for more details.
272
     *
273
     * @param int $parallelMergeInitialYieldRows
274
     *
275
     * @return $this
276
     */
277 5
    public function setParallelMergeInitialYieldRows(int $parallelMergeInitialYieldRows)
278
    {
279 5
        $this->properties['parallelMergeInitialYieldRows'] = $parallelMergeInitialYieldRows;
280
281 5
        return $this;
282
    }
283
284
    /**
285
     * Size of result batches to operate on in ForkJoinPool merge tasks for parallel result
286
     * merging on the Broker. See Broker configuration for more details.
287
     *
288
     * @param int $parallelMergeSmallBatchRows
289
     *
290
     * @return $this
291
     */
292 5
    public function setParallelMergeSmallBatchRows(int $parallelMergeSmallBatchRows)
293
    {
294 5
        $this->properties['parallelMergeSmallBatchRows'] = $parallelMergeSmallBatchRows;
295
296 5
        return $this;
297
    }
298
299
    /**
300
     * If true, Druid will attempt to convert the query filter to Conjunctive Normal Form (CNF).
301
     * During query processing, columns can be pre-filtered by intersecting the bitmap indexes of
302
     * all values that match the eligible filters, often greatly reducing the raw number of rows
303
     * which need to be scanned. But this effect only happens for the top level filter,
304
     * or individual clauses of a top level 'and' filter. As such, filters in CNF potentially have
305
     * a higher chance to utilize a large amount of bitmap indexes on string columns during
306
     * pre-filtering. However, this setting should be used with great caution, as it can sometimes
307
     * have a negative effect on performance, and in some cases, the act of computing CNF of a
308
     * filter can be expensive. We recommend hand tuning your filters to produce an optimal form
309
     * if possible, or at least verifying through experimentation that using this parameter actually
310
     * improves your query performance with no ill-effects.
311
     *
312
     * @param bool $useFilterCNF
313
     *
314
     * @return $this
315
     */
316 5
    public function setUseFilterCNF(bool $useFilterCNF)
317
    {
318 5
        $this->properties['useFilterCNF'] = $useFilterCNF;
319
320 5
        return $this;
321
    }
322
323
    /**
324
     * Enable secondary partition pruning on the Broker. The Broker will always prune
325
     * unnecessary segments from the input scan based on a filter on time intervals,
326
     * but if the data is further partitioned with hash or range partitioning,
327
     * this option will enable additional pruning based on a filter on secondary
328
     * partition dimensions.
329
     *
330
     * @param bool $secondaryPartitionPruning
331
     *
332
     * @return $this
333
     */
334 5
    public function setSecondaryPartitionPruning(bool $secondaryPartitionPruning)
335
    {
336 5
        $this->properties['secondaryPartitionPruning'] = $secondaryPartitionPruning;
337
338 5
        return $this;
339
    }
340
}