Changeset View
Changeset View
Standalone View
Standalone View
swh/lister/core/indexing_lister.py
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | def db_partition_indices(self, partition_size): | ||||
partitions = [] | partitions = [] | ||||
partition_size = min(partition_size, n) | partition_size = min(partition_size, n) | ||||
prev_index = None | prev_index = None | ||||
for i in range(0, n-1, partition_size): | for i in range(0, n-1, partition_size): | ||||
# indexable column from the ith row | # indexable column from the ith row | ||||
index = self.db_session.query(self.MODEL.indexable) \ | index = self.db_session.query(self.MODEL.indexable) \ | ||||
.order_by(self.MODEL.indexable).offset(i).first() | .order_by(self.MODEL.indexable).offset(i).first() | ||||
if index: | |||||
index = index[0] | |||||
if index is not None and prev_index is not None: | if index is not None and prev_index is not None: | ||||
partitions.append((prev_index, index)) | partitions.append((prev_index, index)) | ||||
prev_index = index | prev_index = index | ||||
partitions.append((prev_index, self.db_last_index())) | partitions.append((prev_index, self.db_last_index())) | ||||
return partitions | return partitions | ||||
def db_last_index(self): | def db_last_index(self): | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |