MCPcopy Create free account
hub / github.com/apache/cassandra-python-driver / make_query_plan

Method make_query_plan

cassandra/policies.py:365–393  ·  view source on GitHub ↗
(self, working_keyspace=None, query=None)

Source from the content-addressed store, hash-verified

363 return self._child_policy.distance(*args, **kwargs)
364
365 def make_query_plan(self, working_keyspace=None, query=None):
366 if query and query.keyspace:
367 keyspace = query.keyspace
368 else:
369 keyspace = working_keyspace
370
371 child = self._child_policy
372 if query is None:
373 for host in child.make_query_plan(keyspace, query):
374 yield host
375 else:
376 routing_key = query.routing_key
377 if routing_key is None or keyspace is None:
378 for host in child.make_query_plan(keyspace, query):
379 yield host
380 else:
381 replicas = self._cluster_metadata.get_replicas(keyspace, routing_key)
382 if self.shuffle_replicas:
383 shuffle(replicas)
384 for replica in replicas:
385 if replica.is_up and \
386 child.distance(replica) == HostDistance.LOCAL:
387 yield replica
388
389 for host in child.make_query_plan(keyspace, query):
390 # skip if we've already listed this host
391 if host not in replicas or \
392 child.distance(host) == HostDistance.REMOTE:
393 yield host
394
395 def on_up(self, *args, **kwargs):
396 return self._child_policy.on_up(*args, **kwargs)

Callers 5

test_wrap_round_robinMethod · 0.95
test_wrap_dc_awareMethod · 0.95
test_status_updatesMethod · 0.95
_assert_shuffleMethod · 0.95

Calls 3

make_query_planMethod · 0.45
get_replicasMethod · 0.45
distanceMethod · 0.45

Tested by 5

test_wrap_round_robinMethod · 0.76
test_wrap_dc_awareMethod · 0.76
test_status_updatesMethod · 0.76
_assert_shuffleMethod · 0.76