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)
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()
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
async def receive_progress(self): progress = Progress(self.reader) await progress.read(self.server_info.revision,) return progress
def __init__(self, reader: BufferedReader): self.profile_info = BlockStreamProfileInfo(reader) self.progress = Progress(reader) self.elapsed = 0