@@ -28,16 +28,17 @@ import (
28
28
)
29
29
30
30
const (
31
- keyQueryCount = "arangodb-query-count"
32
- keyQueryBatchSize = "arangodb-query-batchSize"
33
- keyQueryCache = "arangodb-query-cache"
34
- keyQueryMemoryLimit = "arangodb-query-memoryLimit"
35
- keyQueryTTL = "arangodb-query-ttl"
36
- keyQueryOptSatSyncWait = "arangodb-query-opt-satSyncWait"
37
- keyQueryOptFullCount = "arangodb-query-opt-fullCount"
38
- keyQueryOptStream = "arangodb-query-opt-stream"
39
- keyQueryOptProfile = "arangodb-query-opt-profile"
40
- keyQueryOptMaxRuntime = "arangodb-query-opt-maxRuntime"
31
+ keyQueryCount = "arangodb-query-count"
32
+ keyQueryBatchSize = "arangodb-query-batchSize"
33
+ keyQueryCache = "arangodb-query-cache"
34
+ keyQueryMemoryLimit = "arangodb-query-memoryLimit"
35
+ keyQueryForceOneShardAttributeValue = "arangodb-query-forceOneShardAttributeValue"
36
+ keyQueryTTL = "arangodb-query-ttl"
37
+ keyQueryOptSatSyncWait = "arangodb-query-opt-satSyncWait"
38
+ keyQueryOptFullCount = "arangodb-query-opt-fullCount"
39
+ keyQueryOptStream = "arangodb-query-opt-stream"
40
+ keyQueryOptProfile = "arangodb-query-opt-profile"
41
+ keyQueryOptMaxRuntime = "arangodb-query-opt-maxRuntime"
41
42
)
42
43
43
44
// WithQueryCount is used to configure a context that will set the Count of a query request,
@@ -70,6 +71,11 @@ func WithQueryMemoryLimit(parent context.Context, value int64) context.Context {
70
71
return context .WithValue (contextOrBackground (parent ), keyQueryMemoryLimit , value )
71
72
}
72
73
74
+ // WithQueryForceOneShardAttributeValue is used to configure a context that will set the ForceOneShardAttributeValue of a query request,
75
+ func WithQueryForceOneShardAttributeValue (parent context.Context , value string ) context.Context {
76
+ return context .WithValue (contextOrBackground (parent ), keyQueryForceOneShardAttributeValue , value )
77
+ }
78
+
73
79
// WithQueryTTL is used to configure a context that will set the TTL of a query request,
74
80
func WithQueryTTL (parent context.Context , value time.Duration ) context.Context {
75
81
return context .WithValue (contextOrBackground (parent ), keyQueryTTL , value )
@@ -179,6 +185,9 @@ type queryRequest struct {
179
185
// MaxRuntime specify the timeout which can be used to kill a query on the server after the specified
180
186
// amount in time. The timeout value is specified in seconds. A value of 0 means no timeout will be enforced.
181
187
MaxRuntime float64 `json:"maxRuntime,omitempty"`
188
+ // ForceOneShardAttributeValue This query option can be used in complex queries in case the query optimizer cannot
189
+ // automatically detect that the query can be limited to only a single server (e.g. in a disjoint smart graph case).
190
+ ForceOneShardAttributeValue * string `json:"forceOneShardAttributeValue,omitempty"`
182
191
} `json:"options,omitempty"`
183
192
}
184
193
@@ -207,6 +216,11 @@ func (q *queryRequest) applyContextSettings(ctx context.Context) {
207
216
q .MemoryLimit = value
208
217
}
209
218
}
219
+ if rawValue := ctx .Value (keyQueryForceOneShardAttributeValue ); rawValue != nil {
220
+ if value , ok := rawValue .(string ); ok {
221
+ q .Options .ForceOneShardAttributeValue = & value
222
+ }
223
+ }
210
224
if rawValue := ctx .Value (keyQueryTTL ); rawValue != nil {
211
225
if value , ok := rawValue .(time.Duration ); ok {
212
226
q .TTL = value .Seconds ()
0 commit comments