Skip to content

Commit

Permalink
Fix whitespaces and indentations
Browse files Browse the repository at this point in the history
  • Loading branch information
sylwiaszunejko committed Sep 27, 2024
1 parent ea2b70f commit f2cc29d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions cassandra/tablets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Tablet(object):
"""
Represents a single ScyllaDB tablet.
It stores information about each replica, its host and shard,
It stores information about each replica, its host and shard,
and the token interval in the format (first_token, last_token].
"""
first_token = 0
Expand Down Expand Up @@ -40,12 +40,12 @@ class Tablets(object):
def __init__(self, tablets):
self._tablets = tablets
self._lock = Lock()

def get_tablet_for_key(self, keyspace, table, t):
tablet = self._tablets.get((keyspace, table), [])
if not tablet:
return None

id = bisect_left(tablet, t.value, key=lambda tablet: tablet.last_token)
if id < len(tablet) and t.value > tablet[id].first_token:
return tablet[id]
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/experiments/test_tablets.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup_class(cls):
cls.session = cls.cluster.connect()
cls.create_ks_and_cf(cls)
cls.create_data(cls.session)

@classmethod
def teardown_class(cls):
cls.cluster.shutdown()
Expand All @@ -32,7 +32,7 @@ def verify_same_host_in_tracing(self, results):
for event in events:
LOGGER.info("TRACE EVENT: %s %s %s", event.source, event.thread_name, event.description)
host_set.add(event.source)

self.assertEqual(len(host_set), 1)
self.assertIn('locally', "\n".join([event.description for event in events]))

Expand All @@ -43,7 +43,7 @@ def verify_same_host_in_tracing(self, results):
for event in events:
LOGGER.info("TRACE EVENT: %s %s", event.source, event.activity)
host_set.add(event.source)

self.assertEqual(len(host_set), 1)
self.assertIn('locally', "\n".join([event.activity for event in events]))

Expand All @@ -54,7 +54,7 @@ def verify_same_shard_in_tracing(self, results):
for event in events:
LOGGER.info("TRACE EVENT: %s %s %s", event.source, event.thread_name, event.description)
shard_set.add(event.thread_name)

self.assertEqual(len(shard_set), 1)
self.assertIn('locally', "\n".join([event.description for event in events]))

Expand All @@ -65,10 +65,10 @@ def verify_same_shard_in_tracing(self, results):
for event in events:
LOGGER.info("TRACE EVENT: %s %s", event.thread, event.activity)
shard_set.add(event.thread)

self.assertEqual(len(shard_set), 1)
self.assertIn('locally', "\n".join([event.activity for event in events]))

def create_ks_and_cf(self):
self.session.execute(
"""
Expand All @@ -79,8 +79,8 @@ def create_ks_and_cf(self):
"""
CREATE KEYSPACE test1
WITH replication = {
'class': 'NetworkTopologyStrategy',
'replication_factor': 1
'class': 'NetworkTopologyStrategy',
'replication_factor': 1
} AND tablets = {
'initial': 8
}
Expand All @@ -90,14 +90,14 @@ def create_ks_and_cf(self):
"""
CREATE TABLE test1.table1 (pk int, ck int, v int, PRIMARY KEY (pk, ck));
""")

@staticmethod
def create_data(session):
prepared = session.prepare(
"""
INSERT INTO test1.table1 (pk, ck, v) VALUES (?, ?, ?)
""")

for i in range(50):
bound = prepared.bind((i, i%5, i%2))
session.execute(bound)
Expand Down

0 comments on commit f2cc29d

Please sign in to comment.