@@ -165,16 +165,21 @@ type ReadOptions struct {
165165
166166 // The request tag to use for this request.
167167 RequestTag string
168+
169+ // If this is for a partitioned read and DataBoostEnabled field is set to true, the request will be executed
170+ // via Spanner independent compute resources. Setting this option for regular read operations has no effect.
171+ DataBoostEnabled bool
168172}
169173
170174// merge combines two ReadOptions that the input parameter will have higher
171175// order of precedence.
172176func (ro ReadOptions ) merge (opts ReadOptions ) ReadOptions {
173177 merged := ReadOptions {
174- Index : ro .Index ,
175- Limit : ro .Limit ,
176- Priority : ro .Priority ,
177- RequestTag : ro .RequestTag ,
178+ Index : ro .Index ,
179+ Limit : ro .Limit ,
180+ Priority : ro .Priority ,
181+ RequestTag : ro .RequestTag ,
182+ DataBoostEnabled : ro .DataBoostEnabled ,
178183 }
179184 if opts .Index != "" {
180185 merged .Index = opts .Index
@@ -188,6 +193,9 @@ func (ro ReadOptions) merge(opts ReadOptions) ReadOptions {
188193 if opts .RequestTag != "" {
189194 merged .RequestTag = opts .RequestTag
190195 }
196+ if opts .DataBoostEnabled {
197+ merged .DataBoostEnabled = opts .DataBoostEnabled
198+ }
191199 return merged
192200}
193201
@@ -218,13 +226,17 @@ func (t *txReadOnly) ReadWithOptions(ctx context.Context, table string, keys Key
218226 limit := t .ro .Limit
219227 prio := t .ro .Priority
220228 requestTag := t .ro .RequestTag
229+ dataBoostEnabled := t .ro .DataBoostEnabled
221230 if opts != nil {
222231 index = opts .Index
223232 if opts .Limit > 0 {
224233 limit = opts .Limit
225234 }
226235 prio = opts .Priority
227236 requestTag = opts .RequestTag
237+ if opts .DataBoostEnabled {
238+ dataBoostEnabled = opts .DataBoostEnabled
239+ }
228240 }
229241 var setTransactionID func (transactionID )
230242 if _ , ok := ts .Selector .(* sppb.TransactionSelector_Begin ); ok {
@@ -238,15 +250,16 @@ func (t *txReadOnly) ReadWithOptions(ctx context.Context, table string, keys Key
238250 func (ctx context.Context , resumeToken []byte ) (streamingReceiver , error ) {
239251 client , err := client .StreamingRead (ctx ,
240252 & sppb.ReadRequest {
241- Session : t .sh .getID (),
242- Transaction : t .getTransactionSelector (),
243- Table : table ,
244- Index : index ,
245- Columns : columns ,
246- KeySet : kset ,
247- ResumeToken : resumeToken ,
248- Limit : int64 (limit ),
249- RequestOptions : createRequestOptions (prio , requestTag , t .txOpts .TransactionTag ),
253+ Session : t .sh .getID (),
254+ Transaction : t .getTransactionSelector (),
255+ Table : table ,
256+ Index : index ,
257+ Columns : columns ,
258+ KeySet : kset ,
259+ ResumeToken : resumeToken ,
260+ Limit : int64 (limit ),
261+ RequestOptions : createRequestOptions (prio , requestTag , t .txOpts .TransactionTag ),
262+ DataBoostEnabled : dataBoostEnabled ,
250263 })
251264 if err != nil {
252265 if _ , ok := t .getTransactionSelector ().GetSelector ().(* sppb.TransactionSelector_Begin ); ok {
@@ -357,16 +370,21 @@ type QueryOptions struct {
357370
358371 // The request tag to use for this request.
359372 RequestTag string
373+
374+ // If this is for a partitioned query and DataBoostEnabled field is set to true, the request will be executed
375+ // via Spanner independent compute resources. Setting this option for regular query operations has no effect.
376+ DataBoostEnabled bool
360377}
361378
362379// merge combines two QueryOptions that the input parameter will have higher
363380// order of precedence.
364381func (qo QueryOptions ) merge (opts QueryOptions ) QueryOptions {
365382 merged := QueryOptions {
366- Mode : qo .Mode ,
367- Options : & sppb.ExecuteSqlRequest_QueryOptions {},
368- RequestTag : qo .RequestTag ,
369- Priority : qo .Priority ,
383+ Mode : qo .Mode ,
384+ Options : & sppb.ExecuteSqlRequest_QueryOptions {},
385+ RequestTag : qo .RequestTag ,
386+ Priority : qo .Priority ,
387+ DataBoostEnabled : qo .DataBoostEnabled ,
370388 }
371389 if opts .Mode != nil {
372390 merged .Mode = opts .Mode
@@ -377,6 +395,9 @@ func (qo QueryOptions) merge(opts QueryOptions) QueryOptions {
377395 if opts .Priority != sppb .RequestOptions_PRIORITY_UNSPECIFIED {
378396 merged .Priority = opts .Priority
379397 }
398+ if opts .DataBoostEnabled {
399+ merged .DataBoostEnabled = opts .DataBoostEnabled
400+ }
380401 proto .Merge (merged .Options , qo .Options )
381402 proto .Merge (merged .Options , opts .Options )
382403 return merged
@@ -517,15 +538,16 @@ func (t *txReadOnly) prepareExecuteSQL(ctx context.Context, stmt Statement, opti
517538 mode = * options .Mode
518539 }
519540 req := & sppb.ExecuteSqlRequest {
520- Session : sid ,
521- Transaction : ts ,
522- Sql : stmt .SQL ,
523- QueryMode : mode ,
524- Seqno : atomic .AddInt64 (& t .sequenceNumber , 1 ),
525- Params : params ,
526- ParamTypes : paramTypes ,
527- QueryOptions : options .Options ,
528- RequestOptions : createRequestOptions (options .Priority , options .RequestTag , t .txOpts .TransactionTag ),
541+ Session : sid ,
542+ Transaction : ts ,
543+ Sql : stmt .SQL ,
544+ QueryMode : mode ,
545+ Seqno : atomic .AddInt64 (& t .sequenceNumber , 1 ),
546+ Params : params ,
547+ ParamTypes : paramTypes ,
548+ QueryOptions : options .Options ,
549+ RequestOptions : createRequestOptions (options .Priority , options .RequestTag , t .txOpts .TransactionTag ),
550+ DataBoostEnabled : options .DataBoostEnabled ,
529551 }
530552 return req , sh , nil
531553}
0 commit comments