File: progress.py

package info (click to toggle)
python-clickhouse-driver 0.2.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,516 kB
  • sloc: python: 10,950; pascal: 42; makefile: 31; sh: 3
file content (32 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from . import defines
from .varint import read_varint


class Progress(object):
    def __init__(self):
        self.rows = 0
        self.bytes = 0
        self.total_rows = 0
        self.written_rows = 0
        self.written_bytes = 0

        super(Progress, self).__init__()

    def read(self, server_revision, fin):
        self.rows = read_varint(fin)
        self.bytes = read_varint(fin)

        revision = server_revision
        if revision >= defines.DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS:
            self.total_rows = 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)

    def increment(self, another_progress):
        self.rows += another_progress.rows
        self.bytes += another_progress.bytes
        self.total_rows += another_progress.total_rows
        self.written_rows += another_progress.written_rows
        self.written_bytes += another_progress.written_bytes