mirror of https://github.com/milvus-io/milvus.git
enhance: speed up GetByCollectionAndNode (#32232)
Related to https://github.com/milvus-io/milvus/issues/32165 Avoid iterating through all replicas/collections if possible. Iteration is expensive when there are large number of replicas/collections. Signed-off-by: yiwangdr <yiwangdr@gmail.com>pull/32353/head
parent
f0f2f11189
commit
7deda4d5e9
|
@ -241,9 +241,12 @@ func (m *ReplicaManager) GetByCollectionAndNode(collectionID, nodeID typeutil.Un
|
||||||
m.rwmutex.RLock()
|
m.rwmutex.RLock()
|
||||||
defer m.rwmutex.RUnlock()
|
defer m.rwmutex.RUnlock()
|
||||||
|
|
||||||
for _, replica := range m.replicas {
|
if m.collIDToReplicaIDs[collectionID] != nil {
|
||||||
if replica.GetCollectionID() == collectionID && replica.Contains(nodeID) {
|
for replicaID := range m.collIDToReplicaIDs[collectionID] {
|
||||||
return replica
|
replica := m.replicas[replicaID]
|
||||||
|
if replica.Contains(nodeID) {
|
||||||
|
return replica
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue