@@ -75,8 +75,6 @@ type Session struct {
7575 ring ring
7676 metadata clusterMetadata
7777
78- mu sync.RWMutex
79-
8078 control * controlConn
8179
8280 // event handlers
@@ -153,14 +151,15 @@ func NewSession(cfg ClusterConfig) (*Session, error) {
153151
154152 s := & Session {
155153 cons : cfg .Consistency ,
156- prefetch : 0.25 ,
154+ prefetch : cfg . NextPagePrefetch ,
157155 cfg : cfg ,
158156 pageSize : cfg .PageSize ,
159157 stmtsLRU : & preparedLRU {lru : lru .New (cfg .MaxPreparedStmts )},
160158 connectObserver : cfg .ConnectObserver ,
161159 ctx : ctx ,
162160 cancel : cancel ,
163161 logger : cfg .logger (),
162+ trace : cfg .Tracer ,
164163 }
165164
166165 s .schemaDescriber = newSchemaDescriber (s )
@@ -416,41 +415,6 @@ func (s *Session) reconnectDownedHosts(intv time.Duration) {
416415 }
417416}
418417
419- // SetConsistency sets the default consistency level for this session. This
420- // setting can also be changed on a per-query basis and the default value
421- // is Quorum.
422- func (s * Session ) SetConsistency (cons Consistency ) {
423- s .mu .Lock ()
424- s .cons = cons
425- s .mu .Unlock ()
426- }
427-
428- // SetPageSize sets the default page size for this session. A value <= 0 will
429- // disable paging. This setting can also be changed on a per-query basis.
430- func (s * Session ) SetPageSize (n int ) {
431- s .mu .Lock ()
432- s .pageSize = n
433- s .mu .Unlock ()
434- }
435-
436- // SetPrefetch sets the default threshold for pre-fetching new pages. If
437- // there are only p*pageSize rows remaining, the next page will be requested
438- // automatically. This value can also be changed on a per-query basis and
439- // the default value is 0.25.
440- func (s * Session ) SetPrefetch (p float64 ) {
441- s .mu .Lock ()
442- s .prefetch = p
443- s .mu .Unlock ()
444- }
445-
446- // SetTrace sets the default tracer for this session. This setting can also
447- // be changed on a per-query basis.
448- func (s * Session ) SetTrace (trace Tracer ) {
449- s .mu .Lock ()
450- s .trace = trace
451- s .mu .Unlock ()
452- }
453-
454418// Query generates a new query object for interacting with the database.
455419// Further details of the query may be tweaked using the resulting query
456420// value before the query is executed. Query is automatically prepared
@@ -1005,7 +969,6 @@ type queryRoutingInfo struct {
1005969func (q * Query ) defaultsFromSession () {
1006970 s := q .session
1007971
1008- s .mu .RLock ()
1009972 q .cons = s .cons
1010973 q .pageSize = s .pageSize
1011974 q .trace = s .trace
@@ -1018,7 +981,6 @@ func (q *Query) defaultsFromSession() {
1018981 q .metrics = & queryMetrics {m : make (map [string ]* hostMetrics )}
1019982
1020983 q .spec = & NonSpeculativeExecution {}
1021- s .mu .RUnlock ()
1022984}
1023985
1024986// Statement returns the statement that was used to generate this query.
@@ -1855,7 +1817,6 @@ func (s *Session) NewBatch(typ BatchType) *Batch {
18551817
18561818// Batch creates a new batch operation using defaults defined in the cluster
18571819func (s * Session ) Batch (typ BatchType ) * Batch {
1858- s .mu .RLock ()
18591820 batch := & Batch {
18601821 Type : typ ,
18611822 rt : s .cfg .RetryPolicy ,
@@ -1871,7 +1832,6 @@ func (s *Session) Batch(typ BatchType) *Batch {
18711832 routingInfo : & queryRoutingInfo {},
18721833 }
18731834
1874- s .mu .RUnlock ()
18751835 return batch
18761836}
18771837
0 commit comments