Files
zeekay eb74c996a6 rename: this fork is ours — datastore_driver
Imports read `datastore_driver`, distribution `datastore-driver`, so nothing has to
import another product's name to talk to Hanzo Datastore.

Cut from upstream 0.2.9 — the version this stack already ran — rather than from
upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from
HEAD would have dragged versions along with the name (connect alone jumped
0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing
a rename's clothes.

X-ClickHouse-* headers are untouched: they are wire protocol the server sends
and expects, and a different token shape from the module name.
2026-07-26 11:01:28 -07:00

45 lines
1.5 KiB
Python

from . import defines
from .varint import read_varint
class Progress(object):
def __init__(self):
self.rows = 0
self.bytes = 0
self.total_rows = 0 # total_rows_to_read
self.total_bytes = 0 # total_bytes_to_read
self.written_rows = 0
self.written_bytes = 0
self.elapsed_ns = 0
super(Progress, self).__init__()
def read(self, server_info, fin):
self.rows = read_varint(fin)
self.bytes = read_varint(fin)
revision = server_info.used_revision
if revision >= defines.DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS:
self.total_rows = read_varint(fin)
if revision >= defines. \
DBMS_MIN_PROTOCOL_VERSION_WITH_TOTAL_BYTES_IN_PROGRESS:
self.total_bytes = read_varint(fin)
if revision >= defines.DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO:
self.written_rows = read_varint(fin)
self.written_bytes = read_varint(fin)
if revision >= defines. \
DBMS_MIN_PROTOCOL_VERSION_WITH_SERVER_QUERY_TIME_IN_PROGRESS:
self.elapsed_ns = read_varint(fin)
def increment(self, another_progress):
self.rows += another_progress.rows
self.bytes += another_progress.bytes
self.total_rows += another_progress.total_rows
self.total_bytes += another_progress.total_bytes
self.written_rows += another_progress.written_rows
self.written_bytes += another_progress.written_bytes
self.elapsed_ns += another_progress.elapsed_ns