@@ -28,16 +28,17 @@ import (
2828)
2929
3030const (
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"
4142)
4243
4344// 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 {
7071 return context .WithValue (contextOrBackground (parent ), keyQueryMemoryLimit , value )
7172}
7273
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+
7379// WithQueryTTL is used to configure a context that will set the TTL of a query request,
7480func WithQueryTTL (parent context.Context , value time.Duration ) context.Context {
7581 return context .WithValue (contextOrBackground (parent ), keyQueryTTL , value )
@@ -179,6 +185,9 @@ type queryRequest struct {
179185 // MaxRuntime specify the timeout which can be used to kill a query on the server after the specified
180186 // amount in time. The timeout value is specified in seconds. A value of 0 means no timeout will be enforced.
181187 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"`
182191 } `json:"options,omitempty"`
183192}
184193
@@ -207,6 +216,11 @@ func (q *queryRequest) applyContextSettings(ctx context.Context) {
207216 q .MemoryLimit = value
208217 }
209218 }
219+ if rawValue := ctx .Value (keyQueryForceOneShardAttributeValue ); rawValue != nil {
220+ if value , ok := rawValue .(string ); ok {
221+ q .Options .ForceOneShardAttributeValue = & value
222+ }
223+ }
210224 if rawValue := ctx .Value (keyQueryTTL ); rawValue != nil {
211225 if value , ok := rawValue .(time.Duration ); ok {
212226 q .TTL = value .Seconds ()
0 commit comments