Skip to content

Commit

Permalink
Make ExecutableQuery interfaces implementable
Browse files Browse the repository at this point in the history
`ExecutableQuery` uses `partitioner` which makes it unimplementable
  • Loading branch information
dkropachev committed Jun 3, 2024
1 parent 2cb2cb4 commit bd80d3f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions host_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,10 @@ func (h *HostInfo) Hostname() string {
}

func (h *HostInfo) ConnectAddressAndPort() string {
h.mu.Lock()
defer h.mu.Unlock()
addr, _ := h.connectAddressLocked()
return net.JoinHostPort(addr.String(), strconv.Itoa(h.port))
h.mu.Lock()
defer h.mu.Unlock()
addr, _ := h.connectAddressLocked()
return net.JoinHostPort(addr.String(), strconv.Itoa(h.port))
}

func (h *HostInfo) String() string {
Expand Down
2 changes: 1 addition & 1 deletion metadata_scylla.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ type schemaDescriber struct {
session *Session
mu sync.Mutex

cache map[string]*KeyspaceMetadata
cache map[string]*KeyspaceMetadata

// Experimental, this interface and use may change
tabletsCache *TabletsMetadata
Expand Down
2 changes: 1 addition & 1 deletion query_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ExecutableQuery interface {
Table() string
IsIdempotent() bool
IsLWT() bool
GetCustomPartitioner() partitioner
GetCustomPartitioner() Partitioner

withContext(context.Context) ExecutableQuery

Expand Down
14 changes: 7 additions & 7 deletions scylla.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,13 @@ func (p *scyllaConnPicker) Pick(t Token, keyspace string, table string) *Conn {
conn.mu.Lock()
if conn.tabletsRoutingV1 {
tablets := conn.session.getTablets()

// Search for tablets with Keyspace and Table from the Query
l, r := findTablets(tablets, keyspace, table)

if l != -1 {
tablet := findTabletForToken(tablets, mmt, l, r)

for _, replica := range tablet.replicas {
if replica.hostId.String() == p.hostId {
idx = replica.shardId
Expand All @@ -396,7 +396,7 @@ func (p *scyllaConnPicker) Pick(t Token, keyspace string, table string) *Conn {

break
}

if idx == -1 {
idx = p.shardOf(mmt)
}
Expand All @@ -415,15 +415,15 @@ func (p *scyllaConnPicker) maybeReplaceWithLessBusyConnection(c *Conn) *Conn {
return c
}
alternative := p.leastBusyConn()
if alternative == nil || alternative.AvailableStreams()*120 > c.AvailableStreams()*100 {
if alternative == nil || alternative.AvailableStreams() * 120 > c.AvailableStreams() * 100 {
return c
} else {
return alternative
}
}

func isHeavyLoaded(c *Conn) bool {
return c.streams.NumStreams/2 > c.AvailableStreams()
return c.streams.NumStreams / 2 > c.AvailableStreams();
}

func (p *scyllaConnPicker) leastBusyConn() *Conn {
Expand Down Expand Up @@ -860,7 +860,7 @@ func ScyllaGetSourcePort(ctx context.Context) uint16 {

// Returns a partitioner specific to the table, or "nil"
// if the cluster-global partitioner should be used
func scyllaGetTablePartitioner(session *Session, keyspaceName, tableName string) (partitioner, error) {
func scyllaGetTablePartitioner(session *Session, keyspaceName, tableName string) (Partitioner, error) {
isCdc, err := scyllaIsCdcTable(session, keyspaceName, tableName)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion scylla_cdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (

type scyllaCDCPartitioner struct{}

var _ partitioner = scyllaCDCPartitioner{}
var _ Partitioner = scyllaCDCPartitioner{}

func (p scyllaCDCPartitioner) Name() string {
return scyllaCDCPartitionerName
Expand Down
18 changes: 9 additions & 9 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ type queryRoutingInfo struct {
lwt bool

// If not nil, represents a custom partitioner for the table.
partitioner partitioner
partitioner Partitioner

keyspace string

Expand All @@ -999,7 +999,7 @@ func (qri *queryRoutingInfo) isLWT() bool {
return qri.lwt
}

func (qri *queryRoutingInfo) getPartitioner() partitioner {
func (qri *queryRoutingInfo) getPartitioner() Partitioner {
qri.mu.RLock()
defer qri.mu.RUnlock()
return qri.partitioner
Expand Down Expand Up @@ -1310,7 +1310,7 @@ func (q *Query) IsLWT() bool {
return q.routingInfo.isLWT()
}

func (q *Query) GetCustomPartitioner() partitioner {
func (q *Query) GetCustomPartitioner() Partitioner {
return q.routingInfo.getPartitioner()
}

Expand Down Expand Up @@ -1933,7 +1933,7 @@ func (b *Batch) IsLWT() bool {
return b.routingInfo.isLWT()
}

func (b *Batch) GetCustomPartitioner() partitioner {
func (b *Batch) GetCustomPartitioner() Partitioner {
return b.routingInfo.getPartitioner()
}

Expand Down Expand Up @@ -2171,12 +2171,12 @@ type routingKeyInfoLRU struct {
}

type routingKeyInfo struct {
indexes []int
types []TypeInfo
keyspace string
table string
indexes []int
types []TypeInfo
keyspace string
table string
lwt bool
partitioner partitioner
partitioner Partitioner
}

func (r *routingKeyInfo) String() string {
Expand Down
4 changes: 2 additions & 2 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
)

// a token partitioner
type partitioner interface {
type Partitioner interface {
Name() string
Hash([]byte) Token
ParseString(string) Token
Expand Down Expand Up @@ -135,7 +135,7 @@ func (ht hostToken) String() string {

// a data structure for organizing the relationship between tokens and hosts
type tokenRing struct {
partitioner partitioner
partitioner Partitioner

// tokens map token range to primary replica.
// The elements in tokens are sorted by token ascending.
Expand Down

0 comments on commit bd80d3f

Please sign in to comment.