Skip to content

Commit 26570d6

Browse files
committed
group query options and batch options for readability, remove unused fields
1 parent 7ebab76 commit 26570d6

File tree

1 file changed

+54
-35
lines changed

1 file changed

+54
-35
lines changed

query_executor.go

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -229,28 +229,39 @@ func (q *queryExecutor) run(ctx context.Context, qry internalRequest, hostIter N
229229
}
230230

231231
type queryOptions struct {
232-
stmt string
233-
values []interface{}
234-
initialConsistency Consistency
235-
pageSize int
236-
initialPageState []byte
237-
prefetch float64
238-
trace Tracer
239-
observer QueryObserver
240-
rt RetryPolicy
241-
spec SpeculativeExecutionPolicy
242-
binding func(q *QueryInfo) ([]interface{}, error)
243-
serialCons SerialConsistency
232+
stmt string
233+
234+
// Paging
235+
pageSize int
236+
disableAutoPage bool
237+
238+
// Monitoring
239+
trace Tracer
240+
observer QueryObserver
241+
242+
// Parameters
243+
values []interface{}
244+
binding func(q *QueryInfo) ([]interface{}, error)
245+
246+
// Timestamp
244247
defaultTimestamp bool
245248
defaultTimestampValue int64
246-
disableSkipMetadata bool
247-
context context.Context
248-
idempotent bool
249-
customPayload map[string][]byte
250-
keyspace string
251-
disableAutoPage bool
252-
skipPrepare bool
253-
routingKey []byte
249+
250+
// Consistency
251+
serialCons SerialConsistency
252+
253+
// Protocol flag
254+
disableSkipMetadata bool
255+
256+
customPayload map[string][]byte
257+
prefetch float64
258+
rt RetryPolicy
259+
spec SpeculativeExecutionPolicy
260+
context context.Context
261+
idempotent bool
262+
keyspace string
263+
skipPrepare bool
264+
routingKey []byte
254265

255266
// getKeyspace is field so that it can be overriden in tests
256267
getKeyspace func() string
@@ -274,9 +285,7 @@ func newQueryOptions(q *Query, ctx context.Context) *queryOptions {
274285
return &queryOptions{
275286
stmt: q.stmt,
276287
values: q.values,
277-
initialConsistency: q.initialConsistency,
278288
pageSize: q.pageSize,
279-
initialPageState: newPageState,
280289
prefetch: q.prefetch,
281290
trace: q.trace,
282291
observer: q.observer,
@@ -309,12 +318,18 @@ type internalQuery struct {
309318
}
310319

311320
func newInternalQuery(q *Query, ctx context.Context) *internalQuery {
321+
var newPageState []byte
322+
if q.initialPageState != nil {
323+
pageState := q.initialPageState
324+
newPageState = make([]byte, len(pageState))
325+
copy(newPageState, pageState)
326+
}
312327
return &internalQuery{
313328
originalQuery: q,
314329
qryOpts: newQueryOptions(q, ctx),
315330
metrics: &queryMetrics{m: make(map[string]*hostMetrics)},
316331
consistency: uint32(q.initialConsistency),
317-
pageState: nil,
332+
pageState: newPageState,
318333
conn: nil,
319334
session: q.session,
320335
routingInfo: &queryRoutingInfo{},
@@ -432,20 +447,24 @@ func (q *internalQuery) Statement() Statement {
432447
}
433448

434449
type batchOptions struct {
435-
bType BatchType
436-
entries []BatchEntry
437-
customPayload map[string][]byte
438-
rt RetryPolicy
439-
spec SpeculativeExecutionPolicy
440-
trace Tracer
441-
observer BatchObserver
442-
serialCons SerialConsistency
450+
trace Tracer
451+
observer BatchObserver
452+
453+
bType BatchType
454+
entries []BatchEntry
455+
443456
defaultTimestamp bool
444457
defaultTimestampValue int64
445-
context context.Context
446-
keyspace string
447-
idempotent bool
448-
routingKey []byte
458+
459+
serialCons SerialConsistency
460+
461+
customPayload map[string][]byte
462+
rt RetryPolicy
463+
spec SpeculativeExecutionPolicy
464+
context context.Context
465+
keyspace string
466+
idempotent bool
467+
routingKey []byte
449468
}
450469

451470
func newBatchOptions(b *Batch, ctx context.Context) *batchOptions {

0 commit comments

Comments
 (0)