Пример #1
0
 def __init__(self,
              reader: BufferedReader,
              packet_generator,
              with_column_types=False,
              columnar=False):
     super().__init__(reader, packet_generator, with_column_types, columnar)
     self.progress_totals = Progress(self.reader)
Пример #2
0
class ProgressQueryResult(QueryResult):
    """
    Stores query result and progress information from multiple blocks.
    Provides iteration over query progress.
    """
    def __init__(self,
                 reader: BufferedReader,
                 packet_generator,
                 with_column_types=False,
                 columnar=False):
        super().__init__(reader, packet_generator, with_column_types, columnar)
        self.progress_totals = Progress(self.reader)

    def __iter__(self):
        return self

    def __next__(self):
        while True:
            packet = next(self.packet_generator)
            progress_packet = getattr(packet, "progress", None)
            if progress_packet:
                self.progress_totals.increment(progress_packet)
                return self.progress_totals.rows, self.progress_totals.total_rows
            else:
                self.store(packet)

    async def get_result(self):
        # Read all progress packets.
        for _ in self:
            pass

        return await super(ProgressQueryResult, self).get_result()
Пример #3
0
class QueryInfo:
    def __init__(self, reader: BufferedReader):
        self.profile_info = BlockStreamProfileInfo(reader)
        self.progress = Progress(reader)
        self.elapsed = 0

    def store_profile(self, profile_info):
        self.profile_info = profile_info

    def store_progress(self, progress):
        if self.progress:
            self.progress.increment(progress)
        else:
            self.progress = progress

    def store_elapsed(self, elapsed):
        self.elapsed = elapsed
Пример #4
0
 async def receive_progress(self):
     progress = Progress(self.reader)
     await progress.read(self.server_info.revision,)
     return progress
Пример #5
0
 def __init__(self, reader: BufferedReader):
     self.profile_info = BlockStreamProfileInfo(reader)
     self.progress = Progress(reader)
     self.elapsed = 0