def __compress_buckets(self):
    cursor = self.list_row_bucket.first
    i = 0
    while (cursor is not None):
        k = cursor.bucket_size_row
        if (k == (self.MAX_BUCKETS + 1)):
            next_node = cursor.get_next_item()
            if (next_node is None):
                self.list_row_bucket.add_to_tail()
                next_node = cursor.get_next_item()
                self.last_bucket_row += 1
            n1 = self.bucket_size(i)
            n2 = self.bucket_size(i)
            u1 = (cursor.get_total(0) / n1)
            u2 = (cursor.get_total(1) / n2)
            incremental_variance = (((n1 * n2) * ((u1 - u2) * (u1 - u2))) / (n1 + n2))
            next_node.insert_bucket((cursor.get_total(0) + cursor.get_total(1)), (cursor.get_variance(1) + incremental_variance))
            self.bucket_number += 1
            cursor.compress_bucket_row(2)
            if (next_node.bucket_size_row <= self.MAX_BUCKETS):
                break
        else:
            break
        cursor = cursor.get_next_item()
        i += 1
def __compress_buckets(self):
    cursor = self.list_row_bucket.first
    i = 0
    while (cursor is not None):
        k = cursor.bucket_size_row
        if (k == (self.MAX_BUCKETS + 1)):
            next_node = cursor.get_next_item()
            if (next_node is None):
                self.list_row_bucket.add_to_tail()
                next_node = cursor.get_next_item()
                self.last_bucket_row += 1
            n1 = self.bucket_size(i)
            n2 = self.bucket_size(i)
            u1 = (cursor.get_total(0) / n1)
            u2 = (cursor.get_total(1) / n2)
            incremental_variance = (((n1 * n2) * ((u1 - u2) * (u1 - u2))) / (n1 + n2))
            next_node.insert_bucket((cursor.get_total(0) + cursor.get_total(1)), (cursor.get_variance(1) + incremental_variance))
            self.bucket_number += 1
            cursor.compress_bucket_row(2)
            if (next_node.bucket_size_row <= self.MAX_BUCKETS):
                break
        else:
            break
        cursor = cursor.get_next_item()
        i += 1