|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace Level23\Druid\Context; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* GroupBy queries can be executed using two different strategies. The default strategy for a cluster is determined |
|
8
|
|
|
* by the "druid.query.groupBy.defaultStrategy" runtime property on the Broker. This can be overridden using |
|
9
|
|
|
* "groupByStrategy" in the query context. |
|
10
|
|
|
* |
|
11
|
|
|
* Overrides the value of druid.query.groupBy.defaultStrategy for this query. |
|
12
|
|
|
*/ |
|
13
|
|
|
class GroupByQueryContext extends QueryContext implements ContextInterface |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @param array<string,string|int|bool> $properties |
|
17
|
|
|
*/ |
|
18
|
9 |
|
public function __construct(array $properties = []) |
|
19
|
|
|
{ |
|
20
|
9 |
|
parent::__construct($properties); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Overrides the value of druid.query.groupBy.singleThreaded for this query. |
|
25
|
|
|
* |
|
26
|
|
|
* @param bool $groupByIsSingleThreaded |
|
27
|
|
|
* |
|
28
|
|
|
* @return $this |
|
29
|
|
|
*/ |
|
30
|
1 |
|
public function setGroupByIsSingleThreaded(bool $groupByIsSingleThreaded): self |
|
31
|
|
|
{ |
|
32
|
1 |
|
$this->properties['groupByIsSingleThreaded'] = $groupByIsSingleThreaded; |
|
33
|
|
|
|
|
34
|
1 |
|
return $this; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Overrides the value of druid.query.groupBy.bufferGrouperInitialBuckets for this query. |
|
39
|
|
|
* |
|
40
|
|
|
* @param int $bufferGrouperInitialBuckets |
|
41
|
|
|
* |
|
42
|
|
|
* @return $this |
|
43
|
|
|
*/ |
|
44
|
1 |
|
public function setBufferGrouperInitialBuckets(int $bufferGrouperInitialBuckets): self |
|
45
|
|
|
{ |
|
46
|
1 |
|
$this->properties['bufferGrouperInitialBuckets'] = $bufferGrouperInitialBuckets; |
|
47
|
|
|
|
|
48
|
1 |
|
return $this; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Overrides the value of druid.query.groupBy.bufferGrouperMaxLoadFactor for this query. |
|
53
|
|
|
* |
|
54
|
|
|
* @param int $bufferGrouperMaxLoadFactor |
|
55
|
|
|
* |
|
56
|
|
|
* @return $this |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public function setBufferGrouperMaxLoadFactor(int $bufferGrouperMaxLoadFactor): self |
|
59
|
|
|
{ |
|
60
|
1 |
|
$this->properties['bufferGrouperMaxLoadFactor'] = $bufferGrouperMaxLoadFactor; |
|
61
|
|
|
|
|
62
|
1 |
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Overrides the value of druid.query.groupBy.forceHashAggregation |
|
67
|
|
|
* |
|
68
|
|
|
* @param bool $forceHashAggregation |
|
69
|
|
|
* |
|
70
|
|
|
* @return $this |
|
71
|
|
|
*/ |
|
72
|
1 |
|
public function setForceHashAggregation(bool $forceHashAggregation): self |
|
73
|
|
|
{ |
|
74
|
1 |
|
$this->properties['forceHashAggregation'] = $forceHashAggregation; |
|
75
|
|
|
|
|
76
|
1 |
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Overrides the value of druid.query.groupBy.intermediateCombineDegree |
|
81
|
|
|
* |
|
82
|
|
|
* @param int $intermediateCombineDegree |
|
83
|
|
|
* |
|
84
|
|
|
* @return $this |
|
85
|
|
|
*/ |
|
86
|
1 |
|
public function setIntermediateCombineDegree(int $intermediateCombineDegree): self |
|
87
|
|
|
{ |
|
88
|
1 |
|
$this->properties['intermediateCombineDegree'] = $intermediateCombineDegree; |
|
89
|
|
|
|
|
90
|
1 |
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Overrides the value of druid.query.groupBy.numParallelCombineThreads |
|
95
|
|
|
* |
|
96
|
|
|
* @param int $numParallelCombineThreads |
|
97
|
|
|
* |
|
98
|
|
|
* @return $this |
|
99
|
|
|
*/ |
|
100
|
1 |
|
public function setNumParallelCombineThreads(int $numParallelCombineThreads): self |
|
101
|
|
|
{ |
|
102
|
1 |
|
$this->properties['numParallelCombineThreads'] = $numParallelCombineThreads; |
|
103
|
|
|
|
|
104
|
1 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Sort the results first by dimension values and then by timestamp. |
|
109
|
|
|
* |
|
110
|
|
|
* @param bool $sortByDimsFirst |
|
111
|
|
|
* |
|
112
|
|
|
* @return $this |
|
113
|
|
|
*/ |
|
114
|
1 |
|
public function setSortByDimsFirst(bool $sortByDimsFirst): self |
|
115
|
|
|
{ |
|
116
|
1 |
|
$this->properties['sortByDimsFirst'] = $sortByDimsFirst; |
|
117
|
|
|
|
|
118
|
1 |
|
return $this; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* When all fields in the orderBy are part of the grouping key, the Broker will push limit application down to the |
|
123
|
|
|
* Historical processes. When the sorting order uses fields that are not in the grouping key, applying this |
|
124
|
|
|
* optimization can result in approximate results with unknown accuracy, so this optimization is disabled by |
|
125
|
|
|
* default in that case. Enabling this context flag turns on limit push down for limit/orderBy's that contain |
|
126
|
|
|
* non-grouping key columns. |
|
127
|
|
|
* |
|
128
|
|
|
* @param bool $forceLimitPushDown |
|
129
|
|
|
* |
|
130
|
|
|
* @return $this |
|
131
|
|
|
*/ |
|
132
|
1 |
|
public function setForceLimitPushDown(bool $forceLimitPushDown): self |
|
133
|
|
|
{ |
|
134
|
1 |
|
$this->properties['forceLimitPushDown'] = $forceLimitPushDown; |
|
135
|
|
|
|
|
136
|
1 |
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* Can be used to lower the value of druid.query.groupBy.maxMergingDictionarySize for this query. |
|
141
|
|
|
* |
|
142
|
|
|
* @param int $maxMergingDictionarySize |
|
143
|
|
|
* |
|
144
|
|
|
* @return $this |
|
145
|
|
|
*/ |
|
146
|
1 |
|
public function setMaxMergingDictionarySize(int $maxMergingDictionarySize): self |
|
147
|
|
|
{ |
|
148
|
1 |
|
$this->properties['maxMergingDictionarySize'] = $maxMergingDictionarySize; |
|
149
|
|
|
|
|
150
|
1 |
|
return $this; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Can be used to lower the value of druid.query.groupBy.maxOnDiskStorage for this query. |
|
155
|
|
|
* |
|
156
|
|
|
* @param int $maxOnDiskStorage |
|
157
|
|
|
* |
|
158
|
|
|
* @return $this |
|
159
|
|
|
*/ |
|
160
|
3 |
|
public function setMaxOnDiskStorage(int $maxOnDiskStorage): self |
|
161
|
|
|
{ |
|
162
|
3 |
|
$this->properties['maxOnDiskStorage'] = $maxOnDiskStorage; |
|
163
|
|
|
|
|
164
|
3 |
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
/** |
|
168
|
|
|
* If Broker pushes limit down to queryable nodes (historicals, peons) then limit results |
|
169
|
|
|
* during segment scan. This context value can be used to override |
|
170
|
|
|
* druid.query.groupBy.applyLimitPushDownToSegment. |
|
171
|
|
|
* |
|
172
|
|
|
* @param bool $applyLimitPushDownToSegment |
|
173
|
|
|
* |
|
174
|
|
|
* @return $this |
|
175
|
|
|
*/ |
|
176
|
1 |
|
public function setApplyLimitPushDownToSegment(bool $applyLimitPushDownToSegment): self |
|
177
|
|
|
{ |
|
178
|
1 |
|
$this->properties['applyLimitPushDownToSegment'] = $applyLimitPushDownToSegment; |
|
179
|
|
|
|
|
180
|
1 |
|
return $this; |
|
181
|
|
|
} |
|
182
|
|
|
} |