Codebase list python-clickhouse-driver / 16144cc
New upstream version 0.2.0 Federico Ceratto 3 years ago
95 changed file(s) with 14464 addition(s) and 14860 deletion(s). Raw diff Collapse all Expand all
00 env:
1 - VERSION=19.15.3.6 # latest
1 - VERSION=20.10.2.20
2 - VERSION=20.9.3.45
3 - VERSION=20.8.4.11
4 - VERSION=20.7.4.11
5 - VERSION=20.6.8.5
6 - VERSION=20.5.5.74
7 - VERSION=20.4.9.110
8 - VERSION=20.3.20.6
9 - VERSION=20.3.20.6 USE_NUMPY=1
10 - VERSION=19.16.17.80
11 - VERSION=19.15.3.6
212 - VERSION=19.9.2.4 # allow_suspicious_low_cardinality_types
313 - VERSION=19.8.3.8 # SimpleAggregateFunction
414 - VERSION=19.3.3
515 - VERSION=18.12.17
6 - VERSION=18.12.13
716 - VERSION=18.10.3
817 - VERSION=18.6.0
918 - VERSION=18.5.1
1019 - VERSION=18.4.0
1120 - VERSION=18.1.0
12 - VERSION=1.1.54394
13 - VERSION=1.1.54390
14 - VERSION=1.1.54388
15 - VERSION=1.1.54385
16 - VERSION=1.1.54383
21 # - VERSION=1.1.54394
22 # - VERSION=1.1.54390
23 # - VERSION=1.1.54388
24 # - VERSION=1.1.54385
25 # - VERSION=1.1.54383
1726 # - VERSION=1.1.54381
1827 # - VERSION=1.1.54380
1928 # - VERSION=1.1.54378 client's image miss tzdata package: https://github.com/yandex/ClickHouse/commit/1bf49fe8446c7dea95beaef2b131e6c6708b0b62#diff-cc737435a5ba74620a889b7718f39a80
3645 - "3.6"
3746 - "3.7"
3847 - "3.8"
48 - "3.9-dev"
3949 - "pypy2.7-5.10.0"
4050 - "pypy3.5"
4151 cache: pip
5565 - pip install --upgrade pip setuptools
5666 - pip install flake8 flake8-print coveralls cython
5767 script:
68 - if [ -z ${USE_NUMPY+x} ]; then pip uninstall -y numpy pandas; fi
5869 - flake8 && coverage run --source=clickhouse_driver setup.py test
5970 after_success:
6071 coveralls
6172
6273 jobs:
74 # Exclude numpy unsupported versions,
75 exclude:
76 - python: 3.4
77 env: VERSION=20.3.20.6 USE_NUMPY=1
78 - python: 3.9-dev
79 env: VERSION=20.3.20.6 USE_NUMPY=1
80 - python: pypy2.7-5.10.0
81 env: VERSION=20.3.20.6 USE_NUMPY=1
82 - python: pypy3.5
83 env: VERSION=20.3.20.6 USE_NUMPY=1
84
6385 include:
86 - stage: valgrind
87 name: Valgrind check
88 os: linux
89 language: python
90 python:
91 - "3.6"
92 addons:
93 apt:
94 packages:
95 - valgrind
96 install:
97 - docker run -e "TZ=Europe/Moscow" -d -p 127.0.0.1:9000:9000 --name test-clickhouse-server --ulimit nofile=262144:262144 yandex/clickhouse-server:$VERSION
98 - docker run -d --entrypoint "/bin/sh" --name test-clickhouse-client --link test-clickhouse-server:clickhouse-server yandex/clickhouse-client:$VERSION -c 'while :; do sleep 1; done'
99 - docker ps -a
100 # Faking clickhouse-client real communication with container via docker exec.
101 - echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse-client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null
102 - sudo chmod +x /usr/local/bin/clickhouse-client
103 # Overriding setup.cfg. Set host=clickhouse-server
104 - sed -i 's/^host=localhost$/host=clickhouse-server/' setup.cfg
105 # Make host think that clickhouse-server is localhost
106 - echo '127.0.0.1 clickhouse-server' | sudo tee /etc/hosts > /dev/null
107 - pip install --upgrade pip setuptools
108 - pip install cython
109
110 script:
111 - valgrind --error-exitcode=1 python setup.py test
112
113 env:
114 - VERSION=20.3.7.46
115 - USE_NUMPY=1
116 - PYTHONMALLOC=malloc
117
64118 - stage: wheels
65119 name: Wheels for Linux
66120 os: linux
70124
71125 install:
72126 - pip install --upgrade pip setuptools
73 - pip install cython cibuildwheel==1.0.0
127 - pip install cython cibuildwheel==1.6.4
74128
75129 script:
76130 - cibuildwheel --output-dir wheelhouse
91145 tags: true
92146
93147 - stage: wheels
94 name: Wheels for OS X
148 name: Wheels for OS X Python 2
95149 os: osx
96150 language: generic
97151
98152 install:
99 - pip install --upgrade pip setuptools
100 - pip install cython cibuildwheel==1.0.0
153 - pip3 install --upgrade pip setuptools
154 - pip3 install cython cibuildwheel==1.4.0
101155
102156 script:
103157 - cibuildwheel --output-dir wheelhouse
104158
105159 env:
160 - CIBW_BUILD='*p2*'
161 - CIBW_BEFORE_BUILD='pip install cython'
162 deploy:
163 name: Mac OS X
164 provider: releases
165 api_key: $GITHUB_TOKEN
166 file_glob: true
167 file: wheelhouse/*
168 skip_cleanup: true
169 draft: true
170 prerelease: true
171 overwrite: true
172 on:
173 tags: true
174
175 - stage: wheels
176 name: Wheels for OS X Python 3
177 os: osx
178 language: generic
179
180 install:
181 - pip3 install --upgrade pip setuptools
182 - pip3 install cython cibuildwheel==1.6.4
183
184 script:
185 - cibuildwheel --output-dir wheelhouse
186
187 env:
188 - CIBW_BUILD='*p3*'
106189 - CIBW_BEFORE_BUILD='pip install cython'
107190 deploy:
108191 name: Mac OS X
127210 - choco install --ignore-dependencies vcpython27
128211
129212 script:
130 - C:/Python27/python -m pip install cibuildwheel==1.0.0
213 - C:/Python27/python -m pip install cibuildwheel==1.1.0 certifi
214 - export SSL_CERT_FILE=`C:/Python27/python -c "import certifi;print(certifi.where())"`
215 - echo $SSL_CERT_FILE
131216 - C:/Python27/python -m cibuildwheel --platform windows --output-dir wheelhouse
132217
133218 env:
160245 - export LIB="C:\\Program Files (x86)\\common files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Lib\\amd64;C:\\Program Files (x86)\\common files\\Microsoft\\Visual C++ for Python\\9.0\\WinSDK\\Lib\\x64"
161246
162247 script:
163 - C:/Python27-x64/python -m pip install cibuildwheel==1.0.0
248 - C:/Python27-x64/python -m pip install cibuildwheel==1.1.0 certifi
249 - export SSL_CERT_FILE=`C:/Python27-x64/python -c "import certifi;print(certifi.where())"`
250 - echo $SSL_CERT_FILE
164251 - C:/Python27-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
165252
166253 env:
189276 # - export VS100COMNTOOLS="$VS140COMNTOOLS"
190277 #
191278 # script:
192 # - C:/Python34/python -m pip install cibuildwheel==1.0.0
279 # - C:/Python34/python -m pip install cibuildwheel==1.1.0
193280 # - C:/Python34/python -m cibuildwheel --platform windows --output-dir wheelhouse
194281 #
195282 # env:
221308 # - export LIB="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\LIB\\amd64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17134.0\\ucrt\\x64;C:\\Program Files (x86)\\Windows Kits\\10\\lib\\10.0.17134.0\\um\\x64"
222309 #
223310 # script:
224 # - C:/Python34-x64/python -m pip install cibuildwheel==1.0.0
311 # - C:/Python34-x64/python -m pip install cibuildwheel==1.1.0
225312 # - C:/Python34-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
226313 #
227314 # env:
241328 # tags: true
242329
243330 - stage: wheels
244 name: Wheels for Windows Python 3.5
331 name: Wheels for Windows Python 3
245332 os: windows
246333 language: shell
247334
248335 install:
249 - choco install python3 --version 3.5.2.20161029 -y --forcex86 --force --params "/InstallDir:C:\Python35"
250
251 script:
252 - C:/Python35/python -m pip install cibuildwheel==1.0.0
253 - C:/Python35/python -m cibuildwheel --platform windows --output-dir wheelhouse
254
255 env:
256 - CIBW_BUILD='cp35-win32'
336 - choco install python3 --version 3.9.0 --params "/InstallDir:C:\Python39"
337 script:
338 - C:/Python39/python -m pip install cibuildwheel==1.6.4
339 - C:/Python39/python -m cibuildwheel --platform windows --output-dir wheelhouse
340
341 env:
342 - CIBW_BUILD='cp*'
257343 - CIBW_BEFORE_BUILD='python -m pip install cython'
258344 deploy:
259 name: Windows Python 3.5
260 provider: releases
261 api_key: $GITHUB_TOKEN
262 file_glob: true
263 file: wheelhouse/*
264 skip_cleanup: true
265 draft: true
266 prerelease: true
267 overwrite: true
268 on:
269 tags: true
270
271 - stage: wheels
272 name: Wheels for Windows Python 3.5 x64
345 name: Windows Python
346 provider: releases
347 api_key: $GITHUB_TOKEN
348 file_glob: true
349 file: wheelhouse/*
350 skip_cleanup: true
351 draft: true
352 prerelease: true
353 overwrite: true
354 on:
355 tags: true
356
357 - stage: wheels
358 name: Wheels for Windows PyPy
273359 os: windows
274360 language: shell
275361
276362 install:
277 - choco install python3 --version 3.5.2.20161029 -y --force --params "/InstallDir:C:\Python35-x64"
278
279 script:
280 - C:/Python35-x64/python -m pip install cibuildwheel==1.0.0
281 - C:/Python35-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
282
283 env:
284 - CIBW_BUILD='cp35-win_amd64'
363 - choco install python3 --version 3.9.0 --params "/InstallDir:C:\Python39"
364 script:
365 - C:/Python39/python -m pip install cibuildwheel==1.6.4
366 - C:/Python39/python -m cibuildwheel --platform windows --output-dir wheelhouse
367
368 env:
369 - CIBW_BUILD='pp*'
285370 - CIBW_BEFORE_BUILD='python -m pip install cython'
286371 deploy:
287 name: Windows Python 3.5 x64
288 provider: releases
289 api_key: $GITHUB_TOKEN
290 file_glob: true
291 file: wheelhouse/*
292 skip_cleanup: true
293 draft: true
294 prerelease: true
295 overwrite: true
296 on:
297 tags: true
298
299 - stage: wheels
300 name: Wheels for Windows Python 3.[678]
301 os: windows
302 language: shell
303
304 install:
305 - choco install python3 --version 3.6.8 --sidebyside -y --forcex86 --force --params "/InstallDir:C:\Python36"
306 - choco install python3 --version 3.6.8 --sidebyside -y --force --params "/InstallDir:C:\Python36-x64"
307
308 - choco install python3 --version 3.7.4 --sidebyside -y --forcex86 --force --params "/InstallDir:C:\Python37"
309 - choco install python3 --version 3.7.4 --sidebyside -y --force --params "/InstallDir:C:\Python37-x64"
310
311 - choco install python3 --version 3.8.0 --sidebyside -y --forcex86 --force --params "/InstallDir:C:\Python38"
312 - choco install python3 --version 3.8.0 --sidebyside -y --force --params "/InstallDir:C:\Python38-x64"
313 script:
314 - C:/Python36/python -m pip install cibuildwheel==1.0.0
315 - C:/Python36-x64/python -m pip install cibuildwheel==1.0.0
316
317 - C:/Python37/python -m pip install cibuildwheel==1.0.0
318 - C:/Python37-x64/python -m pip install cibuildwheel==1.0.0
319
320 - C:/Python38/python -m pip install cibuildwheel==1.0.0
321 - C:/Python38-x64/python -m pip install cibuildwheel==1.0.0
322
323 - C:/Python36/python -m cibuildwheel --platform windows --output-dir wheelhouse
324 - C:/Python36-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
325
326 - C:/Python37/python -m cibuildwheel --platform windows --output-dir wheelhouse
327 - C:/Python37-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
328
329 - C:/Python38/python -m cibuildwheel --platform windows --output-dir wheelhouse
330 - C:/Python38-x64/python -m cibuildwheel --platform windows --output-dir wheelhouse
331
332 env:
333 - CIBW_BUILD='cp3[678]-*'
334 - CIBW_BEFORE_BUILD='python -m pip install cython'
335 deploy:
336 name: Windows Python 3.[678]
337 provider: releases
338 api_key: $GITHUB_TOKEN
339 file_glob: true
340 file: wheelhouse/*
341 skip_cleanup: true
342 draft: true
343 prerelease: true
344 overwrite: true
345 on:
346 tags: true
372 name: Windows Python PyPy
373 provider: releases
374 api_key: $GITHUB_TOKEN
375 file_glob: true
376 file: wheelhouse/*
377 skip_cleanup: true
378 draft: true
379 prerelease: true
380 overwrite: true
381 on:
382 tags: true
00 # Changelog
1
2 ## [0.2.0] - 2020-12-14
3 ### Added
4 - NumPy reading/writing for columns: Float32/64, [U]Int8/16/32/64, Date/DateTime(‘timezone’)/DateTime64(‘timezone’), String/FixedString(N), LowCardinality(T). Merge [Arturus's](https://github.com/Arturus/clickhouse-driver) fork.
5 - pandas DataFrame reading/writing.
6 - Ability to mark all settings as important to fail on unknown settings on sever side.
7 - SSL SNI support. Solves issue [#172](https://github.com/mymarilyn/clickhouse-driver/issues/172).
8 - Wheels for Python 3.9 and PyPy.
9 - Remember last successful host on connection. Solves issue [#168](https://github.com/mymarilyn/clickhouse-driver/issues/168).
10
11 ### Fixed
12 - Server logs displaying on INSERT.
13 - Make exceptions picklable. Pull request [#169](https://github.com/mymarilyn/clickhouse-driver/pull/169) by [azat](https://github.com/azat).
14 - Enum type deserializing when it wrapped in SimpleAggregateFunction. Pull request [#170](https://github.com/mymarilyn/clickhouse-driver/pull/170) by [flyAwayGG](https://github.com/flyAwayGG).
15 - Pin major `tzlocal` version. Solves issue [#166](https://github.com/mymarilyn/clickhouse-driver/issues/166).
16
17 ### Changed
18 - String and DateTime columns writing optimization.
19 - Array columns reading/writing optimization.
20 - Chunking optimization for large lists/tuples.
21 - Protocol version bumped to 54441.
22
23 ## [0.1.5] - 2020-09-19
24 ### Added
25 - Do not require settings declaration if server support setting-as-string. Pull request [#142](https://github.com/mymarilyn/clickhouse-driver/pull/142) by [azat](https://github.com/azat).
26 - `host_name` in logs. Pull request [#144](https://github.com/mymarilyn/clickhouse-driver/pull/144) by [azat](https://github.com/azat).
27 - Cursor attribute `columns_with_types` to DB API. Issue [#149](https://github.com/mymarilyn/clickhouse-driver/issues/149).
28 - Cursor method `set_query_id` to DB API. Issue [#152](https://github.com/mymarilyn/clickhouse-driver/issues/152).
29
30 ### Fixed
31 - Connection error messages formatting.
32 - `Client.from_url` credentials unquoting. Issue [#146](https://github.com/mymarilyn/clickhouse-driver/issues/146).
33 - Empty nested array handling. Pull request [#161](https://github.com/mymarilyn/clickhouse-driver/pull/161) by [dourvaris](https://github.com/dourvaris).
34 - `read_varint` overflow. Issue [#163](https://github.com/mymarilyn/clickhouse-driver/issues/163).
35 - Malformed reads/writes in `BufferedReader`.
36
37 ### Changed
38 - Use deque for ~4x speedup when reading Array columns. Pull request [#164](https://github.com/mymarilyn/clickhouse-driver/pull/164) by [dourvaris](https://github.com/dourvaris).
39
40 ## [0.1.4] - 2020-06-13
41 ### Added
42 - Tuple type.
43 - Custom String column encoding.
44 - Settings update to v20.4.1.2742 server version. Pull request [#133](https://github.com/mymarilyn/clickhouse-driver/pull/133) by [azat](https://github.com/azat).
45 - Settings update to v20.5.1.3657 server version. Pull request [#141](https://github.com/mymarilyn/clickhouse-driver/pull/141) by [azat](https://github.com/azat).
46 - Unsupported server versions to documentation.
47 - Performance section to documentation.
48 - Python 3.9 in Travis CI build matrix.
49
50 ### Fixed
51 - Reading/writing Array(Tuple).
52 - 20.x server version support.
53 - Settings mutation in `execute`.
54 - Slow columnar results returning (`columnar=True`).
55 - Segfault on passing not encoded strings during `INSERT` into ByteString column.
56
57 ### Changed
58 - Miscellaneous read/write optimizations
59 - Protocol version bumped to 54429.
160
261 ## [0.1.3] - 2020-02-21
362 ### Added
247306 - Date/DateTime types.
248307 - String types.
249308
250 [Unreleased]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.3...HEAD
309 [Unreleased]: https://github.com/mymarilyn/clickhouse-driver/compare/0.2.0...HEAD
310 [0.2.0]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.5...0.2.0
311 [0.1.5]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.4...0.1.5
312 [0.1.4]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.3...0.1.4
251313 [0.1.3]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.2...0.1.3
252314 [0.1.2]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.1...0.1.2
253315 [0.1.1]: https://github.com/mymarilyn/clickhouse-driver/compare/0.1.0...0.1.1
66 .. image:: https://coveralls.io/repos/github/mymarilyn/clickhouse-driver/badge.svg?branch=master
77 :target: https://coveralls.io/github/mymarilyn/clickhouse-driver?branch=master
88
9 .. image:: https://img.shields.io/pypi/l/clickhouse-driver.svg
10 :target: https://pypi.org/project/clickhouse-driver
11
912 .. image:: https://img.shields.io/pypi/pyversions/clickhouse-driver.svg
1013 :target: https://pypi.org/project/clickhouse-driver
1114
12 .. image:: https://img.shields.io/pypi/l/clickhouse-driver.svg
15 .. image:: https://img.shields.io/pypi/dm/clickhouse-driver.svg
1316 :target: https://pypi.org/project/clickhouse-driver
1417
1518 .. image:: https://travis-ci.org/mymarilyn/clickhouse-driver.svg?branch=master
4447 * IPv4/IPv6
4548 * LowCardinality(T)
4649 * SimpleAggregateFunction(F, T)
50 * Tuple(T1, T2, ...)
51 * Nested
4752
4853 - Query progress information.
4954
22 from .dbapi import connect
33
44
5 VERSION = (0, 1, 3)
5 VERSION = (0, 2, 0)
66 __version__ = '.'.join(str(x) for x in VERSION)
77
88 __all__ = ['Client', 'connect']
6060 raise NotImplementedError
6161
6262 def transposed(self):
63 return list(map(tuple, zip(*self.data)))
63 return list(zip(*self.data))
6464
6565
6666 class ColumnOrientedBlock(BaseBlock):
0 /* Generated by Cython 0.29.13 */
0 /* Generated by Cython 0.29.21 */
11
22 /* BEGIN: Cython Metadata
33 {
44 "distutils": {
5 "depends": [],
6 "name": "clickhouse_driver.bufferedreader",
5 "depends": [],
6 "name": "clickhouse_driver.bufferedreader",
77 "sources": [
88 "clickhouse_driver/bufferedreader.pyx"
99 ]
10 },
10 },
1111 "module_name": "clickhouse_driver.bufferedreader"
1212 }
1313 END: Cython Metadata */
1919 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
2020 #error Cython requires Python 2.6+ or Python 3.3+.
2121 #else
22 #define CYTHON_ABI "0_29_13"
23 #define CYTHON_HEX_VERSION 0x001D0DF0
22 #define CYTHON_ABI "0_29_21"
23 #define CYTHON_HEX_VERSION 0x001D15F0
2424 #define CYTHON_FUTURE_DIVISION 1
2525 #include <stddef.h>
2626 #ifndef offsetof
447447 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
448448 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
449449 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
450 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
450451 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
452 #else
453 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
454 #endif
451455 #else
452456 #define CYTHON_PEP393_ENABLED 0
453457 #define PyUnicode_1BYTE_KIND 1
496500 #define PyString_Type PyUnicode_Type
497501 #define PyString_Check PyUnicode_Check
498502 #define PyString_CheckExact PyUnicode_CheckExact
503 #ifndef PyObject_Unicode
499504 #define PyObject_Unicode PyObject_Str
505 #endif
500506 #endif
501507 #if PY_MAJOR_VERSION >= 3
502508 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
507513 #endif
508514 #ifndef PySet_CheckExact
509515 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
516 #endif
517 #if PY_VERSION_HEX >= 0x030900A4
518 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
519 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
520 #else
521 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
522 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
510523 #endif
511524 #if CYTHON_ASSUME_SAFE_MACROS
512525 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
547560 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
548561 #endif
549562 #if PY_MAJOR_VERSION >= 3
550 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
563 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
551564 #else
552565 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
553566 #endif
588601 #define __Pyx_truncl truncl
589602 #endif
590603
591
604 #define __PYX_MARK_ERR_POS(f_index, lineno) \
605 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
592606 #define __PYX_ERR(f_index, lineno, Ln_error) \
593 { \
594 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
595 }
607 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596608
597609 #ifndef __PYX_EXTERN_C
598610 #ifdef __cplusplus
817829
818830 static const char *__pyx_f[] = {
819831 "clickhouse_driver/bufferedreader.pyx",
832 "stringsource",
820833 "type.pxd",
821834 "bool.pxd",
822835 "complex.pxd",
823836 };
824837
825838 /*--- Type declarations ---*/
839 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader;
840 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader;
841 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader;
842
843 /* "clickhouse_driver/bufferedreader.pyx":10
844 *
845 *
846 * cdef class BufferedReader(object): # <<<<<<<<<<<<<<
847 * cdef public unsigned long long position, current_buffer_size
848 * cdef public bytearray buffer
849 */
850 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader {
851 PyObject_HEAD
852 unsigned PY_LONG_LONG position;
853 unsigned PY_LONG_LONG current_buffer_size;
854 PyObject *buffer;
855 };
856
857
858 /* "clickhouse_driver/bufferedreader.pyx":229
859 *
860 *
861 * cdef class BufferedSocketReader(BufferedReader): # <<<<<<<<<<<<<<
862 * cdef object sock
863 *
864 */
865 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader {
866 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader __pyx_base;
867 PyObject *sock;
868 };
869
870
871 /* "clickhouse_driver/bufferedreader.pyx":243
872 *
873 *
874 * cdef class CompressedBufferedReader(BufferedReader): # <<<<<<<<<<<<<<
875 * cdef object read_block
876 *
877 */
878 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader {
879 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader __pyx_base;
880 PyObject *read_block;
881 };
882
826883
827884 /* --- Runtime support code (head) --- */
828885 /* Refnanny.proto */
898955 /* GetBuiltinName.proto */
899956 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
900957
958 /* RaiseDoubleKeywords.proto */
959 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
960
961 /* ParseKeywords.proto */
962 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
963 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
964 const char* function_name);
965
966 /* RaiseArgTupleInvalid.proto */
967 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
968 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
969
970 /* PyCFunctionFastCall.proto */
971 #if CYTHON_FAST_PYCCALL
972 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
973 #else
974 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
975 #endif
976
977 /* PyFunctionFastCall.proto */
978 #if CYTHON_FAST_PYCALL
979 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
980 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
981 #if 1 || PY_VERSION_HEX < 0x030600B1
982 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
983 #else
984 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
985 #endif
986 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
987 (sizeof(char [1 - 2*!(cond)]) - 1)
988 #ifndef Py_MEMBER_SIZE
989 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
990 #endif
991 static size_t __pyx_pyframe_localsplus_offset = 0;
992 #include "frameobject.h"
993 #define __Pxy_PyFrame_Initialize_Offsets()\
994 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
995 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
996 #define __Pyx_PyFrame_GetLocalsplus(frame)\
997 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
998 #endif
999
1000 /* PyObjectCall.proto */
1001 #if CYTHON_COMPILING_IN_CPYTHON
1002 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1003 #else
1004 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
1005 #endif
1006
1007 /* PyObjectCallMethO.proto */
1008 #if CYTHON_COMPILING_IN_CPYTHON
1009 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1010 #endif
1011
1012 /* PyObjectCallOneArg.proto */
1013 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1014
1015 /* PyObjectCallNoArg.proto */
1016 #if CYTHON_COMPILING_IN_CPYTHON
1017 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1018 #else
1019 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1020 #endif
1021
9011022 /* PyThreadStateGet.proto */
9021023 #if CYTHON_FAST_THREAD_STATE
9031024 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
9341055 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
9351056 #endif
9361057
937 /* WriteUnraisableException.proto */
938 static void __Pyx_WriteUnraisable(const char *name, int clineno,
939 int lineno, const char *filename,
940 int full_traceback, int nogil);
941
942 /* RaiseArgTupleInvalid.proto */
943 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
944 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
945
946 /* RaiseDoubleKeywords.proto */
947 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
948
949 /* ParseKeywords.proto */
950 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
951 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
952 const char* function_name);
953
954 /* PyCFunctionFastCall.proto */
955 #if CYTHON_FAST_PYCCALL
956 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
1058 /* RaiseException.proto */
1059 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1060
1061 /* GetItemIntByteArray.proto */
1062 #define __Pyx_GetItemInt_ByteArray(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1063 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1064 __Pyx_GetItemInt_ByteArray_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1065 (PyErr_SetString(PyExc_IndexError, "bytearray index out of range"), -1))
1066 static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
1067 int wraparound, int boundscheck);
1068
1069 /* PyObjectCall2Args.proto */
1070 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1071
1072 /* IncludeStringH.proto */
1073 #include <string.h>
1074
1075 /* decode_c_string_utf16.proto */
1076 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1077 int byteorder = 0;
1078 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1079 }
1080 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1081 int byteorder = -1;
1082 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1083 }
1084 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1085 int byteorder = 1;
1086 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1087 }
1088
1089 /* decode_c_string.proto */
1090 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1091 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1092 const char* encoding, const char* errors,
1093 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1094
1095 /* GetTopmostException.proto */
1096 #if CYTHON_USE_EXC_INFO_STACK
1097 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1098 #endif
1099
1100 /* SaveResetException.proto */
1101 #if CYTHON_FAST_THREAD_STATE
1102 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1103 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1104 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1105 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
9571106 #else
958 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
959 #endif
960
961 /* PyFunctionFastCall.proto */
962 #if CYTHON_FAST_PYCALL
963 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
964 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
965 #if 1 || PY_VERSION_HEX < 0x030600B1
966 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
1107 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1108 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1109 #endif
1110
1111 /* PyErrExceptionMatches.proto */
1112 #if CYTHON_FAST_THREAD_STATE
1113 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1114 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
9671115 #else
968 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
969 #endif
970 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
971 (sizeof(char [1 - 2*!(cond)]) - 1)
972 #ifndef Py_MEMBER_SIZE
973 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
974 #endif
975 static size_t __pyx_pyframe_localsplus_offset = 0;
976 #include "frameobject.h"
977 #define __Pxy_PyFrame_Initialize_Offsets()\
978 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
979 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
980 #define __Pyx_PyFrame_GetLocalsplus(frame)\
981 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
982 #endif
983
984 /* PyObjectCall.proto */
985 #if CYTHON_COMPILING_IN_CPYTHON
986 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
1116 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1117 #endif
1118
1119 /* GetException.proto */
1120 #if CYTHON_FAST_THREAD_STATE
1121 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1122 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
9871123 #else
988 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
989 #endif
990
991 /* PyObjectCallMethO.proto */
992 #if CYTHON_COMPILING_IN_CPYTHON
993 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
994 #endif
995
996 /* PyObjectCallOneArg.proto */
997 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
998
999 /* PyObjectSetAttrStr.proto */
1000 #if CYTHON_USE_TYPE_SLOTS
1001 #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
1002 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
1003 #else
1004 #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
1005 #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
1006 #endif
1124 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1125 #endif
1126
1127 /* GetAttr.proto */
1128 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1129
1130 /* GetAttr3.proto */
1131 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
10071132
10081133 /* PyDictVersioning.proto */
10091134 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
10521177 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
10531178 #endif
10541179
1055 /* PyObjectCallNoArg.proto */
1056 #if CYTHON_COMPILING_IN_CPYTHON
1057 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1058 #else
1059 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1060 #endif
1061
1062 /* RaiseException.proto */
1063 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1064
1065 /* SliceObject.proto */
1066 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1067 PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1068 PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1069 int has_cstart, int has_cstop, int wraparound);
1180 /* Import.proto */
1181 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1182
1183 /* ImportFrom.proto */
1184 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
10701185
10711186 /* GetItemInt.proto */
10721187 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
10901205 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
10911206 int is_list, int wraparound, int boundscheck);
10921207
1093 /* ObjectGetItem.proto */
1094 #if CYTHON_USE_TYPE_SLOTS
1095 static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key);
1208 /* HasAttr.proto */
1209 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
1210
1211 /* CallNextTpTraverse.proto */
1212 static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse);
1213
1214 /* CallNextTpClear.proto */
1215 static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_dealloc);
1216
1217 /* PyObject_GenericGetAttrNoDict.proto */
1218 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1219 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name);
10961220 #else
1097 #define __Pyx_PyObject_GetItem(obj, key) PyObject_GetItem(obj, key)
1098 #endif
1099
1100 /* PyIntBinop.proto */
1101 #if !CYTHON_COMPILING_IN_PYPY
1102 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
1221 #define __Pyx_PyObject_GenericGetAttrNoDict PyObject_GenericGetAttr
1222 #endif
1223
1224 /* PyObject_GenericGetAttr.proto */
1225 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
1226 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name);
11031227 #else
1104 #define __Pyx_PyInt_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
1105 (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
1106 #endif
1107
1108 /* None.proto */
1109 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
1110
1111 /* IncludeStringH.proto */
1112 #include <string.h>
1113
1114 /* decode_c_string_utf16.proto */
1115 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1116 int byteorder = 0;
1117 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1118 }
1119 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1120 int byteorder = -1;
1121 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1122 }
1123 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1124 int byteorder = 1;
1125 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1126 }
1127
1128 /* decode_c_string.proto */
1129 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1130 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1131 const char* encoding, const char* errors,
1132 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1133
1134 /* GetTopmostException.proto */
1135 #if CYTHON_USE_EXC_INFO_STACK
1136 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1137 #endif
1138
1139 /* SaveResetException.proto */
1140 #if CYTHON_FAST_THREAD_STATE
1141 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1142 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1143 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1144 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1145 #else
1146 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1147 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1148 #endif
1149
1150 /* PyErrExceptionMatches.proto */
1151 #if CYTHON_FAST_THREAD_STATE
1152 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1153 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1154 #else
1155 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1156 #endif
1157
1158 /* GetException.proto */
1159 #if CYTHON_FAST_THREAD_STATE
1160 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1161 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1162 #else
1163 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1164 #endif
1165
1166 /* PyObjectCall2Args.proto */
1167 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1168
1169 /* PyIntCompare.proto */
1170 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1228 #define __Pyx_PyObject_GenericGetAttr PyObject_GenericGetAttr
1229 #endif
1230
1231 /* PyObjectGetAttrStrNoError.proto */
1232 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
1233
1234 /* SetupReduce.proto */
1235 static int __Pyx_setup_reduce(PyObject* type_obj);
11711236
11721237 /* TypeImport.proto */
11731238 #ifndef __PYX_HAVE_RT_ImportType_proto
11791244 };
11801245 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
11811246 #endif
1182
1183 /* CalculateMetaclass.proto */
1184 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
1185
1186 /* FetchCommonType.proto */
1187 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1188
1189 /* CythonFunction.proto */
1190 #define __Pyx_CyFunction_USED 1
1191 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
1192 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
1193 #define __Pyx_CYFUNCTION_CCLASS 0x04
1194 #define __Pyx_CyFunction_GetClosure(f)\
1195 (((__pyx_CyFunctionObject *) (f))->func_closure)
1196 #define __Pyx_CyFunction_GetClassObj(f)\
1197 (((__pyx_CyFunctionObject *) (f))->func_classobj)
1198 #define __Pyx_CyFunction_Defaults(type, f)\
1199 ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1200 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1201 ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1202 typedef struct {
1203 PyCFunctionObject func;
1204 #if PY_VERSION_HEX < 0x030500A0
1205 PyObject *func_weakreflist;
1206 #endif
1207 PyObject *func_dict;
1208 PyObject *func_name;
1209 PyObject *func_qualname;
1210 PyObject *func_doc;
1211 PyObject *func_globals;
1212 PyObject *func_code;
1213 PyObject *func_closure;
1214 PyObject *func_classobj;
1215 void *defaults;
1216 int defaults_pyobjects;
1217 int flags;
1218 PyObject *defaults_tuple;
1219 PyObject *defaults_kwdict;
1220 PyObject *(*defaults_getter)(PyObject *);
1221 PyObject *func_annotations;
1222 } __pyx_CyFunctionObject;
1223 static PyTypeObject *__pyx_CyFunctionType = 0;
1224 #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1225 #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
1226 __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
1227 static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
1228 int flags, PyObject* qualname,
1229 PyObject *self,
1230 PyObject *module, PyObject *globals,
1231 PyObject* code);
1232 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1233 size_t size,
1234 int pyobjects);
1235 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1236 PyObject *tuple);
1237 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1238 PyObject *dict);
1239 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1240 PyObject *dict);
1241 static int __pyx_CyFunction_init(void);
1242
1243 /* SetNameInClass.proto */
1244 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
1245 #define __Pyx_SetNameInClass(ns, name, value)\
1246 (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
1247 #elif CYTHON_COMPILING_IN_CPYTHON
1248 #define __Pyx_SetNameInClass(ns, name, value)\
1249 (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
1250 #else
1251 #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
1252 #endif
1253
1254 /* Py3ClassCreate.proto */
1255 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
1256 PyObject *mkw, PyObject *modname, PyObject *doc);
1257 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
1258 PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
12591247
12601248 /* CLineInTraceback.proto */
12611249 #ifdef CYTHON_CLINE_IN_TRACEBACK
12841272 int py_line, const char *filename);
12851273
12861274 /* CIntToPy.proto */
1287 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1275 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value);
1276
1277 /* CIntToPy.proto */
1278 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_char(unsigned char value);
1279
1280 /* CIntToPy.proto */
1281 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1282
1283 /* CIntFromPy.proto */
1284 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
1285
1286 /* CIntFromPy.proto */
1287 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
12881288
12891289 /* CIntFromPy.proto */
12901290 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1291
1292 /* CIntToPy.proto */
1293 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1294
1295 /* CIntFromPy.proto */
1296 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
12971291
12981292 /* FastTypeChecks.proto */
12991293 #if CYTHON_COMPILING_IN_CPYTHON
14011395 /* Module declarations from 'cpython.bytearray' */
14021396
14031397 /* Module declarations from 'clickhouse_driver.bufferedreader' */
1404 static char *__pyx_f_17clickhouse_driver_14bufferedreader_maybe_resize_c_string(char *, Py_ssize_t, Py_ssize_t); /*proto*/
1398 static PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader = 0;
1399 static PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader = 0;
1400 static PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = 0;
1401 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *, PyObject *); /*proto*/
1402 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *, PyObject *); /*proto*/
1403 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *, PyObject *); /*proto*/
14051404 #define __Pyx_MODULE_NAME "clickhouse_driver.bufferedreader"
14061405 extern int __pyx_module_is_main_clickhouse_driver__bufferedreader;
14071406 int __pyx_module_is_main_clickhouse_driver__bufferedreader = 0;
14081407
14091408 /* Implementation of 'clickhouse_driver.bufferedreader' */
1410 static PyObject *__pyx_builtin_object;
1411 static PyObject *__pyx_builtin_MemoryError;
14121409 static PyObject *__pyx_builtin_super;
14131410 static PyObject *__pyx_builtin_NotImplementedError;
1411 static PyObject *__pyx_builtin_object;
14141412 static PyObject *__pyx_builtin_range;
1413 static PyObject *__pyx_builtin_MemoryError;
14151414 static PyObject *__pyx_builtin_UnicodeDecodeError;
14161415 static PyObject *__pyx_builtin_EOFError;
1417 static const char __pyx_k_b[] = "b";
1418 static const char __pyx_k_i[] = "i";
1419 static const char __pyx_k_t[] = "t";
1420 static const char __pyx_k_rv[] = "rv";
1421 static const char __pyx_k_doc[] = "__doc__";
1416 static const char __pyx_k_new[] = "__new__";
1417 static const char __pyx_k_dict[] = "__dict__";
14221418 static const char __pyx_k_init[] = "__init__";
14231419 static const char __pyx_k_main[] = "__main__";
14241420 static const char __pyx_k_name[] = "__name__";
14251421 static const char __pyx_k_read[] = "read";
1426 static const char __pyx_k_self[] = "self";
1427 static const char __pyx_k_size[] = "size";
14281422 static const char __pyx_k_sock[] = "sock";
14291423 static const char __pyx_k_test[] = "__test__";
1430 static const char __pyx_k_items[] = "items";
14311424 static const char __pyx_k_range[] = "range";
1432 static const char __pyx_k_right[] = "right";
1433 static const char __pyx_k_shift[] = "shift";
14341425 static const char __pyx_k_super[] = "super";
1435 static const char __pyx_k_buffer[] = "buffer";
1436 static const char __pyx_k_decode[] = "decode";
1437 static const char __pyx_k_module[] = "__module__";
1426 static const char __pyx_k_utf_8[] = "utf-8";
1427 static const char __pyx_k_encode[] = "encode";
1428 static const char __pyx_k_import[] = "__import__";
1429 static const char __pyx_k_length[] = "length";
14381430 static const char __pyx_k_object[] = "object";
1439 static const char __pyx_k_unread[] = "unread";
1431 static const char __pyx_k_pickle[] = "pickle";
1432 static const char __pyx_k_reduce[] = "__reduce__";
1433 static const char __pyx_k_update[] = "update";
14401434 static const char __pyx_k_bufsize[] = "bufsize";
14411435 static const char __pyx_k_n_items[] = "n_items";
1442 static const char __pyx_k_prepare[] = "__prepare__";
14431436 static const char __pyx_k_EOFError[] = "EOFError";
1444 static const char __pyx_k_c_string[] = "c_string";
1445 static const char __pyx_k_position[] = "position";
1446 static const char __pyx_k_qualname[] = "__qualname__";
1447 static const char __pyx_k_read_one[] = "read_one";
1448 static const char __pyx_k_metaclass[] = "__metaclass__";
1437 static const char __pyx_k_encoding[] = "encoding";
1438 static const char __pyx_k_getstate[] = "__getstate__";
1439 static const char __pyx_k_pyx_type[] = "__pyx_type";
1440 static const char __pyx_k_setstate[] = "__setstate__";
1441 static const char __pyx_k_pyx_state[] = "__pyx_state";
14491442 static const char __pyx_k_recv_into[] = "recv_into";
1450 static const char __pyx_k_buffer_ptr[] = "buffer_ptr";
1451 static const char __pyx_k_bytes_read[] = "bytes_read";
1443 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1444 static const char __pyx_k_pyx_result[] = "__pyx_result";
14521445 static const char __pyx_k_read_block[] = "read_block";
1453 static const char __pyx_k_read_bytes[] = "read_bytes";
14541446 static const char __pyx_k_MemoryError[] = "MemoryError";
1455 static const char __pyx_k_read_strings[] = "read_strings";
1456 static const char __pyx_k_c_string_size[] = "c_string_size";
1457 static const char __pyx_k_next_position[] = "next_position";
1447 static const char __pyx_k_PickleError[] = "PickleError";
1448 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
1449 static const char __pyx_k_stringsource[] = "stringsource";
1450 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
14581451 static const char __pyx_k_BufferedReader[] = "BufferedReader";
1459 static const char __pyx_k_large_str_bytes[] = "large_str_bytes";
1452 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
1453 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
14601454 static const char __pyx_k_read_into_buffer[] = "read_into_buffer";
14611455 static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
14621456 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1463 static const char __pyx_k_BufferedReader_read[] = "BufferedReader.read";
14641457 static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
1465 static const char __pyx_k_current_buffer_size[] = "current_buffer_size";
14661458 static const char __pyx_k_BufferedSocketReader[] = "BufferedSocketReader";
1467 static const char __pyx_k_BufferedReader___init[] = "BufferedReader.__init__";
1468 static const char __pyx_k_BufferedReader_read_one[] = "BufferedReader.read_one";
14691459 static const char __pyx_k_CompressedBufferedReader[] = "CompressedBufferedReader";
1470 static const char __pyx_k_BufferedReader_read_strings[] = "BufferedReader.read_strings";
1471 static const char __pyx_k_BufferedSocketReader___init[] = "BufferedSocketReader.__init__";
1472 static const char __pyx_k_BufferedReader_read_into_buffer[] = "BufferedReader.read_into_buffer";
1473 static const char __pyx_k_CompressedBufferedReader___init[] = "CompressedBufferedReader.__init__";
1474 static const char __pyx_k_BufferedSocketReader_read_into_b[] = "BufferedSocketReader.read_into_buffer";
1475 static const char __pyx_k_CompressedBufferedReader_read_in[] = "CompressedBufferedReader.read_into_buffer";
1460 static const char __pyx_k_pyx_unpickle_BufferedReader[] = "__pyx_unpickle_BufferedReader";
1461 static const char __pyx_k_read_fixed_strings_as_bytes[] = "read_fixed_strings_as_bytes";
1462 static const char __pyx_k_pyx_unpickle_BufferedSocketRea[] = "__pyx_unpickle_BufferedSocketReader";
1463 static const char __pyx_k_pyx_unpickle_CompressedBuffere[] = "__pyx_unpickle_CompressedBufferedReader";
1464 static const char __pyx_k_Incompatible_checksums_s_vs_0x18[] = "Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))";
1465 static const char __pyx_k_Incompatible_checksums_s_vs_0x2a[] = "Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))";
1466 static const char __pyx_k_Incompatible_checksums_s_vs_0xef[] = "Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))";
14761467 static const char __pyx_k_Unexpected_EOF_while_reading_byt[] = "Unexpected EOF while reading bytes";
14771468 static const char __pyx_k_clickhouse_driver_bufferedreader[] = "clickhouse_driver.bufferedreader";
1478 static const char __pyx_k_clickhouse_driver_bufferedreader_2[] = "clickhouse_driver/bufferedreader.pyx";
14791469 static PyObject *__pyx_n_s_BufferedReader;
1480 static PyObject *__pyx_n_s_BufferedReader___init;
1481 static PyObject *__pyx_n_s_BufferedReader_read;
1482 static PyObject *__pyx_n_s_BufferedReader_read_into_buffer;
1483 static PyObject *__pyx_n_s_BufferedReader_read_one;
1484 static PyObject *__pyx_n_s_BufferedReader_read_strings;
14851470 static PyObject *__pyx_n_s_BufferedSocketReader;
1486 static PyObject *__pyx_n_s_BufferedSocketReader___init;
1487 static PyObject *__pyx_n_s_BufferedSocketReader_read_into_b;
14881471 static PyObject *__pyx_n_s_CompressedBufferedReader;
1489 static PyObject *__pyx_n_s_CompressedBufferedReader___init;
1490 static PyObject *__pyx_n_s_CompressedBufferedReader_read_in;
14911472 static PyObject *__pyx_n_s_EOFError;
1473 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x18;
1474 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0x2a;
1475 static PyObject *__pyx_kp_s_Incompatible_checksums_s_vs_0xef;
14921476 static PyObject *__pyx_n_s_MemoryError;
14931477 static PyObject *__pyx_n_s_NotImplementedError;
1478 static PyObject *__pyx_n_s_PickleError;
14941479 static PyObject *__pyx_kp_u_Unexpected_EOF_while_reading_byt;
14951480 static PyObject *__pyx_n_s_UnicodeDecodeError;
1496 static PyObject *__pyx_n_s_b;
1497 static PyObject *__pyx_n_s_buffer;
1498 static PyObject *__pyx_n_s_buffer_ptr;
14991481 static PyObject *__pyx_n_s_bufsize;
1500 static PyObject *__pyx_n_s_bytes_read;
1501 static PyObject *__pyx_n_s_c_string;
1502 static PyObject *__pyx_n_s_c_string_size;
15031482 static PyObject *__pyx_n_s_clickhouse_driver_bufferedreader;
1504 static PyObject *__pyx_kp_s_clickhouse_driver_bufferedreader_2;
15051483 static PyObject *__pyx_n_s_cline_in_traceback;
1506 static PyObject *__pyx_n_s_current_buffer_size;
1507 static PyObject *__pyx_n_s_decode;
1508 static PyObject *__pyx_n_s_doc;
1509 static PyObject *__pyx_n_s_i;
1484 static PyObject *__pyx_n_s_dict;
1485 static PyObject *__pyx_n_s_encode;
1486 static PyObject *__pyx_n_s_encoding;
1487 static PyObject *__pyx_n_s_getstate;
1488 static PyObject *__pyx_n_s_import;
15101489 static PyObject *__pyx_n_s_init;
1511 static PyObject *__pyx_n_s_items;
1512 static PyObject *__pyx_n_s_large_str_bytes;
1490 static PyObject *__pyx_n_s_length;
15131491 static PyObject *__pyx_n_s_main;
1514 static PyObject *__pyx_n_s_metaclass;
1515 static PyObject *__pyx_n_s_module;
15161492 static PyObject *__pyx_n_s_n_items;
15171493 static PyObject *__pyx_n_s_name;
1518 static PyObject *__pyx_n_s_next_position;
1494 static PyObject *__pyx_n_s_new;
15191495 static PyObject *__pyx_n_s_object;
1520 static PyObject *__pyx_n_s_position;
1521 static PyObject *__pyx_n_s_prepare;
1522 static PyObject *__pyx_n_s_qualname;
1496 static PyObject *__pyx_n_s_pickle;
1497 static PyObject *__pyx_n_s_pyx_PickleError;
1498 static PyObject *__pyx_n_s_pyx_checksum;
1499 static PyObject *__pyx_n_s_pyx_result;
1500 static PyObject *__pyx_n_s_pyx_state;
1501 static PyObject *__pyx_n_s_pyx_type;
1502 static PyObject *__pyx_n_s_pyx_unpickle_BufferedReader;
1503 static PyObject *__pyx_n_s_pyx_unpickle_BufferedSocketRea;
1504 static PyObject *__pyx_n_s_pyx_unpickle_CompressedBuffere;
15231505 static PyObject *__pyx_n_s_range;
15241506 static PyObject *__pyx_n_s_read;
15251507 static PyObject *__pyx_n_s_read_block;
1526 static PyObject *__pyx_n_s_read_bytes;
1508 static PyObject *__pyx_n_s_read_fixed_strings_as_bytes;
15271509 static PyObject *__pyx_n_s_read_into_buffer;
1528 static PyObject *__pyx_n_s_read_one;
1529 static PyObject *__pyx_n_s_read_strings;
15301510 static PyObject *__pyx_n_s_recv_into;
1531 static PyObject *__pyx_n_s_right;
1532 static PyObject *__pyx_n_s_rv;
1533 static PyObject *__pyx_n_s_self;
1534 static PyObject *__pyx_n_s_shift;
1535 static PyObject *__pyx_n_s_size;
1511 static PyObject *__pyx_n_s_reduce;
1512 static PyObject *__pyx_n_s_reduce_cython;
1513 static PyObject *__pyx_n_s_reduce_ex;
1514 static PyObject *__pyx_n_s_setstate;
1515 static PyObject *__pyx_n_s_setstate_cython;
15361516 static PyObject *__pyx_n_s_sock;
1517 static PyObject *__pyx_kp_s_stringsource;
15371518 static PyObject *__pyx_n_s_super;
1538 static PyObject *__pyx_n_s_t;
15391519 static PyObject *__pyx_n_s_test;
1540 static PyObject *__pyx_n_s_unread;
1541 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_bufsize); /* proto */
1542 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
1543 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_unread); /* proto */
1544 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1545 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, int __pyx_v_decode); /* proto */
1546 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize); /* proto */
1547 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1548 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize); /* proto */
1549 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1550 static PyObject *__pyx_int_0;
1551 static PyObject *__pyx_int_1;
1520 static PyObject *__pyx_n_s_update;
1521 static PyObject *__pyx_kp_u_utf_8;
1522 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_bufsize); /* proto */
1523 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1524 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_unread); /* proto */
1525 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1526 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items, PyObject *__pyx_v_encoding); /* proto */
1527 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length); /* proto */
1528 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding); /* proto */
1529 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1530 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1531 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1532 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1533 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1534 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
1535 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1536 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self); /* proto */
1537 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1538 static int __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize); /* proto */
1539 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self); /* proto */
1540 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self); /* proto */
1541 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1542 static int __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize); /* proto */
1543 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self); /* proto */
1544 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self); /* proto */
1545 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1546 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1547 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1548 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state); /* proto */
1549 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1550 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1551 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
1552 static PyObject *__pyx_int_25411819;
1553 static PyObject *__pyx_int_44607813;
1554 static PyObject *__pyx_int_251251440;
15521555 static PyObject *__pyx_tuple_;
15531556 static PyObject *__pyx_tuple__2;
1554 static PyObject *__pyx_tuple__3;
1555 static PyObject *__pyx_tuple__5;
1556 static PyObject *__pyx_tuple__7;
1557 static PyObject *__pyx_tuple__9;
1558 static PyObject *__pyx_tuple__11;
1559 static PyObject *__pyx_tuple__13;
1560 static PyObject *__pyx_tuple__15;
1561 static PyObject *__pyx_tuple__17;
1562 static PyObject *__pyx_tuple__19;
1563 static PyObject *__pyx_codeobj__4;
1564 static PyObject *__pyx_codeobj__6;
1565 static PyObject *__pyx_codeobj__8;
1566 static PyObject *__pyx_codeobj__10;
1567 static PyObject *__pyx_codeobj__12;
1568 static PyObject *__pyx_codeobj__14;
1569 static PyObject *__pyx_codeobj__16;
1570 static PyObject *__pyx_codeobj__18;
1571 static PyObject *__pyx_codeobj__20;
1557 static PyObject *__pyx_tuple__4;
1558 static PyObject *__pyx_tuple__6;
1559 static PyObject *__pyx_codeobj__3;
1560 static PyObject *__pyx_codeobj__5;
1561 static PyObject *__pyx_codeobj__7;
15721562 /* Late includes */
15731563
1574 /* "clickhouse_driver/bufferedreader.pyx":10
1575 *
1576 *
1577 * cdef char * maybe_resize_c_string(char *c_string, Py_ssize_t old_size, # <<<<<<<<<<<<<<
1578 * Py_ssize_t new_size):
1579 * if new_size > old_size:
1580 */
1581
1582 static char *__pyx_f_17clickhouse_driver_14bufferedreader_maybe_resize_c_string(char *__pyx_v_c_string, Py_ssize_t __pyx_v_old_size, Py_ssize_t __pyx_v_new_size) {
1583 char *__pyx_r;
1564 /* "clickhouse_driver/bufferedreader.pyx":14
1565 * cdef public bytearray buffer
1566 *
1567 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
1568 * self.buffer = bytearray(bufsize)
1569 *
1570 */
1571
1572 /* Python wrapper */
1573 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1574 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1575 PyObject *__pyx_v_bufsize = 0;
1576 int __pyx_lineno = 0;
1577 const char *__pyx_filename = NULL;
1578 int __pyx_clineno = 0;
1579 int __pyx_r;
15841580 __Pyx_RefNannyDeclarations
1585 int __pyx_t_1;
1586 __Pyx_RefNannySetupContext("maybe_resize_c_string", 0);
1587
1588 /* "clickhouse_driver/bufferedreader.pyx":12
1589 * cdef char * maybe_resize_c_string(char *c_string, Py_ssize_t old_size,
1590 * Py_ssize_t new_size):
1591 * if new_size > old_size: # <<<<<<<<<<<<<<
1592 * c_string = <char *> PyMem_Realloc(c_string, new_size)
1593 * if not c_string:
1594 */
1595 __pyx_t_1 = ((__pyx_v_new_size > __pyx_v_old_size) != 0);
1596 if (__pyx_t_1) {
1597
1598 /* "clickhouse_driver/bufferedreader.pyx":13
1599 * Py_ssize_t new_size):
1600 * if new_size > old_size:
1601 * c_string = <char *> PyMem_Realloc(c_string, new_size) # <<<<<<<<<<<<<<
1602 * if not c_string:
1603 * raise MemoryError()
1604 */
1605 __pyx_v_c_string = ((char *)PyMem_Realloc(__pyx_v_c_string, __pyx_v_new_size));
1606
1607 /* "clickhouse_driver/bufferedreader.pyx":14
1608 * if new_size > old_size:
1609 * c_string = <char *> PyMem_Realloc(c_string, new_size)
1610 * if not c_string: # <<<<<<<<<<<<<<
1611 * raise MemoryError()
1612 * return c_string
1613 */
1614 __pyx_t_1 = ((!(__pyx_v_c_string != 0)) != 0);
1615 if (unlikely(__pyx_t_1)) {
1616
1617 /* "clickhouse_driver/bufferedreader.pyx":15
1618 * c_string = <char *> PyMem_Realloc(c_string, new_size)
1619 * if not c_string:
1620 * raise MemoryError() # <<<<<<<<<<<<<<
1621 * return c_string
1622 *
1623 */
1624 PyErr_NoMemory(); __PYX_ERR(0, 15, __pyx_L1_error)
1625
1626 /* "clickhouse_driver/bufferedreader.pyx":14
1627 * if new_size > old_size:
1628 * c_string = <char *> PyMem_Realloc(c_string, new_size)
1629 * if not c_string: # <<<<<<<<<<<<<<
1630 * raise MemoryError()
1631 * return c_string
1632 */
1633 }
1634
1635 /* "clickhouse_driver/bufferedreader.pyx":12
1636 * cdef char * maybe_resize_c_string(char *c_string, Py_ssize_t old_size,
1637 * Py_ssize_t new_size):
1638 * if new_size > old_size: # <<<<<<<<<<<<<<
1639 * c_string = <char *> PyMem_Realloc(c_string, new_size)
1640 * if not c_string:
1641 */
1581 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1582 {
1583 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_bufsize,0};
1584 PyObject* values[1] = {0};
1585 if (unlikely(__pyx_kwds)) {
1586 Py_ssize_t kw_args;
1587 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1588 switch (pos_args) {
1589 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1590 CYTHON_FALLTHROUGH;
1591 case 0: break;
1592 default: goto __pyx_L5_argtuple_error;
1593 }
1594 kw_args = PyDict_Size(__pyx_kwds);
1595 switch (pos_args) {
1596 case 0:
1597 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
1598 else goto __pyx_L5_argtuple_error;
1599 }
1600 if (unlikely(kw_args > 0)) {
1601 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
1602 }
1603 } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
1604 goto __pyx_L5_argtuple_error;
1605 } else {
1606 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1607 }
1608 __pyx_v_bufsize = values[0];
16421609 }
1643
1644 /* "clickhouse_driver/bufferedreader.pyx":16
1645 * if not c_string:
1646 * raise MemoryError()
1647 * return c_string # <<<<<<<<<<<<<<
1648 *
1649 *
1650 */
1651 __pyx_r = __pyx_v_c_string;
1610 goto __pyx_L4_argument_unpacking_done;
1611 __pyx_L5_argtuple_error:;
1612 __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
1613 __pyx_L3_error:;
1614 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1615 __Pyx_RefNannyFinishContext();
1616 return -1;
1617 __pyx_L4_argument_unpacking_done:;
1618 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_bufsize);
1619
1620 /* function exit code */
1621 __Pyx_RefNannyFinishContext();
1622 return __pyx_r;
1623 }
1624
1625 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_bufsize) {
1626 int __pyx_r;
1627 __Pyx_RefNannyDeclarations
1628 PyObject *__pyx_t_1 = NULL;
1629 PyObject *__pyx_t_2 = NULL;
1630 PyObject *__pyx_t_3 = NULL;
1631 int __pyx_lineno = 0;
1632 const char *__pyx_filename = NULL;
1633 int __pyx_clineno = 0;
1634 __Pyx_RefNannySetupContext("__init__", 0);
1635
1636 /* "clickhouse_driver/bufferedreader.pyx":15
1637 *
1638 * def __init__(self, bufsize):
1639 * self.buffer = bytearray(bufsize) # <<<<<<<<<<<<<<
1640 *
1641 * self.position = 0
1642 */
1643 __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_bufsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
1644 __Pyx_GOTREF(__pyx_t_1);
1645 __Pyx_GIVEREF(__pyx_t_1);
1646 __Pyx_GOTREF(__pyx_v_self->buffer);
1647 __Pyx_DECREF(__pyx_v_self->buffer);
1648 __pyx_v_self->buffer = ((PyObject*)__pyx_t_1);
1649 __pyx_t_1 = 0;
1650
1651 /* "clickhouse_driver/bufferedreader.pyx":17
1652 * self.buffer = bytearray(bufsize)
1653 *
1654 * self.position = 0 # <<<<<<<<<<<<<<
1655 * self.current_buffer_size = 0
1656 *
1657 */
1658 __pyx_v_self->position = 0;
1659
1660 /* "clickhouse_driver/bufferedreader.pyx":18
1661 *
1662 * self.position = 0
1663 * self.current_buffer_size = 0 # <<<<<<<<<<<<<<
1664 *
1665 * super(BufferedReader, self).__init__()
1666 */
1667 __pyx_v_self->current_buffer_size = 0;
1668
1669 /* "clickhouse_driver/bufferedreader.pyx":20
1670 * self.current_buffer_size = 0
1671 *
1672 * super(BufferedReader, self).__init__() # <<<<<<<<<<<<<<
1673 *
1674 * def read_into_buffer(self):
1675 */
1676 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
1677 __Pyx_GOTREF(__pyx_t_2);
1678 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader));
1679 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader));
1680 PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader));
1681 __Pyx_INCREF(((PyObject *)__pyx_v_self));
1682 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
1683 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
1684 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 20, __pyx_L1_error)
1685 __Pyx_GOTREF(__pyx_t_3);
1686 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1687 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 20, __pyx_L1_error)
1688 __Pyx_GOTREF(__pyx_t_2);
1689 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1690 __pyx_t_3 = NULL;
1691 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1692 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1693 if (likely(__pyx_t_3)) {
1694 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1695 __Pyx_INCREF(__pyx_t_3);
1696 __Pyx_INCREF(function);
1697 __Pyx_DECREF_SET(__pyx_t_2, function);
1698 }
1699 }
1700 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
1701 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1702 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
1703 __Pyx_GOTREF(__pyx_t_1);
1704 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1705 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1706
1707 /* "clickhouse_driver/bufferedreader.pyx":14
1708 * cdef public bytearray buffer
1709 *
1710 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
1711 * self.buffer = bytearray(bufsize)
1712 *
1713 */
1714
1715 /* function exit code */
1716 __pyx_r = 0;
16521717 goto __pyx_L0;
1653
1654 /* "clickhouse_driver/bufferedreader.pyx":10
1655 *
1656 *
1657 * cdef char * maybe_resize_c_string(char *c_string, Py_ssize_t old_size, # <<<<<<<<<<<<<<
1658 * Py_ssize_t new_size):
1659 * if new_size > old_size:
1660 */
1661
1662 /* function exit code */
16631718 __pyx_L1_error:;
1664 __Pyx_WriteUnraisable("clickhouse_driver.bufferedreader.maybe_resize_c_string", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0);
1665 __pyx_r = 0;
1719 __Pyx_XDECREF(__pyx_t_1);
1720 __Pyx_XDECREF(__pyx_t_2);
1721 __Pyx_XDECREF(__pyx_t_3);
1722 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
1723 __pyx_r = -1;
16661724 __pyx_L0:;
16671725 __Pyx_RefNannyFinishContext();
16681726 return __pyx_r;
16691727 }
16701728
1671 /* "clickhouse_driver/bufferedreader.pyx":20
1672 *
1673 * class BufferedReader(object):
1674 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
1675 * self.buffer = bytearray(bufsize)
1729 /* "clickhouse_driver/bufferedreader.pyx":22
1730 * super(BufferedReader, self).__init__()
1731 *
1732 * def read_into_buffer(self): # <<<<<<<<<<<<<<
1733 * raise NotImplementedError
16761734 *
16771735 */
16781736
16791737 /* Python wrapper */
1680 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1681 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
1682 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1683 PyObject *__pyx_v_self = 0;
1684 PyObject *__pyx_v_bufsize = 0;
1738 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1739 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
16851740 PyObject *__pyx_r = 0;
16861741 __Pyx_RefNannyDeclarations
1687 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
1742 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
1743 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
1744
1745 /* function exit code */
1746 __Pyx_RefNannyFinishContext();
1747 return __pyx_r;
1748 }
1749
1750 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
1751 PyObject *__pyx_r = NULL;
1752 __Pyx_RefNannyDeclarations
1753 int __pyx_lineno = 0;
1754 const char *__pyx_filename = NULL;
1755 int __pyx_clineno = 0;
1756 __Pyx_RefNannySetupContext("read_into_buffer", 0);
1757
1758 /* "clickhouse_driver/bufferedreader.pyx":23
1759 *
1760 * def read_into_buffer(self):
1761 * raise NotImplementedError # <<<<<<<<<<<<<<
1762 *
1763 * def read(self, unsigned long long unread):
1764 */
1765 __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
1766 __PYX_ERR(0, 23, __pyx_L1_error)
1767
1768 /* "clickhouse_driver/bufferedreader.pyx":22
1769 * super(BufferedReader, self).__init__()
1770 *
1771 * def read_into_buffer(self): # <<<<<<<<<<<<<<
1772 * raise NotImplementedError
1773 *
1774 */
1775
1776 /* function exit code */
1777 __pyx_L1_error:;
1778 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
1779 __pyx_r = NULL;
1780 __Pyx_XGIVEREF(__pyx_r);
1781 __Pyx_RefNannyFinishContext();
1782 return __pyx_r;
1783 }
1784
1785 /* "clickhouse_driver/bufferedreader.pyx":25
1786 * raise NotImplementedError
1787 *
1788 * def read(self, unsigned long long unread): # <<<<<<<<<<<<<<
1789 * # When the buffer is large enough bytes read are almost
1790 * # always hit the buffer.
1791 */
1792
1793 /* Python wrapper */
1794 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_v_self, PyObject *__pyx_arg_unread); /*proto*/
1795 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_v_self, PyObject *__pyx_arg_unread) {
1796 unsigned PY_LONG_LONG __pyx_v_unread;
1797 int __pyx_lineno = 0;
1798 const char *__pyx_filename = NULL;
1799 int __pyx_clineno = 0;
1800 PyObject *__pyx_r = 0;
1801 __Pyx_RefNannyDeclarations
1802 __Pyx_RefNannySetupContext("read (wrapper)", 0);
1803 assert(__pyx_arg_unread); {
1804 __pyx_v_unread = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_arg_unread); if (unlikely((__pyx_v_unread == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 25, __pyx_L3_error)
1805 }
1806 goto __pyx_L4_argument_unpacking_done;
1807 __pyx_L3_error:;
1808 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
1809 __Pyx_RefNannyFinishContext();
1810 return NULL;
1811 __pyx_L4_argument_unpacking_done:;
1812 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((unsigned PY_LONG_LONG)__pyx_v_unread));
1813
1814 /* function exit code */
1815 __Pyx_RefNannyFinishContext();
1816 return __pyx_r;
1817 }
1818
1819 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_unread) {
1820 unsigned PY_LONG_LONG __pyx_v_next_position;
1821 unsigned PY_LONG_LONG __pyx_v_t;
1822 char *__pyx_v_buffer_ptr;
1823 unsigned PY_LONG_LONG __pyx_v_read_bytes;
1824 PyObject *__pyx_v_rv = NULL;
1825 PyObject *__pyx_r = NULL;
1826 __Pyx_RefNannyDeclarations
1827 int __pyx_t_1;
1828 unsigned PY_LONG_LONG __pyx_t_2;
1829 PyObject *__pyx_t_3 = NULL;
1830 PyObject *__pyx_t_4 = NULL;
1831 PyObject *__pyx_t_5 = NULL;
1832 unsigned PY_LONG_LONG __pyx_t_6;
1833 unsigned PY_LONG_LONG __pyx_t_7;
1834 int __pyx_lineno = 0;
1835 const char *__pyx_filename = NULL;
1836 int __pyx_clineno = 0;
1837 __Pyx_RefNannySetupContext("read", 0);
1838
1839 /* "clickhouse_driver/bufferedreader.pyx":28
1840 * # When the buffer is large enough bytes read are almost
1841 * # always hit the buffer.
1842 * cdef unsigned long long next_position = unread + self.position # <<<<<<<<<<<<<<
1843 * if next_position < self.current_buffer_size:
1844 * t = self.position
1845 */
1846 __pyx_v_next_position = (__pyx_v_unread + __pyx_v_self->position);
1847
1848 /* "clickhouse_driver/bufferedreader.pyx":29
1849 * # always hit the buffer.
1850 * cdef unsigned long long next_position = unread + self.position
1851 * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<<
1852 * t = self.position
1853 * self.position = next_position
1854 */
1855 __pyx_t_1 = ((__pyx_v_next_position < __pyx_v_self->current_buffer_size) != 0);
1856 if (__pyx_t_1) {
1857
1858 /* "clickhouse_driver/bufferedreader.pyx":30
1859 * cdef unsigned long long next_position = unread + self.position
1860 * if next_position < self.current_buffer_size:
1861 * t = self.position # <<<<<<<<<<<<<<
1862 * self.position = next_position
1863 * return bytes(self.buffer[t:self.position])
1864 */
1865 __pyx_t_2 = __pyx_v_self->position;
1866 __pyx_v_t = __pyx_t_2;
1867
1868 /* "clickhouse_driver/bufferedreader.pyx":31
1869 * if next_position < self.current_buffer_size:
1870 * t = self.position
1871 * self.position = next_position # <<<<<<<<<<<<<<
1872 * return bytes(self.buffer[t:self.position])
1873 *
1874 */
1875 __pyx_v_self->position = __pyx_v_next_position;
1876
1877 /* "clickhouse_driver/bufferedreader.pyx":32
1878 * t = self.position
1879 * self.position = next_position
1880 * return bytes(self.buffer[t:self.position]) # <<<<<<<<<<<<<<
1881 *
1882 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
1883 */
1884 __Pyx_XDECREF(__pyx_r);
1885 if (unlikely(__pyx_v_self->buffer == Py_None)) {
1886 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
1887 __PYX_ERR(0, 32, __pyx_L1_error)
1888 }
1889 __pyx_t_3 = PySequence_GetSlice(__pyx_v_self->buffer, __pyx_v_t, __pyx_v_self->position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
1890 __Pyx_GOTREF(__pyx_t_3);
1891 __pyx_t_4 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyBytes_Type)), __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
1892 __Pyx_GOTREF(__pyx_t_4);
1893 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1894 __pyx_r = __pyx_t_4;
1895 __pyx_t_4 = 0;
1896 goto __pyx_L0;
1897
1898 /* "clickhouse_driver/bufferedreader.pyx":29
1899 * # always hit the buffer.
1900 * cdef unsigned long long next_position = unread + self.position
1901 * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<<
1902 * t = self.position
1903 * self.position = next_position
1904 */
1905 }
1906
1907 /* "clickhouse_driver/bufferedreader.pyx":34
1908 * return bytes(self.buffer[t:self.position])
1909 *
1910 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
1911 * cdef unsigned long long read_bytes
1912 * rv = bytes()
1913 */
1914 __pyx_t_4 = __pyx_v_self->buffer;
1915 __Pyx_INCREF(__pyx_t_4);
1916 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_4);
1917 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1918
1919 /* "clickhouse_driver/bufferedreader.pyx":36
1920 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
1921 * cdef unsigned long long read_bytes
1922 * rv = bytes() # <<<<<<<<<<<<<<
1923 *
1924 * while unread > 0:
1925 */
1926 __pyx_t_4 = __Pyx_PyObject_CallNoArg(((PyObject *)(&PyBytes_Type))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error)
1927 __Pyx_GOTREF(__pyx_t_4);
1928 __pyx_v_rv = ((PyObject*)__pyx_t_4);
1929 __pyx_t_4 = 0;
1930
1931 /* "clickhouse_driver/bufferedreader.pyx":38
1932 * rv = bytes()
1933 *
1934 * while unread > 0: # <<<<<<<<<<<<<<
1935 * if self.position == self.current_buffer_size:
1936 * self.read_into_buffer()
1937 */
1938 while (1) {
1939 __pyx_t_1 = ((__pyx_v_unread > 0) != 0);
1940 if (!__pyx_t_1) break;
1941
1942 /* "clickhouse_driver/bufferedreader.pyx":39
1943 *
1944 * while unread > 0:
1945 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
1946 * self.read_into_buffer()
1947 * buffer_ptr = PyByteArray_AsString(self.buffer)
1948 */
1949 __pyx_t_1 = ((__pyx_v_self->position == __pyx_v_self->current_buffer_size) != 0);
1950 if (__pyx_t_1) {
1951
1952 /* "clickhouse_driver/bufferedreader.pyx":40
1953 * while unread > 0:
1954 * if self.position == self.current_buffer_size:
1955 * self.read_into_buffer() # <<<<<<<<<<<<<<
1956 * buffer_ptr = PyByteArray_AsString(self.buffer)
1957 * self.position = 0
1958 */
1959 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 40, __pyx_L1_error)
1960 __Pyx_GOTREF(__pyx_t_3);
1961 __pyx_t_5 = NULL;
1962 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1963 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
1964 if (likely(__pyx_t_5)) {
1965 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1966 __Pyx_INCREF(__pyx_t_5);
1967 __Pyx_INCREF(function);
1968 __Pyx_DECREF_SET(__pyx_t_3, function);
1969 }
1970 }
1971 __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
1972 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
1973 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 40, __pyx_L1_error)
1974 __Pyx_GOTREF(__pyx_t_4);
1975 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1976 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1977
1978 /* "clickhouse_driver/bufferedreader.pyx":41
1979 * if self.position == self.current_buffer_size:
1980 * self.read_into_buffer()
1981 * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
1982 * self.position = 0
1983 *
1984 */
1985 __pyx_t_4 = __pyx_v_self->buffer;
1986 __Pyx_INCREF(__pyx_t_4);
1987 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_4);
1988 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1989
1990 /* "clickhouse_driver/bufferedreader.pyx":42
1991 * self.read_into_buffer()
1992 * buffer_ptr = PyByteArray_AsString(self.buffer)
1993 * self.position = 0 # <<<<<<<<<<<<<<
1994 *
1995 * read_bytes = min(unread, self.current_buffer_size - self.position)
1996 */
1997 __pyx_v_self->position = 0;
1998
1999 /* "clickhouse_driver/bufferedreader.pyx":39
2000 *
2001 * while unread > 0:
2002 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2003 * self.read_into_buffer()
2004 * buffer_ptr = PyByteArray_AsString(self.buffer)
2005 */
2006 }
2007
2008 /* "clickhouse_driver/bufferedreader.pyx":44
2009 * self.position = 0
2010 *
2011 * read_bytes = min(unread, self.current_buffer_size - self.position) # <<<<<<<<<<<<<<
2012 * rv += PyBytes_FromStringAndSize(
2013 * &buffer_ptr[self.position], read_bytes
2014 */
2015 __pyx_t_2 = (__pyx_v_self->current_buffer_size - __pyx_v_self->position);
2016 __pyx_t_6 = __pyx_v_unread;
2017 if (((__pyx_t_2 < __pyx_t_6) != 0)) {
2018 __pyx_t_7 = __pyx_t_2;
2019 } else {
2020 __pyx_t_7 = __pyx_t_6;
2021 }
2022 __pyx_v_read_bytes = __pyx_t_7;
2023
2024 /* "clickhouse_driver/bufferedreader.pyx":45
2025 *
2026 * read_bytes = min(unread, self.current_buffer_size - self.position)
2027 * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
2028 * &buffer_ptr[self.position], read_bytes
2029 * )
2030 */
2031 __pyx_t_4 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_read_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 45, __pyx_L1_error)
2032 __Pyx_GOTREF(__pyx_t_4);
2033 __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 45, __pyx_L1_error)
2034 __Pyx_GOTREF(__pyx_t_3);
2035 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2036 __Pyx_DECREF_SET(__pyx_v_rv, ((PyObject*)__pyx_t_3));
2037 __pyx_t_3 = 0;
2038
2039 /* "clickhouse_driver/bufferedreader.pyx":48
2040 * &buffer_ptr[self.position], read_bytes
2041 * )
2042 * self.position += read_bytes # <<<<<<<<<<<<<<
2043 * unread -= read_bytes
2044 *
2045 */
2046 __pyx_v_self->position = (__pyx_v_self->position + __pyx_v_read_bytes);
2047
2048 /* "clickhouse_driver/bufferedreader.pyx":49
2049 * )
2050 * self.position += read_bytes
2051 * unread -= read_bytes # <<<<<<<<<<<<<<
2052 *
2053 * return rv
2054 */
2055 __pyx_v_unread = (__pyx_v_unread - __pyx_v_read_bytes);
2056 }
2057
2058 /* "clickhouse_driver/bufferedreader.pyx":51
2059 * unread -= read_bytes
2060 *
2061 * return rv # <<<<<<<<<<<<<<
2062 *
2063 * def read_one(self):
2064 */
2065 __Pyx_XDECREF(__pyx_r);
2066 __Pyx_INCREF(__pyx_v_rv);
2067 __pyx_r = __pyx_v_rv;
2068 goto __pyx_L0;
2069
2070 /* "clickhouse_driver/bufferedreader.pyx":25
2071 * raise NotImplementedError
2072 *
2073 * def read(self, unsigned long long unread): # <<<<<<<<<<<<<<
2074 * # When the buffer is large enough bytes read are almost
2075 * # always hit the buffer.
2076 */
2077
2078 /* function exit code */
2079 __pyx_L1_error:;
2080 __Pyx_XDECREF(__pyx_t_3);
2081 __Pyx_XDECREF(__pyx_t_4);
2082 __Pyx_XDECREF(__pyx_t_5);
2083 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
2084 __pyx_r = NULL;
2085 __pyx_L0:;
2086 __Pyx_XDECREF(__pyx_v_rv);
2087 __Pyx_XGIVEREF(__pyx_r);
2088 __Pyx_RefNannyFinishContext();
2089 return __pyx_r;
2090 }
2091
2092 /* "clickhouse_driver/bufferedreader.pyx":53
2093 * return rv
2094 *
2095 * def read_one(self): # <<<<<<<<<<<<<<
2096 * if self.position == self.current_buffer_size:
2097 * self.read_into_buffer()
2098 */
2099
2100 /* Python wrapper */
2101 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2102 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
2103 PyObject *__pyx_r = 0;
2104 __Pyx_RefNannyDeclarations
2105 __Pyx_RefNannySetupContext("read_one (wrapper)", 0);
2106 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
2107
2108 /* function exit code */
2109 __Pyx_RefNannyFinishContext();
2110 return __pyx_r;
2111 }
2112
2113 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
2114 unsigned char __pyx_v_rv;
2115 PyObject *__pyx_r = NULL;
2116 __Pyx_RefNannyDeclarations
2117 int __pyx_t_1;
2118 PyObject *__pyx_t_2 = NULL;
2119 PyObject *__pyx_t_3 = NULL;
2120 PyObject *__pyx_t_4 = NULL;
2121 int __pyx_t_5;
2122 int __pyx_lineno = 0;
2123 const char *__pyx_filename = NULL;
2124 int __pyx_clineno = 0;
2125 __Pyx_RefNannySetupContext("read_one", 0);
2126
2127 /* "clickhouse_driver/bufferedreader.pyx":54
2128 *
2129 * def read_one(self):
2130 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2131 * self.read_into_buffer()
2132 * self.position = 0
2133 */
2134 __pyx_t_1 = ((__pyx_v_self->position == __pyx_v_self->current_buffer_size) != 0);
2135 if (__pyx_t_1) {
2136
2137 /* "clickhouse_driver/bufferedreader.pyx":55
2138 * def read_one(self):
2139 * if self.position == self.current_buffer_size:
2140 * self.read_into_buffer() # <<<<<<<<<<<<<<
2141 * self.position = 0
2142 *
2143 */
2144 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 55, __pyx_L1_error)
2145 __Pyx_GOTREF(__pyx_t_3);
2146 __pyx_t_4 = NULL;
2147 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2148 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2149 if (likely(__pyx_t_4)) {
2150 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2151 __Pyx_INCREF(__pyx_t_4);
2152 __Pyx_INCREF(function);
2153 __Pyx_DECREF_SET(__pyx_t_3, function);
2154 }
2155 }
2156 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2157 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2158 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error)
2159 __Pyx_GOTREF(__pyx_t_2);
2160 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2161 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2162
2163 /* "clickhouse_driver/bufferedreader.pyx":56
2164 * if self.position == self.current_buffer_size:
2165 * self.read_into_buffer()
2166 * self.position = 0 # <<<<<<<<<<<<<<
2167 *
2168 * rv = self.buffer[self.position]
2169 */
2170 __pyx_v_self->position = 0;
2171
2172 /* "clickhouse_driver/bufferedreader.pyx":54
2173 *
2174 * def read_one(self):
2175 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2176 * self.read_into_buffer()
2177 * self.position = 0
2178 */
2179 }
2180
2181 /* "clickhouse_driver/bufferedreader.pyx":58
2182 * self.position = 0
2183 *
2184 * rv = self.buffer[self.position] # <<<<<<<<<<<<<<
2185 * self.position += 1
2186 * return rv
2187 */
2188 __pyx_t_5 = __Pyx_GetItemInt_ByteArray(__pyx_v_self->buffer, __pyx_v_self->position, unsigned PY_LONG_LONG, 0, __Pyx_PyInt_From_unsigned_PY_LONG_LONG, 0, 0, 1); if (unlikely(__pyx_t_5 == -1)) __PYX_ERR(0, 58, __pyx_L1_error)
2189 __pyx_v_rv = __pyx_t_5;
2190
2191 /* "clickhouse_driver/bufferedreader.pyx":59
2192 *
2193 * rv = self.buffer[self.position]
2194 * self.position += 1 # <<<<<<<<<<<<<<
2195 * return rv
2196 *
2197 */
2198 __pyx_v_self->position = (__pyx_v_self->position + 1);
2199
2200 /* "clickhouse_driver/bufferedreader.pyx":60
2201 * rv = self.buffer[self.position]
2202 * self.position += 1
2203 * return rv # <<<<<<<<<<<<<<
2204 *
2205 * def read_strings(self, unsigned long long n_items, encoding=None):
2206 */
2207 __Pyx_XDECREF(__pyx_r);
2208 __pyx_t_2 = __Pyx_PyInt_From_unsigned_char(__pyx_v_rv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error)
2209 __Pyx_GOTREF(__pyx_t_2);
2210 __pyx_r = __pyx_t_2;
2211 __pyx_t_2 = 0;
2212 goto __pyx_L0;
2213
2214 /* "clickhouse_driver/bufferedreader.pyx":53
2215 * return rv
2216 *
2217 * def read_one(self): # <<<<<<<<<<<<<<
2218 * if self.position == self.current_buffer_size:
2219 * self.read_into_buffer()
2220 */
2221
2222 /* function exit code */
2223 __pyx_L1_error:;
2224 __Pyx_XDECREF(__pyx_t_2);
2225 __Pyx_XDECREF(__pyx_t_3);
2226 __Pyx_XDECREF(__pyx_t_4);
2227 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_one", __pyx_clineno, __pyx_lineno, __pyx_filename);
2228 __pyx_r = NULL;
2229 __pyx_L0:;
2230 __Pyx_XGIVEREF(__pyx_r);
2231 __Pyx_RefNannyFinishContext();
2232 return __pyx_r;
2233 }
2234
2235 /* "clickhouse_driver/bufferedreader.pyx":62
2236 * return rv
2237 *
2238 * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<<
2239 * """
2240 * Python has great overhead between function calls.
2241 */
2242
2243 /* Python wrapper */
2244 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2245 static char __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings[] = "\n Python has great overhead between function calls.\n We inline strings reading logic here to avoid this overhead.\n ";
2246 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2247 unsigned PY_LONG_LONG __pyx_v_n_items;
2248 PyObject *__pyx_v_encoding = 0;
2249 int __pyx_lineno = 0;
2250 const char *__pyx_filename = NULL;
2251 int __pyx_clineno = 0;
2252 PyObject *__pyx_r = 0;
2253 __Pyx_RefNannyDeclarations
2254 __Pyx_RefNannySetupContext("read_strings (wrapper)", 0);
16882255 {
1689 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_bufsize,0};
2256 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_items,&__pyx_n_s_encoding,0};
2257 PyObject* values[2] = {0,0};
2258 values[1] = ((PyObject *)Py_None);
2259 if (unlikely(__pyx_kwds)) {
2260 Py_ssize_t kw_args;
2261 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2262 switch (pos_args) {
2263 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2264 CYTHON_FALLTHROUGH;
2265 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2266 CYTHON_FALLTHROUGH;
2267 case 0: break;
2268 default: goto __pyx_L5_argtuple_error;
2269 }
2270 kw_args = PyDict_Size(__pyx_kwds);
2271 switch (pos_args) {
2272 case 0:
2273 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
2274 else goto __pyx_L5_argtuple_error;
2275 CYTHON_FALLTHROUGH;
2276 case 1:
2277 if (kw_args > 0) {
2278 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoding);
2279 if (value) { values[1] = value; kw_args--; }
2280 }
2281 }
2282 if (unlikely(kw_args > 0)) {
2283 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_strings") < 0)) __PYX_ERR(0, 62, __pyx_L3_error)
2284 }
2285 } else {
2286 switch (PyTuple_GET_SIZE(__pyx_args)) {
2287 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2288 CYTHON_FALLTHROUGH;
2289 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2290 break;
2291 default: goto __pyx_L5_argtuple_error;
2292 }
2293 }
2294 __pyx_v_n_items = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_n_items == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L3_error)
2295 __pyx_v_encoding = values[1];
2296 }
2297 goto __pyx_L4_argument_unpacking_done;
2298 __pyx_L5_argtuple_error:;
2299 __Pyx_RaiseArgtupleInvalid("read_strings", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 62, __pyx_L3_error)
2300 __pyx_L3_error:;
2301 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2302 __Pyx_RefNannyFinishContext();
2303 return NULL;
2304 __pyx_L4_argument_unpacking_done:;
2305 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_encoding);
2306
2307 /* function exit code */
2308 __Pyx_RefNannyFinishContext();
2309 return __pyx_r;
2310 }
2311
2312 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_n_items, PyObject *__pyx_v_encoding) {
2313 PyObject *__pyx_v_items = NULL;
2314 unsigned PY_LONG_LONG __pyx_v_i;
2315 char *__pyx_v_buffer_ptr;
2316 unsigned PY_LONG_LONG __pyx_v_right;
2317 unsigned PY_LONG_LONG __pyx_v_size;
2318 unsigned PY_LONG_LONG __pyx_v_shift;
2319 unsigned PY_LONG_LONG __pyx_v_bytes_read;
2320 unsigned PY_LONG_LONG __pyx_v_b;
2321 char *__pyx_v_c_string;
2322 unsigned PY_LONG_LONG __pyx_v_c_string_size;
2323 char *__pyx_v_c_encoding;
2324 PyObject *__pyx_v_rv = 0;
2325 PyObject *__pyx_r = NULL;
2326 __Pyx_RefNannyDeclarations
2327 PyObject *__pyx_t_1 = NULL;
2328 int __pyx_t_2;
2329 PyObject *__pyx_t_3 = NULL;
2330 PyObject *__pyx_t_4 = NULL;
2331 char *__pyx_t_5;
2332 unsigned PY_LONG_LONG __pyx_t_6;
2333 unsigned PY_LONG_LONG __pyx_t_7;
2334 unsigned PY_LONG_LONG __pyx_t_8;
2335 unsigned PY_LONG_LONG __pyx_t_9;
2336 unsigned PY_LONG_LONG __pyx_t_10;
2337 unsigned PY_LONG_LONG __pyx_t_11;
2338 PyObject *__pyx_t_12 = NULL;
2339 PyObject *__pyx_t_13 = NULL;
2340 PyObject *__pyx_t_14 = NULL;
2341 int __pyx_t_15;
2342 PyObject *__pyx_t_16 = NULL;
2343 int __pyx_lineno = 0;
2344 const char *__pyx_filename = NULL;
2345 int __pyx_clineno = 0;
2346 __Pyx_RefNannySetupContext("read_strings", 0);
2347 __Pyx_INCREF(__pyx_v_encoding);
2348
2349 /* "clickhouse_driver/bufferedreader.pyx":67
2350 * We inline strings reading logic here to avoid this overhead.
2351 * """
2352 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
2353 *
2354 * cdef unsigned long long i
2355 */
2356 __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
2357 __Pyx_GOTREF(__pyx_t_1);
2358 __pyx_v_items = ((PyObject*)__pyx_t_1);
2359 __pyx_t_1 = 0;
2360
2361 /* "clickhouse_driver/bufferedreader.pyx":71
2362 * cdef unsigned long long i
2363 * # Buffer vars
2364 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
2365 * cdef unsigned long long right
2366 * # String length vars
2367 */
2368 __pyx_t_1 = __pyx_v_self->buffer;
2369 __Pyx_INCREF(__pyx_t_1);
2370 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1);
2371 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2372
2373 /* "clickhouse_driver/bufferedreader.pyx":78
2374 *
2375 * # String for decode vars.
2376 * cdef char *c_string = NULL # <<<<<<<<<<<<<<
2377 * cdef unsigned long long c_string_size = 1024
2378 * cdef char *c_encoding = NULL
2379 */
2380 __pyx_v_c_string = NULL;
2381
2382 /* "clickhouse_driver/bufferedreader.pyx":79
2383 * # String for decode vars.
2384 * cdef char *c_string = NULL
2385 * cdef unsigned long long c_string_size = 1024 # <<<<<<<<<<<<<<
2386 * cdef char *c_encoding = NULL
2387 * if encoding:
2388 */
2389 __pyx_v_c_string_size = 0x400;
2390
2391 /* "clickhouse_driver/bufferedreader.pyx":80
2392 * cdef char *c_string = NULL
2393 * cdef unsigned long long c_string_size = 1024
2394 * cdef char *c_encoding = NULL # <<<<<<<<<<<<<<
2395 * if encoding:
2396 * encoding = encoding.encode('utf-8')
2397 */
2398 __pyx_v_c_encoding = NULL;
2399
2400 /* "clickhouse_driver/bufferedreader.pyx":81
2401 * cdef unsigned long long c_string_size = 1024
2402 * cdef char *c_encoding = NULL
2403 * if encoding: # <<<<<<<<<<<<<<
2404 * encoding = encoding.encode('utf-8')
2405 * c_encoding = encoding
2406 */
2407 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encoding); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 81, __pyx_L1_error)
2408 if (__pyx_t_2) {
2409
2410 /* "clickhouse_driver/bufferedreader.pyx":82
2411 * cdef char *c_encoding = NULL
2412 * if encoding:
2413 * encoding = encoding.encode('utf-8') # <<<<<<<<<<<<<<
2414 * c_encoding = encoding
2415 *
2416 */
2417 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_encoding, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
2418 __Pyx_GOTREF(__pyx_t_3);
2419 __pyx_t_4 = NULL;
2420 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2421 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2422 if (likely(__pyx_t_4)) {
2423 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2424 __Pyx_INCREF(__pyx_t_4);
2425 __Pyx_INCREF(function);
2426 __Pyx_DECREF_SET(__pyx_t_3, function);
2427 }
2428 }
2429 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_utf_8);
2430 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2431 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
2432 __Pyx_GOTREF(__pyx_t_1);
2433 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2434 __Pyx_DECREF_SET(__pyx_v_encoding, __pyx_t_1);
2435 __pyx_t_1 = 0;
2436
2437 /* "clickhouse_driver/bufferedreader.pyx":83
2438 * if encoding:
2439 * encoding = encoding.encode('utf-8')
2440 * c_encoding = encoding # <<<<<<<<<<<<<<
2441 *
2442 * cdef object rv = object()
2443 */
2444 __pyx_t_5 = __Pyx_PyObject_AsWritableString(__pyx_v_encoding); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) __PYX_ERR(0, 83, __pyx_L1_error)
2445 __pyx_v_c_encoding = __pyx_t_5;
2446
2447 /* "clickhouse_driver/bufferedreader.pyx":81
2448 * cdef unsigned long long c_string_size = 1024
2449 * cdef char *c_encoding = NULL
2450 * if encoding: # <<<<<<<<<<<<<<
2451 * encoding = encoding.encode('utf-8')
2452 * c_encoding = encoding
2453 */
2454 }
2455
2456 /* "clickhouse_driver/bufferedreader.pyx":85
2457 * c_encoding = encoding
2458 *
2459 * cdef object rv = object() # <<<<<<<<<<<<<<
2460 * # String for decode vars.
2461 * if c_encoding:
2462 */
2463 __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
2464 __Pyx_GOTREF(__pyx_t_1);
2465 __pyx_v_rv = __pyx_t_1;
2466 __pyx_t_1 = 0;
2467
2468 /* "clickhouse_driver/bufferedreader.pyx":87
2469 * cdef object rv = object()
2470 * # String for decode vars.
2471 * if c_encoding: # <<<<<<<<<<<<<<
2472 * c_string = <char *> PyMem_Realloc(NULL, c_string_size)
2473 *
2474 */
2475 __pyx_t_2 = (__pyx_v_c_encoding != 0);
2476 if (__pyx_t_2) {
2477
2478 /* "clickhouse_driver/bufferedreader.pyx":88
2479 * # String for decode vars.
2480 * if c_encoding:
2481 * c_string = <char *> PyMem_Realloc(NULL, c_string_size) # <<<<<<<<<<<<<<
2482 *
2483 * for i in range(n_items):
2484 */
2485 __pyx_v_c_string = ((char *)PyMem_Realloc(NULL, __pyx_v_c_string_size));
2486
2487 /* "clickhouse_driver/bufferedreader.pyx":87
2488 * cdef object rv = object()
2489 * # String for decode vars.
2490 * if c_encoding: # <<<<<<<<<<<<<<
2491 * c_string = <char *> PyMem_Realloc(NULL, c_string_size)
2492 *
2493 */
2494 }
2495
2496 /* "clickhouse_driver/bufferedreader.pyx":90
2497 * c_string = <char *> PyMem_Realloc(NULL, c_string_size)
2498 *
2499 * for i in range(n_items): # <<<<<<<<<<<<<<
2500 * shift = size = 0
2501 *
2502 */
2503 __pyx_t_6 = __pyx_v_n_items;
2504 __pyx_t_7 = __pyx_t_6;
2505 for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
2506 __pyx_v_i = __pyx_t_8;
2507
2508 /* "clickhouse_driver/bufferedreader.pyx":91
2509 *
2510 * for i in range(n_items):
2511 * shift = size = 0 # <<<<<<<<<<<<<<
2512 *
2513 * # Read string size
2514 */
2515 __pyx_v_shift = 0;
2516 __pyx_v_size = 0;
2517
2518 /* "clickhouse_driver/bufferedreader.pyx":94
2519 *
2520 * # Read string size
2521 * while True: # <<<<<<<<<<<<<<
2522 * if self.position == self.current_buffer_size:
2523 * self.read_into_buffer()
2524 */
2525 while (1) {
2526
2527 /* "clickhouse_driver/bufferedreader.pyx":95
2528 * # Read string size
2529 * while True:
2530 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2531 * self.read_into_buffer()
2532 * # `read_into_buffer` can override buffer
2533 */
2534 __pyx_t_2 = ((__pyx_v_self->position == __pyx_v_self->current_buffer_size) != 0);
2535 if (__pyx_t_2) {
2536
2537 /* "clickhouse_driver/bufferedreader.pyx":96
2538 * while True:
2539 * if self.position == self.current_buffer_size:
2540 * self.read_into_buffer() # <<<<<<<<<<<<<<
2541 * # `read_into_buffer` can override buffer
2542 * buffer_ptr = PyByteArray_AsString(self.buffer)
2543 */
2544 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
2545 __Pyx_GOTREF(__pyx_t_3);
2546 __pyx_t_4 = NULL;
2547 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2548 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2549 if (likely(__pyx_t_4)) {
2550 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2551 __Pyx_INCREF(__pyx_t_4);
2552 __Pyx_INCREF(function);
2553 __Pyx_DECREF_SET(__pyx_t_3, function);
2554 }
2555 }
2556 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2557 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2558 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 96, __pyx_L1_error)
2559 __Pyx_GOTREF(__pyx_t_1);
2560 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2561 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2562
2563 /* "clickhouse_driver/bufferedreader.pyx":98
2564 * self.read_into_buffer()
2565 * # `read_into_buffer` can override buffer
2566 * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
2567 * self.position = 0
2568 *
2569 */
2570 __pyx_t_1 = __pyx_v_self->buffer;
2571 __Pyx_INCREF(__pyx_t_1);
2572 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1);
2573 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2574
2575 /* "clickhouse_driver/bufferedreader.pyx":99
2576 * # `read_into_buffer` can override buffer
2577 * buffer_ptr = PyByteArray_AsString(self.buffer)
2578 * self.position = 0 # <<<<<<<<<<<<<<
2579 *
2580 * b = buffer_ptr[self.position]
2581 */
2582 __pyx_v_self->position = 0;
2583
2584 /* "clickhouse_driver/bufferedreader.pyx":95
2585 * # Read string size
2586 * while True:
2587 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2588 * self.read_into_buffer()
2589 * # `read_into_buffer` can override buffer
2590 */
2591 }
2592
2593 /* "clickhouse_driver/bufferedreader.pyx":101
2594 * self.position = 0
2595 *
2596 * b = buffer_ptr[self.position] # <<<<<<<<<<<<<<
2597 * self.position += 1
2598 *
2599 */
2600 __pyx_v_b = (__pyx_v_buffer_ptr[__pyx_v_self->position]);
2601
2602 /* "clickhouse_driver/bufferedreader.pyx":102
2603 *
2604 * b = buffer_ptr[self.position]
2605 * self.position += 1 # <<<<<<<<<<<<<<
2606 *
2607 * size |= (b & 0x7f) << shift
2608 */
2609 __pyx_v_self->position = (__pyx_v_self->position + 1);
2610
2611 /* "clickhouse_driver/bufferedreader.pyx":104
2612 * self.position += 1
2613 *
2614 * size |= (b & 0x7f) << shift # <<<<<<<<<<<<<<
2615 * if b < 0x80:
2616 * break
2617 */
2618 __pyx_v_size = (__pyx_v_size | ((__pyx_v_b & 0x7f) << __pyx_v_shift));
2619
2620 /* "clickhouse_driver/bufferedreader.pyx":105
2621 *
2622 * size |= (b & 0x7f) << shift
2623 * if b < 0x80: # <<<<<<<<<<<<<<
2624 * break
2625 *
2626 */
2627 __pyx_t_2 = ((__pyx_v_b < 0x80) != 0);
2628 if (__pyx_t_2) {
2629
2630 /* "clickhouse_driver/bufferedreader.pyx":106
2631 * size |= (b & 0x7f) << shift
2632 * if b < 0x80:
2633 * break # <<<<<<<<<<<<<<
2634 *
2635 * shift += 7
2636 */
2637 goto __pyx_L8_break;
2638
2639 /* "clickhouse_driver/bufferedreader.pyx":105
2640 *
2641 * size |= (b & 0x7f) << shift
2642 * if b < 0x80: # <<<<<<<<<<<<<<
2643 * break
2644 *
2645 */
2646 }
2647
2648 /* "clickhouse_driver/bufferedreader.pyx":108
2649 * break
2650 *
2651 * shift += 7 # <<<<<<<<<<<<<<
2652 *
2653 * right = self.position + size
2654 */
2655 __pyx_v_shift = (__pyx_v_shift + 7);
2656 }
2657 __pyx_L8_break:;
2658
2659 /* "clickhouse_driver/bufferedreader.pyx":110
2660 * shift += 7
2661 *
2662 * right = self.position + size # <<<<<<<<<<<<<<
2663 *
2664 * if c_encoding:
2665 */
2666 __pyx_v_right = (__pyx_v_self->position + __pyx_v_size);
2667
2668 /* "clickhouse_driver/bufferedreader.pyx":112
2669 * right = self.position + size
2670 *
2671 * if c_encoding: # <<<<<<<<<<<<<<
2672 * if size + 1 > c_string_size:
2673 * c_string_size = size + 1
2674 */
2675 __pyx_t_2 = (__pyx_v_c_encoding != 0);
2676 if (__pyx_t_2) {
2677
2678 /* "clickhouse_driver/bufferedreader.pyx":113
2679 *
2680 * if c_encoding:
2681 * if size + 1 > c_string_size: # <<<<<<<<<<<<<<
2682 * c_string_size = size + 1
2683 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2684 */
2685 __pyx_t_2 = (((__pyx_v_size + 1) > __pyx_v_c_string_size) != 0);
2686 if (__pyx_t_2) {
2687
2688 /* "clickhouse_driver/bufferedreader.pyx":114
2689 * if c_encoding:
2690 * if size + 1 > c_string_size:
2691 * c_string_size = size + 1 # <<<<<<<<<<<<<<
2692 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2693 * if c_string is NULL:
2694 */
2695 __pyx_v_c_string_size = (__pyx_v_size + 1);
2696
2697 /* "clickhouse_driver/bufferedreader.pyx":115
2698 * if size + 1 > c_string_size:
2699 * c_string_size = size + 1
2700 * c_string = <char *> PyMem_Realloc(c_string, c_string_size) # <<<<<<<<<<<<<<
2701 * if c_string is NULL:
2702 * raise MemoryError()
2703 */
2704 __pyx_v_c_string = ((char *)PyMem_Realloc(__pyx_v_c_string, __pyx_v_c_string_size));
2705
2706 /* "clickhouse_driver/bufferedreader.pyx":116
2707 * c_string_size = size + 1
2708 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2709 * if c_string is NULL: # <<<<<<<<<<<<<<
2710 * raise MemoryError()
2711 * c_string[size] = 0
2712 */
2713 __pyx_t_2 = ((__pyx_v_c_string == NULL) != 0);
2714 if (unlikely(__pyx_t_2)) {
2715
2716 /* "clickhouse_driver/bufferedreader.pyx":117
2717 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2718 * if c_string is NULL:
2719 * raise MemoryError() # <<<<<<<<<<<<<<
2720 * c_string[size] = 0
2721 * bytes_read = 0
2722 */
2723 PyErr_NoMemory(); __PYX_ERR(0, 117, __pyx_L1_error)
2724
2725 /* "clickhouse_driver/bufferedreader.pyx":116
2726 * c_string_size = size + 1
2727 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2728 * if c_string is NULL: # <<<<<<<<<<<<<<
2729 * raise MemoryError()
2730 * c_string[size] = 0
2731 */
2732 }
2733
2734 /* "clickhouse_driver/bufferedreader.pyx":113
2735 *
2736 * if c_encoding:
2737 * if size + 1 > c_string_size: # <<<<<<<<<<<<<<
2738 * c_string_size = size + 1
2739 * c_string = <char *> PyMem_Realloc(c_string, c_string_size)
2740 */
2741 }
2742
2743 /* "clickhouse_driver/bufferedreader.pyx":118
2744 * if c_string is NULL:
2745 * raise MemoryError()
2746 * c_string[size] = 0 # <<<<<<<<<<<<<<
2747 * bytes_read = 0
2748 *
2749 */
2750 (__pyx_v_c_string[__pyx_v_size]) = 0;
2751
2752 /* "clickhouse_driver/bufferedreader.pyx":119
2753 * raise MemoryError()
2754 * c_string[size] = 0
2755 * bytes_read = 0 # <<<<<<<<<<<<<<
2756 *
2757 * # Decoding pure c strings in Cython is faster than in pure Python.
2758 */
2759 __pyx_v_bytes_read = 0;
2760
2761 /* "clickhouse_driver/bufferedreader.pyx":112
2762 * right = self.position + size
2763 *
2764 * if c_encoding: # <<<<<<<<<<<<<<
2765 * if size + 1 > c_string_size:
2766 * c_string_size = size + 1
2767 */
2768 }
2769
2770 /* "clickhouse_driver/bufferedreader.pyx":124
2771 * # We need to copy it into buffer for adding null symbol at the end.
2772 * # In ClickHouse block there is no null
2773 * if right > self.current_buffer_size: # <<<<<<<<<<<<<<
2774 * if c_encoding:
2775 * memcpy(&c_string[bytes_read], &buffer_ptr[self.position],
2776 */
2777 __pyx_t_2 = ((__pyx_v_right > __pyx_v_self->current_buffer_size) != 0);
2778 if (__pyx_t_2) {
2779
2780 /* "clickhouse_driver/bufferedreader.pyx":125
2781 * # In ClickHouse block there is no null
2782 * if right > self.current_buffer_size:
2783 * if c_encoding: # <<<<<<<<<<<<<<
2784 * memcpy(&c_string[bytes_read], &buffer_ptr[self.position],
2785 * self.current_buffer_size - self.position)
2786 */
2787 __pyx_t_2 = (__pyx_v_c_encoding != 0);
2788 if (__pyx_t_2) {
2789
2790 /* "clickhouse_driver/bufferedreader.pyx":126
2791 * if right > self.current_buffer_size:
2792 * if c_encoding:
2793 * memcpy(&c_string[bytes_read], &buffer_ptr[self.position], # <<<<<<<<<<<<<<
2794 * self.current_buffer_size - self.position)
2795 * else:
2796 */
2797 (void)(memcpy((&(__pyx_v_c_string[__pyx_v_bytes_read])), (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), (__pyx_v_self->current_buffer_size - __pyx_v_self->position)));
2798
2799 /* "clickhouse_driver/bufferedreader.pyx":125
2800 * # In ClickHouse block there is no null
2801 * if right > self.current_buffer_size:
2802 * if c_encoding: # <<<<<<<<<<<<<<
2803 * memcpy(&c_string[bytes_read], &buffer_ptr[self.position],
2804 * self.current_buffer_size - self.position)
2805 */
2806 goto __pyx_L15;
2807 }
2808
2809 /* "clickhouse_driver/bufferedreader.pyx":129
2810 * self.current_buffer_size - self.position)
2811 * else:
2812 * rv = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
2813 * &buffer_ptr[self.position],
2814 * self.current_buffer_size - self.position
2815 */
2816 /*else*/ {
2817
2818 /* "clickhouse_driver/bufferedreader.pyx":131
2819 * rv = PyBytes_FromStringAndSize(
2820 * &buffer_ptr[self.position],
2821 * self.current_buffer_size - self.position # <<<<<<<<<<<<<<
2822 * )
2823 *
2824 */
2825 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), (__pyx_v_self->current_buffer_size - __pyx_v_self->position)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
2826 __Pyx_GOTREF(__pyx_t_1);
2827 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_1);
2828 __pyx_t_1 = 0;
2829 }
2830 __pyx_L15:;
2831
2832 /* "clickhouse_driver/bufferedreader.pyx":134
2833 * )
2834 *
2835 * bytes_read = self.current_buffer_size - self.position # <<<<<<<<<<<<<<
2836 * # Read the rest of the string.
2837 * while bytes_read != size:
2838 */
2839 __pyx_v_bytes_read = (__pyx_v_self->current_buffer_size - __pyx_v_self->position);
2840
2841 /* "clickhouse_driver/bufferedreader.pyx":136
2842 * bytes_read = self.current_buffer_size - self.position
2843 * # Read the rest of the string.
2844 * while bytes_read != size: # <<<<<<<<<<<<<<
2845 * self.position = size - bytes_read
2846 *
2847 */
2848 while (1) {
2849 __pyx_t_2 = ((__pyx_v_bytes_read != __pyx_v_size) != 0);
2850 if (!__pyx_t_2) break;
2851
2852 /* "clickhouse_driver/bufferedreader.pyx":137
2853 * # Read the rest of the string.
2854 * while bytes_read != size:
2855 * self.position = size - bytes_read # <<<<<<<<<<<<<<
2856 *
2857 * self.read_into_buffer()
2858 */
2859 __pyx_v_self->position = (__pyx_v_size - __pyx_v_bytes_read);
2860
2861 /* "clickhouse_driver/bufferedreader.pyx":139
2862 * self.position = size - bytes_read
2863 *
2864 * self.read_into_buffer() # <<<<<<<<<<<<<<
2865 * # `read_into_buffer` can override buffer
2866 * buffer_ptr = PyByteArray_AsString(self.buffer)
2867 */
2868 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error)
2869 __Pyx_GOTREF(__pyx_t_3);
2870 __pyx_t_4 = NULL;
2871 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2872 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2873 if (likely(__pyx_t_4)) {
2874 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2875 __Pyx_INCREF(__pyx_t_4);
2876 __Pyx_INCREF(function);
2877 __Pyx_DECREF_SET(__pyx_t_3, function);
2878 }
2879 }
2880 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2881 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2882 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
2883 __Pyx_GOTREF(__pyx_t_1);
2884 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2885 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2886
2887 /* "clickhouse_driver/bufferedreader.pyx":141
2888 * self.read_into_buffer()
2889 * # `read_into_buffer` can override buffer
2890 * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
2891 * # There can be not enough data in buffer.
2892 * self.position = min(
2893 */
2894 __pyx_t_1 = __pyx_v_self->buffer;
2895 __Pyx_INCREF(__pyx_t_1);
2896 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1);
2897 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2898
2899 /* "clickhouse_driver/bufferedreader.pyx":144
2900 * # There can be not enough data in buffer.
2901 * self.position = min(
2902 * self.position, self.current_buffer_size # <<<<<<<<<<<<<<
2903 * )
2904 * if c_encoding:
2905 */
2906 __pyx_t_9 = __pyx_v_self->current_buffer_size;
2907 __pyx_t_10 = __pyx_v_self->position;
2908 if (((__pyx_t_9 < __pyx_t_10) != 0)) {
2909 __pyx_t_11 = __pyx_t_9;
2910 } else {
2911 __pyx_t_11 = __pyx_t_10;
2912 }
2913
2914 /* "clickhouse_driver/bufferedreader.pyx":143
2915 * buffer_ptr = PyByteArray_AsString(self.buffer)
2916 * # There can be not enough data in buffer.
2917 * self.position = min( # <<<<<<<<<<<<<<
2918 * self.position, self.current_buffer_size
2919 * )
2920 */
2921 __pyx_v_self->position = __pyx_t_11;
2922
2923 /* "clickhouse_driver/bufferedreader.pyx":146
2924 * self.position, self.current_buffer_size
2925 * )
2926 * if c_encoding: # <<<<<<<<<<<<<<
2927 * memcpy(
2928 * &c_string[bytes_read], buffer_ptr, self.position
2929 */
2930 __pyx_t_2 = (__pyx_v_c_encoding != 0);
2931 if (__pyx_t_2) {
2932
2933 /* "clickhouse_driver/bufferedreader.pyx":147
2934 * )
2935 * if c_encoding:
2936 * memcpy( # <<<<<<<<<<<<<<
2937 * &c_string[bytes_read], buffer_ptr, self.position
2938 * )
2939 */
2940 (void)(memcpy((&(__pyx_v_c_string[__pyx_v_bytes_read])), __pyx_v_buffer_ptr, __pyx_v_self->position));
2941
2942 /* "clickhouse_driver/bufferedreader.pyx":146
2943 * self.position, self.current_buffer_size
2944 * )
2945 * if c_encoding: # <<<<<<<<<<<<<<
2946 * memcpy(
2947 * &c_string[bytes_read], buffer_ptr, self.position
2948 */
2949 goto __pyx_L18;
2950 }
2951
2952 /* "clickhouse_driver/bufferedreader.pyx":151
2953 * )
2954 * else:
2955 * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
2956 * buffer_ptr, self.position
2957 * )
2958 */
2959 /*else*/ {
2960
2961 /* "clickhouse_driver/bufferedreader.pyx":152
2962 * else:
2963 * rv += PyBytes_FromStringAndSize(
2964 * buffer_ptr, self.position # <<<<<<<<<<<<<<
2965 * )
2966 * bytes_read += self.position
2967 */
2968 __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_buffer_ptr, __pyx_v_self->position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error)
2969 __Pyx_GOTREF(__pyx_t_1);
2970
2971 /* "clickhouse_driver/bufferedreader.pyx":151
2972 * )
2973 * else:
2974 * rv += PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
2975 * buffer_ptr, self.position
2976 * )
2977 */
2978 __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 151, __pyx_L1_error)
2979 __Pyx_GOTREF(__pyx_t_3);
2980 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2981 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3);
2982 __pyx_t_3 = 0;
2983 }
2984 __pyx_L18:;
2985
2986 /* "clickhouse_driver/bufferedreader.pyx":154
2987 * buffer_ptr, self.position
2988 * )
2989 * bytes_read += self.position # <<<<<<<<<<<<<<
2990 *
2991 * else:
2992 */
2993 __pyx_v_bytes_read = (__pyx_v_bytes_read + __pyx_v_self->position);
2994 }
2995
2996 /* "clickhouse_driver/bufferedreader.pyx":124
2997 * # We need to copy it into buffer for adding null symbol at the end.
2998 * # In ClickHouse block there is no null
2999 * if right > self.current_buffer_size: # <<<<<<<<<<<<<<
3000 * if c_encoding:
3001 * memcpy(&c_string[bytes_read], &buffer_ptr[self.position],
3002 */
3003 goto __pyx_L14;
3004 }
3005
3006 /* "clickhouse_driver/bufferedreader.pyx":157
3007 *
3008 * else:
3009 * if c_encoding: # <<<<<<<<<<<<<<
3010 * memcpy(c_string, &buffer_ptr[self.position], size)
3011 * else:
3012 */
3013 /*else*/ {
3014 __pyx_t_2 = (__pyx_v_c_encoding != 0);
3015 if (__pyx_t_2) {
3016
3017 /* "clickhouse_driver/bufferedreader.pyx":158
3018 * else:
3019 * if c_encoding:
3020 * memcpy(c_string, &buffer_ptr[self.position], size) # <<<<<<<<<<<<<<
3021 * else:
3022 * rv = PyBytes_FromStringAndSize(
3023 */
3024 (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_size));
3025
3026 /* "clickhouse_driver/bufferedreader.pyx":157
3027 *
3028 * else:
3029 * if c_encoding: # <<<<<<<<<<<<<<
3030 * memcpy(c_string, &buffer_ptr[self.position], size)
3031 * else:
3032 */
3033 goto __pyx_L19;
3034 }
3035
3036 /* "clickhouse_driver/bufferedreader.pyx":160
3037 * memcpy(c_string, &buffer_ptr[self.position], size)
3038 * else:
3039 * rv = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
3040 * &buffer_ptr[self.position], size
3041 * )
3042 */
3043 /*else*/ {
3044
3045 /* "clickhouse_driver/bufferedreader.pyx":161
3046 * else:
3047 * rv = PyBytes_FromStringAndSize(
3048 * &buffer_ptr[self.position], size # <<<<<<<<<<<<<<
3049 * )
3050 * self.position = right
3051 */
3052 __pyx_t_3 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_self->position])), __pyx_v_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
3053 __Pyx_GOTREF(__pyx_t_3);
3054 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3);
3055 __pyx_t_3 = 0;
3056 }
3057 __pyx_L19:;
3058
3059 /* "clickhouse_driver/bufferedreader.pyx":163
3060 * &buffer_ptr[self.position], size
3061 * )
3062 * self.position = right # <<<<<<<<<<<<<<
3063 *
3064 * if c_encoding:
3065 */
3066 __pyx_v_self->position = __pyx_v_right;
3067 }
3068 __pyx_L14:;
3069
3070 /* "clickhouse_driver/bufferedreader.pyx":165
3071 * self.position = right
3072 *
3073 * if c_encoding: # <<<<<<<<<<<<<<
3074 * try:
3075 * rv = c_string[:size].decode(c_encoding)
3076 */
3077 __pyx_t_2 = (__pyx_v_c_encoding != 0);
3078 if (__pyx_t_2) {
3079
3080 /* "clickhouse_driver/bufferedreader.pyx":166
3081 *
3082 * if c_encoding:
3083 * try: # <<<<<<<<<<<<<<
3084 * rv = c_string[:size].decode(c_encoding)
3085 * except UnicodeDecodeError:
3086 */
3087 {
3088 __Pyx_PyThreadState_declare
3089 __Pyx_PyThreadState_assign
3090 __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
3091 __Pyx_XGOTREF(__pyx_t_12);
3092 __Pyx_XGOTREF(__pyx_t_13);
3093 __Pyx_XGOTREF(__pyx_t_14);
3094 /*try:*/ {
3095
3096 /* "clickhouse_driver/bufferedreader.pyx":167
3097 * if c_encoding:
3098 * try:
3099 * rv = c_string[:size].decode(c_encoding) # <<<<<<<<<<<<<<
3100 * except UnicodeDecodeError:
3101 * rv = PyBytes_FromStringAndSize(c_string, size)
3102 */
3103 __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_c_string, 0, __pyx_v_size, __pyx_v_c_encoding, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L21_error)
3104 __Pyx_GOTREF(__pyx_t_3);
3105 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_3);
3106 __pyx_t_3 = 0;
3107
3108 /* "clickhouse_driver/bufferedreader.pyx":166
3109 *
3110 * if c_encoding:
3111 * try: # <<<<<<<<<<<<<<
3112 * rv = c_string[:size].decode(c_encoding)
3113 * except UnicodeDecodeError:
3114 */
3115 }
3116 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
3117 __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
3118 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
3119 goto __pyx_L28_try_end;
3120 __pyx_L21_error:;
3121 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3122 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3123 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3124
3125 /* "clickhouse_driver/bufferedreader.pyx":168
3126 * try:
3127 * rv = c_string[:size].decode(c_encoding)
3128 * except UnicodeDecodeError: # <<<<<<<<<<<<<<
3129 * rv = PyBytes_FromStringAndSize(c_string, size)
3130 *
3131 */
3132 __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
3133 if (__pyx_t_15) {
3134 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3135 if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 168, __pyx_L23_except_error)
3136 __Pyx_GOTREF(__pyx_t_3);
3137 __Pyx_GOTREF(__pyx_t_1);
3138 __Pyx_GOTREF(__pyx_t_4);
3139
3140 /* "clickhouse_driver/bufferedreader.pyx":169
3141 * rv = c_string[:size].decode(c_encoding)
3142 * except UnicodeDecodeError:
3143 * rv = PyBytes_FromStringAndSize(c_string, size) # <<<<<<<<<<<<<<
3144 *
3145 * Py_INCREF(rv)
3146 */
3147 __pyx_t_16 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_size); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 169, __pyx_L23_except_error)
3148 __Pyx_GOTREF(__pyx_t_16);
3149 __Pyx_DECREF_SET(__pyx_v_rv, __pyx_t_16);
3150 __pyx_t_16 = 0;
3151 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3152 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3153 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3154 goto __pyx_L22_exception_handled;
3155 }
3156 goto __pyx_L23_except_error;
3157 __pyx_L23_except_error:;
3158
3159 /* "clickhouse_driver/bufferedreader.pyx":166
3160 *
3161 * if c_encoding:
3162 * try: # <<<<<<<<<<<<<<
3163 * rv = c_string[:size].decode(c_encoding)
3164 * except UnicodeDecodeError:
3165 */
3166 __Pyx_XGIVEREF(__pyx_t_12);
3167 __Pyx_XGIVEREF(__pyx_t_13);
3168 __Pyx_XGIVEREF(__pyx_t_14);
3169 __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
3170 goto __pyx_L1_error;
3171 __pyx_L22_exception_handled:;
3172 __Pyx_XGIVEREF(__pyx_t_12);
3173 __Pyx_XGIVEREF(__pyx_t_13);
3174 __Pyx_XGIVEREF(__pyx_t_14);
3175 __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
3176 __pyx_L28_try_end:;
3177 }
3178
3179 /* "clickhouse_driver/bufferedreader.pyx":165
3180 * self.position = right
3181 *
3182 * if c_encoding: # <<<<<<<<<<<<<<
3183 * try:
3184 * rv = c_string[:size].decode(c_encoding)
3185 */
3186 }
3187
3188 /* "clickhouse_driver/bufferedreader.pyx":171
3189 * rv = PyBytes_FromStringAndSize(c_string, size)
3190 *
3191 * Py_INCREF(rv) # <<<<<<<<<<<<<<
3192 * PyTuple_SET_ITEM(items, i, rv)
3193 *
3194 */
3195 Py_INCREF(__pyx_v_rv);
3196
3197 /* "clickhouse_driver/bufferedreader.pyx":172
3198 *
3199 * Py_INCREF(rv)
3200 * PyTuple_SET_ITEM(items, i, rv) # <<<<<<<<<<<<<<
3201 *
3202 * if c_string:
3203 */
3204 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_rv);
3205 }
3206
3207 /* "clickhouse_driver/bufferedreader.pyx":174
3208 * PyTuple_SET_ITEM(items, i, rv)
3209 *
3210 * if c_string: # <<<<<<<<<<<<<<
3211 * PyMem_Free(c_string)
3212 *
3213 */
3214 __pyx_t_2 = (__pyx_v_c_string != 0);
3215 if (__pyx_t_2) {
3216
3217 /* "clickhouse_driver/bufferedreader.pyx":175
3218 *
3219 * if c_string:
3220 * PyMem_Free(c_string) # <<<<<<<<<<<<<<
3221 *
3222 * return items
3223 */
3224 PyMem_Free(__pyx_v_c_string);
3225
3226 /* "clickhouse_driver/bufferedreader.pyx":174
3227 * PyTuple_SET_ITEM(items, i, rv)
3228 *
3229 * if c_string: # <<<<<<<<<<<<<<
3230 * PyMem_Free(c_string)
3231 *
3232 */
3233 }
3234
3235 /* "clickhouse_driver/bufferedreader.pyx":177
3236 * PyMem_Free(c_string)
3237 *
3238 * return items # <<<<<<<<<<<<<<
3239 *
3240 * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items,
3241 */
3242 __Pyx_XDECREF(__pyx_r);
3243 __Pyx_INCREF(__pyx_v_items);
3244 __pyx_r = __pyx_v_items;
3245 goto __pyx_L0;
3246
3247 /* "clickhouse_driver/bufferedreader.pyx":62
3248 * return rv
3249 *
3250 * def read_strings(self, unsigned long long n_items, encoding=None): # <<<<<<<<<<<<<<
3251 * """
3252 * Python has great overhead between function calls.
3253 */
3254
3255 /* function exit code */
3256 __pyx_L1_error:;
3257 __Pyx_XDECREF(__pyx_t_1);
3258 __Pyx_XDECREF(__pyx_t_3);
3259 __Pyx_XDECREF(__pyx_t_4);
3260 __Pyx_XDECREF(__pyx_t_16);
3261 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3262 __pyx_r = NULL;
3263 __pyx_L0:;
3264 __Pyx_XDECREF(__pyx_v_items);
3265 __Pyx_XDECREF(__pyx_v_rv);
3266 __Pyx_XDECREF(__pyx_v_encoding);
3267 __Pyx_XGIVEREF(__pyx_r);
3268 __Pyx_RefNannyFinishContext();
3269 return __pyx_r;
3270 }
3271
3272 /* "clickhouse_driver/bufferedreader.pyx":179
3273 * return items
3274 *
3275 * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, # <<<<<<<<<<<<<<
3276 * Py_ssize_t length):
3277 * cdef Py_ssize_t i
3278 */
3279
3280 /* Python wrapper */
3281 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_fixed_strings_as_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3282 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_fixed_strings_as_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3283 Py_ssize_t __pyx_v_n_items;
3284 Py_ssize_t __pyx_v_length;
3285 int __pyx_lineno = 0;
3286 const char *__pyx_filename = NULL;
3287 int __pyx_clineno = 0;
3288 PyObject *__pyx_r = 0;
3289 __Pyx_RefNannyDeclarations
3290 __Pyx_RefNannySetupContext("read_fixed_strings_as_bytes (wrapper)", 0);
3291 {
3292 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_items,&__pyx_n_s_length,0};
16903293 PyObject* values[2] = {0,0};
16913294 if (unlikely(__pyx_kwds)) {
16923295 Py_ssize_t kw_args;
17023305 kw_args = PyDict_Size(__pyx_kwds);
17033306 switch (pos_args) {
17043307 case 0:
1705 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
3308 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
17063309 else goto __pyx_L5_argtuple_error;
17073310 CYTHON_FALLTHROUGH;
17083311 case 1:
1709 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
3312 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_length)) != 0)) kw_args--;
17103313 else {
1711 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 20, __pyx_L3_error)
3314 __Pyx_RaiseArgtupleInvalid("read_fixed_strings_as_bytes", 1, 2, 2, 1); __PYX_ERR(0, 179, __pyx_L3_error)
17123315 }
17133316 }
17143317 if (unlikely(kw_args > 0)) {
1715 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 20, __pyx_L3_error)
3318 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_fixed_strings_as_bytes") < 0)) __PYX_ERR(0, 179, __pyx_L3_error)
17163319 }
17173320 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
17183321 goto __pyx_L5_argtuple_error;
17203323 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
17213324 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
17223325 }
1723 __pyx_v_self = values[0];
1724 __pyx_v_bufsize = values[1];
3326 __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 179, __pyx_L3_error)
3327 __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L3_error)
17253328 }
17263329 goto __pyx_L4_argument_unpacking_done;
17273330 __pyx_L5_argtuple_error:;
1728 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 20, __pyx_L3_error)
3331 __Pyx_RaiseArgtupleInvalid("read_fixed_strings_as_bytes", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 179, __pyx_L3_error)
17293332 __pyx_L3_error:;
1730 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3333 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
17313334 __Pyx_RefNannyFinishContext();
17323335 return NULL;
17333336 __pyx_L4_argument_unpacking_done:;
1734 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(__pyx_self, __pyx_v_self, __pyx_v_bufsize);
3337 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_fixed_strings_as_bytes(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_length);
17353338
17363339 /* function exit code */
17373340 __Pyx_RefNannyFinishContext();
17383341 return __pyx_r;
17393342 }
17403343
1741 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_bufsize) {
3344 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_10read_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length) {
3345 Py_ssize_t __pyx_v_i;
3346 PyObject *__pyx_v_data = NULL;
3347 char *__pyx_v_data_ptr;
3348 PyObject *__pyx_v_items = NULL;
3349 PyObject *__pyx_v_item = NULL;
17423350 PyObject *__pyx_r = NULL;
17433351 __Pyx_RefNannyDeclarations
17443352 PyObject *__pyx_t_1 = NULL;
17453353 PyObject *__pyx_t_2 = NULL;
17463354 PyObject *__pyx_t_3 = NULL;
1747 __Pyx_RefNannySetupContext("__init__", 0);
1748
1749 /* "clickhouse_driver/bufferedreader.pyx":21
1750 * class BufferedReader(object):
3355 PyObject *__pyx_t_4 = NULL;
3356 char *__pyx_t_5;
3357 Py_ssize_t __pyx_t_6;
3358 Py_ssize_t __pyx_t_7;
3359 Py_ssize_t __pyx_t_8;
3360 int __pyx_lineno = 0;
3361 const char *__pyx_filename = NULL;
3362 int __pyx_clineno = 0;
3363 __Pyx_RefNannySetupContext("read_fixed_strings_as_bytes", 0);
3364
3365 /* "clickhouse_driver/bufferedreader.pyx":182
3366 * Py_ssize_t length):
3367 * cdef Py_ssize_t i
3368 * data = self.read(length * n_items) # <<<<<<<<<<<<<<
3369 * cdef char* data_ptr = PyBytes_AsString(data)
3370 *
3371 */
3372 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error)
3373 __Pyx_GOTREF(__pyx_t_2);
3374 __pyx_t_3 = PyInt_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error)
3375 __Pyx_GOTREF(__pyx_t_3);
3376 __pyx_t_4 = NULL;
3377 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3378 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
3379 if (likely(__pyx_t_4)) {
3380 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3381 __Pyx_INCREF(__pyx_t_4);
3382 __Pyx_INCREF(function);
3383 __Pyx_DECREF_SET(__pyx_t_2, function);
3384 }
3385 }
3386 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
3387 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3388 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3389 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error)
3390 __Pyx_GOTREF(__pyx_t_1);
3391 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3392 __pyx_v_data = __pyx_t_1;
3393 __pyx_t_1 = 0;
3394
3395 /* "clickhouse_driver/bufferedreader.pyx":183
3396 * cdef Py_ssize_t i
3397 * data = self.read(length * n_items)
3398 * cdef char* data_ptr = PyBytes_AsString(data) # <<<<<<<<<<<<<<
3399 *
3400 * items = PyTuple_New(n_items)
3401 */
3402 __pyx_t_5 = PyBytes_AsString(__pyx_v_data); if (unlikely(__pyx_t_5 == ((char *)NULL))) __PYX_ERR(0, 183, __pyx_L1_error)
3403 __pyx_v_data_ptr = __pyx_t_5;
3404
3405 /* "clickhouse_driver/bufferedreader.pyx":185
3406 * cdef char* data_ptr = PyBytes_AsString(data)
3407 *
3408 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
3409 * for i in range(n_items):
3410 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3411 */
3412 __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 185, __pyx_L1_error)
3413 __Pyx_GOTREF(__pyx_t_1);
3414 __pyx_v_items = ((PyObject*)__pyx_t_1);
3415 __pyx_t_1 = 0;
3416
3417 /* "clickhouse_driver/bufferedreader.pyx":186
3418 *
3419 * items = PyTuple_New(n_items)
3420 * for i in range(n_items): # <<<<<<<<<<<<<<
3421 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3422 * Py_INCREF(item)
3423 */
3424 __pyx_t_6 = __pyx_v_n_items;
3425 __pyx_t_7 = __pyx_t_6;
3426 for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
3427 __pyx_v_i = __pyx_t_8;
3428
3429 /* "clickhouse_driver/bufferedreader.pyx":187
3430 * items = PyTuple_New(n_items)
3431 * for i in range(n_items):
3432 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) # <<<<<<<<<<<<<<
3433 * Py_INCREF(item)
3434 * PyTuple_SET_ITEM(items, i, item)
3435 */
3436 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
3437 __Pyx_GOTREF(__pyx_t_1);
3438 __Pyx_XDECREF_SET(__pyx_v_item, ((PyObject*)__pyx_t_1));
3439 __pyx_t_1 = 0;
3440
3441 /* "clickhouse_driver/bufferedreader.pyx":188
3442 * for i in range(n_items):
3443 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3444 * Py_INCREF(item) # <<<<<<<<<<<<<<
3445 * PyTuple_SET_ITEM(items, i, item)
3446 * return items
3447 */
3448 Py_INCREF(__pyx_v_item);
3449
3450 /* "clickhouse_driver/bufferedreader.pyx":189
3451 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3452 * Py_INCREF(item)
3453 * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<<
3454 * return items
3455 *
3456 */
3457 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item);
3458 }
3459
3460 /* "clickhouse_driver/bufferedreader.pyx":190
3461 * Py_INCREF(item)
3462 * PyTuple_SET_ITEM(items, i, item)
3463 * return items # <<<<<<<<<<<<<<
3464 *
3465 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length,
3466 */
3467 __Pyx_XDECREF(__pyx_r);
3468 __Pyx_INCREF(__pyx_v_items);
3469 __pyx_r = __pyx_v_items;
3470 goto __pyx_L0;
3471
3472 /* "clickhouse_driver/bufferedreader.pyx":179
3473 * return items
3474 *
3475 * def read_fixed_strings_as_bytes(self, Py_ssize_t n_items, # <<<<<<<<<<<<<<
3476 * Py_ssize_t length):
3477 * cdef Py_ssize_t i
3478 */
3479
3480 /* function exit code */
3481 __pyx_L1_error:;
3482 __Pyx_XDECREF(__pyx_t_1);
3483 __Pyx_XDECREF(__pyx_t_2);
3484 __Pyx_XDECREF(__pyx_t_3);
3485 __Pyx_XDECREF(__pyx_t_4);
3486 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
3487 __pyx_r = NULL;
3488 __pyx_L0:;
3489 __Pyx_XDECREF(__pyx_v_data);
3490 __Pyx_XDECREF(__pyx_v_items);
3491 __Pyx_XDECREF(__pyx_v_item);
3492 __Pyx_XGIVEREF(__pyx_r);
3493 __Pyx_RefNannyFinishContext();
3494 return __pyx_r;
3495 }
3496
3497 /* "clickhouse_driver/bufferedreader.pyx":192
3498 * return items
3499 *
3500 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<<
3501 * encoding=None):
3502 * if encoding is None:
3503 */
3504
3505 /* Python wrapper */
3506 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3507 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3508 Py_ssize_t __pyx_v_n_items;
3509 Py_ssize_t __pyx_v_length;
3510 PyObject *__pyx_v_encoding = 0;
3511 int __pyx_lineno = 0;
3512 const char *__pyx_filename = NULL;
3513 int __pyx_clineno = 0;
3514 PyObject *__pyx_r = 0;
3515 __Pyx_RefNannyDeclarations
3516 __Pyx_RefNannySetupContext("read_fixed_strings (wrapper)", 0);
3517 {
3518 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_n_items,&__pyx_n_s_length,&__pyx_n_s_encoding,0};
3519 PyObject* values[3] = {0,0,0};
3520
3521 /* "clickhouse_driver/bufferedreader.pyx":193
3522 *
3523 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length,
3524 * encoding=None): # <<<<<<<<<<<<<<
3525 * if encoding is None:
3526 * return self.read_fixed_strings_as_bytes(n_items, length)
3527 */
3528 values[2] = ((PyObject *)Py_None);
3529 if (unlikely(__pyx_kwds)) {
3530 Py_ssize_t kw_args;
3531 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3532 switch (pos_args) {
3533 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3534 CYTHON_FALLTHROUGH;
3535 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3536 CYTHON_FALLTHROUGH;
3537 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3538 CYTHON_FALLTHROUGH;
3539 case 0: break;
3540 default: goto __pyx_L5_argtuple_error;
3541 }
3542 kw_args = PyDict_Size(__pyx_kwds);
3543 switch (pos_args) {
3544 case 0:
3545 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
3546 else goto __pyx_L5_argtuple_error;
3547 CYTHON_FALLTHROUGH;
3548 case 1:
3549 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_length)) != 0)) kw_args--;
3550 else {
3551 __Pyx_RaiseArgtupleInvalid("read_fixed_strings", 0, 2, 3, 1); __PYX_ERR(0, 192, __pyx_L3_error)
3552 }
3553 CYTHON_FALLTHROUGH;
3554 case 2:
3555 if (kw_args > 0) {
3556 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoding);
3557 if (value) { values[2] = value; kw_args--; }
3558 }
3559 }
3560 if (unlikely(kw_args > 0)) {
3561 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_fixed_strings") < 0)) __PYX_ERR(0, 192, __pyx_L3_error)
3562 }
3563 } else {
3564 switch (PyTuple_GET_SIZE(__pyx_args)) {
3565 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3566 CYTHON_FALLTHROUGH;
3567 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3568 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3569 break;
3570 default: goto __pyx_L5_argtuple_error;
3571 }
3572 }
3573 __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L3_error)
3574 __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L3_error)
3575 __pyx_v_encoding = values[2];
3576 }
3577 goto __pyx_L4_argument_unpacking_done;
3578 __pyx_L5_argtuple_error:;
3579 __Pyx_RaiseArgtupleInvalid("read_fixed_strings", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 192, __pyx_L3_error)
3580 __pyx_L3_error:;
3581 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3582 __Pyx_RefNannyFinishContext();
3583 return NULL;
3584 __pyx_L4_argument_unpacking_done:;
3585 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), __pyx_v_n_items, __pyx_v_length, __pyx_v_encoding);
3586
3587 /* "clickhouse_driver/bufferedreader.pyx":192
3588 * return items
3589 *
3590 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<<
3591 * encoding=None):
3592 * if encoding is None:
3593 */
3594
3595 /* function exit code */
3596 __Pyx_RefNannyFinishContext();
3597 return __pyx_r;
3598 }
3599
3600 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_12read_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, Py_ssize_t __pyx_v_n_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding) {
3601 Py_ssize_t __pyx_v_i;
3602 Py_ssize_t __pyx_v_j;
3603 char *__pyx_v_c_encoding;
3604 PyObject *__pyx_v_data = NULL;
3605 char *__pyx_v_data_ptr;
3606 char *__pyx_v_c_string;
3607 PyObject *__pyx_v_items = NULL;
3608 PyObject *__pyx_v_item = NULL;
3609 PyObject *__pyx_r = NULL;
3610 __Pyx_RefNannyDeclarations
3611 int __pyx_t_1;
3612 int __pyx_t_2;
3613 PyObject *__pyx_t_3 = NULL;
3614 PyObject *__pyx_t_4 = NULL;
3615 PyObject *__pyx_t_5 = NULL;
3616 PyObject *__pyx_t_6 = NULL;
3617 PyObject *__pyx_t_7 = NULL;
3618 int __pyx_t_8;
3619 PyObject *__pyx_t_9 = NULL;
3620 char *__pyx_t_10;
3621 Py_ssize_t __pyx_t_11;
3622 Py_ssize_t __pyx_t_12;
3623 Py_ssize_t __pyx_t_13;
3624 PyObject *__pyx_t_14 = NULL;
3625 PyObject *__pyx_t_15 = NULL;
3626 PyObject *__pyx_t_16 = NULL;
3627 int __pyx_lineno = 0;
3628 const char *__pyx_filename = NULL;
3629 int __pyx_clineno = 0;
3630 __Pyx_RefNannySetupContext("read_fixed_strings", 0);
3631 __Pyx_INCREF(__pyx_v_encoding);
3632
3633 /* "clickhouse_driver/bufferedreader.pyx":194
3634 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length,
3635 * encoding=None):
3636 * if encoding is None: # <<<<<<<<<<<<<<
3637 * return self.read_fixed_strings_as_bytes(n_items, length)
3638 *
3639 */
3640 __pyx_t_1 = (__pyx_v_encoding == Py_None);
3641 __pyx_t_2 = (__pyx_t_1 != 0);
3642 if (__pyx_t_2) {
3643
3644 /* "clickhouse_driver/bufferedreader.pyx":195
3645 * encoding=None):
3646 * if encoding is None:
3647 * return self.read_fixed_strings_as_bytes(n_items, length) # <<<<<<<<<<<<<<
3648 *
3649 * cdef Py_ssize_t i, j
3650 */
3651 __Pyx_XDECREF(__pyx_r);
3652 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_fixed_strings_as_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 195, __pyx_L1_error)
3653 __Pyx_GOTREF(__pyx_t_4);
3654 __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_n_items); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 195, __pyx_L1_error)
3655 __Pyx_GOTREF(__pyx_t_5);
3656 __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 195, __pyx_L1_error)
3657 __Pyx_GOTREF(__pyx_t_6);
3658 __pyx_t_7 = NULL;
3659 __pyx_t_8 = 0;
3660 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
3661 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
3662 if (likely(__pyx_t_7)) {
3663 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3664 __Pyx_INCREF(__pyx_t_7);
3665 __Pyx_INCREF(function);
3666 __Pyx_DECREF_SET(__pyx_t_4, function);
3667 __pyx_t_8 = 1;
3668 }
3669 }
3670 #if CYTHON_FAST_PYCALL
3671 if (PyFunction_Check(__pyx_t_4)) {
3672 PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
3673 __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
3674 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3675 __Pyx_GOTREF(__pyx_t_3);
3676 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3677 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3678 } else
3679 #endif
3680 #if CYTHON_FAST_PYCCALL
3681 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
3682 PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_t_5, __pyx_t_6};
3683 __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
3684 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3685 __Pyx_GOTREF(__pyx_t_3);
3686 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3687 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3688 } else
3689 #endif
3690 {
3691 __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 195, __pyx_L1_error)
3692 __Pyx_GOTREF(__pyx_t_9);
3693 if (__pyx_t_7) {
3694 __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
3695 }
3696 __Pyx_GIVEREF(__pyx_t_5);
3697 PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5);
3698 __Pyx_GIVEREF(__pyx_t_6);
3699 PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_6);
3700 __pyx_t_5 = 0;
3701 __pyx_t_6 = 0;
3702 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
3703 __Pyx_GOTREF(__pyx_t_3);
3704 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3705 }
3706 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3707 __pyx_r = __pyx_t_3;
3708 __pyx_t_3 = 0;
3709 goto __pyx_L0;
3710
3711 /* "clickhouse_driver/bufferedreader.pyx":194
3712 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length,
3713 * encoding=None):
3714 * if encoding is None: # <<<<<<<<<<<<<<
3715 * return self.read_fixed_strings_as_bytes(n_items, length)
3716 *
3717 */
3718 }
3719
3720 /* "clickhouse_driver/bufferedreader.pyx":198
3721 *
3722 * cdef Py_ssize_t i, j
3723 * encoding = encoding.encode('utf-8') # <<<<<<<<<<<<<<
3724 * cdef char* c_encoding = encoding
3725 * data = self.read(length * n_items)
3726 */
3727 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_encoding, __pyx_n_s_encode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 198, __pyx_L1_error)
3728 __Pyx_GOTREF(__pyx_t_4);
3729 __pyx_t_9 = NULL;
3730 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
3731 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4);
3732 if (likely(__pyx_t_9)) {
3733 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3734 __Pyx_INCREF(__pyx_t_9);
3735 __Pyx_INCREF(function);
3736 __Pyx_DECREF_SET(__pyx_t_4, function);
3737 }
3738 }
3739 __pyx_t_3 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_9, __pyx_kp_u_utf_8) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_utf_8);
3740 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
3741 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 198, __pyx_L1_error)
3742 __Pyx_GOTREF(__pyx_t_3);
3743 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3744 __Pyx_DECREF_SET(__pyx_v_encoding, __pyx_t_3);
3745 __pyx_t_3 = 0;
3746
3747 /* "clickhouse_driver/bufferedreader.pyx":199
3748 * cdef Py_ssize_t i, j
3749 * encoding = encoding.encode('utf-8')
3750 * cdef char* c_encoding = encoding # <<<<<<<<<<<<<<
3751 * data = self.read(length * n_items)
3752 * cdef char* data_ptr = PyBytes_AsString(data)
3753 */
3754 __pyx_t_10 = __Pyx_PyObject_AsWritableString(__pyx_v_encoding); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) __PYX_ERR(0, 199, __pyx_L1_error)
3755 __pyx_v_c_encoding = __pyx_t_10;
3756
3757 /* "clickhouse_driver/bufferedreader.pyx":200
3758 * encoding = encoding.encode('utf-8')
3759 * cdef char* c_encoding = encoding
3760 * data = self.read(length * n_items) # <<<<<<<<<<<<<<
3761 * cdef char* data_ptr = PyBytes_AsString(data)
3762 *
3763 */
3764 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
3765 __Pyx_GOTREF(__pyx_t_4);
3766 __pyx_t_9 = PyInt_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 200, __pyx_L1_error)
3767 __Pyx_GOTREF(__pyx_t_9);
3768 __pyx_t_6 = NULL;
3769 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
3770 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
3771 if (likely(__pyx_t_6)) {
3772 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3773 __Pyx_INCREF(__pyx_t_6);
3774 __Pyx_INCREF(function);
3775 __Pyx_DECREF_SET(__pyx_t_4, function);
3776 }
3777 }
3778 __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_6, __pyx_t_9) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_9);
3779 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3780 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3781 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
3782 __Pyx_GOTREF(__pyx_t_3);
3783 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3784 __pyx_v_data = __pyx_t_3;
3785 __pyx_t_3 = 0;
3786
3787 /* "clickhouse_driver/bufferedreader.pyx":201
3788 * cdef char* c_encoding = encoding
3789 * data = self.read(length * n_items)
3790 * cdef char* data_ptr = PyBytes_AsString(data) # <<<<<<<<<<<<<<
3791 *
3792 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
3793 */
3794 __pyx_t_10 = PyBytes_AsString(__pyx_v_data); if (unlikely(__pyx_t_10 == ((char *)NULL))) __PYX_ERR(0, 201, __pyx_L1_error)
3795 __pyx_v_data_ptr = __pyx_t_10;
3796
3797 /* "clickhouse_driver/bufferedreader.pyx":203
3798 * cdef char* data_ptr = PyBytes_AsString(data)
3799 *
3800 * cdef char* c_string = <char *>PyMem_Malloc(length + 1) # <<<<<<<<<<<<<<
3801 * if not c_string:
3802 * raise MemoryError()
3803 */
3804 __pyx_v_c_string = ((char *)PyMem_Malloc((__pyx_v_length + 1)));
3805
3806 /* "clickhouse_driver/bufferedreader.pyx":204
3807 *
3808 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
3809 * if not c_string: # <<<<<<<<<<<<<<
3810 * raise MemoryError()
3811 * c_string[length] = 0
3812 */
3813 __pyx_t_2 = ((!(__pyx_v_c_string != 0)) != 0);
3814 if (unlikely(__pyx_t_2)) {
3815
3816 /* "clickhouse_driver/bufferedreader.pyx":205
3817 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
3818 * if not c_string:
3819 * raise MemoryError() # <<<<<<<<<<<<<<
3820 * c_string[length] = 0
3821 *
3822 */
3823 PyErr_NoMemory(); __PYX_ERR(0, 205, __pyx_L1_error)
3824
3825 /* "clickhouse_driver/bufferedreader.pyx":204
3826 *
3827 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
3828 * if not c_string: # <<<<<<<<<<<<<<
3829 * raise MemoryError()
3830 * c_string[length] = 0
3831 */
3832 }
3833
3834 /* "clickhouse_driver/bufferedreader.pyx":206
3835 * if not c_string:
3836 * raise MemoryError()
3837 * c_string[length] = 0 # <<<<<<<<<<<<<<
3838 *
3839 * items = PyTuple_New(n_items)
3840 */
3841 (__pyx_v_c_string[__pyx_v_length]) = 0;
3842
3843 /* "clickhouse_driver/bufferedreader.pyx":208
3844 * c_string[length] = 0
3845 *
3846 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
3847 * for i in range(n_items):
3848 * memcpy(c_string, &data_ptr[i * length], length)
3849 */
3850 __pyx_t_3 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 208, __pyx_L1_error)
3851 __Pyx_GOTREF(__pyx_t_3);
3852 __pyx_v_items = ((PyObject*)__pyx_t_3);
3853 __pyx_t_3 = 0;
3854
3855 /* "clickhouse_driver/bufferedreader.pyx":209
3856 *
3857 * items = PyTuple_New(n_items)
3858 * for i in range(n_items): # <<<<<<<<<<<<<<
3859 * memcpy(c_string, &data_ptr[i * length], length)
3860 *
3861 */
3862 __pyx_t_11 = __pyx_v_n_items;
3863 __pyx_t_12 = __pyx_t_11;
3864 for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13+=1) {
3865 __pyx_v_i = __pyx_t_13;
3866
3867 /* "clickhouse_driver/bufferedreader.pyx":210
3868 * items = PyTuple_New(n_items)
3869 * for i in range(n_items):
3870 * memcpy(c_string, &data_ptr[i * length], length) # <<<<<<<<<<<<<<
3871 *
3872 * # Get last non zero byte of string from the end.
3873 */
3874 (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length));
3875
3876 /* "clickhouse_driver/bufferedreader.pyx":213
3877 *
3878 * # Get last non zero byte of string from the end.
3879 * j = length - 1 # <<<<<<<<<<<<<<
3880 * while j >= 0 and not c_string[j]:
3881 * j -= 1
3882 */
3883 __pyx_v_j = (__pyx_v_length - 1);
3884
3885 /* "clickhouse_driver/bufferedreader.pyx":214
3886 * # Get last non zero byte of string from the end.
3887 * j = length - 1
3888 * while j >= 0 and not c_string[j]: # <<<<<<<<<<<<<<
3889 * j -= 1
3890 *
3891 */
3892 while (1) {
3893 __pyx_t_1 = ((__pyx_v_j >= 0) != 0);
3894 if (__pyx_t_1) {
3895 } else {
3896 __pyx_t_2 = __pyx_t_1;
3897 goto __pyx_L9_bool_binop_done;
3898 }
3899 __pyx_t_1 = ((!((__pyx_v_c_string[__pyx_v_j]) != 0)) != 0);
3900 __pyx_t_2 = __pyx_t_1;
3901 __pyx_L9_bool_binop_done:;
3902 if (!__pyx_t_2) break;
3903
3904 /* "clickhouse_driver/bufferedreader.pyx":215
3905 * j = length - 1
3906 * while j >= 0 and not c_string[j]:
3907 * j -= 1 # <<<<<<<<<<<<<<
3908 *
3909 * try:
3910 */
3911 __pyx_v_j = (__pyx_v_j - 1);
3912 }
3913
3914 /* "clickhouse_driver/bufferedreader.pyx":217
3915 * j -= 1
3916 *
3917 * try: # <<<<<<<<<<<<<<
3918 * item = c_string[:j + 1].decode(c_encoding)
3919 * except UnicodeDecodeError:
3920 */
3921 {
3922 __Pyx_PyThreadState_declare
3923 __Pyx_PyThreadState_assign
3924 __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
3925 __Pyx_XGOTREF(__pyx_t_14);
3926 __Pyx_XGOTREF(__pyx_t_15);
3927 __Pyx_XGOTREF(__pyx_t_16);
3928 /*try:*/ {
3929
3930 /* "clickhouse_driver/bufferedreader.pyx":218
3931 *
3932 * try:
3933 * item = c_string[:j + 1].decode(c_encoding) # <<<<<<<<<<<<<<
3934 * except UnicodeDecodeError:
3935 * item = PyBytes_FromStringAndSize(c_string, length)
3936 */
3937 __pyx_t_3 = __Pyx_decode_c_string(__pyx_v_c_string, 0, (__pyx_v_j + 1), __pyx_v_c_encoding, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 218, __pyx_L11_error)
3938 __Pyx_GOTREF(__pyx_t_3);
3939 __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_3);
3940 __pyx_t_3 = 0;
3941
3942 /* "clickhouse_driver/bufferedreader.pyx":217
3943 * j -= 1
3944 *
3945 * try: # <<<<<<<<<<<<<<
3946 * item = c_string[:j + 1].decode(c_encoding)
3947 * except UnicodeDecodeError:
3948 */
3949 }
3950 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
3951 __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
3952 __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
3953 goto __pyx_L18_try_end;
3954 __pyx_L11_error:;
3955 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3956 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3957 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3958 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3959 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3960 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
3961
3962 /* "clickhouse_driver/bufferedreader.pyx":219
3963 * try:
3964 * item = c_string[:j + 1].decode(c_encoding)
3965 * except UnicodeDecodeError: # <<<<<<<<<<<<<<
3966 * item = PyBytes_FromStringAndSize(c_string, length)
3967 * Py_INCREF(item)
3968 */
3969 __pyx_t_8 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
3970 if (__pyx_t_8) {
3971 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3972 if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_9) < 0) __PYX_ERR(0, 219, __pyx_L13_except_error)
3973 __Pyx_GOTREF(__pyx_t_3);
3974 __Pyx_GOTREF(__pyx_t_4);
3975 __Pyx_GOTREF(__pyx_t_9);
3976
3977 /* "clickhouse_driver/bufferedreader.pyx":220
3978 * item = c_string[:j + 1].decode(c_encoding)
3979 * except UnicodeDecodeError:
3980 * item = PyBytes_FromStringAndSize(c_string, length) # <<<<<<<<<<<<<<
3981 * Py_INCREF(item)
3982 * PyTuple_SET_ITEM(items, i, item)
3983 */
3984 __pyx_t_6 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_length); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 220, __pyx_L13_except_error)
3985 __Pyx_GOTREF(__pyx_t_6);
3986 __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6);
3987 __pyx_t_6 = 0;
3988 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3989 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3990 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
3991 goto __pyx_L12_exception_handled;
3992 }
3993 goto __pyx_L13_except_error;
3994 __pyx_L13_except_error:;
3995
3996 /* "clickhouse_driver/bufferedreader.pyx":217
3997 * j -= 1
3998 *
3999 * try: # <<<<<<<<<<<<<<
4000 * item = c_string[:j + 1].decode(c_encoding)
4001 * except UnicodeDecodeError:
4002 */
4003 __Pyx_XGIVEREF(__pyx_t_14);
4004 __Pyx_XGIVEREF(__pyx_t_15);
4005 __Pyx_XGIVEREF(__pyx_t_16);
4006 __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
4007 goto __pyx_L1_error;
4008 __pyx_L12_exception_handled:;
4009 __Pyx_XGIVEREF(__pyx_t_14);
4010 __Pyx_XGIVEREF(__pyx_t_15);
4011 __Pyx_XGIVEREF(__pyx_t_16);
4012 __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
4013 __pyx_L18_try_end:;
4014 }
4015
4016 /* "clickhouse_driver/bufferedreader.pyx":221
4017 * except UnicodeDecodeError:
4018 * item = PyBytes_FromStringAndSize(c_string, length)
4019 * Py_INCREF(item) # <<<<<<<<<<<<<<
4020 * PyTuple_SET_ITEM(items, i, item)
4021 *
4022 */
4023 Py_INCREF(__pyx_v_item);
4024
4025 /* "clickhouse_driver/bufferedreader.pyx":222
4026 * item = PyBytes_FromStringAndSize(c_string, length)
4027 * Py_INCREF(item)
4028 * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<<
4029 *
4030 * PyMem_Free(c_string)
4031 */
4032 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item);
4033 }
4034
4035 /* "clickhouse_driver/bufferedreader.pyx":224
4036 * PyTuple_SET_ITEM(items, i, item)
4037 *
4038 * PyMem_Free(c_string) # <<<<<<<<<<<<<<
4039 *
4040 * return items
4041 */
4042 PyMem_Free(__pyx_v_c_string);
4043
4044 /* "clickhouse_driver/bufferedreader.pyx":226
4045 * PyMem_Free(c_string)
4046 *
4047 * return items # <<<<<<<<<<<<<<
4048 *
4049 *
4050 */
4051 __Pyx_XDECREF(__pyx_r);
4052 __Pyx_INCREF(__pyx_v_items);
4053 __pyx_r = __pyx_v_items;
4054 goto __pyx_L0;
4055
4056 /* "clickhouse_driver/bufferedreader.pyx":192
4057 * return items
4058 *
4059 * def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length, # <<<<<<<<<<<<<<
4060 * encoding=None):
4061 * if encoding is None:
4062 */
4063
4064 /* function exit code */
4065 __pyx_L1_error:;
4066 __Pyx_XDECREF(__pyx_t_3);
4067 __Pyx_XDECREF(__pyx_t_4);
4068 __Pyx_XDECREF(__pyx_t_5);
4069 __Pyx_XDECREF(__pyx_t_6);
4070 __Pyx_XDECREF(__pyx_t_7);
4071 __Pyx_XDECREF(__pyx_t_9);
4072 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
4073 __pyx_r = NULL;
4074 __pyx_L0:;
4075 __Pyx_XDECREF(__pyx_v_data);
4076 __Pyx_XDECREF(__pyx_v_items);
4077 __Pyx_XDECREF(__pyx_v_item);
4078 __Pyx_XDECREF(__pyx_v_encoding);
4079 __Pyx_XGIVEREF(__pyx_r);
4080 __Pyx_RefNannyFinishContext();
4081 return __pyx_r;
4082 }
4083
4084 /* "clickhouse_driver/bufferedreader.pyx":11
4085 *
4086 * cdef class BufferedReader(object):
4087 * cdef public unsigned long long position, current_buffer_size # <<<<<<<<<<<<<<
4088 * cdef public bytearray buffer
4089 *
4090 */
4091
4092 /* Python wrapper */
4093 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(PyObject *__pyx_v_self); /*proto*/
4094 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(PyObject *__pyx_v_self) {
4095 PyObject *__pyx_r = 0;
4096 __Pyx_RefNannyDeclarations
4097 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4098 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
4099
4100 /* function exit code */
4101 __Pyx_RefNannyFinishContext();
4102 return __pyx_r;
4103 }
4104
4105 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
4106 PyObject *__pyx_r = NULL;
4107 __Pyx_RefNannyDeclarations
4108 PyObject *__pyx_t_1 = NULL;
4109 int __pyx_lineno = 0;
4110 const char *__pyx_filename = NULL;
4111 int __pyx_clineno = 0;
4112 __Pyx_RefNannySetupContext("__get__", 0);
4113 __Pyx_XDECREF(__pyx_r);
4114 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
4115 __Pyx_GOTREF(__pyx_t_1);
4116 __pyx_r = __pyx_t_1;
4117 __pyx_t_1 = 0;
4118 goto __pyx_L0;
4119
4120 /* function exit code */
4121 __pyx_L1_error:;
4122 __Pyx_XDECREF(__pyx_t_1);
4123 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.position.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4124 __pyx_r = NULL;
4125 __pyx_L0:;
4126 __Pyx_XGIVEREF(__pyx_r);
4127 __Pyx_RefNannyFinishContext();
4128 return __pyx_r;
4129 }
4130
4131 /* Python wrapper */
4132 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
4133 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4134 int __pyx_r;
4135 __Pyx_RefNannyDeclarations
4136 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4137 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4138
4139 /* function exit code */
4140 __Pyx_RefNannyFinishContext();
4141 return __pyx_r;
4142 }
4143
4144 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) {
4145 int __pyx_r;
4146 __Pyx_RefNannyDeclarations
4147 unsigned PY_LONG_LONG __pyx_t_1;
4148 int __pyx_lineno = 0;
4149 const char *__pyx_filename = NULL;
4150 int __pyx_clineno = 0;
4151 __Pyx_RefNannySetupContext("__set__", 0);
4152 __pyx_t_1 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)
4153 __pyx_v_self->position = __pyx_t_1;
4154
4155 /* function exit code */
4156 __pyx_r = 0;
4157 goto __pyx_L0;
4158 __pyx_L1_error:;
4159 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.position.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4160 __pyx_r = -1;
4161 __pyx_L0:;
4162 __Pyx_RefNannyFinishContext();
4163 return __pyx_r;
4164 }
4165
4166 /* Python wrapper */
4167 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(PyObject *__pyx_v_self); /*proto*/
4168 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(PyObject *__pyx_v_self) {
4169 PyObject *__pyx_r = 0;
4170 __Pyx_RefNannyDeclarations
4171 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4172 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
4173
4174 /* function exit code */
4175 __Pyx_RefNannyFinishContext();
4176 return __pyx_r;
4177 }
4178
4179 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
4180 PyObject *__pyx_r = NULL;
4181 __Pyx_RefNannyDeclarations
4182 PyObject *__pyx_t_1 = NULL;
4183 int __pyx_lineno = 0;
4184 const char *__pyx_filename = NULL;
4185 int __pyx_clineno = 0;
4186 __Pyx_RefNannySetupContext("__get__", 0);
4187 __Pyx_XDECREF(__pyx_r);
4188 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
4189 __Pyx_GOTREF(__pyx_t_1);
4190 __pyx_r = __pyx_t_1;
4191 __pyx_t_1 = 0;
4192 goto __pyx_L0;
4193
4194 /* function exit code */
4195 __pyx_L1_error:;
4196 __Pyx_XDECREF(__pyx_t_1);
4197 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.current_buffer_size.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4198 __pyx_r = NULL;
4199 __pyx_L0:;
4200 __Pyx_XGIVEREF(__pyx_r);
4201 __Pyx_RefNannyFinishContext();
4202 return __pyx_r;
4203 }
4204
4205 /* Python wrapper */
4206 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
4207 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4208 int __pyx_r;
4209 __Pyx_RefNannyDeclarations
4210 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4211 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4212
4213 /* function exit code */
4214 __Pyx_RefNannyFinishContext();
4215 return __pyx_r;
4216 }
4217
4218 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) {
4219 int __pyx_r;
4220 __Pyx_RefNannyDeclarations
4221 unsigned PY_LONG_LONG __pyx_t_1;
4222 int __pyx_lineno = 0;
4223 const char *__pyx_filename = NULL;
4224 int __pyx_clineno = 0;
4225 __Pyx_RefNannySetupContext("__set__", 0);
4226 __pyx_t_1 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 11, __pyx_L1_error)
4227 __pyx_v_self->current_buffer_size = __pyx_t_1;
4228
4229 /* function exit code */
4230 __pyx_r = 0;
4231 goto __pyx_L0;
4232 __pyx_L1_error:;
4233 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.current_buffer_size.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4234 __pyx_r = -1;
4235 __pyx_L0:;
4236 __Pyx_RefNannyFinishContext();
4237 return __pyx_r;
4238 }
4239
4240 /* "clickhouse_driver/bufferedreader.pyx":12
4241 * cdef class BufferedReader(object):
4242 * cdef public unsigned long long position, current_buffer_size
4243 * cdef public bytearray buffer # <<<<<<<<<<<<<<
4244 *
17514245 * def __init__(self, bufsize):
1752 * self.buffer = bytearray(bufsize) # <<<<<<<<<<<<<<
1753 *
1754 * self.position = 0
1755 */
1756 __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_bufsize); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
4246 */
4247
4248 /* Python wrapper */
4249 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(PyObject *__pyx_v_self); /*proto*/
4250 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(PyObject *__pyx_v_self) {
4251 PyObject *__pyx_r = 0;
4252 __Pyx_RefNannyDeclarations
4253 __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
4254 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
4255
4256 /* function exit code */
4257 __Pyx_RefNannyFinishContext();
4258 return __pyx_r;
4259 }
4260
4261 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer___get__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
4262 PyObject *__pyx_r = NULL;
4263 __Pyx_RefNannyDeclarations
4264 __Pyx_RefNannySetupContext("__get__", 0);
4265 __Pyx_XDECREF(__pyx_r);
4266 __Pyx_INCREF(__pyx_v_self->buffer);
4267 __pyx_r = __pyx_v_self->buffer;
4268 goto __pyx_L0;
4269
4270 /* function exit code */
4271 __pyx_L0:;
4272 __Pyx_XGIVEREF(__pyx_r);
4273 __Pyx_RefNannyFinishContext();
4274 return __pyx_r;
4275 }
4276
4277 /* Python wrapper */
4278 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
4279 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
4280 int __pyx_r;
4281 __Pyx_RefNannyDeclarations
4282 __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
4283 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v_value));
4284
4285 /* function exit code */
4286 __Pyx_RefNannyFinishContext();
4287 return __pyx_r;
4288 }
4289
4290 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_2__set__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v_value) {
4291 int __pyx_r;
4292 __Pyx_RefNannyDeclarations
4293 PyObject *__pyx_t_1 = NULL;
4294 int __pyx_lineno = 0;
4295 const char *__pyx_filename = NULL;
4296 int __pyx_clineno = 0;
4297 __Pyx_RefNannySetupContext("__set__", 0);
4298 if (!(likely(PyByteArray_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_v_value)->tp_name), 0))) __PYX_ERR(0, 12, __pyx_L1_error)
4299 __pyx_t_1 = __pyx_v_value;
4300 __Pyx_INCREF(__pyx_t_1);
4301 __Pyx_GIVEREF(__pyx_t_1);
4302 __Pyx_GOTREF(__pyx_v_self->buffer);
4303 __Pyx_DECREF(__pyx_v_self->buffer);
4304 __pyx_v_self->buffer = ((PyObject*)__pyx_t_1);
4305 __pyx_t_1 = 0;
4306
4307 /* function exit code */
4308 __pyx_r = 0;
4309 goto __pyx_L0;
4310 __pyx_L1_error:;
4311 __Pyx_XDECREF(__pyx_t_1);
4312 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.buffer.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4313 __pyx_r = -1;
4314 __pyx_L0:;
4315 __Pyx_RefNannyFinishContext();
4316 return __pyx_r;
4317 }
4318
4319 /* Python wrapper */
4320 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(PyObject *__pyx_v_self); /*proto*/
4321 static int __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(PyObject *__pyx_v_self) {
4322 int __pyx_r;
4323 __Pyx_RefNannyDeclarations
4324 __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
4325 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
4326
4327 /* function exit code */
4328 __Pyx_RefNannyFinishContext();
4329 return __pyx_r;
4330 }
4331
4332 static int __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_4__del__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
4333 int __pyx_r;
4334 __Pyx_RefNannyDeclarations
4335 __Pyx_RefNannySetupContext("__del__", 0);
4336 __Pyx_INCREF(Py_None);
4337 __Pyx_GIVEREF(Py_None);
4338 __Pyx_GOTREF(__pyx_v_self->buffer);
4339 __Pyx_DECREF(__pyx_v_self->buffer);
4340 __pyx_v_self->buffer = ((PyObject*)Py_None);
4341
4342 /* function exit code */
4343 __pyx_r = 0;
4344 __Pyx_RefNannyFinishContext();
4345 return __pyx_r;
4346 }
4347
4348 /* "(tree fragment)":1
4349 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
4350 * cdef tuple state
4351 * cdef object _dict
4352 */
4353
4354 /* Python wrapper */
4355 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4356 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4357 PyObject *__pyx_r = 0;
4358 __Pyx_RefNannyDeclarations
4359 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
4360 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self));
4361
4362 /* function exit code */
4363 __Pyx_RefNannyFinishContext();
4364 return __pyx_r;
4365 }
4366
4367 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_14__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self) {
4368 PyObject *__pyx_v_state = 0;
4369 PyObject *__pyx_v__dict = 0;
4370 int __pyx_v_use_setstate;
4371 PyObject *__pyx_r = NULL;
4372 __Pyx_RefNannyDeclarations
4373 PyObject *__pyx_t_1 = NULL;
4374 PyObject *__pyx_t_2 = NULL;
4375 PyObject *__pyx_t_3 = NULL;
4376 int __pyx_t_4;
4377 int __pyx_t_5;
4378 int __pyx_lineno = 0;
4379 const char *__pyx_filename = NULL;
4380 int __pyx_clineno = 0;
4381 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
4382
4383 /* "(tree fragment)":5
4384 * cdef object _dict
4385 * cdef bint use_setstate
4386 * state = (self.buffer, self.current_buffer_size, self.position) # <<<<<<<<<<<<<<
4387 * _dict = getattr(self, '__dict__', None)
4388 * if _dict is not None:
4389 */
4390 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
17574391 __Pyx_GOTREF(__pyx_t_1);
1758 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_buffer, __pyx_t_1) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
4392 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
4393 __Pyx_GOTREF(__pyx_t_2);
4394 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
4395 __Pyx_GOTREF(__pyx_t_3);
4396 __Pyx_INCREF(__pyx_v_self->buffer);
4397 __Pyx_GIVEREF(__pyx_v_self->buffer);
4398 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->buffer);
4399 __Pyx_GIVEREF(__pyx_t_1);
4400 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
4401 __Pyx_GIVEREF(__pyx_t_2);
4402 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
4403 __pyx_t_1 = 0;
4404 __pyx_t_2 = 0;
4405 __pyx_v_state = ((PyObject*)__pyx_t_3);
4406 __pyx_t_3 = 0;
4407
4408 /* "(tree fragment)":6
4409 * cdef bint use_setstate
4410 * state = (self.buffer, self.current_buffer_size, self.position)
4411 * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
4412 * if _dict is not None:
4413 * state += (_dict,)
4414 */
4415 __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
4416 __Pyx_GOTREF(__pyx_t_3);
4417 __pyx_v__dict = __pyx_t_3;
4418 __pyx_t_3 = 0;
4419
4420 /* "(tree fragment)":7
4421 * state = (self.buffer, self.current_buffer_size, self.position)
4422 * _dict = getattr(self, '__dict__', None)
4423 * if _dict is not None: # <<<<<<<<<<<<<<
4424 * state += (_dict,)
4425 * use_setstate = True
4426 */
4427 __pyx_t_4 = (__pyx_v__dict != Py_None);
4428 __pyx_t_5 = (__pyx_t_4 != 0);
4429 if (__pyx_t_5) {
4430
4431 /* "(tree fragment)":8
4432 * _dict = getattr(self, '__dict__', None)
4433 * if _dict is not None:
4434 * state += (_dict,) # <<<<<<<<<<<<<<
4435 * use_setstate = True
4436 * else:
4437 */
4438 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
4439 __Pyx_GOTREF(__pyx_t_3);
4440 __Pyx_INCREF(__pyx_v__dict);
4441 __Pyx_GIVEREF(__pyx_v__dict);
4442 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
4443 __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
4444 __Pyx_GOTREF(__pyx_t_2);
4445 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4446 __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
4447 __pyx_t_2 = 0;
4448
4449 /* "(tree fragment)":9
4450 * if _dict is not None:
4451 * state += (_dict,)
4452 * use_setstate = True # <<<<<<<<<<<<<<
4453 * else:
4454 * use_setstate = self.buffer is not None
4455 */
4456 __pyx_v_use_setstate = 1;
4457
4458 /* "(tree fragment)":7
4459 * state = (self.buffer, self.current_buffer_size, self.position)
4460 * _dict = getattr(self, '__dict__', None)
4461 * if _dict is not None: # <<<<<<<<<<<<<<
4462 * state += (_dict,)
4463 * use_setstate = True
4464 */
4465 goto __pyx_L3;
4466 }
4467
4468 /* "(tree fragment)":11
4469 * use_setstate = True
4470 * else:
4471 * use_setstate = self.buffer is not None # <<<<<<<<<<<<<<
4472 * if use_setstate:
4473 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, None), state
4474 */
4475 /*else*/ {
4476 __pyx_t_5 = (__pyx_v_self->buffer != ((PyObject*)Py_None));
4477 __pyx_v_use_setstate = __pyx_t_5;
4478 }
4479 __pyx_L3:;
4480
4481 /* "(tree fragment)":12
4482 * else:
4483 * use_setstate = self.buffer is not None
4484 * if use_setstate: # <<<<<<<<<<<<<<
4485 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, None), state
4486 * else:
4487 */
4488 __pyx_t_5 = (__pyx_v_use_setstate != 0);
4489 if (__pyx_t_5) {
4490
4491 /* "(tree fragment)":13
4492 * use_setstate = self.buffer is not None
4493 * if use_setstate:
4494 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, None), state # <<<<<<<<<<<<<<
4495 * else:
4496 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, state)
4497 */
4498 __Pyx_XDECREF(__pyx_r);
4499 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_BufferedReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
4500 __Pyx_GOTREF(__pyx_t_2);
4501 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
4502 __Pyx_GOTREF(__pyx_t_3);
4503 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4504 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4505 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4506 __Pyx_INCREF(__pyx_int_44607813);
4507 __Pyx_GIVEREF(__pyx_int_44607813);
4508 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_44607813);
4509 __Pyx_INCREF(Py_None);
4510 __Pyx_GIVEREF(Py_None);
4511 PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
4512 __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
4513 __Pyx_GOTREF(__pyx_t_1);
4514 __Pyx_GIVEREF(__pyx_t_2);
4515 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
4516 __Pyx_GIVEREF(__pyx_t_3);
4517 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
4518 __Pyx_INCREF(__pyx_v_state);
4519 __Pyx_GIVEREF(__pyx_v_state);
4520 PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
4521 __pyx_t_2 = 0;
4522 __pyx_t_3 = 0;
4523 __pyx_r = __pyx_t_1;
4524 __pyx_t_1 = 0;
4525 goto __pyx_L0;
4526
4527 /* "(tree fragment)":12
4528 * else:
4529 * use_setstate = self.buffer is not None
4530 * if use_setstate: # <<<<<<<<<<<<<<
4531 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, None), state
4532 * else:
4533 */
4534 }
4535
4536 /* "(tree fragment)":15
4537 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, None), state
4538 * else:
4539 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, state) # <<<<<<<<<<<<<<
4540 * def __setstate_cython__(self, __pyx_state):
4541 * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state)
4542 */
4543 /*else*/ {
4544 __Pyx_XDECREF(__pyx_r);
4545 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_BufferedReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
4546 __Pyx_GOTREF(__pyx_t_1);
4547 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
4548 __Pyx_GOTREF(__pyx_t_3);
4549 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4550 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4551 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
4552 __Pyx_INCREF(__pyx_int_44607813);
4553 __Pyx_GIVEREF(__pyx_int_44607813);
4554 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_44607813);
4555 __Pyx_INCREF(__pyx_v_state);
4556 __Pyx_GIVEREF(__pyx_v_state);
4557 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
4558 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
4559 __Pyx_GOTREF(__pyx_t_2);
4560 __Pyx_GIVEREF(__pyx_t_1);
4561 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4562 __Pyx_GIVEREF(__pyx_t_3);
4563 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
4564 __pyx_t_1 = 0;
4565 __pyx_t_3 = 0;
4566 __pyx_r = __pyx_t_2;
4567 __pyx_t_2 = 0;
4568 goto __pyx_L0;
4569 }
4570
4571 /* "(tree fragment)":1
4572 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
4573 * cdef tuple state
4574 * cdef object _dict
4575 */
4576
4577 /* function exit code */
4578 __pyx_L1_error:;
4579 __Pyx_XDECREF(__pyx_t_1);
4580 __Pyx_XDECREF(__pyx_t_2);
4581 __Pyx_XDECREF(__pyx_t_3);
4582 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4583 __pyx_r = NULL;
4584 __pyx_L0:;
4585 __Pyx_XDECREF(__pyx_v_state);
4586 __Pyx_XDECREF(__pyx_v__dict);
4587 __Pyx_XGIVEREF(__pyx_r);
4588 __Pyx_RefNannyFinishContext();
4589 return __pyx_r;
4590 }
4591
4592 /* "(tree fragment)":16
4593 * else:
4594 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, state)
4595 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
4596 * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state)
4597 */
4598
4599 /* Python wrapper */
4600 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
4601 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
4602 PyObject *__pyx_r = 0;
4603 __Pyx_RefNannyDeclarations
4604 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
4605 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
4606
4607 /* function exit code */
4608 __Pyx_RefNannyFinishContext();
4609 return __pyx_r;
4610 }
4611
4612 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_16__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
4613 PyObject *__pyx_r = NULL;
4614 __Pyx_RefNannyDeclarations
4615 PyObject *__pyx_t_1 = NULL;
4616 int __pyx_lineno = 0;
4617 const char *__pyx_filename = NULL;
4618 int __pyx_clineno = 0;
4619 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
4620
4621 /* "(tree fragment)":17
4622 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, state)
4623 * def __setstate_cython__(self, __pyx_state):
4624 * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
4625 */
4626 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
4627 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
4628 __Pyx_GOTREF(__pyx_t_1);
17594629 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17604630
1761 /* "clickhouse_driver/bufferedreader.pyx":23
1762 * self.buffer = bytearray(bufsize)
1763 *
1764 * self.position = 0 # <<<<<<<<<<<<<<
1765 * self.current_buffer_size = 0
1766 *
1767 */
1768 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_int_0) < 0) __PYX_ERR(0, 23, __pyx_L1_error)
1769
1770 /* "clickhouse_driver/bufferedreader.pyx":24
1771 *
1772 * self.position = 0
1773 * self.current_buffer_size = 0 # <<<<<<<<<<<<<<
1774 *
1775 * super(BufferedReader, self).__init__()
1776 */
1777 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size, __pyx_int_0) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
1778
1779 /* "clickhouse_driver/bufferedreader.pyx":26
1780 * self.current_buffer_size = 0
1781 *
1782 * super(BufferedReader, self).__init__() # <<<<<<<<<<<<<<
1783 *
1784 * def read_into_buffer(self):
1785 */
1786 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BufferedReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
1787 __Pyx_GOTREF(__pyx_t_2);
1788 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1789 __Pyx_GOTREF(__pyx_t_3);
1790 __Pyx_GIVEREF(__pyx_t_2);
1791 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
1792 __Pyx_INCREF(__pyx_v_self);
1793 __Pyx_GIVEREF(__pyx_v_self);
1794 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
1795 __pyx_t_2 = 0;
1796 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
1797 __Pyx_GOTREF(__pyx_t_2);
1798 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1799 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1800 __Pyx_GOTREF(__pyx_t_3);
1801 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1802 __pyx_t_2 = NULL;
1803 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
1804 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
1805 if (likely(__pyx_t_2)) {
1806 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1807 __Pyx_INCREF(__pyx_t_2);
1808 __Pyx_INCREF(function);
1809 __Pyx_DECREF_SET(__pyx_t_3, function);
1810 }
1811 }
1812 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
1813 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
1814 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
1815 __Pyx_GOTREF(__pyx_t_1);
1816 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1817 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1818
1819 /* "clickhouse_driver/bufferedreader.pyx":20
1820 *
1821 * class BufferedReader(object):
1822 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
1823 * self.buffer = bytearray(bufsize)
1824 *
4631 /* "(tree fragment)":16
4632 * else:
4633 * return __pyx_unpickle_BufferedReader, (type(self), 0x2a8a945, state)
4634 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
4635 * __pyx_unpickle_BufferedReader__set_state(self, __pyx_state)
18254636 */
18264637
18274638 /* function exit code */
18294640 goto __pyx_L0;
18304641 __pyx_L1_error:;
18314642 __Pyx_XDECREF(__pyx_t_1);
1832 __Pyx_XDECREF(__pyx_t_2);
1833 __Pyx_XDECREF(__pyx_t_3);
1834 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4643 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
18354644 __pyx_r = NULL;
18364645 __pyx_L0:;
18374646 __Pyx_XGIVEREF(__pyx_r);
18394648 return __pyx_r;
18404649 }
18414650
1842 /* "clickhouse_driver/bufferedreader.pyx":28
1843 * super(BufferedReader, self).__init__()
1844 *
1845 * def read_into_buffer(self): # <<<<<<<<<<<<<<
1846 * raise NotImplementedError
1847 *
4651 /* "clickhouse_driver/bufferedreader.pyx":232
4652 * cdef object sock
4653 *
4654 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
4655 * self.sock = sock
4656 * super(BufferedSocketReader, self).__init__(bufsize)
18484657 */
18494658
18504659 /* Python wrapper */
1851 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
1852 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, METH_O, 0};
1853 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self) {
1854 PyObject *__pyx_r = 0;
4660 static int __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4661 static int __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4662 PyObject *__pyx_v_sock = 0;
4663 PyObject *__pyx_v_bufsize = 0;
4664 int __pyx_lineno = 0;
4665 const char *__pyx_filename = NULL;
4666 int __pyx_clineno = 0;
4667 int __pyx_r;
18554668 __Pyx_RefNannyDeclarations
1856 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
1857 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(__pyx_self, ((PyObject *)__pyx_v_self));
1858
1859 /* function exit code */
1860 __Pyx_RefNannyFinishContext();
1861 return __pyx_r;
1862 }
1863
1864 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
1865 PyObject *__pyx_r = NULL;
1866 __Pyx_RefNannyDeclarations
1867 __Pyx_RefNannySetupContext("read_into_buffer", 0);
1868
1869 /* "clickhouse_driver/bufferedreader.pyx":29
1870 *
1871 * def read_into_buffer(self):
1872 * raise NotImplementedError # <<<<<<<<<<<<<<
1873 *
1874 * def read(self, Py_ssize_t unread):
1875 */
1876 __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
1877 __PYX_ERR(0, 29, __pyx_L1_error)
1878
1879 /* "clickhouse_driver/bufferedreader.pyx":28
1880 * super(BufferedReader, self).__init__()
1881 *
1882 * def read_into_buffer(self): # <<<<<<<<<<<<<<
1883 * raise NotImplementedError
1884 *
1885 */
1886
1887 /* function exit code */
1888 __pyx_L1_error:;
1889 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
1890 __pyx_r = NULL;
1891 __Pyx_XGIVEREF(__pyx_r);
1892 __Pyx_RefNannyFinishContext();
1893 return __pyx_r;
1894 }
1895
1896 /* "clickhouse_driver/bufferedreader.pyx":31
1897 * raise NotImplementedError
1898 *
1899 * def read(self, Py_ssize_t unread): # <<<<<<<<<<<<<<
1900 * # When the buffer is large enough bytes read are almost
1901 * # always hit the buffer.
1902 */
1903
1904 /* Python wrapper */
1905 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1906 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_5read = {"read", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, METH_VARARGS|METH_KEYWORDS, 0};
1907 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1908 PyObject *__pyx_v_self = 0;
1909 Py_ssize_t __pyx_v_unread;
1910 PyObject *__pyx_r = 0;
1911 __Pyx_RefNannyDeclarations
1912 __Pyx_RefNannySetupContext("read (wrapper)", 0);
4669 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
19134670 {
1914 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_unread,0};
4671 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sock,&__pyx_n_s_bufsize,0};
19154672 PyObject* values[2] = {0,0};
19164673 if (unlikely(__pyx_kwds)) {
19174674 Py_ssize_t kw_args;
19274684 kw_args = PyDict_Size(__pyx_kwds);
19284685 switch (pos_args) {
19294686 case 0:
1930 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
4687 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sock)) != 0)) kw_args--;
19314688 else goto __pyx_L5_argtuple_error;
19324689 CYTHON_FALLTHROUGH;
19334690 case 1:
1934 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_unread)) != 0)) kw_args--;
4691 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
19354692 else {
1936 __Pyx_RaiseArgtupleInvalid("read", 1, 2, 2, 1); __PYX_ERR(0, 31, __pyx_L3_error)
4693 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 232, __pyx_L3_error)
19374694 }
19384695 }
19394696 if (unlikely(kw_args > 0)) {
1940 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read") < 0)) __PYX_ERR(0, 31, __pyx_L3_error)
4697 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 232, __pyx_L3_error)
19414698 }
19424699 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
19434700 goto __pyx_L5_argtuple_error;
19454702 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
19464703 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
19474704 }
1948 __pyx_v_self = values[0];
1949 __pyx_v_unread = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_unread == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 31, __pyx_L3_error)
4705 __pyx_v_sock = values[0];
4706 __pyx_v_bufsize = values[1];
19504707 }
19514708 goto __pyx_L4_argument_unpacking_done;
19524709 __pyx_L5_argtuple_error:;
1953 __Pyx_RaiseArgtupleInvalid("read", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 31, __pyx_L3_error)
4710 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 232, __pyx_L3_error)
19544711 __pyx_L3_error:;
1955 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
4712 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
19564713 __Pyx_RefNannyFinishContext();
1957 return NULL;
4714 return -1;
19584715 __pyx_L4_argument_unpacking_done:;
1959 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(__pyx_self, __pyx_v_self, __pyx_v_unread);
4716 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self), __pyx_v_sock, __pyx_v_bufsize);
19604717
19614718 /* function exit code */
19624719 __Pyx_RefNannyFinishContext();
19634720 return __pyx_r;
19644721 }
19654722
1966 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_4read(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_unread) {
1967 PyObject *__pyx_v_next_position = NULL;
1968 PyObject *__pyx_v_t = NULL;
1969 char *__pyx_v_buffer_ptr;
1970 Py_ssize_t __pyx_v_read_bytes;
1971 Py_ssize_t __pyx_v_position;
1972 Py_ssize_t __pyx_v_current_buffer_size;
1973 PyObject *__pyx_v_rv = NULL;
4723 static int __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize) {
4724 int __pyx_r;
4725 __Pyx_RefNannyDeclarations
4726 PyObject *__pyx_t_1 = NULL;
4727 PyObject *__pyx_t_2 = NULL;
4728 PyObject *__pyx_t_3 = NULL;
4729 int __pyx_lineno = 0;
4730 const char *__pyx_filename = NULL;
4731 int __pyx_clineno = 0;
4732 __Pyx_RefNannySetupContext("__init__", 0);
4733
4734 /* "clickhouse_driver/bufferedreader.pyx":233
4735 *
4736 * def __init__(self, sock, bufsize):
4737 * self.sock = sock # <<<<<<<<<<<<<<
4738 * super(BufferedSocketReader, self).__init__(bufsize)
4739 *
4740 */
4741 __Pyx_INCREF(__pyx_v_sock);
4742 __Pyx_GIVEREF(__pyx_v_sock);
4743 __Pyx_GOTREF(__pyx_v_self->sock);
4744 __Pyx_DECREF(__pyx_v_self->sock);
4745 __pyx_v_self->sock = __pyx_v_sock;
4746
4747 /* "clickhouse_driver/bufferedreader.pyx":234
4748 * def __init__(self, sock, bufsize):
4749 * self.sock = sock
4750 * super(BufferedSocketReader, self).__init__(bufsize) # <<<<<<<<<<<<<<
4751 *
4752 * def read_into_buffer(self):
4753 */
4754 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
4755 __Pyx_GOTREF(__pyx_t_2);
4756 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader));
4757 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader));
4758 PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader));
4759 __Pyx_INCREF(((PyObject *)__pyx_v_self));
4760 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
4761 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
4762 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error)
4763 __Pyx_GOTREF(__pyx_t_3);
4764 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4765 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
4766 __Pyx_GOTREF(__pyx_t_2);
4767 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4768 __pyx_t_3 = NULL;
4769 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
4770 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
4771 if (likely(__pyx_t_3)) {
4772 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
4773 __Pyx_INCREF(__pyx_t_3);
4774 __Pyx_INCREF(function);
4775 __Pyx_DECREF_SET(__pyx_t_2, function);
4776 }
4777 }
4778 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_bufsize);
4779 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4780 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
4781 __Pyx_GOTREF(__pyx_t_1);
4782 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4783 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4784
4785 /* "clickhouse_driver/bufferedreader.pyx":232
4786 * cdef object sock
4787 *
4788 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
4789 * self.sock = sock
4790 * super(BufferedSocketReader, self).__init__(bufsize)
4791 */
4792
4793 /* function exit code */
4794 __pyx_r = 0;
4795 goto __pyx_L0;
4796 __pyx_L1_error:;
4797 __Pyx_XDECREF(__pyx_t_1);
4798 __Pyx_XDECREF(__pyx_t_2);
4799 __Pyx_XDECREF(__pyx_t_3);
4800 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
4801 __pyx_r = -1;
4802 __pyx_L0:;
4803 __Pyx_RefNannyFinishContext();
4804 return __pyx_r;
4805 }
4806
4807 /* "clickhouse_driver/bufferedreader.pyx":236
4808 * super(BufferedSocketReader, self).__init__(bufsize)
4809 *
4810 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4811 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4812 *
4813 */
4814
4815 /* Python wrapper */
4816 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4817 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4818 PyObject *__pyx_r = 0;
4819 __Pyx_RefNannyDeclarations
4820 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
4821 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self));
4822
4823 /* function exit code */
4824 __Pyx_RefNannyFinishContext();
4825 return __pyx_r;
4826 }
4827
4828 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self) {
4829 PyObject *__pyx_r = NULL;
4830 __Pyx_RefNannyDeclarations
4831 PyObject *__pyx_t_1 = NULL;
4832 PyObject *__pyx_t_2 = NULL;
4833 PyObject *__pyx_t_3 = NULL;
4834 unsigned PY_LONG_LONG __pyx_t_4;
4835 int __pyx_t_5;
4836 int __pyx_lineno = 0;
4837 const char *__pyx_filename = NULL;
4838 int __pyx_clineno = 0;
4839 __Pyx_RefNannySetupContext("read_into_buffer", 0);
4840
4841 /* "clickhouse_driver/bufferedreader.pyx":237
4842 *
4843 * def read_into_buffer(self):
4844 * self.current_buffer_size = self.sock.recv_into(self.buffer) # <<<<<<<<<<<<<<
4845 *
4846 * if self.current_buffer_size == 0:
4847 */
4848 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sock, __pyx_n_s_recv_into); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 237, __pyx_L1_error)
4849 __Pyx_GOTREF(__pyx_t_2);
4850 __pyx_t_3 = NULL;
4851 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
4852 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
4853 if (likely(__pyx_t_3)) {
4854 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
4855 __Pyx_INCREF(__pyx_t_3);
4856 __Pyx_INCREF(function);
4857 __Pyx_DECREF_SET(__pyx_t_2, function);
4858 }
4859 }
4860 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_self->__pyx_base.buffer) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_self->__pyx_base.buffer);
4861 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4862 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
4863 __Pyx_GOTREF(__pyx_t_1);
4864 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4865 __pyx_t_4 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 237, __pyx_L1_error)
4866 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4867 __pyx_v_self->__pyx_base.current_buffer_size = __pyx_t_4;
4868
4869 /* "clickhouse_driver/bufferedreader.pyx":239
4870 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4871 *
4872 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
4873 * raise EOFError('Unexpected EOF while reading bytes')
4874 *
4875 */
4876 __pyx_t_5 = ((__pyx_v_self->__pyx_base.current_buffer_size == 0) != 0);
4877 if (unlikely(__pyx_t_5)) {
4878
4879 /* "clickhouse_driver/bufferedreader.pyx":240
4880 *
4881 * if self.current_buffer_size == 0:
4882 * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<<
4883 *
4884 *
4885 */
4886 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_EOFError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 240, __pyx_L1_error)
4887 __Pyx_GOTREF(__pyx_t_1);
4888 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
4889 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4890 __PYX_ERR(0, 240, __pyx_L1_error)
4891
4892 /* "clickhouse_driver/bufferedreader.pyx":239
4893 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4894 *
4895 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
4896 * raise EOFError('Unexpected EOF while reading bytes')
4897 *
4898 */
4899 }
4900
4901 /* "clickhouse_driver/bufferedreader.pyx":236
4902 * super(BufferedSocketReader, self).__init__(bufsize)
4903 *
4904 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4905 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4906 *
4907 */
4908
4909 /* function exit code */
4910 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4911 goto __pyx_L0;
4912 __pyx_L1_error:;
4913 __Pyx_XDECREF(__pyx_t_1);
4914 __Pyx_XDECREF(__pyx_t_2);
4915 __Pyx_XDECREF(__pyx_t_3);
4916 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
4917 __pyx_r = NULL;
4918 __pyx_L0:;
4919 __Pyx_XGIVEREF(__pyx_r);
4920 __Pyx_RefNannyFinishContext();
4921 return __pyx_r;
4922 }
4923
4924 /* "(tree fragment)":1
4925 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
4926 * cdef tuple state
4927 * cdef object _dict
4928 */
4929
4930 /* Python wrapper */
4931 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4932 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4933 PyObject *__pyx_r = 0;
4934 __Pyx_RefNannyDeclarations
4935 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
4936 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self));
4937
4938 /* function exit code */
4939 __Pyx_RefNannyFinishContext();
4940 return __pyx_r;
4941 }
4942
4943 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self) {
4944 PyObject *__pyx_v_state = 0;
4945 PyObject *__pyx_v__dict = 0;
4946 int __pyx_v_use_setstate;
19744947 PyObject *__pyx_r = NULL;
19754948 __Pyx_RefNannyDeclarations
19764949 PyObject *__pyx_t_1 = NULL;
19774950 PyObject *__pyx_t_2 = NULL;
19784951 PyObject *__pyx_t_3 = NULL;
19794952 int __pyx_t_4;
1980 Py_ssize_t __pyx_t_5;
1981 Py_ssize_t __pyx_t_6;
1982 Py_ssize_t __pyx_t_7;
1983 __Pyx_RefNannySetupContext("read", 0);
1984
1985 /* "clickhouse_driver/bufferedreader.pyx":34
1986 * # When the buffer is large enough bytes read are almost
1987 * # always hit the buffer.
1988 * next_position = unread + self.position # <<<<<<<<<<<<<<
1989 * if next_position < self.current_buffer_size:
1990 * t = self.position
1991 */
1992 __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_unread); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
4953 int __pyx_t_5;
4954 int __pyx_t_6;
4955 int __pyx_lineno = 0;
4956 const char *__pyx_filename = NULL;
4957 int __pyx_clineno = 0;
4958 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
4959
4960 /* "(tree fragment)":5
4961 * cdef object _dict
4962 * cdef bint use_setstate
4963 * state = (self.buffer, self.current_buffer_size, self.position, self.sock) # <<<<<<<<<<<<<<
4964 * _dict = getattr(self, '__dict__', None)
4965 * if _dict is not None:
4966 */
4967 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
19934968 __Pyx_GOTREF(__pyx_t_1);
1994 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 34, __pyx_L1_error)
4969 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
19954970 __Pyx_GOTREF(__pyx_t_2);
1996 __pyx_t_3 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 34, __pyx_L1_error)
4971 __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
19974972 __Pyx_GOTREF(__pyx_t_3);
1998 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1999 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2000 __pyx_v_next_position = __pyx_t_3;
4973 __Pyx_INCREF(__pyx_v_self->__pyx_base.buffer);
4974 __Pyx_GIVEREF(__pyx_v_self->__pyx_base.buffer);
4975 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->__pyx_base.buffer);
4976 __Pyx_GIVEREF(__pyx_t_1);
4977 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
4978 __Pyx_GIVEREF(__pyx_t_2);
4979 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
4980 __Pyx_INCREF(__pyx_v_self->sock);
4981 __Pyx_GIVEREF(__pyx_v_self->sock);
4982 PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->sock);
4983 __pyx_t_1 = 0;
4984 __pyx_t_2 = 0;
4985 __pyx_v_state = ((PyObject*)__pyx_t_3);
20014986 __pyx_t_3 = 0;
20024987
2003 /* "clickhouse_driver/bufferedreader.pyx":35
2004 * # always hit the buffer.
2005 * next_position = unread + self.position
2006 * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<<
2007 * t = self.position
2008 * self.position = next_position
2009 */
2010 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 35, __pyx_L1_error)
4988 /* "(tree fragment)":6
4989 * cdef bint use_setstate
4990 * state = (self.buffer, self.current_buffer_size, self.position, self.sock)
4991 * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
4992 * if _dict is not None:
4993 * state += (_dict,)
4994 */
4995 __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
20114996 __Pyx_GOTREF(__pyx_t_3);
2012 __pyx_t_2 = PyObject_RichCompare(__pyx_v_next_position, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 35, __pyx_L1_error)
2013 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2014 __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 35, __pyx_L1_error)
2015 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2016 if (__pyx_t_4) {
2017
2018 /* "clickhouse_driver/bufferedreader.pyx":36
2019 * next_position = unread + self.position
2020 * if next_position < self.current_buffer_size:
2021 * t = self.position # <<<<<<<<<<<<<<
2022 * self.position = next_position
2023 * return self.buffer[t:self.position]
2024 */
2025 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 36, __pyx_L1_error)
4997 __pyx_v__dict = __pyx_t_3;
4998 __pyx_t_3 = 0;
4999
5000 /* "(tree fragment)":7
5001 * state = (self.buffer, self.current_buffer_size, self.position, self.sock)
5002 * _dict = getattr(self, '__dict__', None)
5003 * if _dict is not None: # <<<<<<<<<<<<<<
5004 * state += (_dict,)
5005 * use_setstate = True
5006 */
5007 __pyx_t_4 = (__pyx_v__dict != Py_None);
5008 __pyx_t_5 = (__pyx_t_4 != 0);
5009 if (__pyx_t_5) {
5010
5011 /* "(tree fragment)":8
5012 * _dict = getattr(self, '__dict__', None)
5013 * if _dict is not None:
5014 * state += (_dict,) # <<<<<<<<<<<<<<
5015 * use_setstate = True
5016 * else:
5017 */
5018 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
5019 __Pyx_GOTREF(__pyx_t_3);
5020 __Pyx_INCREF(__pyx_v__dict);
5021 __Pyx_GIVEREF(__pyx_v__dict);
5022 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
5023 __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
20265024 __Pyx_GOTREF(__pyx_t_2);
2027 __pyx_v_t = __pyx_t_2;
5025 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5026 __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
20285027 __pyx_t_2 = 0;
20295028
2030 /* "clickhouse_driver/bufferedreader.pyx":37
2031 * if next_position < self.current_buffer_size:
2032 * t = self.position
2033 * self.position = next_position # <<<<<<<<<<<<<<
2034 * return self.buffer[t:self.position]
2035 *
2036 */
2037 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_v_next_position) < 0) __PYX_ERR(0, 37, __pyx_L1_error)
2038
2039 /* "clickhouse_driver/bufferedreader.pyx":38
2040 * t = self.position
2041 * self.position = next_position
2042 * return self.buffer[t:self.position] # <<<<<<<<<<<<<<
2043 *
2044 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
5029 /* "(tree fragment)":9
5030 * if _dict is not None:
5031 * state += (_dict,)
5032 * use_setstate = True # <<<<<<<<<<<<<<
5033 * else:
5034 * use_setstate = self.buffer is not None or self.sock is not None
5035 */
5036 __pyx_v_use_setstate = 1;
5037
5038 /* "(tree fragment)":7
5039 * state = (self.buffer, self.current_buffer_size, self.position, self.sock)
5040 * _dict = getattr(self, '__dict__', None)
5041 * if _dict is not None: # <<<<<<<<<<<<<<
5042 * state += (_dict,)
5043 * use_setstate = True
5044 */
5045 goto __pyx_L3;
5046 }
5047
5048 /* "(tree fragment)":11
5049 * use_setstate = True
5050 * else:
5051 * use_setstate = self.buffer is not None or self.sock is not None # <<<<<<<<<<<<<<
5052 * if use_setstate:
5053 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, None), state
5054 */
5055 /*else*/ {
5056 __pyx_t_4 = (__pyx_v_self->__pyx_base.buffer != ((PyObject*)Py_None));
5057 __pyx_t_6 = (__pyx_t_4 != 0);
5058 if (!__pyx_t_6) {
5059 } else {
5060 __pyx_t_5 = __pyx_t_6;
5061 goto __pyx_L4_bool_binop_done;
5062 }
5063 __pyx_t_6 = (__pyx_v_self->sock != Py_None);
5064 __pyx_t_4 = (__pyx_t_6 != 0);
5065 __pyx_t_5 = __pyx_t_4;
5066 __pyx_L4_bool_binop_done:;
5067 __pyx_v_use_setstate = __pyx_t_5;
5068 }
5069 __pyx_L3:;
5070
5071 /* "(tree fragment)":12
5072 * else:
5073 * use_setstate = self.buffer is not None or self.sock is not None
5074 * if use_setstate: # <<<<<<<<<<<<<<
5075 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, None), state
5076 * else:
5077 */
5078 __pyx_t_5 = (__pyx_v_use_setstate != 0);
5079 if (__pyx_t_5) {
5080
5081 /* "(tree fragment)":13
5082 * use_setstate = self.buffer is not None or self.sock is not None
5083 * if use_setstate:
5084 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, None), state # <<<<<<<<<<<<<<
5085 * else:
5086 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, state)
20455087 */
20465088 __Pyx_XDECREF(__pyx_r);
2047 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
5089 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_BufferedSocketRea); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
20485090 __Pyx_GOTREF(__pyx_t_2);
2049 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 38, __pyx_L1_error)
5091 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
20505092 __Pyx_GOTREF(__pyx_t_3);
2051 __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_t_2, 0, 0, &__pyx_v_t, &__pyx_t_3, NULL, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
5093 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5094 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5095 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5096 __Pyx_INCREF(__pyx_int_251251440);
5097 __Pyx_GIVEREF(__pyx_int_251251440);
5098 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_251251440);
5099 __Pyx_INCREF(Py_None);
5100 __Pyx_GIVEREF(Py_None);
5101 PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
5102 __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
20525103 __Pyx_GOTREF(__pyx_t_1);
2053 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2054 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5104 __Pyx_GIVEREF(__pyx_t_2);
5105 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
5106 __Pyx_GIVEREF(__pyx_t_3);
5107 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
5108 __Pyx_INCREF(__pyx_v_state);
5109 __Pyx_GIVEREF(__pyx_v_state);
5110 PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
5111 __pyx_t_2 = 0;
5112 __pyx_t_3 = 0;
20555113 __pyx_r = __pyx_t_1;
20565114 __pyx_t_1 = 0;
20575115 goto __pyx_L0;
20585116
2059 /* "clickhouse_driver/bufferedreader.pyx":35
2060 * # always hit the buffer.
2061 * next_position = unread + self.position
2062 * if next_position < self.current_buffer_size: # <<<<<<<<<<<<<<
2063 * t = self.position
2064 * self.position = next_position
5117 /* "(tree fragment)":12
5118 * else:
5119 * use_setstate = self.buffer is not None or self.sock is not None
5120 * if use_setstate: # <<<<<<<<<<<<<<
5121 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, None), state
5122 * else:
20655123 */
20665124 }
20675125
2068 /* "clickhouse_driver/bufferedreader.pyx":40
2069 * return self.buffer[t:self.position]
2070 *
2071 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
2072 * cdef Py_ssize_t read_bytes
2073 * cdef Py_ssize_t position = self.position
2074 */
2075 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
2076 __Pyx_GOTREF(__pyx_t_1);
2077 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1);
2078 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2079
2080 /* "clickhouse_driver/bufferedreader.pyx":42
2081 * cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
2082 * cdef Py_ssize_t read_bytes
2083 * cdef Py_ssize_t position = self.position # <<<<<<<<<<<<<<
2084 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size
2085 * rv = bytes()
2086 */
2087 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
2088 __Pyx_GOTREF(__pyx_t_1);
2089 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 42, __pyx_L1_error)
2090 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2091 __pyx_v_position = __pyx_t_5;
2092
2093 /* "clickhouse_driver/bufferedreader.pyx":43
2094 * cdef Py_ssize_t read_bytes
2095 * cdef Py_ssize_t position = self.position
2096 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size # <<<<<<<<<<<<<<
2097 * rv = bytes()
2098 *
2099 */
2100 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
2101 __Pyx_GOTREF(__pyx_t_1);
2102 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 43, __pyx_L1_error)
2103 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2104 __pyx_v_current_buffer_size = __pyx_t_5;
2105
2106 /* "clickhouse_driver/bufferedreader.pyx":44
2107 * cdef Py_ssize_t position = self.position
2108 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size
2109 * rv = bytes() # <<<<<<<<<<<<<<
2110 *
2111 * while unread > 0:
2112 */
2113 __pyx_t_1 = __Pyx_PyObject_CallNoArg(((PyObject *)(&PyBytes_Type))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
2114 __Pyx_GOTREF(__pyx_t_1);
2115 __pyx_v_rv = ((PyObject*)__pyx_t_1);
2116 __pyx_t_1 = 0;
2117
2118 /* "clickhouse_driver/bufferedreader.pyx":46
2119 * rv = bytes()
2120 *
2121 * while unread > 0: # <<<<<<<<<<<<<<
2122 * if position == current_buffer_size:
2123 * self.read_into_buffer()
2124 */
2125 while (1) {
2126 __pyx_t_4 = ((__pyx_v_unread > 0) != 0);
2127 if (!__pyx_t_4) break;
2128
2129 /* "clickhouse_driver/bufferedreader.pyx":47
2130 *
2131 * while unread > 0:
2132 * if position == current_buffer_size: # <<<<<<<<<<<<<<
2133 * self.read_into_buffer()
2134 * buffer_ptr = PyByteArray_AsString(self.buffer)
2135 */
2136 __pyx_t_4 = ((__pyx_v_position == __pyx_v_current_buffer_size) != 0);
2137 if (__pyx_t_4) {
2138
2139 /* "clickhouse_driver/bufferedreader.pyx":48
2140 * while unread > 0:
2141 * if position == current_buffer_size:
2142 * self.read_into_buffer() # <<<<<<<<<<<<<<
2143 * buffer_ptr = PyByteArray_AsString(self.buffer)
2144 * current_buffer_size = self.current_buffer_size
2145 */
2146 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 48, __pyx_L1_error)
2147 __Pyx_GOTREF(__pyx_t_3);
2148 __pyx_t_2 = NULL;
2149 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2150 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2151 if (likely(__pyx_t_2)) {
2152 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2153 __Pyx_INCREF(__pyx_t_2);
2154 __Pyx_INCREF(function);
2155 __Pyx_DECREF_SET(__pyx_t_3, function);
2156 }
2157 }
2158 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
2159 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2160 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
2161 __Pyx_GOTREF(__pyx_t_1);
2162 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2163 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2164
2165 /* "clickhouse_driver/bufferedreader.pyx":49
2166 * if position == current_buffer_size:
2167 * self.read_into_buffer()
2168 * buffer_ptr = PyByteArray_AsString(self.buffer) # <<<<<<<<<<<<<<
2169 * current_buffer_size = self.current_buffer_size
2170 * position = 0
2171 */
2172 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
2173 __Pyx_GOTREF(__pyx_t_1);
2174 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_t_1);
2175 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2176
2177 /* "clickhouse_driver/bufferedreader.pyx":50
2178 * self.read_into_buffer()
2179 * buffer_ptr = PyByteArray_AsString(self.buffer)
2180 * current_buffer_size = self.current_buffer_size # <<<<<<<<<<<<<<
2181 * position = 0
2182 *
2183 */
2184 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
2185 __Pyx_GOTREF(__pyx_t_1);
2186 __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L1_error)
2187 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2188 __pyx_v_current_buffer_size = __pyx_t_5;
2189
2190 /* "clickhouse_driver/bufferedreader.pyx":51
2191 * buffer_ptr = PyByteArray_AsString(self.buffer)
2192 * current_buffer_size = self.current_buffer_size
2193 * position = 0 # <<<<<<<<<<<<<<
2194 *
2195 * read_bytes = min(unread, current_buffer_size - position)
2196 */
2197 __pyx_v_position = 0;
2198
2199 /* "clickhouse_driver/bufferedreader.pyx":47
2200 *
2201 * while unread > 0:
2202 * if position == current_buffer_size: # <<<<<<<<<<<<<<
2203 * self.read_into_buffer()
2204 * buffer_ptr = PyByteArray_AsString(self.buffer)
2205 */
2206 }
2207
2208 /* "clickhouse_driver/bufferedreader.pyx":53
2209 * position = 0
2210 *
2211 * read_bytes = min(unread, current_buffer_size - position) # <<<<<<<<<<<<<<
2212 * rv += PyBytes_FromStringAndSize(&buffer_ptr[position], read_bytes)
2213 * position += read_bytes
2214 */
2215 __pyx_t_5 = (__pyx_v_current_buffer_size - __pyx_v_position);
2216 __pyx_t_6 = __pyx_v_unread;
2217 if (((__pyx_t_5 < __pyx_t_6) != 0)) {
2218 __pyx_t_7 = __pyx_t_5;
2219 } else {
2220 __pyx_t_7 = __pyx_t_6;
2221 }
2222 __pyx_v_read_bytes = __pyx_t_7;
2223
2224 /* "clickhouse_driver/bufferedreader.pyx":54
2225 *
2226 * read_bytes = min(unread, current_buffer_size - position)
2227 * rv += PyBytes_FromStringAndSize(&buffer_ptr[position], read_bytes) # <<<<<<<<<<<<<<
2228 * position += read_bytes
2229 * unread -= read_bytes
2230 */
2231 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_position])), __pyx_v_read_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
5126 /* "(tree fragment)":15
5127 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, None), state
5128 * else:
5129 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, state) # <<<<<<<<<<<<<<
5130 * def __setstate_cython__(self, __pyx_state):
5131 * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state)
5132 */
5133 /*else*/ {
5134 __Pyx_XDECREF(__pyx_r);
5135 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_BufferedSocketRea); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
22325136 __Pyx_GOTREF(__pyx_t_1);
2233 __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 54, __pyx_L1_error)
5137 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
22345138 __Pyx_GOTREF(__pyx_t_3);
2235 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2236 __Pyx_DECREF_SET(__pyx_v_rv, ((PyObject*)__pyx_t_3));
5139 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5140 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5141 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5142 __Pyx_INCREF(__pyx_int_251251440);
5143 __Pyx_GIVEREF(__pyx_int_251251440);
5144 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_251251440);
5145 __Pyx_INCREF(__pyx_v_state);
5146 __Pyx_GIVEREF(__pyx_v_state);
5147 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
5148 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
5149 __Pyx_GOTREF(__pyx_t_2);
5150 __Pyx_GIVEREF(__pyx_t_1);
5151 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
5152 __Pyx_GIVEREF(__pyx_t_3);
5153 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
5154 __pyx_t_1 = 0;
22375155 __pyx_t_3 = 0;
2238
2239 /* "clickhouse_driver/bufferedreader.pyx":55
2240 * read_bytes = min(unread, current_buffer_size - position)
2241 * rv += PyBytes_FromStringAndSize(&buffer_ptr[position], read_bytes)
2242 * position += read_bytes # <<<<<<<<<<<<<<
2243 * unread -= read_bytes
2244 *
2245 */
2246 __pyx_v_position = (__pyx_v_position + __pyx_v_read_bytes);
2247
2248 /* "clickhouse_driver/bufferedreader.pyx":56
2249 * rv += PyBytes_FromStringAndSize(&buffer_ptr[position], read_bytes)
2250 * position += read_bytes
2251 * unread -= read_bytes # <<<<<<<<<<<<<<
2252 *
2253 * # Restore self-variables.
2254 */
2255 __pyx_v_unread = (__pyx_v_unread - __pyx_v_read_bytes);
5156 __pyx_r = __pyx_t_2;
5157 __pyx_t_2 = 0;
5158 goto __pyx_L0;
22565159 }
22575160
2258 /* "clickhouse_driver/bufferedreader.pyx":59
2259 *
2260 * # Restore self-variables.
2261 * self.position = position # <<<<<<<<<<<<<<
2262 * self.current_buffer_size = current_buffer_size
2263 *
2264 */
2265 __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 59, __pyx_L1_error)
2266 __Pyx_GOTREF(__pyx_t_3);
2267 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_t_3) < 0) __PYX_ERR(0, 59, __pyx_L1_error)
2268 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2269
2270 /* "clickhouse_driver/bufferedreader.pyx":60
2271 * # Restore self-variables.
2272 * self.position = position
2273 * self.current_buffer_size = current_buffer_size # <<<<<<<<<<<<<<
2274 *
2275 * return bytearray(rv)
2276 */
2277 __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_current_buffer_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 60, __pyx_L1_error)
2278 __Pyx_GOTREF(__pyx_t_3);
2279 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size, __pyx_t_3) < 0) __PYX_ERR(0, 60, __pyx_L1_error)
2280 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2281
2282 /* "clickhouse_driver/bufferedreader.pyx":62
2283 * self.current_buffer_size = current_buffer_size
2284 *
2285 * return bytearray(rv) # <<<<<<<<<<<<<<
2286 *
2287 * def read_one(self):
2288 */
2289 __Pyx_XDECREF(__pyx_r);
2290 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_v_rv); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 62, __pyx_L1_error)
2291 __Pyx_GOTREF(__pyx_t_3);
2292 __pyx_r = __pyx_t_3;
2293 __pyx_t_3 = 0;
2294 goto __pyx_L0;
2295
2296 /* "clickhouse_driver/bufferedreader.pyx":31
2297 * raise NotImplementedError
2298 *
2299 * def read(self, Py_ssize_t unread): # <<<<<<<<<<<<<<
2300 * # When the buffer is large enough bytes read are almost
2301 * # always hit the buffer.
5161 /* "(tree fragment)":1
5162 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
5163 * cdef tuple state
5164 * cdef object _dict
23025165 */
23035166
23045167 /* function exit code */
23065169 __Pyx_XDECREF(__pyx_t_1);
23075170 __Pyx_XDECREF(__pyx_t_2);
23085171 __Pyx_XDECREF(__pyx_t_3);
2309 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read", __pyx_clineno, __pyx_lineno, __pyx_filename);
5172 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
23105173 __pyx_r = NULL;
23115174 __pyx_L0:;
2312 __Pyx_XDECREF(__pyx_v_next_position);
2313 __Pyx_XDECREF(__pyx_v_t);
2314 __Pyx_XDECREF(__pyx_v_rv);
5175 __Pyx_XDECREF(__pyx_v_state);
5176 __Pyx_XDECREF(__pyx_v__dict);
23155177 __Pyx_XGIVEREF(__pyx_r);
23165178 __Pyx_RefNannyFinishContext();
23175179 return __pyx_r;
23185180 }
23195181
2320 /* "clickhouse_driver/bufferedreader.pyx":64
2321 * return bytearray(rv)
2322 *
2323 * def read_one(self): # <<<<<<<<<<<<<<
2324 * if self.position == self.current_buffer_size:
2325 * self.read_into_buffer()
5182 /* "(tree fragment)":16
5183 * else:
5184 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, state)
5185 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5186 * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state)
23265187 */
23275188
23285189 /* Python wrapper */
2329 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
2330 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one = {"read_one", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, METH_O, 0};
2331 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one(PyObject *__pyx_self, PyObject *__pyx_v_self) {
5190 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
5191 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
23325192 PyObject *__pyx_r = 0;
23335193 __Pyx_RefNannyDeclarations
2334 __Pyx_RefNannySetupContext("read_one (wrapper)", 0);
2335 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(__pyx_self, ((PyObject *)__pyx_v_self));
5194 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
5195 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
23365196
23375197 /* function exit code */
23385198 __Pyx_RefNannyFinishContext();
23395199 return __pyx_r;
23405200 }
23415201
2342 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_6read_one(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
2343 PyObject *__pyx_v_rv = NULL;
5202 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
5203 PyObject *__pyx_r = NULL;
5204 __Pyx_RefNannyDeclarations
5205 PyObject *__pyx_t_1 = NULL;
5206 int __pyx_lineno = 0;
5207 const char *__pyx_filename = NULL;
5208 int __pyx_clineno = 0;
5209 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
5210
5211 /* "(tree fragment)":17
5212 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, state)
5213 * def __setstate_cython__(self, __pyx_state):
5214 * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
5215 */
5216 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
5217 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
5218 __Pyx_GOTREF(__pyx_t_1);
5219 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5220
5221 /* "(tree fragment)":16
5222 * else:
5223 * return __pyx_unpickle_BufferedSocketReader, (type(self), 0xef9caf0, state)
5224 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5225 * __pyx_unpickle_BufferedSocketReader__set_state(self, __pyx_state)
5226 */
5227
5228 /* function exit code */
5229 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5230 goto __pyx_L0;
5231 __pyx_L1_error:;
5232 __Pyx_XDECREF(__pyx_t_1);
5233 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5234 __pyx_r = NULL;
5235 __pyx_L0:;
5236 __Pyx_XGIVEREF(__pyx_r);
5237 __Pyx_RefNannyFinishContext();
5238 return __pyx_r;
5239 }
5240
5241 /* "clickhouse_driver/bufferedreader.pyx":246
5242 * cdef object read_block
5243 *
5244 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
5245 * self.read_block = read_block
5246 * super(CompressedBufferedReader, self).__init__(bufsize)
5247 */
5248
5249 /* Python wrapper */
5250 static int __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5251 static int __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5252 PyObject *__pyx_v_read_block = 0;
5253 PyObject *__pyx_v_bufsize = 0;
5254 int __pyx_lineno = 0;
5255 const char *__pyx_filename = NULL;
5256 int __pyx_clineno = 0;
5257 int __pyx_r;
5258 __Pyx_RefNannyDeclarations
5259 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
5260 {
5261 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_read_block,&__pyx_n_s_bufsize,0};
5262 PyObject* values[2] = {0,0};
5263 if (unlikely(__pyx_kwds)) {
5264 Py_ssize_t kw_args;
5265 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5266 switch (pos_args) {
5267 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5268 CYTHON_FALLTHROUGH;
5269 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5270 CYTHON_FALLTHROUGH;
5271 case 0: break;
5272 default: goto __pyx_L5_argtuple_error;
5273 }
5274 kw_args = PyDict_Size(__pyx_kwds);
5275 switch (pos_args) {
5276 case 0:
5277 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_read_block)) != 0)) kw_args--;
5278 else goto __pyx_L5_argtuple_error;
5279 CYTHON_FALLTHROUGH;
5280 case 1:
5281 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
5282 else {
5283 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 246, __pyx_L3_error)
5284 }
5285 }
5286 if (unlikely(kw_args > 0)) {
5287 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 246, __pyx_L3_error)
5288 }
5289 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
5290 goto __pyx_L5_argtuple_error;
5291 } else {
5292 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5293 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5294 }
5295 __pyx_v_read_block = values[0];
5296 __pyx_v_bufsize = values[1];
5297 }
5298 goto __pyx_L4_argument_unpacking_done;
5299 __pyx_L5_argtuple_error:;
5300 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 246, __pyx_L3_error)
5301 __pyx_L3_error:;
5302 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5303 __Pyx_RefNannyFinishContext();
5304 return -1;
5305 __pyx_L4_argument_unpacking_done:;
5306 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self), __pyx_v_read_block, __pyx_v_bufsize);
5307
5308 /* function exit code */
5309 __Pyx_RefNannyFinishContext();
5310 return __pyx_r;
5311 }
5312
5313 static int __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize) {
5314 int __pyx_r;
5315 __Pyx_RefNannyDeclarations
5316 PyObject *__pyx_t_1 = NULL;
5317 PyObject *__pyx_t_2 = NULL;
5318 PyObject *__pyx_t_3 = NULL;
5319 int __pyx_lineno = 0;
5320 const char *__pyx_filename = NULL;
5321 int __pyx_clineno = 0;
5322 __Pyx_RefNannySetupContext("__init__", 0);
5323
5324 /* "clickhouse_driver/bufferedreader.pyx":247
5325 *
5326 * def __init__(self, read_block, bufsize):
5327 * self.read_block = read_block # <<<<<<<<<<<<<<
5328 * super(CompressedBufferedReader, self).__init__(bufsize)
5329 *
5330 */
5331 __Pyx_INCREF(__pyx_v_read_block);
5332 __Pyx_GIVEREF(__pyx_v_read_block);
5333 __Pyx_GOTREF(__pyx_v_self->read_block);
5334 __Pyx_DECREF(__pyx_v_self->read_block);
5335 __pyx_v_self->read_block = __pyx_v_read_block;
5336
5337 /* "clickhouse_driver/bufferedreader.pyx":248
5338 * def __init__(self, read_block, bufsize):
5339 * self.read_block = read_block
5340 * super(CompressedBufferedReader, self).__init__(bufsize) # <<<<<<<<<<<<<<
5341 *
5342 * def read_into_buffer(self):
5343 */
5344 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
5345 __Pyx_GOTREF(__pyx_t_2);
5346 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader));
5347 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader));
5348 PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader));
5349 __Pyx_INCREF(((PyObject *)__pyx_v_self));
5350 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
5351 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
5352 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 248, __pyx_L1_error)
5353 __Pyx_GOTREF(__pyx_t_3);
5354 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5355 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
5356 __Pyx_GOTREF(__pyx_t_2);
5357 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5358 __pyx_t_3 = NULL;
5359 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
5360 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5361 if (likely(__pyx_t_3)) {
5362 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5363 __Pyx_INCREF(__pyx_t_3);
5364 __Pyx_INCREF(function);
5365 __Pyx_DECREF_SET(__pyx_t_2, function);
5366 }
5367 }
5368 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_bufsize);
5369 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5370 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error)
5371 __Pyx_GOTREF(__pyx_t_1);
5372 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5373 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5374
5375 /* "clickhouse_driver/bufferedreader.pyx":246
5376 * cdef object read_block
5377 *
5378 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
5379 * self.read_block = read_block
5380 * super(CompressedBufferedReader, self).__init__(bufsize)
5381 */
5382
5383 /* function exit code */
5384 __pyx_r = 0;
5385 goto __pyx_L0;
5386 __pyx_L1_error:;
5387 __Pyx_XDECREF(__pyx_t_1);
5388 __Pyx_XDECREF(__pyx_t_2);
5389 __Pyx_XDECREF(__pyx_t_3);
5390 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5391 __pyx_r = -1;
5392 __pyx_L0:;
5393 __Pyx_RefNannyFinishContext();
5394 return __pyx_r;
5395 }
5396
5397 /* "clickhouse_driver/bufferedreader.pyx":250
5398 * super(CompressedBufferedReader, self).__init__(bufsize)
5399 *
5400 * def read_into_buffer(self): # <<<<<<<<<<<<<<
5401 * self.buffer = bytearray(self.read_block())
5402 * self.current_buffer_size = len(self.buffer)
5403 */
5404
5405 /* Python wrapper */
5406 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
5407 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5408 PyObject *__pyx_r = 0;
5409 __Pyx_RefNannyDeclarations
5410 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
5411 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self));
5412
5413 /* function exit code */
5414 __Pyx_RefNannyFinishContext();
5415 return __pyx_r;
5416 }
5417
5418 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self) {
5419 PyObject *__pyx_r = NULL;
5420 __Pyx_RefNannyDeclarations
5421 PyObject *__pyx_t_1 = NULL;
5422 PyObject *__pyx_t_2 = NULL;
5423 PyObject *__pyx_t_3 = NULL;
5424 Py_ssize_t __pyx_t_4;
5425 int __pyx_t_5;
5426 int __pyx_lineno = 0;
5427 const char *__pyx_filename = NULL;
5428 int __pyx_clineno = 0;
5429 __Pyx_RefNannySetupContext("read_into_buffer", 0);
5430
5431 /* "clickhouse_driver/bufferedreader.pyx":251
5432 *
5433 * def read_into_buffer(self):
5434 * self.buffer = bytearray(self.read_block()) # <<<<<<<<<<<<<<
5435 * self.current_buffer_size = len(self.buffer)
5436 *
5437 */
5438 __Pyx_INCREF(__pyx_v_self->read_block);
5439 __pyx_t_2 = __pyx_v_self->read_block; __pyx_t_3 = NULL;
5440 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
5441 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
5442 if (likely(__pyx_t_3)) {
5443 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5444 __Pyx_INCREF(__pyx_t_3);
5445 __Pyx_INCREF(function);
5446 __Pyx_DECREF_SET(__pyx_t_2, function);
5447 }
5448 }
5449 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
5450 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5451 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
5452 __Pyx_GOTREF(__pyx_t_1);
5453 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5454 __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
5455 __Pyx_GOTREF(__pyx_t_2);
5456 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5457 __Pyx_GIVEREF(__pyx_t_2);
5458 __Pyx_GOTREF(__pyx_v_self->__pyx_base.buffer);
5459 __Pyx_DECREF(__pyx_v_self->__pyx_base.buffer);
5460 __pyx_v_self->__pyx_base.buffer = ((PyObject*)__pyx_t_2);
5461 __pyx_t_2 = 0;
5462
5463 /* "clickhouse_driver/bufferedreader.pyx":252
5464 * def read_into_buffer(self):
5465 * self.buffer = bytearray(self.read_block())
5466 * self.current_buffer_size = len(self.buffer) # <<<<<<<<<<<<<<
5467 *
5468 * if self.current_buffer_size == 0:
5469 */
5470 __pyx_t_2 = __pyx_v_self->__pyx_base.buffer;
5471 __Pyx_INCREF(__pyx_t_2);
5472 if (unlikely(__pyx_t_2 == Py_None)) {
5473 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
5474 __PYX_ERR(0, 252, __pyx_L1_error)
5475 }
5476 __pyx_t_4 = PyByteArray_GET_SIZE(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 252, __pyx_L1_error)
5477 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5478 __pyx_v_self->__pyx_base.current_buffer_size = __pyx_t_4;
5479
5480 /* "clickhouse_driver/bufferedreader.pyx":254
5481 * self.current_buffer_size = len(self.buffer)
5482 *
5483 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
5484 * raise EOFError('Unexpected EOF while reading bytes')
5485 */
5486 __pyx_t_5 = ((__pyx_v_self->__pyx_base.current_buffer_size == 0) != 0);
5487 if (unlikely(__pyx_t_5)) {
5488
5489 /* "clickhouse_driver/bufferedreader.pyx":255
5490 *
5491 * if self.current_buffer_size == 0:
5492 * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<<
5493 */
5494 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_EOFError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 255, __pyx_L1_error)
5495 __Pyx_GOTREF(__pyx_t_2);
5496 __Pyx_Raise(__pyx_t_2, 0, 0, 0);
5497 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5498 __PYX_ERR(0, 255, __pyx_L1_error)
5499
5500 /* "clickhouse_driver/bufferedreader.pyx":254
5501 * self.current_buffer_size = len(self.buffer)
5502 *
5503 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
5504 * raise EOFError('Unexpected EOF while reading bytes')
5505 */
5506 }
5507
5508 /* "clickhouse_driver/bufferedreader.pyx":250
5509 * super(CompressedBufferedReader, self).__init__(bufsize)
5510 *
5511 * def read_into_buffer(self): # <<<<<<<<<<<<<<
5512 * self.buffer = bytearray(self.read_block())
5513 * self.current_buffer_size = len(self.buffer)
5514 */
5515
5516 /* function exit code */
5517 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5518 goto __pyx_L0;
5519 __pyx_L1_error:;
5520 __Pyx_XDECREF(__pyx_t_1);
5521 __Pyx_XDECREF(__pyx_t_2);
5522 __Pyx_XDECREF(__pyx_t_3);
5523 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
5524 __pyx_r = NULL;
5525 __pyx_L0:;
5526 __Pyx_XGIVEREF(__pyx_r);
5527 __Pyx_RefNannyFinishContext();
5528 return __pyx_r;
5529 }
5530
5531 /* "(tree fragment)":1
5532 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
5533 * cdef tuple state
5534 * cdef object _dict
5535 */
5536
5537 /* Python wrapper */
5538 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
5539 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5540 PyObject *__pyx_r = 0;
5541 __Pyx_RefNannyDeclarations
5542 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
5543 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self));
5544
5545 /* function exit code */
5546 __Pyx_RefNannyFinishContext();
5547 return __pyx_r;
5548 }
5549
5550 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self) {
5551 PyObject *__pyx_v_state = 0;
5552 PyObject *__pyx_v__dict = 0;
5553 int __pyx_v_use_setstate;
23445554 PyObject *__pyx_r = NULL;
23455555 __Pyx_RefNannyDeclarations
23465556 PyObject *__pyx_t_1 = NULL;
23475557 PyObject *__pyx_t_2 = NULL;
23485558 PyObject *__pyx_t_3 = NULL;
23495559 int __pyx_t_4;
2350 __Pyx_RefNannySetupContext("read_one", 0);
2351
2352 /* "clickhouse_driver/bufferedreader.pyx":65
2353 *
2354 * def read_one(self):
2355 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2356 * self.read_into_buffer()
2357 * self.position = 0
2358 */
2359 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
5560 int __pyx_t_5;
5561 int __pyx_t_6;
5562 int __pyx_lineno = 0;
5563 const char *__pyx_filename = NULL;
5564 int __pyx_clineno = 0;
5565 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
5566
5567 /* "(tree fragment)":5
5568 * cdef object _dict
5569 * cdef bint use_setstate
5570 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block) # <<<<<<<<<<<<<<
5571 * _dict = getattr(self, '__dict__', None)
5572 * if _dict is not None:
5573 */
5574 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
23605575 __Pyx_GOTREF(__pyx_t_1);
2361 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
5576 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
23625577 __Pyx_GOTREF(__pyx_t_2);
2363 __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 65, __pyx_L1_error)
2364 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2365 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2366 __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 65, __pyx_L1_error)
2367 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2368 if (__pyx_t_4) {
2369
2370 /* "clickhouse_driver/bufferedreader.pyx":66
2371 * def read_one(self):
2372 * if self.position == self.current_buffer_size:
2373 * self.read_into_buffer() # <<<<<<<<<<<<<<
2374 * self.position = 0
2375 *
2376 */
2377 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error)
5578 __pyx_t_3 = PyTuple_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
5579 __Pyx_GOTREF(__pyx_t_3);
5580 __Pyx_INCREF(__pyx_v_self->__pyx_base.buffer);
5581 __Pyx_GIVEREF(__pyx_v_self->__pyx_base.buffer);
5582 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_self->__pyx_base.buffer);
5583 __Pyx_GIVEREF(__pyx_t_1);
5584 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
5585 __Pyx_GIVEREF(__pyx_t_2);
5586 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_t_2);
5587 __Pyx_INCREF(__pyx_v_self->read_block);
5588 __Pyx_GIVEREF(__pyx_v_self->read_block);
5589 PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_v_self->read_block);
5590 __pyx_t_1 = 0;
5591 __pyx_t_2 = 0;
5592 __pyx_v_state = ((PyObject*)__pyx_t_3);
5593 __pyx_t_3 = 0;
5594
5595 /* "(tree fragment)":6
5596 * cdef bint use_setstate
5597 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block)
5598 * _dict = getattr(self, '__dict__', None) # <<<<<<<<<<<<<<
5599 * if _dict is not None:
5600 * state += (_dict,)
5601 */
5602 __pyx_t_3 = __Pyx_GetAttr3(((PyObject *)__pyx_v_self), __pyx_n_s_dict, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
5603 __Pyx_GOTREF(__pyx_t_3);
5604 __pyx_v__dict = __pyx_t_3;
5605 __pyx_t_3 = 0;
5606
5607 /* "(tree fragment)":7
5608 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block)
5609 * _dict = getattr(self, '__dict__', None)
5610 * if _dict is not None: # <<<<<<<<<<<<<<
5611 * state += (_dict,)
5612 * use_setstate = True
5613 */
5614 __pyx_t_4 = (__pyx_v__dict != Py_None);
5615 __pyx_t_5 = (__pyx_t_4 != 0);
5616 if (__pyx_t_5) {
5617
5618 /* "(tree fragment)":8
5619 * _dict = getattr(self, '__dict__', None)
5620 * if _dict is not None:
5621 * state += (_dict,) # <<<<<<<<<<<<<<
5622 * use_setstate = True
5623 * else:
5624 */
5625 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 8, __pyx_L1_error)
5626 __Pyx_GOTREF(__pyx_t_3);
5627 __Pyx_INCREF(__pyx_v__dict);
5628 __Pyx_GIVEREF(__pyx_v__dict);
5629 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v__dict);
5630 __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_state, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 8, __pyx_L1_error)
23785631 __Pyx_GOTREF(__pyx_t_2);
2379 __pyx_t_1 = NULL;
2380 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2381 __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
2382 if (likely(__pyx_t_1)) {
2383 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2384 __Pyx_INCREF(__pyx_t_1);
2385 __Pyx_INCREF(function);
2386 __Pyx_DECREF_SET(__pyx_t_2, function);
2387 }
2388 }
2389 __pyx_t_3 = (__pyx_t_1) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
2390 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2391 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error)
5632 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5633 __Pyx_DECREF_SET(__pyx_v_state, ((PyObject*)__pyx_t_2));
5634 __pyx_t_2 = 0;
5635
5636 /* "(tree fragment)":9
5637 * if _dict is not None:
5638 * state += (_dict,)
5639 * use_setstate = True # <<<<<<<<<<<<<<
5640 * else:
5641 * use_setstate = self.buffer is not None or self.read_block is not None
5642 */
5643 __pyx_v_use_setstate = 1;
5644
5645 /* "(tree fragment)":7
5646 * state = (self.buffer, self.current_buffer_size, self.position, self.read_block)
5647 * _dict = getattr(self, '__dict__', None)
5648 * if _dict is not None: # <<<<<<<<<<<<<<
5649 * state += (_dict,)
5650 * use_setstate = True
5651 */
5652 goto __pyx_L3;
5653 }
5654
5655 /* "(tree fragment)":11
5656 * use_setstate = True
5657 * else:
5658 * use_setstate = self.buffer is not None or self.read_block is not None # <<<<<<<<<<<<<<
5659 * if use_setstate:
5660 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, None), state
5661 */
5662 /*else*/ {
5663 __pyx_t_4 = (__pyx_v_self->__pyx_base.buffer != ((PyObject*)Py_None));
5664 __pyx_t_6 = (__pyx_t_4 != 0);
5665 if (!__pyx_t_6) {
5666 } else {
5667 __pyx_t_5 = __pyx_t_6;
5668 goto __pyx_L4_bool_binop_done;
5669 }
5670 __pyx_t_6 = (__pyx_v_self->read_block != Py_None);
5671 __pyx_t_4 = (__pyx_t_6 != 0);
5672 __pyx_t_5 = __pyx_t_4;
5673 __pyx_L4_bool_binop_done:;
5674 __pyx_v_use_setstate = __pyx_t_5;
5675 }
5676 __pyx_L3:;
5677
5678 /* "(tree fragment)":12
5679 * else:
5680 * use_setstate = self.buffer is not None or self.read_block is not None
5681 * if use_setstate: # <<<<<<<<<<<<<<
5682 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, None), state
5683 * else:
5684 */
5685 __pyx_t_5 = (__pyx_v_use_setstate != 0);
5686 if (__pyx_t_5) {
5687
5688 /* "(tree fragment)":13
5689 * use_setstate = self.buffer is not None or self.read_block is not None
5690 * if use_setstate:
5691 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, None), state # <<<<<<<<<<<<<<
5692 * else:
5693 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, state)
5694 */
5695 __Pyx_XDECREF(__pyx_r);
5696 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 13, __pyx_L1_error)
5697 __Pyx_GOTREF(__pyx_t_2);
5698 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 13, __pyx_L1_error)
23925699 __Pyx_GOTREF(__pyx_t_3);
2393 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2394 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2395
2396 /* "clickhouse_driver/bufferedreader.pyx":67
2397 * if self.position == self.current_buffer_size:
2398 * self.read_into_buffer()
2399 * self.position = 0 # <<<<<<<<<<<<<<
2400 *
2401 * rv = self.buffer[self.position]
2402 */
2403 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_int_0) < 0) __PYX_ERR(0, 67, __pyx_L1_error)
2404
2405 /* "clickhouse_driver/bufferedreader.pyx":65
2406 *
2407 * def read_one(self):
2408 * if self.position == self.current_buffer_size: # <<<<<<<<<<<<<<
2409 * self.read_into_buffer()
2410 * self.position = 0
5700 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5701 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5702 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5703 __Pyx_INCREF(__pyx_int_25411819);
5704 __Pyx_GIVEREF(__pyx_int_25411819);
5705 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_25411819);
5706 __Pyx_INCREF(Py_None);
5707 __Pyx_GIVEREF(Py_None);
5708 PyTuple_SET_ITEM(__pyx_t_3, 2, Py_None);
5709 __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 13, __pyx_L1_error)
5710 __Pyx_GOTREF(__pyx_t_1);
5711 __Pyx_GIVEREF(__pyx_t_2);
5712 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
5713 __Pyx_GIVEREF(__pyx_t_3);
5714 PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
5715 __Pyx_INCREF(__pyx_v_state);
5716 __Pyx_GIVEREF(__pyx_v_state);
5717 PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_state);
5718 __pyx_t_2 = 0;
5719 __pyx_t_3 = 0;
5720 __pyx_r = __pyx_t_1;
5721 __pyx_t_1 = 0;
5722 goto __pyx_L0;
5723
5724 /* "(tree fragment)":12
5725 * else:
5726 * use_setstate = self.buffer is not None or self.read_block is not None
5727 * if use_setstate: # <<<<<<<<<<<<<<
5728 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, None), state
5729 * else:
24115730 */
24125731 }
24135732
2414 /* "clickhouse_driver/bufferedreader.pyx":69
2415 * self.position = 0
2416 *
2417 * rv = self.buffer[self.position] # <<<<<<<<<<<<<<
2418 * self.position += 1
2419 * return rv
2420 */
2421 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 69, __pyx_L1_error)
2422 __Pyx_GOTREF(__pyx_t_3);
2423 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
2424 __Pyx_GOTREF(__pyx_t_2);
2425 __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
2426 __Pyx_GOTREF(__pyx_t_1);
2427 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2428 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2429 __pyx_v_rv = __pyx_t_1;
2430 __pyx_t_1 = 0;
2431
2432 /* "clickhouse_driver/bufferedreader.pyx":70
2433 *
2434 * rv = self.buffer[self.position]
2435 * self.position += 1 # <<<<<<<<<<<<<<
2436 * return rv
2437 *
2438 */
2439 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
2440 __Pyx_GOTREF(__pyx_t_1);
2441 __pyx_t_2 = __Pyx_PyInt_AddObjC(__pyx_t_1, __pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
2442 __Pyx_GOTREF(__pyx_t_2);
2443 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2444 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_t_2) < 0) __PYX_ERR(0, 70, __pyx_L1_error)
2445 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2446
2447 /* "clickhouse_driver/bufferedreader.pyx":71
2448 * rv = self.buffer[self.position]
2449 * self.position += 1
2450 * return rv # <<<<<<<<<<<<<<
2451 *
2452 * def read_strings(self, Py_ssize_t n_items, int decode=0):
2453 */
2454 __Pyx_XDECREF(__pyx_r);
2455 __Pyx_INCREF(__pyx_v_rv);
2456 __pyx_r = __pyx_v_rv;
2457 goto __pyx_L0;
2458
2459 /* "clickhouse_driver/bufferedreader.pyx":64
2460 * return bytearray(rv)
2461 *
2462 * def read_one(self): # <<<<<<<<<<<<<<
2463 * if self.position == self.current_buffer_size:
2464 * self.read_into_buffer()
5733 /* "(tree fragment)":15
5734 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, None), state
5735 * else:
5736 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, state) # <<<<<<<<<<<<<<
5737 * def __setstate_cython__(self, __pyx_state):
5738 * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state)
5739 */
5740 /*else*/ {
5741 __Pyx_XDECREF(__pyx_r);
5742 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_pyx_unpickle_CompressedBuffere); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 15, __pyx_L1_error)
5743 __Pyx_GOTREF(__pyx_t_1);
5744 __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 15, __pyx_L1_error)
5745 __Pyx_GOTREF(__pyx_t_3);
5746 __Pyx_INCREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5747 __Pyx_GIVEREF(((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5748 PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)Py_TYPE(((PyObject *)__pyx_v_self))));
5749 __Pyx_INCREF(__pyx_int_25411819);
5750 __Pyx_GIVEREF(__pyx_int_25411819);
5751 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_25411819);
5752 __Pyx_INCREF(__pyx_v_state);
5753 __Pyx_GIVEREF(__pyx_v_state);
5754 PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_state);
5755 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 15, __pyx_L1_error)
5756 __Pyx_GOTREF(__pyx_t_2);
5757 __Pyx_GIVEREF(__pyx_t_1);
5758 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
5759 __Pyx_GIVEREF(__pyx_t_3);
5760 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
5761 __pyx_t_1 = 0;
5762 __pyx_t_3 = 0;
5763 __pyx_r = __pyx_t_2;
5764 __pyx_t_2 = 0;
5765 goto __pyx_L0;
5766 }
5767
5768 /* "(tree fragment)":1
5769 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
5770 * cdef tuple state
5771 * cdef object _dict
24655772 */
24665773
24675774 /* function exit code */
24695776 __Pyx_XDECREF(__pyx_t_1);
24705777 __Pyx_XDECREF(__pyx_t_2);
24715778 __Pyx_XDECREF(__pyx_t_3);
2472 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_one", __pyx_clineno, __pyx_lineno, __pyx_filename);
5779 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
24735780 __pyx_r = NULL;
24745781 __pyx_L0:;
2475 __Pyx_XDECREF(__pyx_v_rv);
5782 __Pyx_XDECREF(__pyx_v_state);
5783 __Pyx_XDECREF(__pyx_v__dict);
24765784 __Pyx_XGIVEREF(__pyx_r);
24775785 __Pyx_RefNannyFinishContext();
24785786 return __pyx_r;
24795787 }
24805788
2481 /* "clickhouse_driver/bufferedreader.pyx":73
2482 * return rv
2483 *
2484 * def read_strings(self, Py_ssize_t n_items, int decode=0): # <<<<<<<<<<<<<<
2485 * """
2486 * Python has great overhead between function calls.
5789 /* "(tree fragment)":16
5790 * else:
5791 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, state)
5792 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5793 * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state)
24875794 */
24885795
24895796 /* Python wrapper */
2490 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2491 static char __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings[] = "\n Python has great overhead between function calls.\n We inline strings reading logic here to avoid this overhead.\n ";
2492 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings = {"read_strings", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, METH_VARARGS|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings};
2493 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2494 PyObject *__pyx_v_self = 0;
2495 Py_ssize_t __pyx_v_n_items;
2496 int __pyx_v_decode;
5797 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
5798 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
24975799 PyObject *__pyx_r = 0;
24985800 __Pyx_RefNannyDeclarations
2499 __Pyx_RefNannySetupContext("read_strings (wrapper)", 0);
5801 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
5802 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
5803
5804 /* function exit code */
5805 __Pyx_RefNannyFinishContext();
5806 return __pyx_r;
5807 }
5808
5809 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_6__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
5810 PyObject *__pyx_r = NULL;
5811 __Pyx_RefNannyDeclarations
5812 PyObject *__pyx_t_1 = NULL;
5813 int __pyx_lineno = 0;
5814 const char *__pyx_filename = NULL;
5815 int __pyx_clineno = 0;
5816 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
5817
5818 /* "(tree fragment)":17
5819 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, state)
5820 * def __setstate_cython__(self, __pyx_state):
5821 * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state) # <<<<<<<<<<<<<<
5822 */
5823 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 17, __pyx_L1_error)
5824 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(__pyx_v_self, ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 17, __pyx_L1_error)
5825 __Pyx_GOTREF(__pyx_t_1);
5826 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5827
5828 /* "(tree fragment)":16
5829 * else:
5830 * return __pyx_unpickle_CompressedBufferedReader, (type(self), 0x183c0eb, state)
5831 * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<<
5832 * __pyx_unpickle_CompressedBufferedReader__set_state(self, __pyx_state)
5833 */
5834
5835 /* function exit code */
5836 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5837 goto __pyx_L0;
5838 __pyx_L1_error:;
5839 __Pyx_XDECREF(__pyx_t_1);
5840 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename);
5841 __pyx_r = NULL;
5842 __pyx_L0:;
5843 __Pyx_XGIVEREF(__pyx_r);
5844 __Pyx_RefNannyFinishContext();
5845 return __pyx_r;
5846 }
5847
5848 /* "(tree fragment)":1
5849 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
5850 * cdef object __pyx_PickleError
5851 * cdef object __pyx_result
5852 */
5853
5854 /* Python wrapper */
5855 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5856 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader = {"__pyx_unpickle_BufferedReader", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader, METH_VARARGS|METH_KEYWORDS, 0};
5857 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5858 PyObject *__pyx_v___pyx_type = 0;
5859 long __pyx_v___pyx_checksum;
5860 PyObject *__pyx_v___pyx_state = 0;
5861 int __pyx_lineno = 0;
5862 const char *__pyx_filename = NULL;
5863 int __pyx_clineno = 0;
5864 PyObject *__pyx_r = 0;
5865 __Pyx_RefNannyDeclarations
5866 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader (wrapper)", 0);
25005867 {
2501 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_decode,0};
5868 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
25025869 PyObject* values[3] = {0,0,0};
25035870 if (unlikely(__pyx_kwds)) {
25045871 Py_ssize_t kw_args;
25165883 kw_args = PyDict_Size(__pyx_kwds);
25175884 switch (pos_args) {
25185885 case 0:
2519 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
5886 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
25205887 else goto __pyx_L5_argtuple_error;
25215888 CYTHON_FALLTHROUGH;
25225889 case 1:
2523 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
5890 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
25245891 else {
2525 __Pyx_RaiseArgtupleInvalid("read_strings", 0, 2, 3, 1); __PYX_ERR(0, 73, __pyx_L3_error)
5892 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedReader", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
25265893 }
25275894 CYTHON_FALLTHROUGH;
25285895 case 2:
2529 if (kw_args > 0) {
2530 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_decode);
2531 if (value) { values[2] = value; kw_args--; }
5896 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
5897 else {
5898 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedReader", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
25325899 }
25335900 }
25345901 if (unlikely(kw_args > 0)) {
2535 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_strings") < 0)) __PYX_ERR(0, 73, __pyx_L3_error)
5902 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_BufferedReader") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
25365903 }
5904 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
5905 goto __pyx_L5_argtuple_error;
25375906 } else {
2538 switch (PyTuple_GET_SIZE(__pyx_args)) {
2539 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2540 CYTHON_FALLTHROUGH;
2541 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2542 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2543 break;
2544 default: goto __pyx_L5_argtuple_error;
2545 }
2546 }
2547 __pyx_v_self = values[0];
2548 __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L3_error)
2549 if (values[2]) {
2550 __pyx_v_decode = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_decode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 73, __pyx_L3_error)
2551 } else {
2552 __pyx_v_decode = ((int)((int)0));
2553 }
5907 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5908 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5909 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5910 }
5911 __pyx_v___pyx_type = values[0];
5912 __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
5913 __pyx_v___pyx_state = values[2];
25545914 }
25555915 goto __pyx_L4_argument_unpacking_done;
25565916 __pyx_L5_argtuple_error:;
2557 __Pyx_RaiseArgtupleInvalid("read_strings", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 73, __pyx_L3_error)
5917 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedReader", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
25585918 __pyx_L3_error:;
2559 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
5919 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
25605920 __Pyx_RefNannyFinishContext();
25615921 return NULL;
25625922 __pyx_L4_argument_unpacking_done:;
2563 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_decode);
5923 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
25645924
25655925 /* function exit code */
25665926 __Pyx_RefNannyFinishContext();
25675927 return __pyx_r;
25685928 }
25695929
2570 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, int __pyx_v_decode) {
2571 PyObject *__pyx_v_items = NULL;
2572 PyObject *__pyx_v_buffer = NULL;
2573 Py_ssize_t __pyx_v_i;
2574 char *__pyx_v_buffer_ptr;
2575 Py_ssize_t __pyx_v_right;
2576 Py_ssize_t __pyx_v_position;
2577 Py_ssize_t __pyx_v_current_buffer_size;
2578 Py_ssize_t __pyx_v_size;
2579 Py_ssize_t __pyx_v_shift;
2580 unsigned char __pyx_v_b;
2581 char *__pyx_v_c_string;
2582 Py_ssize_t __pyx_v_c_string_size;
2583 PyObject *__pyx_v_bytes_read = NULL;
2584 PyObject *__pyx_v_rv = NULL;
5930 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
5931 PyObject *__pyx_v___pyx_PickleError = 0;
5932 PyObject *__pyx_v___pyx_result = 0;
5933 PyObject *__pyx_r = NULL;
5934 __Pyx_RefNannyDeclarations
5935 int __pyx_t_1;
5936 PyObject *__pyx_t_2 = NULL;
5937 PyObject *__pyx_t_3 = NULL;
5938 PyObject *__pyx_t_4 = NULL;
5939 PyObject *__pyx_t_5 = NULL;
5940 int __pyx_t_6;
5941 int __pyx_lineno = 0;
5942 const char *__pyx_filename = NULL;
5943 int __pyx_clineno = 0;
5944 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader", 0);
5945
5946 /* "(tree fragment)":4
5947 * cdef object __pyx_PickleError
5948 * cdef object __pyx_result
5949 * if __pyx_checksum != 0x2a8a945: # <<<<<<<<<<<<<<
5950 * from pickle import PickleError as __pyx_PickleError
5951 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
5952 */
5953 __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x2a8a945) != 0);
5954 if (__pyx_t_1) {
5955
5956 /* "(tree fragment)":5
5957 * cdef object __pyx_result
5958 * if __pyx_checksum != 0x2a8a945:
5959 * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
5960 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
5961 * __pyx_result = BufferedReader.__new__(__pyx_type)
5962 */
5963 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
5964 __Pyx_GOTREF(__pyx_t_2);
5965 __Pyx_INCREF(__pyx_n_s_PickleError);
5966 __Pyx_GIVEREF(__pyx_n_s_PickleError);
5967 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
5968 __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
5969 __Pyx_GOTREF(__pyx_t_3);
5970 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5971 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
5972 __Pyx_GOTREF(__pyx_t_2);
5973 __Pyx_INCREF(__pyx_t_2);
5974 __pyx_v___pyx_PickleError = __pyx_t_2;
5975 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5976 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5977
5978 /* "(tree fragment)":6
5979 * if __pyx_checksum != 0x2a8a945:
5980 * from pickle import PickleError as __pyx_PickleError
5981 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum) # <<<<<<<<<<<<<<
5982 * __pyx_result = BufferedReader.__new__(__pyx_type)
5983 * if __pyx_state is not None:
5984 */
5985 __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
5986 __Pyx_GOTREF(__pyx_t_2);
5987 __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x2a, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
5988 __Pyx_GOTREF(__pyx_t_4);
5989 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5990 __Pyx_INCREF(__pyx_v___pyx_PickleError);
5991 __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
5992 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5993 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
5994 if (likely(__pyx_t_5)) {
5995 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5996 __Pyx_INCREF(__pyx_t_5);
5997 __Pyx_INCREF(function);
5998 __Pyx_DECREF_SET(__pyx_t_2, function);
5999 }
6000 }
6001 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
6002 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6003 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6004 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
6005 __Pyx_GOTREF(__pyx_t_3);
6006 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6007 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6008 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6009 __PYX_ERR(1, 6, __pyx_L1_error)
6010
6011 /* "(tree fragment)":4
6012 * cdef object __pyx_PickleError
6013 * cdef object __pyx_result
6014 * if __pyx_checksum != 0x2a8a945: # <<<<<<<<<<<<<<
6015 * from pickle import PickleError as __pyx_PickleError
6016 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
6017 */
6018 }
6019
6020 /* "(tree fragment)":7
6021 * from pickle import PickleError as __pyx_PickleError
6022 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
6023 * __pyx_result = BufferedReader.__new__(__pyx_type) # <<<<<<<<<<<<<<
6024 * if __pyx_state is not None:
6025 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6026 */
6027 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
6028 __Pyx_GOTREF(__pyx_t_2);
6029 __pyx_t_4 = NULL;
6030 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
6031 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
6032 if (likely(__pyx_t_4)) {
6033 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6034 __Pyx_INCREF(__pyx_t_4);
6035 __Pyx_INCREF(function);
6036 __Pyx_DECREF_SET(__pyx_t_2, function);
6037 }
6038 }
6039 __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
6040 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6041 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
6042 __Pyx_GOTREF(__pyx_t_3);
6043 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6044 __pyx_v___pyx_result = __pyx_t_3;
6045 __pyx_t_3 = 0;
6046
6047 /* "(tree fragment)":8
6048 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
6049 * __pyx_result = BufferedReader.__new__(__pyx_type)
6050 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6051 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6052 * return __pyx_result
6053 */
6054 __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
6055 __pyx_t_6 = (__pyx_t_1 != 0);
6056 if (__pyx_t_6) {
6057
6058 /* "(tree fragment)":9
6059 * __pyx_result = BufferedReader.__new__(__pyx_type)
6060 * if __pyx_state is not None:
6061 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
6062 * return __pyx_result
6063 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state):
6064 */
6065 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
6066 __pyx_t_3 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
6067 __Pyx_GOTREF(__pyx_t_3);
6068 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6069
6070 /* "(tree fragment)":8
6071 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x2a8a945 = (buffer, current_buffer_size, position))" % __pyx_checksum)
6072 * __pyx_result = BufferedReader.__new__(__pyx_type)
6073 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6074 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6075 * return __pyx_result
6076 */
6077 }
6078
6079 /* "(tree fragment)":10
6080 * if __pyx_state is not None:
6081 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6082 * return __pyx_result # <<<<<<<<<<<<<<
6083 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state):
6084 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6085 */
6086 __Pyx_XDECREF(__pyx_r);
6087 __Pyx_INCREF(__pyx_v___pyx_result);
6088 __pyx_r = __pyx_v___pyx_result;
6089 goto __pyx_L0;
6090
6091 /* "(tree fragment)":1
6092 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6093 * cdef object __pyx_PickleError
6094 * cdef object __pyx_result
6095 */
6096
6097 /* function exit code */
6098 __pyx_L1_error:;
6099 __Pyx_XDECREF(__pyx_t_2);
6100 __Pyx_XDECREF(__pyx_t_3);
6101 __Pyx_XDECREF(__pyx_t_4);
6102 __Pyx_XDECREF(__pyx_t_5);
6103 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
6104 __pyx_r = NULL;
6105 __pyx_L0:;
6106 __Pyx_XDECREF(__pyx_v___pyx_PickleError);
6107 __Pyx_XDECREF(__pyx_v___pyx_result);
6108 __Pyx_XGIVEREF(__pyx_r);
6109 __Pyx_RefNannyFinishContext();
6110 return __pyx_r;
6111 }
6112
6113 /* "(tree fragment)":11
6114 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6115 * return __pyx_result
6116 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
6117 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6118 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
6119 */
6120
6121 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
25856122 PyObject *__pyx_r = NULL;
25866123 __Pyx_RefNannyDeclarations
25876124 PyObject *__pyx_t_1 = NULL;
2588 Py_ssize_t __pyx_t_2;
2589 Py_ssize_t __pyx_t_3;
6125 unsigned PY_LONG_LONG __pyx_t_2;
6126 int __pyx_t_3;
25906127 Py_ssize_t __pyx_t_4;
25916128 int __pyx_t_5;
2592 PyObject *__pyx_t_6 = NULL;
6129 int __pyx_t_6;
25936130 PyObject *__pyx_t_7 = NULL;
2594 Py_ssize_t __pyx_t_8;
2595 Py_ssize_t __pyx_t_9;
2596 Py_ssize_t __pyx_t_10;
2597 PyObject *__pyx_t_11 = NULL;
2598 PyObject *__pyx_t_12 = NULL;
2599 PyObject *__pyx_t_13 = NULL;
2600 int __pyx_t_14;
2601 PyObject *__pyx_t_15 = NULL;
2602 __Pyx_RefNannySetupContext("read_strings", 0);
2603
2604 /* "clickhouse_driver/bufferedreader.pyx":78
2605 * We inline strings reading logic here to avoid this overhead.
2606 * """
2607 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
2608 *
2609 * # Reduce getattr(self, ...), calls.
2610 */
2611 __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error)
6131 PyObject *__pyx_t_8 = NULL;
6132 PyObject *__pyx_t_9 = NULL;
6133 int __pyx_lineno = 0;
6134 const char *__pyx_filename = NULL;
6135 int __pyx_clineno = 0;
6136 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedReader__set_state", 0);
6137
6138 /* "(tree fragment)":12
6139 * return __pyx_result
6140 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state):
6141 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2] # <<<<<<<<<<<<<<
6142 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
6143 * __pyx_result.__dict__.update(__pyx_state[3])
6144 */
6145 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6146 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6147 __PYX_ERR(1, 12, __pyx_L1_error)
6148 }
6149 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
26126150 __Pyx_GOTREF(__pyx_t_1);
2613 __pyx_v_items = ((PyObject*)__pyx_t_1);
6151 if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
6152 __Pyx_GIVEREF(__pyx_t_1);
6153 __Pyx_GOTREF(__pyx_v___pyx_result->buffer);
6154 __Pyx_DECREF(__pyx_v___pyx_result->buffer);
6155 __pyx_v___pyx_result->buffer = ((PyObject*)__pyx_t_1);
26146156 __pyx_t_1 = 0;
2615
2616 /* "clickhouse_driver/bufferedreader.pyx":81
2617 *
2618 * # Reduce getattr(self, ...), calls.
2619 * buffer = self.buffer # <<<<<<<<<<<<<<
2620 * cdef Py_ssize_t i
2621 * # Buffer vars
2622 */
2623 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error)
6157 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6158 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6159 __PYX_ERR(1, 12, __pyx_L1_error)
6160 }
6161 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
26246162 __Pyx_GOTREF(__pyx_t_1);
2625 __pyx_v_buffer = __pyx_t_1;
2626 __pyx_t_1 = 0;
2627
2628 /* "clickhouse_driver/bufferedreader.pyx":84
2629 * cdef Py_ssize_t i
2630 * # Buffer vars
2631 * cdef char* buffer_ptr = PyByteArray_AsString(buffer) # <<<<<<<<<<<<<<
2632 * cdef Py_ssize_t right, position = self.position
2633 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size
2634 */
2635 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_v_buffer);
2636
2637 /* "clickhouse_driver/bufferedreader.pyx":85
2638 * # Buffer vars
2639 * cdef char* buffer_ptr = PyByteArray_AsString(buffer)
2640 * cdef Py_ssize_t right, position = self.position # <<<<<<<<<<<<<<
2641 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size
2642 * # String length vars
2643 */
2644 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error)
6163 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
6164 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6165 __pyx_v___pyx_result->current_buffer_size = __pyx_t_2;
6166 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6167 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6168 __PYX_ERR(1, 12, __pyx_L1_error)
6169 }
6170 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
26456171 __Pyx_GOTREF(__pyx_t_1);
2646 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
6172 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
26476173 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2648 __pyx_v_position = __pyx_t_2;
2649
2650 /* "clickhouse_driver/bufferedreader.pyx":86
2651 * cdef char* buffer_ptr = PyByteArray_AsString(buffer)
2652 * cdef Py_ssize_t right, position = self.position
2653 * cdef Py_ssize_t current_buffer_size = self.current_buffer_size # <<<<<<<<<<<<<<
2654 * # String length vars
2655 * cdef Py_ssize_t size, shift
2656 */
2657 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
2658 __Pyx_GOTREF(__pyx_t_1);
2659 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L1_error)
2660 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2661 __pyx_v_current_buffer_size = __pyx_t_2;
2662
2663 /* "clickhouse_driver/bufferedreader.pyx":92
2664 *
2665 * # String for decode vars.
2666 * cdef char *c_string = NULL # <<<<<<<<<<<<<<
2667 * cdef Py_ssize_t c_string_size = 0, large_str_bytes
2668 *
2669 */
2670 __pyx_v_c_string = NULL;
2671
2672 /* "clickhouse_driver/bufferedreader.pyx":93
2673 * # String for decode vars.
2674 * cdef char *c_string = NULL
2675 * cdef Py_ssize_t c_string_size = 0, large_str_bytes # <<<<<<<<<<<<<<
2676 *
2677 * for i in range(n_items):
2678 */
2679 __pyx_v_c_string_size = 0;
2680
2681 /* "clickhouse_driver/bufferedreader.pyx":95
2682 * cdef Py_ssize_t c_string_size = 0, large_str_bytes
2683 *
2684 * for i in range(n_items): # <<<<<<<<<<<<<<
2685 * shift = size = 0
2686 *
2687 */
2688 __pyx_t_2 = __pyx_v_n_items;
2689 __pyx_t_3 = __pyx_t_2;
2690 for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
2691 __pyx_v_i = __pyx_t_4;
2692
2693 /* "clickhouse_driver/bufferedreader.pyx":96
2694 *
2695 * for i in range(n_items):
2696 * shift = size = 0 # <<<<<<<<<<<<<<
2697 *
2698 * # Read string size
2699 */
2700 __pyx_v_shift = 0;
2701 __pyx_v_size = 0;
2702
2703 /* "clickhouse_driver/bufferedreader.pyx":99
2704 *
2705 * # Read string size
2706 * while True: # <<<<<<<<<<<<<<
2707 * if position == current_buffer_size:
2708 * self.read_into_buffer()
2709 */
2710 while (1) {
2711
2712 /* "clickhouse_driver/bufferedreader.pyx":100
2713 * # Read string size
2714 * while True:
2715 * if position == current_buffer_size: # <<<<<<<<<<<<<<
2716 * self.read_into_buffer()
2717 * # `read_into_buffer` can override
2718 */
2719 __pyx_t_5 = ((__pyx_v_position == __pyx_v_current_buffer_size) != 0);
2720 if (__pyx_t_5) {
2721
2722 /* "clickhouse_driver/bufferedreader.pyx":101
2723 * while True:
2724 * if position == current_buffer_size:
2725 * self.read_into_buffer() # <<<<<<<<<<<<<<
2726 * # `read_into_buffer` can override
2727 * # buffer, current_buffer_size
2728 */
2729 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 101, __pyx_L1_error)
2730 __Pyx_GOTREF(__pyx_t_6);
2731 __pyx_t_7 = NULL;
2732 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
2733 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
2734 if (likely(__pyx_t_7)) {
2735 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2736 __Pyx_INCREF(__pyx_t_7);
2737 __Pyx_INCREF(function);
2738 __Pyx_DECREF_SET(__pyx_t_6, function);
2739 }
2740 }
2741 __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
2742 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2743 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error)
2744 __Pyx_GOTREF(__pyx_t_1);
2745 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2746 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2747
2748 /* "clickhouse_driver/bufferedreader.pyx":105
2749 * # buffer, current_buffer_size
2750 * # We need to restore them.
2751 * buffer = self.buffer # <<<<<<<<<<<<<<
2752 * current_buffer_size = self.current_buffer_size
2753 * buffer_ptr = PyByteArray_AsString(buffer)
2754 */
2755 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error)
2756 __Pyx_GOTREF(__pyx_t_1);
2757 __Pyx_DECREF_SET(__pyx_v_buffer, __pyx_t_1);
2758 __pyx_t_1 = 0;
2759
2760 /* "clickhouse_driver/bufferedreader.pyx":106
2761 * # We need to restore them.
2762 * buffer = self.buffer
2763 * current_buffer_size = self.current_buffer_size # <<<<<<<<<<<<<<
2764 * buffer_ptr = PyByteArray_AsString(buffer)
2765 * position = 0
2766 */
2767 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 106, __pyx_L1_error)
2768 __Pyx_GOTREF(__pyx_t_1);
2769 __pyx_t_8 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_8 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 106, __pyx_L1_error)
2770 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2771 __pyx_v_current_buffer_size = __pyx_t_8;
2772
2773 /* "clickhouse_driver/bufferedreader.pyx":107
2774 * buffer = self.buffer
2775 * current_buffer_size = self.current_buffer_size
2776 * buffer_ptr = PyByteArray_AsString(buffer) # <<<<<<<<<<<<<<
2777 * position = 0
2778 *
2779 */
2780 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_v_buffer);
2781
2782 /* "clickhouse_driver/bufferedreader.pyx":108
2783 * current_buffer_size = self.current_buffer_size
2784 * buffer_ptr = PyByteArray_AsString(buffer)
2785 * position = 0 # <<<<<<<<<<<<<<
2786 *
2787 * b = buffer_ptr[position]
2788 */
2789 __pyx_v_position = 0;
2790
2791 /* "clickhouse_driver/bufferedreader.pyx":100
2792 * # Read string size
2793 * while True:
2794 * if position == current_buffer_size: # <<<<<<<<<<<<<<
2795 * self.read_into_buffer()
2796 * # `read_into_buffer` can override
2797 */
6174 __pyx_v___pyx_result->position = __pyx_t_2;
6175
6176 /* "(tree fragment)":13
6177 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state):
6178 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6179 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
6180 * __pyx_result.__dict__.update(__pyx_state[3])
6181 */
6182 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6183 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
6184 __PYX_ERR(1, 13, __pyx_L1_error)
6185 }
6186 __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6187 __pyx_t_5 = ((__pyx_t_4 > 3) != 0);
6188 if (__pyx_t_5) {
6189 } else {
6190 __pyx_t_3 = __pyx_t_5;
6191 goto __pyx_L4_bool_binop_done;
6192 }
6193 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6194 __pyx_t_6 = (__pyx_t_5 != 0);
6195 __pyx_t_3 = __pyx_t_6;
6196 __pyx_L4_bool_binop_done:;
6197 if (__pyx_t_3) {
6198
6199 /* "(tree fragment)":14
6200 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6201 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
6202 * __pyx_result.__dict__.update(__pyx_state[3]) # <<<<<<<<<<<<<<
6203 */
6204 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
6205 __Pyx_GOTREF(__pyx_t_7);
6206 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
6207 __Pyx_GOTREF(__pyx_t_8);
6208 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6209 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6210 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6211 __PYX_ERR(1, 14, __pyx_L1_error)
6212 }
6213 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
6214 __Pyx_GOTREF(__pyx_t_7);
6215 __pyx_t_9 = NULL;
6216 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
6217 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
6218 if (likely(__pyx_t_9)) {
6219 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
6220 __Pyx_INCREF(__pyx_t_9);
6221 __Pyx_INCREF(function);
6222 __Pyx_DECREF_SET(__pyx_t_8, function);
27986223 }
2799
2800 /* "clickhouse_driver/bufferedreader.pyx":110
2801 * position = 0
2802 *
2803 * b = buffer_ptr[position] # <<<<<<<<<<<<<<
2804 * position += 1
2805 *
2806 */
2807 __pyx_v_b = (__pyx_v_buffer_ptr[__pyx_v_position]);
2808
2809 /* "clickhouse_driver/bufferedreader.pyx":111
2810 *
2811 * b = buffer_ptr[position]
2812 * position += 1 # <<<<<<<<<<<<<<
2813 *
2814 * size |= (b & 0x7f) << shift
2815 */
2816 __pyx_v_position = (__pyx_v_position + 1);
2817
2818 /* "clickhouse_driver/bufferedreader.pyx":113
2819 * position += 1
2820 *
2821 * size |= (b & 0x7f) << shift # <<<<<<<<<<<<<<
2822 * if b < 0x80:
2823 * break
2824 */
2825 __pyx_v_size = (__pyx_v_size | ((__pyx_v_b & 0x7f) << __pyx_v_shift));
2826
2827 /* "clickhouse_driver/bufferedreader.pyx":114
2828 *
2829 * size |= (b & 0x7f) << shift
2830 * if b < 0x80: # <<<<<<<<<<<<<<
2831 * break
2832 *
2833 */
2834 __pyx_t_5 = ((__pyx_v_b < 0x80) != 0);
2835 if (__pyx_t_5) {
2836
2837 /* "clickhouse_driver/bufferedreader.pyx":115
2838 * size |= (b & 0x7f) << shift
2839 * if b < 0x80:
2840 * break # <<<<<<<<<<<<<<
2841 *
2842 * shift += 7
2843 */
2844 goto __pyx_L6_break;
2845
2846 /* "clickhouse_driver/bufferedreader.pyx":114
2847 *
2848 * size |= (b & 0x7f) << shift
2849 * if b < 0x80: # <<<<<<<<<<<<<<
2850 * break
2851 *
2852 */
2853 }
2854
2855 /* "clickhouse_driver/bufferedreader.pyx":117
2856 * break
2857 *
2858 * shift += 7 # <<<<<<<<<<<<<<
2859 *
2860 * right = position + size
2861 */
2862 __pyx_v_shift = (__pyx_v_shift + 7);
2863 }
2864 __pyx_L6_break:;
2865
2866 /* "clickhouse_driver/bufferedreader.pyx":119
2867 * shift += 7
2868 *
2869 * right = position + size # <<<<<<<<<<<<<<
2870 *
2871 * if decode:
2872 */
2873 __pyx_v_right = (__pyx_v_position + __pyx_v_size);
2874
2875 /* "clickhouse_driver/bufferedreader.pyx":121
2876 * right = position + size
2877 *
2878 * if decode: # <<<<<<<<<<<<<<
2879 * c_string = maybe_resize_c_string(c_string, c_string_size,
2880 * size + 1)
2881 */
2882 __pyx_t_5 = (__pyx_v_decode != 0);
2883 if (__pyx_t_5) {
2884
2885 /* "clickhouse_driver/bufferedreader.pyx":122
2886 *
2887 * if decode:
2888 * c_string = maybe_resize_c_string(c_string, c_string_size, # <<<<<<<<<<<<<<
2889 * size + 1)
2890 * c_string_size = max(c_string_size, size + 1)
2891 */
2892 __pyx_v_c_string = __pyx_f_17clickhouse_driver_14bufferedreader_maybe_resize_c_string(__pyx_v_c_string, __pyx_v_c_string_size, (__pyx_v_size + 1));
2893
2894 /* "clickhouse_driver/bufferedreader.pyx":124
2895 * c_string = maybe_resize_c_string(c_string, c_string_size,
2896 * size + 1)
2897 * c_string_size = max(c_string_size, size + 1) # <<<<<<<<<<<<<<
2898 * c_string[size] = 0
2899 * bytes_read = 0
2900 */
2901 __pyx_t_8 = (__pyx_v_size + 1);
2902 __pyx_t_9 = __pyx_v_c_string_size;
2903 if (((__pyx_t_8 > __pyx_t_9) != 0)) {
2904 __pyx_t_10 = __pyx_t_8;
2905 } else {
2906 __pyx_t_10 = __pyx_t_9;
2907 }
2908 __pyx_v_c_string_size = __pyx_t_10;
2909
2910 /* "clickhouse_driver/bufferedreader.pyx":125
2911 * size + 1)
2912 * c_string_size = max(c_string_size, size + 1)
2913 * c_string[size] = 0 # <<<<<<<<<<<<<<
2914 * bytes_read = 0
2915 *
2916 */
2917 (__pyx_v_c_string[__pyx_v_size]) = 0;
2918
2919 /* "clickhouse_driver/bufferedreader.pyx":126
2920 * c_string_size = max(c_string_size, size + 1)
2921 * c_string[size] = 0
2922 * bytes_read = 0 # <<<<<<<<<<<<<<
2923 *
2924 * # Decoding pure c strings in Cython is faster than in pure Python.
2925 */
2926 __Pyx_INCREF(__pyx_int_0);
2927 __Pyx_XDECREF_SET(__pyx_v_bytes_read, __pyx_int_0);
2928
2929 /* "clickhouse_driver/bufferedreader.pyx":121
2930 * right = position + size
2931 *
2932 * if decode: # <<<<<<<<<<<<<<
2933 * c_string = maybe_resize_c_string(c_string, c_string_size,
2934 * size + 1)
2935 */
2936 }
2937
2938 /* "clickhouse_driver/bufferedreader.pyx":131
2939 * # We need to copy it into buffer for adding null symbol at the end.
2940 * # In ClickHouse block there is no null
2941 * if right > current_buffer_size: # <<<<<<<<<<<<<<
2942 * if decode:
2943 * memcpy(&c_string[bytes_read], &buffer_ptr[position],
2944 */
2945 __pyx_t_5 = ((__pyx_v_right > __pyx_v_current_buffer_size) != 0);
2946 if (__pyx_t_5) {
2947
2948 /* "clickhouse_driver/bufferedreader.pyx":132
2949 * # In ClickHouse block there is no null
2950 * if right > current_buffer_size:
2951 * if decode: # <<<<<<<<<<<<<<
2952 * memcpy(&c_string[bytes_read], &buffer_ptr[position],
2953 * current_buffer_size - position)
2954 */
2955 __pyx_t_5 = (__pyx_v_decode != 0);
2956 if (__pyx_t_5) {
2957
2958 /* "clickhouse_driver/bufferedreader.pyx":133
2959 * if right > current_buffer_size:
2960 * if decode:
2961 * memcpy(&c_string[bytes_read], &buffer_ptr[position], # <<<<<<<<<<<<<<
2962 * current_buffer_size - position)
2963 * else:
2964 */
2965 if (unlikely(!__pyx_v_bytes_read)) { __Pyx_RaiseUnboundLocalError("bytes_read"); __PYX_ERR(0, 133, __pyx_L1_error) }
2966 __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bytes_read); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L1_error)
2967
2968 /* "clickhouse_driver/bufferedreader.pyx":134
2969 * if decode:
2970 * memcpy(&c_string[bytes_read], &buffer_ptr[position],
2971 * current_buffer_size - position) # <<<<<<<<<<<<<<
2972 * else:
2973 * rv = PyBytes_FromStringAndSize(
2974 */
2975 (void)(memcpy((&(__pyx_v_c_string[__pyx_t_10])), (&(__pyx_v_buffer_ptr[__pyx_v_position])), (__pyx_v_current_buffer_size - __pyx_v_position)));
2976
2977 /* "clickhouse_driver/bufferedreader.pyx":132
2978 * # In ClickHouse block there is no null
2979 * if right > current_buffer_size:
2980 * if decode: # <<<<<<<<<<<<<<
2981 * memcpy(&c_string[bytes_read], &buffer_ptr[position],
2982 * current_buffer_size - position)
2983 */
2984 goto __pyx_L11;
2985 }
2986
2987 /* "clickhouse_driver/bufferedreader.pyx":136
2988 * current_buffer_size - position)
2989 * else:
2990 * rv = PyBytes_FromStringAndSize( # <<<<<<<<<<<<<<
2991 * &buffer_ptr[position], current_buffer_size - position
2992 * )
2993 */
2994 /*else*/ {
2995
2996 /* "clickhouse_driver/bufferedreader.pyx":137
2997 * else:
2998 * rv = PyBytes_FromStringAndSize(
2999 * &buffer_ptr[position], current_buffer_size - position # <<<<<<<<<<<<<<
3000 * )
3001 *
3002 */
3003 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_position])), (__pyx_v_current_buffer_size - __pyx_v_position)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 136, __pyx_L1_error)
3004 __Pyx_GOTREF(__pyx_t_1);
3005 __Pyx_XDECREF_SET(__pyx_v_rv, __pyx_t_1);
3006 __pyx_t_1 = 0;
3007 }
3008 __pyx_L11:;
3009
3010 /* "clickhouse_driver/bufferedreader.pyx":140
3011 * )
3012 *
3013 * bytes_read = current_buffer_size - position # <<<<<<<<<<<<<<
3014 * # Read the rest of the string.
3015 * while bytes_read != size:
3016 */
3017 __pyx_t_1 = PyInt_FromSsize_t((__pyx_v_current_buffer_size - __pyx_v_position)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
3018 __Pyx_GOTREF(__pyx_t_1);
3019 __Pyx_XDECREF_SET(__pyx_v_bytes_read, __pyx_t_1);
3020 __pyx_t_1 = 0;
3021
3022 /* "clickhouse_driver/bufferedreader.pyx":142
3023 * bytes_read = current_buffer_size - position
3024 * # Read the rest of the string.
3025 * while bytes_read != size: # <<<<<<<<<<<<<<
3026 * position = size - bytes_read
3027 *
3028 */
3029 while (1) {
3030 __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
3031 __Pyx_GOTREF(__pyx_t_1);
3032 __pyx_t_6 = PyObject_RichCompare(__pyx_v_bytes_read, __pyx_t_1, Py_NE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 142, __pyx_L1_error)
3033 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3034 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 142, __pyx_L1_error)
3035 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3036 if (!__pyx_t_5) break;
3037
3038 /* "clickhouse_driver/bufferedreader.pyx":143
3039 * # Read the rest of the string.
3040 * while bytes_read != size:
3041 * position = size - bytes_read # <<<<<<<<<<<<<<
3042 *
3043 * self.read_into_buffer()
3044 */
3045 __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 143, __pyx_L1_error)
3046 __Pyx_GOTREF(__pyx_t_6);
3047 __pyx_t_1 = PyNumber_Subtract(__pyx_t_6, __pyx_v_bytes_read); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
3048 __Pyx_GOTREF(__pyx_t_1);
3049 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3050 __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 143, __pyx_L1_error)
3051 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3052 __pyx_v_position = __pyx_t_10;
3053
3054 /* "clickhouse_driver/bufferedreader.pyx":145
3055 * position = size - bytes_read
3056 *
3057 * self.read_into_buffer() # <<<<<<<<<<<<<<
3058 * # `read_into_buffer` can override
3059 * # buffer, current_buffer_size
3060 */
3061 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_into_buffer); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 145, __pyx_L1_error)
3062 __Pyx_GOTREF(__pyx_t_6);
3063 __pyx_t_7 = NULL;
3064 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
3065 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
3066 if (likely(__pyx_t_7)) {
3067 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
3068 __Pyx_INCREF(__pyx_t_7);
3069 __Pyx_INCREF(function);
3070 __Pyx_DECREF_SET(__pyx_t_6, function);
3071 }
3072 }
3073 __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_6);
3074 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3075 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 145, __pyx_L1_error)
3076 __Pyx_GOTREF(__pyx_t_1);
3077 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3078 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3079
3080 /* "clickhouse_driver/bufferedreader.pyx":149
3081 * # buffer, current_buffer_size
3082 * # We need to restore them.
3083 * buffer = self.buffer # <<<<<<<<<<<<<<
3084 * current_buffer_size = self.current_buffer_size
3085 * buffer_ptr = PyByteArray_AsString(buffer)
3086 */
3087 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
3088 __Pyx_GOTREF(__pyx_t_1);
3089 __Pyx_DECREF_SET(__pyx_v_buffer, __pyx_t_1);
3090 __pyx_t_1 = 0;
3091
3092 /* "clickhouse_driver/bufferedreader.pyx":150
3093 * # We need to restore them.
3094 * buffer = self.buffer
3095 * current_buffer_size = self.current_buffer_size # <<<<<<<<<<<<<<
3096 * buffer_ptr = PyByteArray_AsString(buffer)
3097 * # There can be not enough data in buffer.
3098 */
3099 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L1_error)
3100 __Pyx_GOTREF(__pyx_t_1);
3101 __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 150, __pyx_L1_error)
3102 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3103 __pyx_v_current_buffer_size = __pyx_t_10;
3104
3105 /* "clickhouse_driver/bufferedreader.pyx":151
3106 * buffer = self.buffer
3107 * current_buffer_size = self.current_buffer_size
3108 * buffer_ptr = PyByteArray_AsString(buffer) # <<<<<<<<<<<<<<
3109 * # There can be not enough data in buffer.
3110 * position = min(position, current_buffer_size)
3111 */
3112 __pyx_v_buffer_ptr = PyByteArray_AsString(__pyx_v_buffer);
3113
3114 /* "clickhouse_driver/bufferedreader.pyx":153
3115 * buffer_ptr = PyByteArray_AsString(buffer)
3116 * # There can be not enough data in buffer.
3117 * position = min(position, current_buffer_size) # <<<<<<<<<<<<<<
3118 * if decode:
3119 * memcpy(&c_string[bytes_read], buffer_ptr, position)
3120 */
3121 __pyx_t_10 = __pyx_v_current_buffer_size;
3122 __pyx_t_8 = __pyx_v_position;
3123 if (((__pyx_t_10 < __pyx_t_8) != 0)) {
3124 __pyx_t_9 = __pyx_t_10;
3125 } else {
3126 __pyx_t_9 = __pyx_t_8;
3127 }
3128 __pyx_v_position = __pyx_t_9;
3129
3130 /* "clickhouse_driver/bufferedreader.pyx":154
3131 * # There can be not enough data in buffer.
3132 * position = min(position, current_buffer_size)
3133 * if decode: # <<<<<<<<<<<<<<
3134 * memcpy(&c_string[bytes_read], buffer_ptr, position)
3135 * else:
3136 */
3137 __pyx_t_5 = (__pyx_v_decode != 0);
3138 if (__pyx_t_5) {
3139
3140 /* "clickhouse_driver/bufferedreader.pyx":155
3141 * position = min(position, current_buffer_size)
3142 * if decode:
3143 * memcpy(&c_string[bytes_read], buffer_ptr, position) # <<<<<<<<<<<<<<
3144 * else:
3145 * rv += PyBytes_FromStringAndSize(buffer_ptr, position)
3146 */
3147 __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_bytes_read); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 155, __pyx_L1_error)
3148 (void)(memcpy((&(__pyx_v_c_string[__pyx_t_9])), __pyx_v_buffer_ptr, __pyx_v_position));
3149
3150 /* "clickhouse_driver/bufferedreader.pyx":154
3151 * # There can be not enough data in buffer.
3152 * position = min(position, current_buffer_size)
3153 * if decode: # <<<<<<<<<<<<<<
3154 * memcpy(&c_string[bytes_read], buffer_ptr, position)
3155 * else:
3156 */
3157 goto __pyx_L14;
3158 }
3159
3160 /* "clickhouse_driver/bufferedreader.pyx":157
3161 * memcpy(&c_string[bytes_read], buffer_ptr, position)
3162 * else:
3163 * rv += PyBytes_FromStringAndSize(buffer_ptr, position) # <<<<<<<<<<<<<<
3164 * bytes_read += position
3165 *
3166 */
3167 /*else*/ {
3168 if (unlikely(!__pyx_v_rv)) { __Pyx_RaiseUnboundLocalError("rv"); __PYX_ERR(0, 157, __pyx_L1_error) }
3169 __pyx_t_1 = PyBytes_FromStringAndSize(__pyx_v_buffer_ptr, __pyx_v_position); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error)
3170 __Pyx_GOTREF(__pyx_t_1);
3171 __pyx_t_6 = PyNumber_InPlaceAdd(__pyx_v_rv, __pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 157, __pyx_L1_error)
3172 __Pyx_GOTREF(__pyx_t_6);
3173 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3174 __Pyx_XDECREF_SET(__pyx_v_rv, __pyx_t_6);
3175 __pyx_t_6 = 0;
3176 }
3177 __pyx_L14:;
3178
3179 /* "clickhouse_driver/bufferedreader.pyx":158
3180 * else:
3181 * rv += PyBytes_FromStringAndSize(buffer_ptr, position)
3182 * bytes_read += position # <<<<<<<<<<<<<<
3183 *
3184 * else:
3185 */
3186 __pyx_t_6 = PyInt_FromSsize_t(__pyx_v_position); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
3187 __Pyx_GOTREF(__pyx_t_6);
3188 __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_v_bytes_read, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
3189 __Pyx_GOTREF(__pyx_t_1);
3190 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3191 __Pyx_DECREF_SET(__pyx_v_bytes_read, __pyx_t_1);
3192 __pyx_t_1 = 0;
3193 }
3194
3195 /* "clickhouse_driver/bufferedreader.pyx":131
3196 * # We need to copy it into buffer for adding null symbol at the end.
3197 * # In ClickHouse block there is no null
3198 * if right > current_buffer_size: # <<<<<<<<<<<<<<
3199 * if decode:
3200 * memcpy(&c_string[bytes_read], &buffer_ptr[position],
3201 */
3202 goto __pyx_L10;
3203 }
3204
3205 /* "clickhouse_driver/bufferedreader.pyx":161
3206 *
3207 * else:
3208 * if decode: # <<<<<<<<<<<<<<
3209 * memcpy(c_string, &buffer_ptr[position], size)
3210 * else:
3211 */
3212 /*else*/ {
3213 __pyx_t_5 = (__pyx_v_decode != 0);
3214 if (__pyx_t_5) {
3215
3216 /* "clickhouse_driver/bufferedreader.pyx":162
3217 * else:
3218 * if decode:
3219 * memcpy(c_string, &buffer_ptr[position], size) # <<<<<<<<<<<<<<
3220 * else:
3221 * rv = PyBytes_FromStringAndSize(&buffer_ptr[position], size)
3222 */
3223 (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_buffer_ptr[__pyx_v_position])), __pyx_v_size));
3224
3225 /* "clickhouse_driver/bufferedreader.pyx":161
3226 *
3227 * else:
3228 * if decode: # <<<<<<<<<<<<<<
3229 * memcpy(c_string, &buffer_ptr[position], size)
3230 * else:
3231 */
3232 goto __pyx_L15;
3233 }
3234
3235 /* "clickhouse_driver/bufferedreader.pyx":164
3236 * memcpy(c_string, &buffer_ptr[position], size)
3237 * else:
3238 * rv = PyBytes_FromStringAndSize(&buffer_ptr[position], size) # <<<<<<<<<<<<<<
3239 * position = right
3240 *
3241 */
3242 /*else*/ {
3243 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_buffer_ptr[__pyx_v_position])), __pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error)
3244 __Pyx_GOTREF(__pyx_t_1);
3245 __Pyx_XDECREF_SET(__pyx_v_rv, __pyx_t_1);
3246 __pyx_t_1 = 0;
3247 }
3248 __pyx_L15:;
3249
3250 /* "clickhouse_driver/bufferedreader.pyx":165
3251 * else:
3252 * rv = PyBytes_FromStringAndSize(&buffer_ptr[position], size)
3253 * position = right # <<<<<<<<<<<<<<
3254 *
3255 * if decode:
3256 */
3257 __pyx_v_position = __pyx_v_right;
3258 }
3259 __pyx_L10:;
3260
3261 /* "clickhouse_driver/bufferedreader.pyx":167
3262 * position = right
3263 *
3264 * if decode: # <<<<<<<<<<<<<<
3265 * try:
3266 * rv = c_string[:size].decode('utf-8')
3267 */
3268 __pyx_t_5 = (__pyx_v_decode != 0);
3269 if (__pyx_t_5) {
3270
3271 /* "clickhouse_driver/bufferedreader.pyx":168
3272 *
3273 * if decode:
3274 * try: # <<<<<<<<<<<<<<
3275 * rv = c_string[:size].decode('utf-8')
3276 * except UnicodeDecodeError:
3277 */
3278 {
3279 __Pyx_PyThreadState_declare
3280 __Pyx_PyThreadState_assign
3281 __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
3282 __Pyx_XGOTREF(__pyx_t_11);
3283 __Pyx_XGOTREF(__pyx_t_12);
3284 __Pyx_XGOTREF(__pyx_t_13);
3285 /*try:*/ {
3286
3287 /* "clickhouse_driver/bufferedreader.pyx":169
3288 * if decode:
3289 * try:
3290 * rv = c_string[:size].decode('utf-8') # <<<<<<<<<<<<<<
3291 * except UnicodeDecodeError:
3292 * rv = PyBytes_FromStringAndSize(c_string, size)
3293 */
3294 __pyx_t_1 = __Pyx_decode_c_string(__pyx_v_c_string, 0, __pyx_v_size, NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L17_error)
3295 __Pyx_GOTREF(__pyx_t_1);
3296 __Pyx_XDECREF_SET(__pyx_v_rv, __pyx_t_1);
3297 __pyx_t_1 = 0;
3298
3299 /* "clickhouse_driver/bufferedreader.pyx":168
3300 *
3301 * if decode:
3302 * try: # <<<<<<<<<<<<<<
3303 * rv = c_string[:size].decode('utf-8')
3304 * except UnicodeDecodeError:
3305 */
3306 }
3307 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
3308 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
3309 __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
3310 goto __pyx_L24_try_end;
3311 __pyx_L17_error:;
3312 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3313 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3314 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3315
3316 /* "clickhouse_driver/bufferedreader.pyx":170
3317 * try:
3318 * rv = c_string[:size].decode('utf-8')
3319 * except UnicodeDecodeError: # <<<<<<<<<<<<<<
3320 * rv = PyBytes_FromStringAndSize(c_string, size)
3321 *
3322 */
3323 __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
3324 if (__pyx_t_14) {
3325 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3326 if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_7) < 0) __PYX_ERR(0, 170, __pyx_L19_except_error)
3327 __Pyx_GOTREF(__pyx_t_1);
3328 __Pyx_GOTREF(__pyx_t_6);
3329 __Pyx_GOTREF(__pyx_t_7);
3330
3331 /* "clickhouse_driver/bufferedreader.pyx":171
3332 * rv = c_string[:size].decode('utf-8')
3333 * except UnicodeDecodeError:
3334 * rv = PyBytes_FromStringAndSize(c_string, size) # <<<<<<<<<<<<<<
3335 *
3336 * Py_INCREF(rv)
3337 */
3338 __pyx_t_15 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_size); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 171, __pyx_L19_except_error)
3339 __Pyx_GOTREF(__pyx_t_15);
3340 __Pyx_XDECREF_SET(__pyx_v_rv, __pyx_t_15);
3341 __pyx_t_15 = 0;
3342 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
3343 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3344 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3345 goto __pyx_L18_exception_handled;
3346 }
3347 goto __pyx_L19_except_error;
3348 __pyx_L19_except_error:;
3349
3350 /* "clickhouse_driver/bufferedreader.pyx":168
3351 *
3352 * if decode:
3353 * try: # <<<<<<<<<<<<<<
3354 * rv = c_string[:size].decode('utf-8')
3355 * except UnicodeDecodeError:
3356 */
3357 __Pyx_XGIVEREF(__pyx_t_11);
3358 __Pyx_XGIVEREF(__pyx_t_12);
3359 __Pyx_XGIVEREF(__pyx_t_13);
3360 __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
3361 goto __pyx_L1_error;
3362 __pyx_L18_exception_handled:;
3363 __Pyx_XGIVEREF(__pyx_t_11);
3364 __Pyx_XGIVEREF(__pyx_t_12);
3365 __Pyx_XGIVEREF(__pyx_t_13);
3366 __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
3367 __pyx_L24_try_end:;
3368 }
3369
3370 /* "clickhouse_driver/bufferedreader.pyx":167
3371 * position = right
3372 *
3373 * if decode: # <<<<<<<<<<<<<<
3374 * try:
3375 * rv = c_string[:size].decode('utf-8')
3376 */
3377 }
3378
3379 /* "clickhouse_driver/bufferedreader.pyx":173
3380 * rv = PyBytes_FromStringAndSize(c_string, size)
3381 *
3382 * Py_INCREF(rv) # <<<<<<<<<<<<<<
3383 * PyTuple_SET_ITEM(items, i, rv)
3384 *
3385 */
3386 if (unlikely(!__pyx_v_rv)) { __Pyx_RaiseUnboundLocalError("rv"); __PYX_ERR(0, 173, __pyx_L1_error) }
3387 Py_INCREF(__pyx_v_rv);
3388
3389 /* "clickhouse_driver/bufferedreader.pyx":174
3390 *
3391 * Py_INCREF(rv)
3392 * PyTuple_SET_ITEM(items, i, rv) # <<<<<<<<<<<<<<
3393 *
3394 * if c_string:
3395 */
3396 if (unlikely(!__pyx_v_rv)) { __Pyx_RaiseUnboundLocalError("rv"); __PYX_ERR(0, 174, __pyx_L1_error) }
3397 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_rv);
6224 }
6225 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
6226 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6227 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6228 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
6229 __Pyx_GOTREF(__pyx_t_1);
6230 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6231 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6232
6233 /* "(tree fragment)":13
6234 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state):
6235 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6236 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
6237 * __pyx_result.__dict__.update(__pyx_state[3])
6238 */
33986239 }
33996240
3400 /* "clickhouse_driver/bufferedreader.pyx":176
3401 * PyTuple_SET_ITEM(items, i, rv)
3402 *
3403 * if c_string: # <<<<<<<<<<<<<<
3404 * PyMem_Free(c_string)
3405 *
3406 */
3407 __pyx_t_5 = (__pyx_v_c_string != 0);
3408 if (__pyx_t_5) {
3409
3410 /* "clickhouse_driver/bufferedreader.pyx":177
3411 *
3412 * if c_string:
3413 * PyMem_Free(c_string) # <<<<<<<<<<<<<<
3414 *
3415 * # Restore self-variables.
3416 */
3417 PyMem_Free(__pyx_v_c_string);
3418
3419 /* "clickhouse_driver/bufferedreader.pyx":176
3420 * PyTuple_SET_ITEM(items, i, rv)
3421 *
3422 * if c_string: # <<<<<<<<<<<<<<
3423 * PyMem_Free(c_string)
3424 *
3425 */
3426 }
3427
3428 /* "clickhouse_driver/bufferedreader.pyx":180
3429 *
3430 * # Restore self-variables.
3431 * self.buffer = buffer # <<<<<<<<<<<<<<
3432 * self.position = position
3433 * self.current_buffer_size = current_buffer_size
3434 */
3435 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_buffer, __pyx_v_buffer) < 0) __PYX_ERR(0, 180, __pyx_L1_error)
3436
3437 /* "clickhouse_driver/bufferedreader.pyx":181
3438 * # Restore self-variables.
3439 * self.buffer = buffer
3440 * self.position = position # <<<<<<<<<<<<<<
3441 * self.current_buffer_size = current_buffer_size
3442 *
3443 */
3444 __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_position); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 181, __pyx_L1_error)
3445 __Pyx_GOTREF(__pyx_t_7);
3446 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_position, __pyx_t_7) < 0) __PYX_ERR(0, 181, __pyx_L1_error)
3447 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3448
3449 /* "clickhouse_driver/bufferedreader.pyx":182
3450 * self.buffer = buffer
3451 * self.position = position
3452 * self.current_buffer_size = current_buffer_size # <<<<<<<<<<<<<<
3453 *
3454 * return items
3455 */
3456 __pyx_t_7 = PyInt_FromSsize_t(__pyx_v_current_buffer_size); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 182, __pyx_L1_error)
3457 __Pyx_GOTREF(__pyx_t_7);
3458 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size, __pyx_t_7) < 0) __PYX_ERR(0, 182, __pyx_L1_error)
3459 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3460
3461 /* "clickhouse_driver/bufferedreader.pyx":184
3462 * self.current_buffer_size = current_buffer_size
3463 *
3464 * return items # <<<<<<<<<<<<<<
3465 *
3466 *
3467 */
3468 __Pyx_XDECREF(__pyx_r);
3469 __Pyx_INCREF(__pyx_v_items);
3470 __pyx_r = __pyx_v_items;
6241 /* "(tree fragment)":11
6242 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
6243 * return __pyx_result
6244 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
6245 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
6246 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
6247 */
6248
6249 /* function exit code */
6250 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
34716251 goto __pyx_L0;
3472
3473 /* "clickhouse_driver/bufferedreader.pyx":73
3474 * return rv
3475 *
3476 * def read_strings(self, Py_ssize_t n_items, int decode=0): # <<<<<<<<<<<<<<
3477 * """
3478 * Python has great overhead between function calls.
3479 */
3480
3481 /* function exit code */
34826252 __pyx_L1_error:;
34836253 __Pyx_XDECREF(__pyx_t_1);
3484 __Pyx_XDECREF(__pyx_t_6);
34856254 __Pyx_XDECREF(__pyx_t_7);
3486 __Pyx_XDECREF(__pyx_t_15);
3487 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedReader.read_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3488 __pyx_r = NULL;
6255 __Pyx_XDECREF(__pyx_t_8);
6256 __Pyx_XDECREF(__pyx_t_9);
6257 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
6258 __pyx_r = 0;
34896259 __pyx_L0:;
3490 __Pyx_XDECREF(__pyx_v_items);
3491 __Pyx_XDECREF(__pyx_v_buffer);
3492 __Pyx_XDECREF(__pyx_v_bytes_read);
3493 __Pyx_XDECREF(__pyx_v_rv);
34946260 __Pyx_XGIVEREF(__pyx_r);
34956261 __Pyx_RefNannyFinishContext();
34966262 return __pyx_r;
34976263 }
34986264
3499 /* "clickhouse_driver/bufferedreader.pyx":188
3500 *
3501 * class BufferedSocketReader(BufferedReader):
3502 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
3503 * self.sock = sock
3504 * super(BufferedSocketReader, self).__init__(bufsize)
6265 /* "(tree fragment)":1
6266 * def __pyx_unpickle_BufferedSocketReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6267 * cdef object __pyx_PickleError
6268 * cdef object __pyx_result
35056269 */
35066270
35076271 /* Python wrapper */
3508 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3509 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
3510 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3511 PyObject *__pyx_v_self = 0;
3512 PyObject *__pyx_v_sock = 0;
3513 PyObject *__pyx_v_bufsize = 0;
6272 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6273 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader = {"__pyx_unpickle_BufferedSocketReader", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader, METH_VARARGS|METH_KEYWORDS, 0};
6274 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6275 PyObject *__pyx_v___pyx_type = 0;
6276 long __pyx_v___pyx_checksum;
6277 PyObject *__pyx_v___pyx_state = 0;
6278 int __pyx_lineno = 0;
6279 const char *__pyx_filename = NULL;
6280 int __pyx_clineno = 0;
35146281 PyObject *__pyx_r = 0;
35156282 __Pyx_RefNannyDeclarations
3516 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
6283 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader (wrapper)", 0);
35176284 {
3518 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_sock,&__pyx_n_s_bufsize,0};
6285 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
35196286 PyObject* values[3] = {0,0,0};
35206287 if (unlikely(__pyx_kwds)) {
35216288 Py_ssize_t kw_args;
35336300 kw_args = PyDict_Size(__pyx_kwds);
35346301 switch (pos_args) {
35356302 case 0:
3536 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
6303 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
35376304 else goto __pyx_L5_argtuple_error;
35386305 CYTHON_FALLTHROUGH;
35396306 case 1:
3540 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_sock)) != 0)) kw_args--;
6307 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
35416308 else {
3542 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 188, __pyx_L3_error)
6309 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketReader", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
35436310 }
35446311 CYTHON_FALLTHROUGH;
35456312 case 2:
3546 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
6313 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
35476314 else {
3548 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 188, __pyx_L3_error)
6315 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketReader", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
35496316 }
35506317 }
35516318 if (unlikely(kw_args > 0)) {
3552 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 188, __pyx_L3_error)
6319 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_BufferedSocketReader") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
35536320 }
35546321 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
35556322 goto __pyx_L5_argtuple_error;
35586325 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
35596326 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
35606327 }
3561 __pyx_v_self = values[0];
3562 __pyx_v_sock = values[1];
3563 __pyx_v_bufsize = values[2];
6328 __pyx_v___pyx_type = values[0];
6329 __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
6330 __pyx_v___pyx_state = values[2];
35646331 }
35656332 goto __pyx_L4_argument_unpacking_done;
35666333 __pyx_L5_argtuple_error:;
3567 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 188, __pyx_L3_error)
6334 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_BufferedSocketReader", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
35686335 __pyx_L3_error:;
3569 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6336 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
35706337 __Pyx_RefNannyFinishContext();
35716338 return NULL;
35726339 __pyx_L4_argument_unpacking_done:;
3573 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(__pyx_self, __pyx_v_self, __pyx_v_sock, __pyx_v_bufsize);
6340 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
35746341
35756342 /* function exit code */
35766343 __Pyx_RefNannyFinishContext();
35776344 return __pyx_r;
35786345 }
35796346
3580 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize) {
6347 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_2__pyx_unpickle_BufferedSocketReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
6348 PyObject *__pyx_v___pyx_PickleError = 0;
6349 PyObject *__pyx_v___pyx_result = 0;
6350 PyObject *__pyx_r = NULL;
6351 __Pyx_RefNannyDeclarations
6352 int __pyx_t_1;
6353 PyObject *__pyx_t_2 = NULL;
6354 PyObject *__pyx_t_3 = NULL;
6355 PyObject *__pyx_t_4 = NULL;
6356 PyObject *__pyx_t_5 = NULL;
6357 int __pyx_t_6;
6358 int __pyx_lineno = 0;
6359 const char *__pyx_filename = NULL;
6360 int __pyx_clineno = 0;
6361 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader", 0);
6362
6363 /* "(tree fragment)":4
6364 * cdef object __pyx_PickleError
6365 * cdef object __pyx_result
6366 * if __pyx_checksum != 0xef9caf0: # <<<<<<<<<<<<<<
6367 * from pickle import PickleError as __pyx_PickleError
6368 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6369 */
6370 __pyx_t_1 = ((__pyx_v___pyx_checksum != 0xef9caf0) != 0);
6371 if (__pyx_t_1) {
6372
6373 /* "(tree fragment)":5
6374 * cdef object __pyx_result
6375 * if __pyx_checksum != 0xef9caf0:
6376 * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
6377 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6378 * __pyx_result = BufferedSocketReader.__new__(__pyx_type)
6379 */
6380 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
6381 __Pyx_GOTREF(__pyx_t_2);
6382 __Pyx_INCREF(__pyx_n_s_PickleError);
6383 __Pyx_GIVEREF(__pyx_n_s_PickleError);
6384 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
6385 __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
6386 __Pyx_GOTREF(__pyx_t_3);
6387 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6388 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
6389 __Pyx_GOTREF(__pyx_t_2);
6390 __Pyx_INCREF(__pyx_t_2);
6391 __pyx_v___pyx_PickleError = __pyx_t_2;
6392 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6393 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6394
6395 /* "(tree fragment)":6
6396 * if __pyx_checksum != 0xef9caf0:
6397 * from pickle import PickleError as __pyx_PickleError
6398 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum) # <<<<<<<<<<<<<<
6399 * __pyx_result = BufferedSocketReader.__new__(__pyx_type)
6400 * if __pyx_state is not None:
6401 */
6402 __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
6403 __Pyx_GOTREF(__pyx_t_2);
6404 __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0xef, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
6405 __Pyx_GOTREF(__pyx_t_4);
6406 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6407 __Pyx_INCREF(__pyx_v___pyx_PickleError);
6408 __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
6409 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6410 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
6411 if (likely(__pyx_t_5)) {
6412 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6413 __Pyx_INCREF(__pyx_t_5);
6414 __Pyx_INCREF(function);
6415 __Pyx_DECREF_SET(__pyx_t_2, function);
6416 }
6417 }
6418 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
6419 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6420 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6421 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
6422 __Pyx_GOTREF(__pyx_t_3);
6423 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6424 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6425 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6426 __PYX_ERR(1, 6, __pyx_L1_error)
6427
6428 /* "(tree fragment)":4
6429 * cdef object __pyx_PickleError
6430 * cdef object __pyx_result
6431 * if __pyx_checksum != 0xef9caf0: # <<<<<<<<<<<<<<
6432 * from pickle import PickleError as __pyx_PickleError
6433 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6434 */
6435 }
6436
6437 /* "(tree fragment)":7
6438 * from pickle import PickleError as __pyx_PickleError
6439 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6440 * __pyx_result = BufferedSocketReader.__new__(__pyx_type) # <<<<<<<<<<<<<<
6441 * if __pyx_state is not None:
6442 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6443 */
6444 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
6445 __Pyx_GOTREF(__pyx_t_2);
6446 __pyx_t_4 = NULL;
6447 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
6448 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
6449 if (likely(__pyx_t_4)) {
6450 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6451 __Pyx_INCREF(__pyx_t_4);
6452 __Pyx_INCREF(function);
6453 __Pyx_DECREF_SET(__pyx_t_2, function);
6454 }
6455 }
6456 __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
6457 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6458 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
6459 __Pyx_GOTREF(__pyx_t_3);
6460 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6461 __pyx_v___pyx_result = __pyx_t_3;
6462 __pyx_t_3 = 0;
6463
6464 /* "(tree fragment)":8
6465 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6466 * __pyx_result = BufferedSocketReader.__new__(__pyx_type)
6467 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6468 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6469 * return __pyx_result
6470 */
6471 __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
6472 __pyx_t_6 = (__pyx_t_1 != 0);
6473 if (__pyx_t_6) {
6474
6475 /* "(tree fragment)":9
6476 * __pyx_result = BufferedSocketReader.__new__(__pyx_type)
6477 * if __pyx_state is not None:
6478 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
6479 * return __pyx_result
6480 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):
6481 */
6482 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
6483 __pyx_t_3 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
6484 __Pyx_GOTREF(__pyx_t_3);
6485 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6486
6487 /* "(tree fragment)":8
6488 * raise __pyx_PickleError("Incompatible checksums (%s vs 0xef9caf0 = (buffer, current_buffer_size, position, sock))" % __pyx_checksum)
6489 * __pyx_result = BufferedSocketReader.__new__(__pyx_type)
6490 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6491 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6492 * return __pyx_result
6493 */
6494 }
6495
6496 /* "(tree fragment)":10
6497 * if __pyx_state is not None:
6498 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6499 * return __pyx_result # <<<<<<<<<<<<<<
6500 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):
6501 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6502 */
6503 __Pyx_XDECREF(__pyx_r);
6504 __Pyx_INCREF(__pyx_v___pyx_result);
6505 __pyx_r = __pyx_v___pyx_result;
6506 goto __pyx_L0;
6507
6508 /* "(tree fragment)":1
6509 * def __pyx_unpickle_BufferedSocketReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6510 * cdef object __pyx_PickleError
6511 * cdef object __pyx_result
6512 */
6513
6514 /* function exit code */
6515 __pyx_L1_error:;
6516 __Pyx_XDECREF(__pyx_t_2);
6517 __Pyx_XDECREF(__pyx_t_3);
6518 __Pyx_XDECREF(__pyx_t_4);
6519 __Pyx_XDECREF(__pyx_t_5);
6520 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
6521 __pyx_r = NULL;
6522 __pyx_L0:;
6523 __Pyx_XDECREF(__pyx_v___pyx_PickleError);
6524 __Pyx_XDECREF(__pyx_v___pyx_result);
6525 __Pyx_XGIVEREF(__pyx_r);
6526 __Pyx_RefNannyFinishContext();
6527 return __pyx_r;
6528 }
6529
6530 /* "(tree fragment)":11
6531 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6532 * return __pyx_result
6533 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
6534 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6535 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
6536 */
6537
6538 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_BufferedSocketReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
35816539 PyObject *__pyx_r = NULL;
35826540 __Pyx_RefNannyDeclarations
35836541 PyObject *__pyx_t_1 = NULL;
3584 PyObject *__pyx_t_2 = NULL;
3585 PyObject *__pyx_t_3 = NULL;
3586 __Pyx_RefNannySetupContext("__init__", 0);
3587
3588 /* "clickhouse_driver/bufferedreader.pyx":189
3589 * class BufferedSocketReader(BufferedReader):
3590 * def __init__(self, sock, bufsize):
3591 * self.sock = sock # <<<<<<<<<<<<<<
3592 * super(BufferedSocketReader, self).__init__(bufsize)
3593 *
3594 */
3595 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sock, __pyx_v_sock) < 0) __PYX_ERR(0, 189, __pyx_L1_error)
3596
3597 /* "clickhouse_driver/bufferedreader.pyx":190
3598 * def __init__(self, sock, bufsize):
3599 * self.sock = sock
3600 * super(BufferedSocketReader, self).__init__(bufsize) # <<<<<<<<<<<<<<
3601 *
3602 * def read_into_buffer(self):
3603 */
3604 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BufferedSocketReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
3605 __Pyx_GOTREF(__pyx_t_2);
3606 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
3607 __Pyx_GOTREF(__pyx_t_3);
3608 __Pyx_GIVEREF(__pyx_t_2);
3609 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3610 __Pyx_INCREF(__pyx_v_self);
3611 __Pyx_GIVEREF(__pyx_v_self);
3612 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
3613 __pyx_t_2 = 0;
3614 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 190, __pyx_L1_error)
3615 __Pyx_GOTREF(__pyx_t_2);
3616 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3617 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
3618 __Pyx_GOTREF(__pyx_t_3);
3619 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3620 __pyx_t_2 = NULL;
3621 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3622 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3623 if (likely(__pyx_t_2)) {
3624 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3625 __Pyx_INCREF(__pyx_t_2);
3626 __Pyx_INCREF(function);
3627 __Pyx_DECREF_SET(__pyx_t_3, function);
3628 }
6542 unsigned PY_LONG_LONG __pyx_t_2;
6543 int __pyx_t_3;
6544 Py_ssize_t __pyx_t_4;
6545 int __pyx_t_5;
6546 int __pyx_t_6;
6547 PyObject *__pyx_t_7 = NULL;
6548 PyObject *__pyx_t_8 = NULL;
6549 PyObject *__pyx_t_9 = NULL;
6550 int __pyx_lineno = 0;
6551 const char *__pyx_filename = NULL;
6552 int __pyx_clineno = 0;
6553 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketReader__set_state", 0);
6554
6555 /* "(tree fragment)":12
6556 * return __pyx_result
6557 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):
6558 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3] # <<<<<<<<<<<<<<
6559 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
6560 * __pyx_result.__dict__.update(__pyx_state[4])
6561 */
6562 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6563 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6564 __PYX_ERR(1, 12, __pyx_L1_error)
36296565 }
3630 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_bufsize);
3631 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3632 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
6566 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
36336567 __Pyx_GOTREF(__pyx_t_1);
3634 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6568 if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
6569 __Pyx_GIVEREF(__pyx_t_1);
6570 __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer);
6571 __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.buffer);
6572 __pyx_v___pyx_result->__pyx_base.buffer = ((PyObject*)__pyx_t_1);
6573 __pyx_t_1 = 0;
6574 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6575 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6576 __PYX_ERR(1, 12, __pyx_L1_error)
6577 }
6578 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
6579 __Pyx_GOTREF(__pyx_t_1);
6580 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
36356581 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3636
3637 /* "clickhouse_driver/bufferedreader.pyx":188
3638 *
3639 * class BufferedSocketReader(BufferedReader):
3640 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
3641 * self.sock = sock
3642 * super(BufferedSocketReader, self).__init__(bufsize)
6582 __pyx_v___pyx_result->__pyx_base.current_buffer_size = __pyx_t_2;
6583 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6584 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6585 __PYX_ERR(1, 12, __pyx_L1_error)
6586 }
6587 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
6588 __Pyx_GOTREF(__pyx_t_1);
6589 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
6590 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6591 __pyx_v___pyx_result->__pyx_base.position = __pyx_t_2;
6592 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6593 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6594 __PYX_ERR(1, 12, __pyx_L1_error)
6595 }
6596 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
6597 __Pyx_GOTREF(__pyx_t_1);
6598 __Pyx_GIVEREF(__pyx_t_1);
6599 __Pyx_GOTREF(__pyx_v___pyx_result->sock);
6600 __Pyx_DECREF(__pyx_v___pyx_result->sock);
6601 __pyx_v___pyx_result->sock = __pyx_t_1;
6602 __pyx_t_1 = 0;
6603
6604 /* "(tree fragment)":13
6605 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):
6606 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6607 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
6608 * __pyx_result.__dict__.update(__pyx_state[4])
6609 */
6610 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6611 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
6612 __PYX_ERR(1, 13, __pyx_L1_error)
6613 }
6614 __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6615 __pyx_t_5 = ((__pyx_t_4 > 4) != 0);
6616 if (__pyx_t_5) {
6617 } else {
6618 __pyx_t_3 = __pyx_t_5;
6619 goto __pyx_L4_bool_binop_done;
6620 }
6621 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6622 __pyx_t_6 = (__pyx_t_5 != 0);
6623 __pyx_t_3 = __pyx_t_6;
6624 __pyx_L4_bool_binop_done:;
6625 if (__pyx_t_3) {
6626
6627 /* "(tree fragment)":14
6628 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6629 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
6630 * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<<
6631 */
6632 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
6633 __Pyx_GOTREF(__pyx_t_7);
6634 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
6635 __Pyx_GOTREF(__pyx_t_8);
6636 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6637 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6638 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6639 __PYX_ERR(1, 14, __pyx_L1_error)
6640 }
6641 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
6642 __Pyx_GOTREF(__pyx_t_7);
6643 __pyx_t_9 = NULL;
6644 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
6645 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
6646 if (likely(__pyx_t_9)) {
6647 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
6648 __Pyx_INCREF(__pyx_t_9);
6649 __Pyx_INCREF(function);
6650 __Pyx_DECREF_SET(__pyx_t_8, function);
6651 }
6652 }
6653 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
6654 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
6655 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6656 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
6657 __Pyx_GOTREF(__pyx_t_1);
6658 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6659 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6660
6661 /* "(tree fragment)":13
6662 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state):
6663 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6664 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
6665 * __pyx_result.__dict__.update(__pyx_state[4])
6666 */
6667 }
6668
6669 /* "(tree fragment)":11
6670 * __pyx_unpickle_BufferedSocketReader__set_state(<BufferedSocketReader> __pyx_result, __pyx_state)
6671 * return __pyx_result
6672 * cdef __pyx_unpickle_BufferedSocketReader__set_state(BufferedSocketReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
6673 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.sock = __pyx_state[3]
6674 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
36436675 */
36446676
36456677 /* function exit code */
36476679 goto __pyx_L0;
36486680 __pyx_L1_error:;
36496681 __Pyx_XDECREF(__pyx_t_1);
3650 __Pyx_XDECREF(__pyx_t_2);
3651 __Pyx_XDECREF(__pyx_t_3);
3652 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3653 __pyx_r = NULL;
6682 __Pyx_XDECREF(__pyx_t_7);
6683 __Pyx_XDECREF(__pyx_t_8);
6684 __Pyx_XDECREF(__pyx_t_9);
6685 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_BufferedSocketReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
6686 __pyx_r = 0;
36546687 __pyx_L0:;
36556688 __Pyx_XGIVEREF(__pyx_r);
36566689 __Pyx_RefNannyFinishContext();
36576690 return __pyx_r;
36586691 }
36596692
3660 /* "clickhouse_driver/bufferedreader.pyx":192
3661 * super(BufferedSocketReader, self).__init__(bufsize)
3662 *
3663 * def read_into_buffer(self): # <<<<<<<<<<<<<<
3664 * self.current_buffer_size = self.sock.recv_into(self.buffer)
3665 *
6693 /* "(tree fragment)":1
6694 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6695 * cdef object __pyx_PickleError
6696 * cdef object __pyx_result
36666697 */
36676698
36686699 /* Python wrapper */
3669 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3670 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, METH_O, 0};
3671 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self) {
6700 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6701 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader = {"__pyx_unpickle_CompressedBufferedReader", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader, METH_VARARGS|METH_KEYWORDS, 0};
6702 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6703 PyObject *__pyx_v___pyx_type = 0;
6704 long __pyx_v___pyx_checksum;
6705 PyObject *__pyx_v___pyx_state = 0;
6706 int __pyx_lineno = 0;
6707 const char *__pyx_filename = NULL;
6708 int __pyx_clineno = 0;
36726709 PyObject *__pyx_r = 0;
36736710 __Pyx_RefNannyDeclarations
3674 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
3675 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(__pyx_self, ((PyObject *)__pyx_v_self));
3676
3677 /* function exit code */
3678 __Pyx_RefNannyFinishContext();
3679 return __pyx_r;
3680 }
3681
3682 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
3683 PyObject *__pyx_r = NULL;
3684 __Pyx_RefNannyDeclarations
3685 PyObject *__pyx_t_1 = NULL;
3686 PyObject *__pyx_t_2 = NULL;
3687 PyObject *__pyx_t_3 = NULL;
3688 PyObject *__pyx_t_4 = NULL;
3689 int __pyx_t_5;
3690 __Pyx_RefNannySetupContext("read_into_buffer", 0);
3691
3692 /* "clickhouse_driver/bufferedreader.pyx":193
3693 *
3694 * def read_into_buffer(self):
3695 * self.current_buffer_size = self.sock.recv_into(self.buffer) # <<<<<<<<<<<<<<
3696 *
3697 * if self.current_buffer_size == 0:
3698 */
3699 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
3700 __Pyx_GOTREF(__pyx_t_2);
3701 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_recv_into); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L1_error)
3702 __Pyx_GOTREF(__pyx_t_3);
3703 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3704 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L1_error)
3705 __Pyx_GOTREF(__pyx_t_2);
3706 __pyx_t_4 = NULL;
3707 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3708 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3709 if (likely(__pyx_t_4)) {
3710 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3711 __Pyx_INCREF(__pyx_t_4);
3712 __Pyx_INCREF(function);
3713 __Pyx_DECREF_SET(__pyx_t_3, function);
3714 }
3715 }
3716 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_2) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2);
3717 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3718 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3719 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error)
3720 __Pyx_GOTREF(__pyx_t_1);
3721 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3722 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size, __pyx_t_1) < 0) __PYX_ERR(0, 193, __pyx_L1_error)
3723 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3724
3725 /* "clickhouse_driver/bufferedreader.pyx":195
3726 * self.current_buffer_size = self.sock.recv_into(self.buffer)
3727 *
3728 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
3729 * raise EOFError('Unexpected EOF while reading bytes')
3730 *
3731 */
3732 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error)
3733 __Pyx_GOTREF(__pyx_t_1);
3734 __pyx_t_3 = __Pyx_PyInt_EqObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 195, __pyx_L1_error)
3735 __Pyx_GOTREF(__pyx_t_3);
3736 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3737 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 195, __pyx_L1_error)
3738 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3739 if (unlikely(__pyx_t_5)) {
3740
3741 /* "clickhouse_driver/bufferedreader.pyx":196
3742 *
3743 * if self.current_buffer_size == 0:
3744 * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<<
3745 *
3746 *
3747 */
3748 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_EOFError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 196, __pyx_L1_error)
3749 __Pyx_GOTREF(__pyx_t_3);
3750 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
3751 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3752 __PYX_ERR(0, 196, __pyx_L1_error)
3753
3754 /* "clickhouse_driver/bufferedreader.pyx":195
3755 * self.current_buffer_size = self.sock.recv_into(self.buffer)
3756 *
3757 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
3758 * raise EOFError('Unexpected EOF while reading bytes')
3759 *
3760 */
3761 }
3762
3763 /* "clickhouse_driver/bufferedreader.pyx":192
3764 * super(BufferedSocketReader, self).__init__(bufsize)
3765 *
3766 * def read_into_buffer(self): # <<<<<<<<<<<<<<
3767 * self.current_buffer_size = self.sock.recv_into(self.buffer)
3768 *
3769 */
3770
3771 /* function exit code */
3772 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3773 goto __pyx_L0;
3774 __pyx_L1_error:;
3775 __Pyx_XDECREF(__pyx_t_1);
3776 __Pyx_XDECREF(__pyx_t_2);
3777 __Pyx_XDECREF(__pyx_t_3);
3778 __Pyx_XDECREF(__pyx_t_4);
3779 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.BufferedSocketReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
3780 __pyx_r = NULL;
3781 __pyx_L0:;
3782 __Pyx_XGIVEREF(__pyx_r);
3783 __Pyx_RefNannyFinishContext();
3784 return __pyx_r;
3785 }
3786
3787 /* "clickhouse_driver/bufferedreader.pyx":200
3788 *
3789 * class CompressedBufferedReader(BufferedReader):
3790 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
3791 * self.read_block = read_block
3792 * super(CompressedBufferedReader, self).__init__(bufsize)
3793 */
3794
3795 /* Python wrapper */
3796 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3797 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
3798 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3799 PyObject *__pyx_v_self = 0;
3800 PyObject *__pyx_v_read_block = 0;
3801 PyObject *__pyx_v_bufsize = 0;
3802 PyObject *__pyx_r = 0;
3803 __Pyx_RefNannyDeclarations
3804 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
6711 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader (wrapper)", 0);
38056712 {
3806 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_read_block,&__pyx_n_s_bufsize,0};
6713 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_pyx_type,&__pyx_n_s_pyx_checksum,&__pyx_n_s_pyx_state,0};
38076714 PyObject* values[3] = {0,0,0};
38086715 if (unlikely(__pyx_kwds)) {
38096716 Py_ssize_t kw_args;
38216728 kw_args = PyDict_Size(__pyx_kwds);
38226729 switch (pos_args) {
38236730 case 0:
3824 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
6731 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_type)) != 0)) kw_args--;
38256732 else goto __pyx_L5_argtuple_error;
38266733 CYTHON_FALLTHROUGH;
38276734 case 1:
3828 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_read_block)) != 0)) kw_args--;
6735 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_checksum)) != 0)) kw_args--;
38296736 else {
3830 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 200, __pyx_L3_error)
6737 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedReader", 1, 3, 3, 1); __PYX_ERR(1, 1, __pyx_L3_error)
38316738 }
38326739 CYTHON_FALLTHROUGH;
38336740 case 2:
3834 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
6741 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_pyx_state)) != 0)) kw_args--;
38356742 else {
3836 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 200, __pyx_L3_error)
6743 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedReader", 1, 3, 3, 2); __PYX_ERR(1, 1, __pyx_L3_error)
38376744 }
38386745 }
38396746 if (unlikely(kw_args > 0)) {
3840 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 200, __pyx_L3_error)
6747 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__pyx_unpickle_CompressedBufferedReader") < 0)) __PYX_ERR(1, 1, __pyx_L3_error)
38416748 }
38426749 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
38436750 goto __pyx_L5_argtuple_error;
38466753 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
38476754 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
38486755 }
3849 __pyx_v_self = values[0];
3850 __pyx_v_read_block = values[1];
3851 __pyx_v_bufsize = values[2];
6756 __pyx_v___pyx_type = values[0];
6757 __pyx_v___pyx_checksum = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v___pyx_checksum == (long)-1) && PyErr_Occurred())) __PYX_ERR(1, 1, __pyx_L3_error)
6758 __pyx_v___pyx_state = values[2];
38526759 }
38536760 goto __pyx_L4_argument_unpacking_done;
38546761 __pyx_L5_argtuple_error:;
3855 __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 200, __pyx_L3_error)
6762 __Pyx_RaiseArgtupleInvalid("__pyx_unpickle_CompressedBufferedReader", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(1, 1, __pyx_L3_error)
38566763 __pyx_L3_error:;
3857 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6764 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
38586765 __Pyx_RefNannyFinishContext();
38596766 return NULL;
38606767 __pyx_L4_argument_unpacking_done:;
3861 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(__pyx_self, __pyx_v_self, __pyx_v_read_block, __pyx_v_bufsize);
6768 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(__pyx_self, __pyx_v___pyx_type, __pyx_v___pyx_checksum, __pyx_v___pyx_state);
38626769
38636770 /* function exit code */
38646771 __Pyx_RefNannyFinishContext();
38656772 return __pyx_r;
38666773 }
38676774
3868 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_read_block, PyObject *__pyx_v_bufsize) {
6775 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_4__pyx_unpickle_CompressedBufferedReader(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v___pyx_type, long __pyx_v___pyx_checksum, PyObject *__pyx_v___pyx_state) {
6776 PyObject *__pyx_v___pyx_PickleError = 0;
6777 PyObject *__pyx_v___pyx_result = 0;
6778 PyObject *__pyx_r = NULL;
6779 __Pyx_RefNannyDeclarations
6780 int __pyx_t_1;
6781 PyObject *__pyx_t_2 = NULL;
6782 PyObject *__pyx_t_3 = NULL;
6783 PyObject *__pyx_t_4 = NULL;
6784 PyObject *__pyx_t_5 = NULL;
6785 int __pyx_t_6;
6786 int __pyx_lineno = 0;
6787 const char *__pyx_filename = NULL;
6788 int __pyx_clineno = 0;
6789 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader", 0);
6790
6791 /* "(tree fragment)":4
6792 * cdef object __pyx_PickleError
6793 * cdef object __pyx_result
6794 * if __pyx_checksum != 0x183c0eb: # <<<<<<<<<<<<<<
6795 * from pickle import PickleError as __pyx_PickleError
6796 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6797 */
6798 __pyx_t_1 = ((__pyx_v___pyx_checksum != 0x183c0eb) != 0);
6799 if (__pyx_t_1) {
6800
6801 /* "(tree fragment)":5
6802 * cdef object __pyx_result
6803 * if __pyx_checksum != 0x183c0eb:
6804 * from pickle import PickleError as __pyx_PickleError # <<<<<<<<<<<<<<
6805 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6806 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type)
6807 */
6808 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
6809 __Pyx_GOTREF(__pyx_t_2);
6810 __Pyx_INCREF(__pyx_n_s_PickleError);
6811 __Pyx_GIVEREF(__pyx_n_s_PickleError);
6812 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_PickleError);
6813 __pyx_t_3 = __Pyx_Import(__pyx_n_s_pickle, __pyx_t_2, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
6814 __Pyx_GOTREF(__pyx_t_3);
6815 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6816 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_3, __pyx_n_s_PickleError); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
6817 __Pyx_GOTREF(__pyx_t_2);
6818 __Pyx_INCREF(__pyx_t_2);
6819 __pyx_v___pyx_PickleError = __pyx_t_2;
6820 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6821 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6822
6823 /* "(tree fragment)":6
6824 * if __pyx_checksum != 0x183c0eb:
6825 * from pickle import PickleError as __pyx_PickleError
6826 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum) # <<<<<<<<<<<<<<
6827 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type)
6828 * if __pyx_state is not None:
6829 */
6830 __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v___pyx_checksum); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 6, __pyx_L1_error)
6831 __Pyx_GOTREF(__pyx_t_2);
6832 __pyx_t_4 = __Pyx_PyString_Format(__pyx_kp_s_Incompatible_checksums_s_vs_0x18, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 6, __pyx_L1_error)
6833 __Pyx_GOTREF(__pyx_t_4);
6834 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6835 __Pyx_INCREF(__pyx_v___pyx_PickleError);
6836 __pyx_t_2 = __pyx_v___pyx_PickleError; __pyx_t_5 = NULL;
6837 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6838 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
6839 if (likely(__pyx_t_5)) {
6840 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6841 __Pyx_INCREF(__pyx_t_5);
6842 __Pyx_INCREF(function);
6843 __Pyx_DECREF_SET(__pyx_t_2, function);
6844 }
6845 }
6846 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4);
6847 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
6848 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6849 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 6, __pyx_L1_error)
6850 __Pyx_GOTREF(__pyx_t_3);
6851 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6852 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
6853 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6854 __PYX_ERR(1, 6, __pyx_L1_error)
6855
6856 /* "(tree fragment)":4
6857 * cdef object __pyx_PickleError
6858 * cdef object __pyx_result
6859 * if __pyx_checksum != 0x183c0eb: # <<<<<<<<<<<<<<
6860 * from pickle import PickleError as __pyx_PickleError
6861 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6862 */
6863 }
6864
6865 /* "(tree fragment)":7
6866 * from pickle import PickleError as __pyx_PickleError
6867 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6868 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type) # <<<<<<<<<<<<<<
6869 * if __pyx_state is not None:
6870 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
6871 */
6872 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader), __pyx_n_s_new); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 7, __pyx_L1_error)
6873 __Pyx_GOTREF(__pyx_t_2);
6874 __pyx_t_4 = NULL;
6875 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
6876 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
6877 if (likely(__pyx_t_4)) {
6878 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6879 __Pyx_INCREF(__pyx_t_4);
6880 __Pyx_INCREF(function);
6881 __Pyx_DECREF_SET(__pyx_t_2, function);
6882 }
6883 }
6884 __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_v___pyx_type) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v___pyx_type);
6885 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6886 if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 7, __pyx_L1_error)
6887 __Pyx_GOTREF(__pyx_t_3);
6888 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6889 __pyx_v___pyx_result = __pyx_t_3;
6890 __pyx_t_3 = 0;
6891
6892 /* "(tree fragment)":8
6893 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6894 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type)
6895 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6896 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
6897 * return __pyx_result
6898 */
6899 __pyx_t_1 = (__pyx_v___pyx_state != Py_None);
6900 __pyx_t_6 = (__pyx_t_1 != 0);
6901 if (__pyx_t_6) {
6902
6903 /* "(tree fragment)":9
6904 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type)
6905 * if __pyx_state is not None:
6906 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state) # <<<<<<<<<<<<<<
6907 * return __pyx_result
6908 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state):
6909 */
6910 if (!(likely(PyTuple_CheckExact(__pyx_v___pyx_state))||((__pyx_v___pyx_state) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "tuple", Py_TYPE(__pyx_v___pyx_state)->tp_name), 0))) __PYX_ERR(1, 9, __pyx_L1_error)
6911 __pyx_t_3 = __pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)__pyx_v___pyx_result), ((PyObject*)__pyx_v___pyx_state)); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 9, __pyx_L1_error)
6912 __Pyx_GOTREF(__pyx_t_3);
6913 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6914
6915 /* "(tree fragment)":8
6916 * raise __pyx_PickleError("Incompatible checksums (%s vs 0x183c0eb = (buffer, current_buffer_size, position, read_block))" % __pyx_checksum)
6917 * __pyx_result = CompressedBufferedReader.__new__(__pyx_type)
6918 * if __pyx_state is not None: # <<<<<<<<<<<<<<
6919 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
6920 * return __pyx_result
6921 */
6922 }
6923
6924 /* "(tree fragment)":10
6925 * if __pyx_state is not None:
6926 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
6927 * return __pyx_result # <<<<<<<<<<<<<<
6928 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state):
6929 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
6930 */
6931 __Pyx_XDECREF(__pyx_r);
6932 __Pyx_INCREF(__pyx_v___pyx_result);
6933 __pyx_r = __pyx_v___pyx_result;
6934 goto __pyx_L0;
6935
6936 /* "(tree fragment)":1
6937 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
6938 * cdef object __pyx_PickleError
6939 * cdef object __pyx_result
6940 */
6941
6942 /* function exit code */
6943 __pyx_L1_error:;
6944 __Pyx_XDECREF(__pyx_t_2);
6945 __Pyx_XDECREF(__pyx_t_3);
6946 __Pyx_XDECREF(__pyx_t_4);
6947 __Pyx_XDECREF(__pyx_t_5);
6948 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader", __pyx_clineno, __pyx_lineno, __pyx_filename);
6949 __pyx_r = NULL;
6950 __pyx_L0:;
6951 __Pyx_XDECREF(__pyx_v___pyx_PickleError);
6952 __Pyx_XDECREF(__pyx_v___pyx_result);
6953 __Pyx_XGIVEREF(__pyx_r);
6954 __Pyx_RefNannyFinishContext();
6955 return __pyx_r;
6956 }
6957
6958 /* "(tree fragment)":11
6959 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
6960 * return __pyx_result
6961 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
6962 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
6963 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
6964 */
6965
6966 static PyObject *__pyx_f_17clickhouse_driver_14bufferedreader___pyx_unpickle_CompressedBufferedReader__set_state(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *__pyx_v___pyx_result, PyObject *__pyx_v___pyx_state) {
38696967 PyObject *__pyx_r = NULL;
38706968 __Pyx_RefNannyDeclarations
38716969 PyObject *__pyx_t_1 = NULL;
3872 PyObject *__pyx_t_2 = NULL;
3873 PyObject *__pyx_t_3 = NULL;
3874 __Pyx_RefNannySetupContext("__init__", 0);
3875
3876 /* "clickhouse_driver/bufferedreader.pyx":201
3877 * class CompressedBufferedReader(BufferedReader):
3878 * def __init__(self, read_block, bufsize):
3879 * self.read_block = read_block # <<<<<<<<<<<<<<
3880 * super(CompressedBufferedReader, self).__init__(bufsize)
3881 *
3882 */
3883 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_read_block, __pyx_v_read_block) < 0) __PYX_ERR(0, 201, __pyx_L1_error)
3884
3885 /* "clickhouse_driver/bufferedreader.pyx":202
3886 * def __init__(self, read_block, bufsize):
3887 * self.read_block = read_block
3888 * super(CompressedBufferedReader, self).__init__(bufsize) # <<<<<<<<<<<<<<
3889 *
3890 * def read_into_buffer(self):
3891 */
3892 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CompressedBufferedReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
3893 __Pyx_GOTREF(__pyx_t_2);
3894 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
3895 __Pyx_GOTREF(__pyx_t_3);
3896 __Pyx_GIVEREF(__pyx_t_2);
3897 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3898 __Pyx_INCREF(__pyx_v_self);
3899 __Pyx_GIVEREF(__pyx_v_self);
3900 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
3901 __pyx_t_2 = 0;
3902 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 202, __pyx_L1_error)
3903 __Pyx_GOTREF(__pyx_t_2);
3904 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3905 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 202, __pyx_L1_error)
3906 __Pyx_GOTREF(__pyx_t_3);
3907 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3908 __pyx_t_2 = NULL;
3909 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3910 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3911 if (likely(__pyx_t_2)) {
3912 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3913 __Pyx_INCREF(__pyx_t_2);
3914 __Pyx_INCREF(function);
3915 __Pyx_DECREF_SET(__pyx_t_3, function);
3916 }
6970 unsigned PY_LONG_LONG __pyx_t_2;
6971 int __pyx_t_3;
6972 Py_ssize_t __pyx_t_4;
6973 int __pyx_t_5;
6974 int __pyx_t_6;
6975 PyObject *__pyx_t_7 = NULL;
6976 PyObject *__pyx_t_8 = NULL;
6977 PyObject *__pyx_t_9 = NULL;
6978 int __pyx_lineno = 0;
6979 const char *__pyx_filename = NULL;
6980 int __pyx_clineno = 0;
6981 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedReader__set_state", 0);
6982
6983 /* "(tree fragment)":12
6984 * return __pyx_result
6985 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state):
6986 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3] # <<<<<<<<<<<<<<
6987 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
6988 * __pyx_result.__dict__.update(__pyx_state[4])
6989 */
6990 if (unlikely(__pyx_v___pyx_state == Py_None)) {
6991 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
6992 __PYX_ERR(1, 12, __pyx_L1_error)
39176993 }
3918 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_bufsize);
3919 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3920 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 202, __pyx_L1_error)
6994 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
39216995 __Pyx_GOTREF(__pyx_t_1);
3922 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6996 if (!(likely(PyByteArray_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(1, 12, __pyx_L1_error)
6997 __Pyx_GIVEREF(__pyx_t_1);
6998 __Pyx_GOTREF(__pyx_v___pyx_result->__pyx_base.buffer);
6999 __Pyx_DECREF(__pyx_v___pyx_result->__pyx_base.buffer);
7000 __pyx_v___pyx_result->__pyx_base.buffer = ((PyObject*)__pyx_t_1);
7001 __pyx_t_1 = 0;
7002 if (unlikely(__pyx_v___pyx_state == Py_None)) {
7003 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7004 __PYX_ERR(1, 12, __pyx_L1_error)
7005 }
7006 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
7007 __Pyx_GOTREF(__pyx_t_1);
7008 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
39237009 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3924
3925 /* "clickhouse_driver/bufferedreader.pyx":200
3926 *
3927 * class CompressedBufferedReader(BufferedReader):
3928 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
3929 * self.read_block = read_block
3930 * super(CompressedBufferedReader, self).__init__(bufsize)
7010 __pyx_v___pyx_result->__pyx_base.current_buffer_size = __pyx_t_2;
7011 if (unlikely(__pyx_v___pyx_state == Py_None)) {
7012 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7013 __PYX_ERR(1, 12, __pyx_L1_error)
7014 }
7015 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
7016 __Pyx_GOTREF(__pyx_t_1);
7017 __pyx_t_2 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_2 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
7018 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7019 __pyx_v___pyx_result->__pyx_base.position = __pyx_t_2;
7020 if (unlikely(__pyx_v___pyx_state == Py_None)) {
7021 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7022 __PYX_ERR(1, 12, __pyx_L1_error)
7023 }
7024 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
7025 __Pyx_GOTREF(__pyx_t_1);
7026 __Pyx_GIVEREF(__pyx_t_1);
7027 __Pyx_GOTREF(__pyx_v___pyx_result->read_block);
7028 __Pyx_DECREF(__pyx_v___pyx_result->read_block);
7029 __pyx_v___pyx_result->read_block = __pyx_t_1;
7030 __pyx_t_1 = 0;
7031
7032 /* "(tree fragment)":13
7033 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state):
7034 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
7035 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
7036 * __pyx_result.__dict__.update(__pyx_state[4])
7037 */
7038 if (unlikely(__pyx_v___pyx_state == Py_None)) {
7039 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
7040 __PYX_ERR(1, 13, __pyx_L1_error)
7041 }
7042 __pyx_t_4 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
7043 __pyx_t_5 = ((__pyx_t_4 > 4) != 0);
7044 if (__pyx_t_5) {
7045 } else {
7046 __pyx_t_3 = __pyx_t_5;
7047 goto __pyx_L4_bool_binop_done;
7048 }
7049 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
7050 __pyx_t_6 = (__pyx_t_5 != 0);
7051 __pyx_t_3 = __pyx_t_6;
7052 __pyx_L4_bool_binop_done:;
7053 if (__pyx_t_3) {
7054
7055 /* "(tree fragment)":14
7056 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
7057 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
7058 * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<<
7059 */
7060 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
7061 __Pyx_GOTREF(__pyx_t_7);
7062 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
7063 __Pyx_GOTREF(__pyx_t_8);
7064 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7065 if (unlikely(__pyx_v___pyx_state == Py_None)) {
7066 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
7067 __PYX_ERR(1, 14, __pyx_L1_error)
7068 }
7069 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
7070 __Pyx_GOTREF(__pyx_t_7);
7071 __pyx_t_9 = NULL;
7072 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
7073 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
7074 if (likely(__pyx_t_9)) {
7075 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
7076 __Pyx_INCREF(__pyx_t_9);
7077 __Pyx_INCREF(function);
7078 __Pyx_DECREF_SET(__pyx_t_8, function);
7079 }
7080 }
7081 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
7082 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
7083 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7084 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
7085 __Pyx_GOTREF(__pyx_t_1);
7086 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7087 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7088
7089 /* "(tree fragment)":13
7090 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state):
7091 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
7092 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'): # <<<<<<<<<<<<<<
7093 * __pyx_result.__dict__.update(__pyx_state[4])
7094 */
7095 }
7096
7097 /* "(tree fragment)":11
7098 * __pyx_unpickle_CompressedBufferedReader__set_state(<CompressedBufferedReader> __pyx_result, __pyx_state)
7099 * return __pyx_result
7100 * cdef __pyx_unpickle_CompressedBufferedReader__set_state(CompressedBufferedReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
7101 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]; __pyx_result.read_block = __pyx_state[3]
7102 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
39317103 */
39327104
39337105 /* function exit code */
39357107 goto __pyx_L0;
39367108 __pyx_L1_error:;
39377109 __Pyx_XDECREF(__pyx_t_1);
3938 __Pyx_XDECREF(__pyx_t_2);
3939 __Pyx_XDECREF(__pyx_t_3);
3940 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
3941 __pyx_r = NULL;
7110 __Pyx_XDECREF(__pyx_t_7);
7111 __Pyx_XDECREF(__pyx_t_8);
7112 __Pyx_XDECREF(__pyx_t_9);
7113 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.__pyx_unpickle_CompressedBufferedReader__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
7114 __pyx_r = 0;
39427115 __pyx_L0:;
39437116 __Pyx_XGIVEREF(__pyx_r);
39447117 __Pyx_RefNannyFinishContext();
39457118 return __pyx_r;
39467119 }
39477120
3948 /* "clickhouse_driver/bufferedreader.pyx":204
3949 * super(CompressedBufferedReader, self).__init__(bufsize)
3950 *
3951 * def read_into_buffer(self): # <<<<<<<<<<<<<<
3952 * self.buffer = bytearray(self.read_block())
3953 * self.current_buffer_size = len(self.buffer)
3954 */
3955
3956 /* Python wrapper */
3957 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3958 static PyMethodDef __pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer = {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, METH_O, 0};
3959 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3960 PyObject *__pyx_r = 0;
3961 __Pyx_RefNannyDeclarations
3962 __Pyx_RefNannySetupContext("read_into_buffer (wrapper)", 0);
3963 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(__pyx_self, ((PyObject *)__pyx_v_self));
3964
3965 /* function exit code */
3966 __Pyx_RefNannyFinishContext();
3967 return __pyx_r;
3968 }
3969
3970 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_2read_into_buffer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
3971 PyObject *__pyx_r = NULL;
3972 __Pyx_RefNannyDeclarations
3973 PyObject *__pyx_t_1 = NULL;
3974 PyObject *__pyx_t_2 = NULL;
3975 PyObject *__pyx_t_3 = NULL;
3976 Py_ssize_t __pyx_t_4;
3977 int __pyx_t_5;
3978 __Pyx_RefNannySetupContext("read_into_buffer", 0);
3979
3980 /* "clickhouse_driver/bufferedreader.pyx":205
3981 *
3982 * def read_into_buffer(self):
3983 * self.buffer = bytearray(self.read_block()) # <<<<<<<<<<<<<<
3984 * self.current_buffer_size = len(self.buffer)
3985 *
3986 */
3987 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_read_block); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
3988 __Pyx_GOTREF(__pyx_t_2);
3989 __pyx_t_3 = NULL;
3990 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3991 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
3992 if (likely(__pyx_t_3)) {
3993 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3994 __Pyx_INCREF(__pyx_t_3);
3995 __Pyx_INCREF(function);
3996 __Pyx_DECREF_SET(__pyx_t_2, function);
3997 }
7121 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
7122 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *p;
7123 PyObject *o;
7124 if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
7125 o = (*t->tp_alloc)(t, 0);
7126 } else {
7127 o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
39987128 }
3999 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
4000 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
4001 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
4002 __Pyx_GOTREF(__pyx_t_1);
4003 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4004 __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyByteArray_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
4005 __Pyx_GOTREF(__pyx_t_2);
4006 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4007 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_buffer, __pyx_t_2) < 0) __PYX_ERR(0, 205, __pyx_L1_error)
4008 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4009
4010 /* "clickhouse_driver/bufferedreader.pyx":206
4011 * def read_into_buffer(self):
4012 * self.buffer = bytearray(self.read_block())
4013 * self.current_buffer_size = len(self.buffer) # <<<<<<<<<<<<<<
4014 *
4015 * if self.current_buffer_size == 0:
4016 */
4017 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_buffer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
4018 __Pyx_GOTREF(__pyx_t_2);
4019 __pyx_t_4 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_4 == ((Py_ssize_t)-1))) __PYX_ERR(0, 206, __pyx_L1_error)
4020 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4021 __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L1_error)
4022 __Pyx_GOTREF(__pyx_t_2);
4023 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size, __pyx_t_2) < 0) __PYX_ERR(0, 206, __pyx_L1_error)
4024 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4025
4026 /* "clickhouse_driver/bufferedreader.pyx":208
4027 * self.current_buffer_size = len(self.buffer)
4028 *
4029 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
4030 * raise EOFError('Unexpected EOF while reading bytes')
4031 */
4032 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_current_buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error)
4033 __Pyx_GOTREF(__pyx_t_2);
4034 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 208, __pyx_L1_error)
4035 __Pyx_GOTREF(__pyx_t_1);
4036 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4037 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 208, __pyx_L1_error)
4038 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4039 if (unlikely(__pyx_t_5)) {
4040
4041 /* "clickhouse_driver/bufferedreader.pyx":209
4042 *
4043 * if self.current_buffer_size == 0:
4044 * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<<
4045 */
4046 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_EOFError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error)
4047 __Pyx_GOTREF(__pyx_t_1);
4048 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
4049 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4050 __PYX_ERR(0, 209, __pyx_L1_error)
4051
4052 /* "clickhouse_driver/bufferedreader.pyx":208
4053 * self.current_buffer_size = len(self.buffer)
4054 *
4055 * if self.current_buffer_size == 0: # <<<<<<<<<<<<<<
4056 * raise EOFError('Unexpected EOF while reading bytes')
4057 */
7129 if (unlikely(!o)) return 0;
7130 p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)o);
7131 p->buffer = ((PyObject*)Py_None); Py_INCREF(Py_None);
7132 return o;
7133 }
7134
7135 static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(PyObject *o) {
7136 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader *)o;
7137 #if CYTHON_USE_TP_FINALIZE
7138 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
7139 if (PyObject_CallFinalizerFromDealloc(o)) return;
40587140 }
4059
4060 /* "clickhouse_driver/bufferedreader.pyx":204
4061 * super(CompressedBufferedReader, self).__init__(bufsize)
4062 *
4063 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4064 * self.buffer = bytearray(self.read_block())
4065 * self.current_buffer_size = len(self.buffer)
4066 */
4067
4068 /* function exit code */
4069 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4070 goto __pyx_L0;
4071 __pyx_L1_error:;
4072 __Pyx_XDECREF(__pyx_t_1);
4073 __Pyx_XDECREF(__pyx_t_2);
4074 __Pyx_XDECREF(__pyx_t_3);
4075 __Pyx_AddTraceback("clickhouse_driver.bufferedreader.CompressedBufferedReader.read_into_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename);
4076 __pyx_r = NULL;
4077 __pyx_L0:;
4078 __Pyx_XGIVEREF(__pyx_r);
4079 __Pyx_RefNannyFinishContext();
4080 return __pyx_r;
4081 }
7141 #endif
7142 Py_CLEAR(p->buffer);
7143 (*Py_TYPE(o)->tp_free)(o);
7144 }
7145
7146 static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position(PyObject *o, CYTHON_UNUSED void *x) {
7147 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_1__get__(o);
7148 }
7149
7150 static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
7151 if (v) {
7152 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_8position_3__set__(o, v);
7153 }
7154 else {
7155 PyErr_SetString(PyExc_NotImplementedError, "__del__");
7156 return -1;
7157 }
7158 }
7159
7160 static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size(PyObject *o, CYTHON_UNUSED void *x) {
7161 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_1__get__(o);
7162 }
7163
7164 static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
7165 if (v) {
7166 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_19current_buffer_size_3__set__(o, v);
7167 }
7168 else {
7169 PyErr_SetString(PyExc_NotImplementedError, "__del__");
7170 return -1;
7171 }
7172 }
7173
7174 static PyObject *__pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer(PyObject *o, CYTHON_UNUSED void *x) {
7175 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_1__get__(o);
7176 }
7177
7178 static int __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
7179 if (v) {
7180 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_3__set__(o, v);
7181 }
7182 else {
7183 return __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_6buffer_5__del__(o);
7184 }
7185 }
7186
7187 static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedReader[] = {
7188 {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, METH_NOARGS, 0},
7189 {"read", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, METH_O, 0},
7190 {"read_one", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, METH_NOARGS, 0},
7191 {"read_strings", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, METH_VARARGS|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_14bufferedreader_14BufferedReader_8read_strings},
7192 {"read_fixed_strings_as_bytes", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_11read_fixed_strings_as_bytes, METH_VARARGS|METH_KEYWORDS, 0},
7193 {"read_fixed_strings", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_13read_fixed_strings, METH_VARARGS|METH_KEYWORDS, 0},
7194 {"__reduce_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_15__reduce_cython__, METH_NOARGS, 0},
7195 {"__setstate_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_17__setstate_cython__, METH_O, 0},
7196 {0, 0, 0, 0}
7197 };
7198
7199 static struct PyGetSetDef __pyx_getsets_17clickhouse_driver_14bufferedreader_BufferedReader[] = {
7200 {(char *)"position", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_position, (char *)0, 0},
7201 {(char *)"current_buffer_size", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_current_buffer_size, (char *)0, 0},
7202 {(char *)"buffer", __pyx_getprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer, __pyx_setprop_17clickhouse_driver_14bufferedreader_14BufferedReader_buffer, (char *)0, 0},
7203 {0, 0, 0, 0, 0}
7204 };
7205
7206 static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader = {
7207 PyVarObject_HEAD_INIT(0, 0)
7208 "clickhouse_driver.bufferedreader.BufferedReader", /*tp_name*/
7209 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedReader), /*tp_basicsize*/
7210 0, /*tp_itemsize*/
7211 __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_dealloc*/
7212 #if PY_VERSION_HEX < 0x030800b4
7213 0, /*tp_print*/
7214 #endif
7215 #if PY_VERSION_HEX >= 0x030800b4
7216 0, /*tp_vectorcall_offset*/
7217 #endif
7218 0, /*tp_getattr*/
7219 0, /*tp_setattr*/
7220 #if PY_MAJOR_VERSION < 3
7221 0, /*tp_compare*/
7222 #endif
7223 #if PY_MAJOR_VERSION >= 3
7224 0, /*tp_as_async*/
7225 #endif
7226 0, /*tp_repr*/
7227 0, /*tp_as_number*/
7228 0, /*tp_as_sequence*/
7229 0, /*tp_as_mapping*/
7230 0, /*tp_hash*/
7231 0, /*tp_call*/
7232 0, /*tp_str*/
7233 0, /*tp_getattro*/
7234 0, /*tp_setattro*/
7235 0, /*tp_as_buffer*/
7236 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
7237 0, /*tp_doc*/
7238 0, /*tp_traverse*/
7239 0, /*tp_clear*/
7240 0, /*tp_richcompare*/
7241 0, /*tp_weaklistoffset*/
7242 0, /*tp_iter*/
7243 0, /*tp_iternext*/
7244 __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_methods*/
7245 0, /*tp_members*/
7246 __pyx_getsets_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_getset*/
7247 0, /*tp_base*/
7248 0, /*tp_dict*/
7249 0, /*tp_descr_get*/
7250 0, /*tp_descr_set*/
7251 0, /*tp_dictoffset*/
7252 __pyx_pw_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__, /*tp_init*/
7253 0, /*tp_alloc*/
7254 __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader, /*tp_new*/
7255 0, /*tp_free*/
7256 0, /*tp_is_gc*/
7257 0, /*tp_bases*/
7258 0, /*tp_mro*/
7259 0, /*tp_cache*/
7260 0, /*tp_subclasses*/
7261 0, /*tp_weaklist*/
7262 0, /*tp_del*/
7263 0, /*tp_version_tag*/
7264 #if PY_VERSION_HEX >= 0x030400a1
7265 0, /*tp_finalize*/
7266 #endif
7267 #if PY_VERSION_HEX >= 0x030800b1
7268 0, /*tp_vectorcall*/
7269 #endif
7270 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7271 0, /*tp_print*/
7272 #endif
7273 };
7274
7275 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyTypeObject *t, PyObject *a, PyObject *k) {
7276 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p;
7277 PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(t, a, k);
7278 if (unlikely(!o)) return 0;
7279 p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o);
7280 p->sock = Py_None; Py_INCREF(Py_None);
7281 return o;
7282 }
7283
7284 static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o) {
7285 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o;
7286 #if CYTHON_USE_TP_FINALIZE
7287 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
7288 if (PyObject_CallFinalizerFromDealloc(o)) return;
7289 }
7290 #endif
7291 PyObject_GC_UnTrack(o);
7292 Py_CLEAR(p->sock);
7293 #if CYTHON_USE_TYPE_SLOTS
7294 if (PyType_IS_GC(Py_TYPE(o)->tp_base))
7295 #endif
7296 PyObject_GC_Track(o);
7297 __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(o);
7298 }
7299
7300 static int __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o, visitproc v, void *a) {
7301 int e;
7302 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o;
7303 e = ((likely(__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) ? ((__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_traverse) ? __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader)); if (e) return e;
7304 if (p->sock) {
7305 e = (*v)(p->sock, a); if (e) return e;
7306 }
7307 return 0;
7308 }
7309
7310 static int __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader(PyObject *o) {
7311 PyObject* tmp;
7312 struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader *)o;
7313 if (likely(__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { if (__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_clear) __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader);
7314 tmp = ((PyObject*)p->sock);
7315 p->sock = Py_None; Py_INCREF(Py_None);
7316 Py_XDECREF(tmp);
7317 return 0;
7318 }
7319
7320 static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedSocketReader[] = {
7321 {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, METH_NOARGS, 0},
7322 {"__reduce_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_5__reduce_cython__, METH_NOARGS, 0},
7323 {"__setstate_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_7__setstate_cython__, METH_O, 0},
7324 {0, 0, 0, 0}
7325 };
7326
7327 static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader = {
7328 PyVarObject_HEAD_INIT(0, 0)
7329 "clickhouse_driver.bufferedreader.BufferedSocketReader", /*tp_name*/
7330 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_BufferedSocketReader), /*tp_basicsize*/
7331 0, /*tp_itemsize*/
7332 __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_dealloc*/
7333 #if PY_VERSION_HEX < 0x030800b4
7334 0, /*tp_print*/
7335 #endif
7336 #if PY_VERSION_HEX >= 0x030800b4
7337 0, /*tp_vectorcall_offset*/
7338 #endif
7339 0, /*tp_getattr*/
7340 0, /*tp_setattr*/
7341 #if PY_MAJOR_VERSION < 3
7342 0, /*tp_compare*/
7343 #endif
7344 #if PY_MAJOR_VERSION >= 3
7345 0, /*tp_as_async*/
7346 #endif
7347 0, /*tp_repr*/
7348 0, /*tp_as_number*/
7349 0, /*tp_as_sequence*/
7350 0, /*tp_as_mapping*/
7351 0, /*tp_hash*/
7352 0, /*tp_call*/
7353 0, /*tp_str*/
7354 0, /*tp_getattro*/
7355 0, /*tp_setattro*/
7356 0, /*tp_as_buffer*/
7357 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
7358 0, /*tp_doc*/
7359 __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_traverse*/
7360 __pyx_tp_clear_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_clear*/
7361 0, /*tp_richcompare*/
7362 0, /*tp_weaklistoffset*/
7363 0, /*tp_iter*/
7364 0, /*tp_iternext*/
7365 __pyx_methods_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_methods*/
7366 0, /*tp_members*/
7367 0, /*tp_getset*/
7368 0, /*tp_base*/
7369 0, /*tp_dict*/
7370 0, /*tp_descr_get*/
7371 0, /*tp_descr_set*/
7372 0, /*tp_dictoffset*/
7373 __pyx_pw_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__, /*tp_init*/
7374 0, /*tp_alloc*/
7375 __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedSocketReader, /*tp_new*/
7376 0, /*tp_free*/
7377 0, /*tp_is_gc*/
7378 0, /*tp_bases*/
7379 0, /*tp_mro*/
7380 0, /*tp_cache*/
7381 0, /*tp_subclasses*/
7382 0, /*tp_weaklist*/
7383 0, /*tp_del*/
7384 0, /*tp_version_tag*/
7385 #if PY_VERSION_HEX >= 0x030400a1
7386 0, /*tp_finalize*/
7387 #endif
7388 #if PY_VERSION_HEX >= 0x030800b1
7389 0, /*tp_vectorcall*/
7390 #endif
7391 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7392 0, /*tp_print*/
7393 #endif
7394 };
7395
7396 static PyObject *__pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyTypeObject *t, PyObject *a, PyObject *k) {
7397 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p;
7398 PyObject *o = __pyx_tp_new_17clickhouse_driver_14bufferedreader_BufferedReader(t, a, k);
7399 if (unlikely(!o)) return 0;
7400 p = ((struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o);
7401 p->read_block = Py_None; Py_INCREF(Py_None);
7402 return o;
7403 }
7404
7405 static void __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o) {
7406 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o;
7407 #if CYTHON_USE_TP_FINALIZE
7408 if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
7409 if (PyObject_CallFinalizerFromDealloc(o)) return;
7410 }
7411 #endif
7412 PyObject_GC_UnTrack(o);
7413 Py_CLEAR(p->read_block);
7414 #if CYTHON_USE_TYPE_SLOTS
7415 if (PyType_IS_GC(Py_TYPE(o)->tp_base))
7416 #endif
7417 PyObject_GC_Track(o);
7418 __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_BufferedReader(o);
7419 }
7420
7421 static int __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o, visitproc v, void *a) {
7422 int e;
7423 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o;
7424 e = ((likely(__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) ? ((__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_traverse) ? __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_traverse(o, v, a) : 0) : __Pyx_call_next_tp_traverse(o, v, a, __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader)); if (e) return e;
7425 if (p->read_block) {
7426 e = (*v)(p->read_block, a); if (e) return e;
7427 }
7428 return 0;
7429 }
7430
7431 static int __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader(PyObject *o) {
7432 PyObject* tmp;
7433 struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *p = (struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader *)o;
7434 if (likely(__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader)) { if (__pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_clear) __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader->tp_clear(o); } else __Pyx_call_next_tp_clear(o, __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader);
7435 tmp = ((PyObject*)p->read_block);
7436 p->read_block = Py_None; Py_INCREF(Py_None);
7437 Py_XDECREF(tmp);
7438 return 0;
7439 }
7440
7441 static PyMethodDef __pyx_methods_17clickhouse_driver_14bufferedreader_CompressedBufferedReader[] = {
7442 {"read_into_buffer", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, METH_NOARGS, 0},
7443 {"__reduce_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_5__reduce_cython__, METH_NOARGS, 0},
7444 {"__setstate_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_7__setstate_cython__, METH_O, 0},
7445 {0, 0, 0, 0}
7446 };
7447
7448 static PyTypeObject __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = {
7449 PyVarObject_HEAD_INIT(0, 0)
7450 "clickhouse_driver.bufferedreader.CompressedBufferedReader", /*tp_name*/
7451 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedreader_CompressedBufferedReader), /*tp_basicsize*/
7452 0, /*tp_itemsize*/
7453 __pyx_tp_dealloc_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_dealloc*/
7454 #if PY_VERSION_HEX < 0x030800b4
7455 0, /*tp_print*/
7456 #endif
7457 #if PY_VERSION_HEX >= 0x030800b4
7458 0, /*tp_vectorcall_offset*/
7459 #endif
7460 0, /*tp_getattr*/
7461 0, /*tp_setattr*/
7462 #if PY_MAJOR_VERSION < 3
7463 0, /*tp_compare*/
7464 #endif
7465 #if PY_MAJOR_VERSION >= 3
7466 0, /*tp_as_async*/
7467 #endif
7468 0, /*tp_repr*/
7469 0, /*tp_as_number*/
7470 0, /*tp_as_sequence*/
7471 0, /*tp_as_mapping*/
7472 0, /*tp_hash*/
7473 0, /*tp_call*/
7474 0, /*tp_str*/
7475 0, /*tp_getattro*/
7476 0, /*tp_setattro*/
7477 0, /*tp_as_buffer*/
7478 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
7479 0, /*tp_doc*/
7480 __pyx_tp_traverse_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_traverse*/
7481 __pyx_tp_clear_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_clear*/
7482 0, /*tp_richcompare*/
7483 0, /*tp_weaklistoffset*/
7484 0, /*tp_iter*/
7485 0, /*tp_iternext*/
7486 __pyx_methods_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_methods*/
7487 0, /*tp_members*/
7488 0, /*tp_getset*/
7489 0, /*tp_base*/
7490 0, /*tp_dict*/
7491 0, /*tp_descr_get*/
7492 0, /*tp_descr_set*/
7493 0, /*tp_dictoffset*/
7494 __pyx_pw_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__, /*tp_init*/
7495 0, /*tp_alloc*/
7496 __pyx_tp_new_17clickhouse_driver_14bufferedreader_CompressedBufferedReader, /*tp_new*/
7497 0, /*tp_free*/
7498 0, /*tp_is_gc*/
7499 0, /*tp_bases*/
7500 0, /*tp_mro*/
7501 0, /*tp_cache*/
7502 0, /*tp_subclasses*/
7503 0, /*tp_weaklist*/
7504 0, /*tp_del*/
7505 0, /*tp_version_tag*/
7506 #if PY_VERSION_HEX >= 0x030400a1
7507 0, /*tp_finalize*/
7508 #endif
7509 #if PY_VERSION_HEX >= 0x030800b1
7510 0, /*tp_vectorcall*/
7511 #endif
7512 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
7513 0, /*tp_print*/
7514 #endif
7515 };
40827516
40837517 static PyMethodDef __pyx_methods[] = {
40847518 {0, 0, 0, 0}
41277561
41287562 static __Pyx_StringTabEntry __pyx_string_tab[] = {
41297563 {&__pyx_n_s_BufferedReader, __pyx_k_BufferedReader, sizeof(__pyx_k_BufferedReader), 0, 0, 1, 1},
4130 {&__pyx_n_s_BufferedReader___init, __pyx_k_BufferedReader___init, sizeof(__pyx_k_BufferedReader___init), 0, 0, 1, 1},
4131 {&__pyx_n_s_BufferedReader_read, __pyx_k_BufferedReader_read, sizeof(__pyx_k_BufferedReader_read), 0, 0, 1, 1},
4132 {&__pyx_n_s_BufferedReader_read_into_buffer, __pyx_k_BufferedReader_read_into_buffer, sizeof(__pyx_k_BufferedReader_read_into_buffer), 0, 0, 1, 1},
4133 {&__pyx_n_s_BufferedReader_read_one, __pyx_k_BufferedReader_read_one, sizeof(__pyx_k_BufferedReader_read_one), 0, 0, 1, 1},
4134 {&__pyx_n_s_BufferedReader_read_strings, __pyx_k_BufferedReader_read_strings, sizeof(__pyx_k_BufferedReader_read_strings), 0, 0, 1, 1},
41357564 {&__pyx_n_s_BufferedSocketReader, __pyx_k_BufferedSocketReader, sizeof(__pyx_k_BufferedSocketReader), 0, 0, 1, 1},
4136 {&__pyx_n_s_BufferedSocketReader___init, __pyx_k_BufferedSocketReader___init, sizeof(__pyx_k_BufferedSocketReader___init), 0, 0, 1, 1},
4137 {&__pyx_n_s_BufferedSocketReader_read_into_b, __pyx_k_BufferedSocketReader_read_into_b, sizeof(__pyx_k_BufferedSocketReader_read_into_b), 0, 0, 1, 1},
41387565 {&__pyx_n_s_CompressedBufferedReader, __pyx_k_CompressedBufferedReader, sizeof(__pyx_k_CompressedBufferedReader), 0, 0, 1, 1},
4139 {&__pyx_n_s_CompressedBufferedReader___init, __pyx_k_CompressedBufferedReader___init, sizeof(__pyx_k_CompressedBufferedReader___init), 0, 0, 1, 1},
4140 {&__pyx_n_s_CompressedBufferedReader_read_in, __pyx_k_CompressedBufferedReader_read_in, sizeof(__pyx_k_CompressedBufferedReader_read_in), 0, 0, 1, 1},
41417566 {&__pyx_n_s_EOFError, __pyx_k_EOFError, sizeof(__pyx_k_EOFError), 0, 0, 1, 1},
7567 {&__pyx_kp_s_Incompatible_checksums_s_vs_0x18, __pyx_k_Incompatible_checksums_s_vs_0x18, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x18), 0, 0, 1, 0},
7568 {&__pyx_kp_s_Incompatible_checksums_s_vs_0x2a, __pyx_k_Incompatible_checksums_s_vs_0x2a, sizeof(__pyx_k_Incompatible_checksums_s_vs_0x2a), 0, 0, 1, 0},
7569 {&__pyx_kp_s_Incompatible_checksums_s_vs_0xef, __pyx_k_Incompatible_checksums_s_vs_0xef, sizeof(__pyx_k_Incompatible_checksums_s_vs_0xef), 0, 0, 1, 0},
41427570 {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
41437571 {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
7572 {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
41447573 {&__pyx_kp_u_Unexpected_EOF_while_reading_byt, __pyx_k_Unexpected_EOF_while_reading_byt, sizeof(__pyx_k_Unexpected_EOF_while_reading_byt), 0, 1, 0, 0},
41457574 {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1},
4146 {&__pyx_n_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 1},
4147 {&__pyx_n_s_buffer, __pyx_k_buffer, sizeof(__pyx_k_buffer), 0, 0, 1, 1},
4148 {&__pyx_n_s_buffer_ptr, __pyx_k_buffer_ptr, sizeof(__pyx_k_buffer_ptr), 0, 0, 1, 1},
41497575 {&__pyx_n_s_bufsize, __pyx_k_bufsize, sizeof(__pyx_k_bufsize), 0, 0, 1, 1},
4150 {&__pyx_n_s_bytes_read, __pyx_k_bytes_read, sizeof(__pyx_k_bytes_read), 0, 0, 1, 1},
4151 {&__pyx_n_s_c_string, __pyx_k_c_string, sizeof(__pyx_k_c_string), 0, 0, 1, 1},
4152 {&__pyx_n_s_c_string_size, __pyx_k_c_string_size, sizeof(__pyx_k_c_string_size), 0, 0, 1, 1},
41537576 {&__pyx_n_s_clickhouse_driver_bufferedreader, __pyx_k_clickhouse_driver_bufferedreader, sizeof(__pyx_k_clickhouse_driver_bufferedreader), 0, 0, 1, 1},
4154 {&__pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_k_clickhouse_driver_bufferedreader_2, sizeof(__pyx_k_clickhouse_driver_bufferedreader_2), 0, 0, 1, 0},
41557577 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
4156 {&__pyx_n_s_current_buffer_size, __pyx_k_current_buffer_size, sizeof(__pyx_k_current_buffer_size), 0, 0, 1, 1},
4157 {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
4158 {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
4159 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
7578 {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
7579 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
7580 {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
7581 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
7582 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
41607583 {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
4161 {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
4162 {&__pyx_n_s_large_str_bytes, __pyx_k_large_str_bytes, sizeof(__pyx_k_large_str_bytes), 0, 0, 1, 1},
7584 {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
41637585 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
4164 {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
4165 {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
41667586 {&__pyx_n_s_n_items, __pyx_k_n_items, sizeof(__pyx_k_n_items), 0, 0, 1, 1},
41677587 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
4168 {&__pyx_n_s_next_position, __pyx_k_next_position, sizeof(__pyx_k_next_position), 0, 0, 1, 1},
7588 {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
41697589 {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
4170 {&__pyx_n_s_position, __pyx_k_position, sizeof(__pyx_k_position), 0, 0, 1, 1},
4171 {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
4172 {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
7590 {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
7591 {&__pyx_n_s_pyx_PickleError, __pyx_k_pyx_PickleError, sizeof(__pyx_k_pyx_PickleError), 0, 0, 1, 1},
7592 {&__pyx_n_s_pyx_checksum, __pyx_k_pyx_checksum, sizeof(__pyx_k_pyx_checksum), 0, 0, 1, 1},
7593 {&__pyx_n_s_pyx_result, __pyx_k_pyx_result, sizeof(__pyx_k_pyx_result), 0, 0, 1, 1},
7594 {&__pyx_n_s_pyx_state, __pyx_k_pyx_state, sizeof(__pyx_k_pyx_state), 0, 0, 1, 1},
7595 {&__pyx_n_s_pyx_type, __pyx_k_pyx_type, sizeof(__pyx_k_pyx_type), 0, 0, 1, 1},
7596 {&__pyx_n_s_pyx_unpickle_BufferedReader, __pyx_k_pyx_unpickle_BufferedReader, sizeof(__pyx_k_pyx_unpickle_BufferedReader), 0, 0, 1, 1},
7597 {&__pyx_n_s_pyx_unpickle_BufferedSocketRea, __pyx_k_pyx_unpickle_BufferedSocketRea, sizeof(__pyx_k_pyx_unpickle_BufferedSocketRea), 0, 0, 1, 1},
7598 {&__pyx_n_s_pyx_unpickle_CompressedBuffere, __pyx_k_pyx_unpickle_CompressedBuffere, sizeof(__pyx_k_pyx_unpickle_CompressedBuffere), 0, 0, 1, 1},
41737599 {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
41747600 {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
41757601 {&__pyx_n_s_read_block, __pyx_k_read_block, sizeof(__pyx_k_read_block), 0, 0, 1, 1},
4176 {&__pyx_n_s_read_bytes, __pyx_k_read_bytes, sizeof(__pyx_k_read_bytes), 0, 0, 1, 1},
7602 {&__pyx_n_s_read_fixed_strings_as_bytes, __pyx_k_read_fixed_strings_as_bytes, sizeof(__pyx_k_read_fixed_strings_as_bytes), 0, 0, 1, 1},
41777603 {&__pyx_n_s_read_into_buffer, __pyx_k_read_into_buffer, sizeof(__pyx_k_read_into_buffer), 0, 0, 1, 1},
4178 {&__pyx_n_s_read_one, __pyx_k_read_one, sizeof(__pyx_k_read_one), 0, 0, 1, 1},
4179 {&__pyx_n_s_read_strings, __pyx_k_read_strings, sizeof(__pyx_k_read_strings), 0, 0, 1, 1},
41807604 {&__pyx_n_s_recv_into, __pyx_k_recv_into, sizeof(__pyx_k_recv_into), 0, 0, 1, 1},
4181 {&__pyx_n_s_right, __pyx_k_right, sizeof(__pyx_k_right), 0, 0, 1, 1},
4182 {&__pyx_n_s_rv, __pyx_k_rv, sizeof(__pyx_k_rv), 0, 0, 1, 1},
4183 {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
4184 {&__pyx_n_s_shift, __pyx_k_shift, sizeof(__pyx_k_shift), 0, 0, 1, 1},
4185 {&__pyx_n_s_size, __pyx_k_size, sizeof(__pyx_k_size), 0, 0, 1, 1},
7605 {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1},
7606 {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1},
7607 {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1},
7608 {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1},
7609 {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1},
41867610 {&__pyx_n_s_sock, __pyx_k_sock, sizeof(__pyx_k_sock), 0, 0, 1, 1},
7611 {&__pyx_kp_s_stringsource, __pyx_k_stringsource, sizeof(__pyx_k_stringsource), 0, 0, 1, 0},
41877612 {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
4188 {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
41897613 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
4190 {&__pyx_n_s_unread, __pyx_k_unread, sizeof(__pyx_k_unread), 0, 0, 1, 1},
7614 {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
7615 {&__pyx_kp_u_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 1, 0, 0},
41917616 {0, 0, 0, 0, 0, 0, 0}
41927617 };
41937618 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
4194 __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 19, __pyx_L1_error)
4195 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 15, __pyx_L1_error)
4196 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 26, __pyx_L1_error)
4197 __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 29, __pyx_L1_error)
4198 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 95, __pyx_L1_error)
4199 __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 170, __pyx_L1_error)
4200 __pyx_builtin_EOFError = __Pyx_GetBuiltinName(__pyx_n_s_EOFError); if (!__pyx_builtin_EOFError) __PYX_ERR(0, 196, __pyx_L1_error)
7619 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 20, __pyx_L1_error)
7620 __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 23, __pyx_L1_error)
7621 __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 85, __pyx_L1_error)
7622 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 90, __pyx_L1_error)
7623 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 117, __pyx_L1_error)
7624 __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 168, __pyx_L1_error)
7625 __pyx_builtin_EOFError = __Pyx_GetBuiltinName(__pyx_n_s_EOFError); if (!__pyx_builtin_EOFError) __PYX_ERR(0, 240, __pyx_L1_error)
42017626 return 0;
42027627 __pyx_L1_error:;
42037628 return -1;
42077632 __Pyx_RefNannyDeclarations
42087633 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
42097634
4210 /* "clickhouse_driver/bufferedreader.pyx":196
7635 /* "clickhouse_driver/bufferedreader.pyx":240
42117636 *
42127637 * if self.current_buffer_size == 0:
42137638 * raise EOFError('Unexpected EOF while reading bytes') # <<<<<<<<<<<<<<
42147639 *
42157640 *
42167641 */
4217 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Unexpected_EOF_while_reading_byt); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 196, __pyx_L1_error)
7642 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_Unexpected_EOF_while_reading_byt); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 240, __pyx_L1_error)
42187643 __Pyx_GOTREF(__pyx_tuple_);
42197644 __Pyx_GIVEREF(__pyx_tuple_);
42207645
4221 /* "clickhouse_driver/bufferedreader.pyx":19
4222 *
4223 *
4224 * class BufferedReader(object): # <<<<<<<<<<<<<<
4225 * def __init__(self, bufsize):
4226 * self.buffer = bytearray(bufsize)
4227 */
4228 __pyx_tuple__2 = PyTuple_Pack(1, __pyx_builtin_object); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 19, __pyx_L1_error)
7646 /* "(tree fragment)":1
7647 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
7648 * cdef object __pyx_PickleError
7649 * cdef object __pyx_result
7650 */
7651 __pyx_tuple__2 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 1, __pyx_L1_error)
42297652 __Pyx_GOTREF(__pyx_tuple__2);
42307653 __Pyx_GIVEREF(__pyx_tuple__2);
4231
4232 /* "clickhouse_driver/bufferedreader.pyx":20
4233 *
4234 * class BufferedReader(object):
4235 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
4236 * self.buffer = bytearray(bufsize)
4237 *
4238 */
4239 __pyx_tuple__3 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_bufsize); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 20, __pyx_L1_error)
4240 __Pyx_GOTREF(__pyx_tuple__3);
4241 __Pyx_GIVEREF(__pyx_tuple__3);
4242 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_init, 20, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 20, __pyx_L1_error)
4243
4244 /* "clickhouse_driver/bufferedreader.pyx":28
4245 * super(BufferedReader, self).__init__()
4246 *
4247 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4248 * raise NotImplementedError
4249 *
4250 */
4251 __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 28, __pyx_L1_error)
4252 __Pyx_GOTREF(__pyx_tuple__5);
4253 __Pyx_GIVEREF(__pyx_tuple__5);
4254 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read_into_buffer, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 28, __pyx_L1_error)
4255
4256 /* "clickhouse_driver/bufferedreader.pyx":31
4257 * raise NotImplementedError
4258 *
4259 * def read(self, Py_ssize_t unread): # <<<<<<<<<<<<<<
4260 * # When the buffer is large enough bytes read are almost
4261 * # always hit the buffer.
4262 */
4263 __pyx_tuple__7 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_unread, __pyx_n_s_next_position, __pyx_n_s_t, __pyx_n_s_buffer_ptr, __pyx_n_s_read_bytes, __pyx_n_s_position, __pyx_n_s_current_buffer_size, __pyx_n_s_rv); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 31, __pyx_L1_error)
4264 __Pyx_GOTREF(__pyx_tuple__7);
4265 __Pyx_GIVEREF(__pyx_tuple__7);
4266 __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(2, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read, 31, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 31, __pyx_L1_error)
4267
4268 /* "clickhouse_driver/bufferedreader.pyx":64
4269 * return bytearray(rv)
4270 *
4271 * def read_one(self): # <<<<<<<<<<<<<<
4272 * if self.position == self.current_buffer_size:
4273 * self.read_into_buffer()
4274 */
4275 __pyx_tuple__9 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_rv); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 64, __pyx_L1_error)
4276 __Pyx_GOTREF(__pyx_tuple__9);
4277 __Pyx_GIVEREF(__pyx_tuple__9);
4278 __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read_one, 64, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 64, __pyx_L1_error)
4279
4280 /* "clickhouse_driver/bufferedreader.pyx":73
4281 * return rv
4282 *
4283 * def read_strings(self, Py_ssize_t n_items, int decode=0): # <<<<<<<<<<<<<<
4284 * """
4285 * Python has great overhead between function calls.
4286 */
4287 __pyx_tuple__11 = PyTuple_Pack(18, __pyx_n_s_self, __pyx_n_s_n_items, __pyx_n_s_decode, __pyx_n_s_items, __pyx_n_s_buffer, __pyx_n_s_i, __pyx_n_s_buffer_ptr, __pyx_n_s_right, __pyx_n_s_position, __pyx_n_s_current_buffer_size, __pyx_n_s_size, __pyx_n_s_shift, __pyx_n_s_b, __pyx_n_s_c_string, __pyx_n_s_c_string_size, __pyx_n_s_large_str_bytes, __pyx_n_s_bytes_read, __pyx_n_s_rv); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 73, __pyx_L1_error)
4288 __Pyx_GOTREF(__pyx_tuple__11);
4289 __Pyx_GIVEREF(__pyx_tuple__11);
4290 __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(3, 0, 18, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read_strings, 73, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 73, __pyx_L1_error)
4291
4292 /* "clickhouse_driver/bufferedreader.pyx":188
4293 *
4294 * class BufferedSocketReader(BufferedReader):
4295 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
4296 * self.sock = sock
4297 * super(BufferedSocketReader, self).__init__(bufsize)
4298 */
4299 __pyx_tuple__13 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_sock, __pyx_n_s_bufsize); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 188, __pyx_L1_error)
4300 __Pyx_GOTREF(__pyx_tuple__13);
4301 __Pyx_GIVEREF(__pyx_tuple__13);
4302 __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_init, 188, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 188, __pyx_L1_error)
4303
4304 /* "clickhouse_driver/bufferedreader.pyx":192
4305 * super(BufferedSocketReader, self).__init__(bufsize)
4306 *
4307 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4308 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4309 *
4310 */
4311 __pyx_tuple__15 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 192, __pyx_L1_error)
4312 __Pyx_GOTREF(__pyx_tuple__15);
4313 __Pyx_GIVEREF(__pyx_tuple__15);
4314 __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read_into_buffer, 192, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 192, __pyx_L1_error)
4315
4316 /* "clickhouse_driver/bufferedreader.pyx":200
4317 *
4318 * class CompressedBufferedReader(BufferedReader):
4319 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
4320 * self.read_block = read_block
4321 * super(CompressedBufferedReader, self).__init__(bufsize)
4322 */
4323 __pyx_tuple__17 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_read_block, __pyx_n_s_bufsize); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 200, __pyx_L1_error)
4324 __Pyx_GOTREF(__pyx_tuple__17);
4325 __Pyx_GIVEREF(__pyx_tuple__17);
4326 __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_init, 200, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 200, __pyx_L1_error)
4327
4328 /* "clickhouse_driver/bufferedreader.pyx":204
4329 * super(CompressedBufferedReader, self).__init__(bufsize)
4330 *
4331 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4332 * self.buffer = bytearray(self.read_block())
4333 * self.current_buffer_size = len(self.buffer)
4334 */
4335 __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 204, __pyx_L1_error)
4336 __Pyx_GOTREF(__pyx_tuple__19);
4337 __Pyx_GIVEREF(__pyx_tuple__19);
4338 __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_bufferedreader_2, __pyx_n_s_read_into_buffer, 204, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 204, __pyx_L1_error)
7654 __pyx_codeobj__3 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__2, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedReader, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__3)) __PYX_ERR(1, 1, __pyx_L1_error)
7655 __pyx_tuple__4 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 1, __pyx_L1_error)
7656 __Pyx_GOTREF(__pyx_tuple__4);
7657 __Pyx_GIVEREF(__pyx_tuple__4);
7658 __pyx_codeobj__5 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__4, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedSocketRea, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__5)) __PYX_ERR(1, 1, __pyx_L1_error)
7659 __pyx_tuple__6 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 1, __pyx_L1_error)
7660 __Pyx_GOTREF(__pyx_tuple__6);
7661 __Pyx_GIVEREF(__pyx_tuple__6);
7662 __pyx_codeobj__7 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__6, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_CompressedBuffere, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__7)) __PYX_ERR(1, 1, __pyx_L1_error)
43397663 __Pyx_RefNannyFinishContext();
43407664 return 0;
43417665 __pyx_L1_error:;
43457669
43467670 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
43477671 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4348 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
4349 __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) __PYX_ERR(0, 1, __pyx_L1_error)
7672 __pyx_int_25411819 = PyInt_FromLong(25411819L); if (unlikely(!__pyx_int_25411819)) __PYX_ERR(0, 1, __pyx_L1_error)
7673 __pyx_int_44607813 = PyInt_FromLong(44607813L); if (unlikely(!__pyx_int_44607813)) __PYX_ERR(0, 1, __pyx_L1_error)
7674 __pyx_int_251251440 = PyInt_FromLong(251251440L); if (unlikely(!__pyx_int_251251440)) __PYX_ERR(0, 1, __pyx_L1_error)
43507675 return 0;
43517676 __pyx_L1_error:;
43527677 return -1;
43867711
43877712 static int __Pyx_modinit_type_init_code(void) {
43887713 __Pyx_RefNannyDeclarations
7714 int __pyx_lineno = 0;
7715 const char *__pyx_filename = NULL;
7716 int __pyx_clineno = 0;
43897717 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
43907718 /*--- Type init code ---*/
7719 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
7720 #if PY_VERSION_HEX < 0x030800B1
7721 __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader.tp_print = 0;
7722 #endif
7723 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader.tp_getattro == PyObject_GenericGetAttr)) {
7724 __pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader.tp_getattro = __Pyx_PyObject_GenericGetAttr;
7725 }
7726 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedReader, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
7727 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
7728 __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader = &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedReader;
7729 __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader.tp_base = __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader;
7730 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
7731 #if PY_VERSION_HEX < 0x030800B1
7732 __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader.tp_print = 0;
7733 #endif
7734 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader.tp_getattro == PyObject_GenericGetAttr)) {
7735 __pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader.tp_getattro = __Pyx_PyObject_GenericGetAttr;
7736 }
7737 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedSocketReader, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
7738 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader) < 0) __PYX_ERR(0, 229, __pyx_L1_error)
7739 __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedSocketReader = &__pyx_type_17clickhouse_driver_14bufferedreader_BufferedSocketReader;
7740 __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader.tp_base = __pyx_ptype_17clickhouse_driver_14bufferedreader_BufferedReader;
7741 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < 0) __PYX_ERR(0, 243, __pyx_L1_error)
7742 #if PY_VERSION_HEX < 0x030800B1
7743 __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader.tp_print = 0;
7744 #endif
7745 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader.tp_getattro == PyObject_GenericGetAttr)) {
7746 __pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader.tp_getattro = __Pyx_PyObject_GenericGetAttr;
7747 }
7748 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CompressedBufferedReader, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < 0) __PYX_ERR(0, 243, __pyx_L1_error)
7749 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader) < 0) __PYX_ERR(0, 243, __pyx_L1_error)
7750 __pyx_ptype_17clickhouse_driver_14bufferedreader_CompressedBufferedReader = &__pyx_type_17clickhouse_driver_14bufferedreader_CompressedBufferedReader;
43917751 __Pyx_RefNannyFinishContext();
43927752 return 0;
7753 __pyx_L1_error:;
7754 __Pyx_RefNannyFinishContext();
7755 return -1;
43937756 }
43947757
43957758 static int __Pyx_modinit_type_import_code(void) {
43967759 __Pyx_RefNannyDeclarations
43977760 PyObject *__pyx_t_1 = NULL;
7761 int __pyx_lineno = 0;
7762 const char *__pyx_filename = NULL;
7763 int __pyx_clineno = 0;
43987764 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
43997765 /*--- Type import code ---*/
4400 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
7766 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
44017767 __Pyx_GOTREF(__pyx_t_1);
44027768 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
44037769 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
44067772 sizeof(PyHeapTypeObject),
44077773 #endif
44087774 __Pyx_ImportType_CheckSize_Warn);
4409 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
7775 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(2, 9, __pyx_L1_error)
44107776 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4411 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
7777 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 8, __pyx_L1_error)
44127778 __Pyx_GOTREF(__pyx_t_1);
44137779 __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
4414 if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(2, 8, __pyx_L1_error)
7780 if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(3, 8, __pyx_L1_error)
44157781 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4416 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
7782 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(4, 15, __pyx_L1_error)
44177783 __Pyx_GOTREF(__pyx_t_1);
44187784 __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
4419 if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(3, 15, __pyx_L1_error)
7785 if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(4, 15, __pyx_L1_error)
44207786 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
44217787 __Pyx_RefNannyFinishContext();
44227788 return 0;
44437809 }
44447810
44457811
4446 #if PY_MAJOR_VERSION < 3
4447 #ifdef CYTHON_NO_PYINIT_EXPORT
7812 #ifndef CYTHON_NO_PYINIT_EXPORT
7813 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
7814 #elif PY_MAJOR_VERSION < 3
7815 #ifdef __cplusplus
7816 #define __Pyx_PyMODINIT_FUNC extern "C" void
7817 #else
44487818 #define __Pyx_PyMODINIT_FUNC void
7819 #endif
44497820 #else
4450 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
4451 #endif
7821 #ifdef __cplusplus
7822 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
44527823 #else
4453 #ifdef CYTHON_NO_PYINIT_EXPORT
44547824 #define __Pyx_PyMODINIT_FUNC PyObject *
4455 #else
4456 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
44577825 #endif
44587826 #endif
44597827
45357903 #endif
45367904 {
45377905 PyObject *__pyx_t_1 = NULL;
4538 PyObject *__pyx_t_2 = NULL;
4539 PyObject *__pyx_t_3 = NULL;
4540 PyObject *__pyx_t_4 = NULL;
7906 int __pyx_lineno = 0;
7907 const char *__pyx_filename = NULL;
7908 int __pyx_clineno = 0;
45417909 __Pyx_RefNannyDeclarations
45427910 #if CYTHON_PEP489_MULTI_PHASE_INIT
45437911 if (__pyx_m) {
46267994 }
46277995 #endif
46287996 /*--- Builtin init code ---*/
4629 if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
7997 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
46307998 /*--- Constants init code ---*/
4631 if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
7999 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
46328000 /*--- Global type/function init code ---*/
46338001 (void)__Pyx_modinit_global_init_code();
46348002 (void)__Pyx_modinit_variable_export_code();
46358003 (void)__Pyx_modinit_function_export_code();
4636 (void)__Pyx_modinit_type_init_code();
4637 if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
8004 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
8005 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
46388006 (void)__Pyx_modinit_variable_import_code();
46398007 (void)__Pyx_modinit_function_import_code();
46408008 /*--- Execution code ---*/
46428010 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
46438011 #endif
46448012
4645 /* "clickhouse_driver/bufferedreader.pyx":19
4646 *
4647 *
4648 * class BufferedReader(object): # <<<<<<<<<<<<<<
4649 * def __init__(self, bufsize):
4650 * self.buffer = bytearray(bufsize)
4651 */
4652 __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_tuple__2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
8013 /* "(tree fragment)":1
8014 * def __pyx_unpickle_BufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
8015 * cdef object __pyx_PickleError
8016 * cdef object __pyx_result
8017 */
8018 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_1__pyx_unpickle_BufferedReader, NULL, __pyx_n_s_clickhouse_driver_bufferedreader); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
46538019 __Pyx_GOTREF(__pyx_t_1);
4654 __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_tuple__2, __pyx_n_s_BufferedReader, __pyx_n_s_BufferedReader, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_bufferedreader, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 19, __pyx_L1_error)
4655 __Pyx_GOTREF(__pyx_t_2);
4656
4657 /* "clickhouse_driver/bufferedreader.pyx":20
4658 *
4659 * class BufferedReader(object):
4660 * def __init__(self, bufsize): # <<<<<<<<<<<<<<
4661 * self.buffer = bytearray(bufsize)
4662 *
4663 */
4664 __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_1__init__, 0, __pyx_n_s_BufferedReader___init, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 20, __pyx_L1_error)
4665 __Pyx_GOTREF(__pyx_t_3);
4666 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_3) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
4667 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4668
4669 /* "clickhouse_driver/bufferedreader.pyx":28
4670 * super(BufferedReader, self).__init__()
4671 *
4672 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4673 * raise NotImplementedError
4674 *
4675 */
4676 __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_3read_into_buffer, 0, __pyx_n_s_BufferedReader_read_into_buffer, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 28, __pyx_L1_error)
4677 __Pyx_GOTREF(__pyx_t_3);
4678 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_read_into_buffer, __pyx_t_3) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
4679 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4680
4681 /* "clickhouse_driver/bufferedreader.pyx":31
4682 * raise NotImplementedError
4683 *
4684 * def read(self, Py_ssize_t unread): # <<<<<<<<<<<<<<
4685 * # When the buffer is large enough bytes read are almost
4686 * # always hit the buffer.
4687 */
4688 __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_5read, 0, __pyx_n_s_BufferedReader_read, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 31, __pyx_L1_error)
4689 __Pyx_GOTREF(__pyx_t_3);
4690 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_read, __pyx_t_3) < 0) __PYX_ERR(0, 31, __pyx_L1_error)
4691 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4692
4693 /* "clickhouse_driver/bufferedreader.pyx":64
4694 * return bytearray(rv)
4695 *
4696 * def read_one(self): # <<<<<<<<<<<<<<
4697 * if self.position == self.current_buffer_size:
4698 * self.read_into_buffer()
4699 */
4700 __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_7read_one, 0, __pyx_n_s_BufferedReader_read_one, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 64, __pyx_L1_error)
4701 __Pyx_GOTREF(__pyx_t_3);
4702 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_read_one, __pyx_t_3) < 0) __PYX_ERR(0, 64, __pyx_L1_error)
4703 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4704
4705 /* "clickhouse_driver/bufferedreader.pyx":73
4706 * return rv
4707 *
4708 * def read_strings(self, Py_ssize_t n_items, int decode=0): # <<<<<<<<<<<<<<
4709 * """
4710 * Python has great overhead between function calls.
4711 */
4712 __pyx_t_3 = __Pyx_PyInt_From_int(((int)0)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
4713 __Pyx_GOTREF(__pyx_t_3);
4714 __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error)
4715 __Pyx_GOTREF(__pyx_t_4);
4716 __Pyx_GIVEREF(__pyx_t_3);
4717 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
4718 __pyx_t_3 = 0;
4719 __pyx_t_3 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_14BufferedReader_9read_strings, 0, __pyx_n_s_BufferedReader_read_strings, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 73, __pyx_L1_error)
4720 __Pyx_GOTREF(__pyx_t_3);
4721 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_3, __pyx_t_4);
4722 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4723 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_read_strings, __pyx_t_3) < 0) __PYX_ERR(0, 73, __pyx_L1_error)
4724 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4725
4726 /* "clickhouse_driver/bufferedreader.pyx":19
4727 *
4728 *
4729 * class BufferedReader(object): # <<<<<<<<<<<<<<
4730 * def __init__(self, bufsize):
4731 * self.buffer = bytearray(bufsize)
4732 */
4733 __pyx_t_3 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_BufferedReader, __pyx_tuple__2, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 19, __pyx_L1_error)
4734 __Pyx_GOTREF(__pyx_t_3);
4735 if (PyDict_SetItem(__pyx_d, __pyx_n_s_BufferedReader, __pyx_t_3) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
4736 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4737 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8020 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_BufferedReader, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
47388021 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
47398022
4740 /* "clickhouse_driver/bufferedreader.pyx":187
4741 *
4742 *
4743 * class BufferedSocketReader(BufferedReader): # <<<<<<<<<<<<<<
4744 * def __init__(self, sock, bufsize):
4745 * self.sock = sock
4746 */
4747 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BufferedReader); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
8023 /* "(tree fragment)":11
8024 * __pyx_unpickle_BufferedReader__set_state(<BufferedReader> __pyx_result, __pyx_state)
8025 * return __pyx_result
8026 * cdef __pyx_unpickle_BufferedReader__set_state(BufferedReader __pyx_result, tuple __pyx_state): # <<<<<<<<<<<<<<
8027 * __pyx_result.buffer = __pyx_state[0]; __pyx_result.current_buffer_size = __pyx_state[1]; __pyx_result.position = __pyx_state[2]
8028 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
8029 */
8030 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_3__pyx_unpickle_BufferedSocketReader, NULL, __pyx_n_s_clickhouse_driver_bufferedreader); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
47488031 __Pyx_GOTREF(__pyx_t_1);
4749 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
4750 __Pyx_GOTREF(__pyx_t_2);
4751 __Pyx_GIVEREF(__pyx_t_1);
4752 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4753 __pyx_t_1 = 0;
4754 __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
8032 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_BufferedSocketRea, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
8033 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8034
8035 /* "(tree fragment)":1
8036 * def __pyx_unpickle_CompressedBufferedReader(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
8037 * cdef object __pyx_PickleError
8038 * cdef object __pyx_result
8039 */
8040 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_5__pyx_unpickle_CompressedBufferedReader, NULL, __pyx_n_s_clickhouse_driver_bufferedreader); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 1, __pyx_L1_error)
47558041 __Pyx_GOTREF(__pyx_t_1);
4756 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_BufferedSocketReader, __pyx_n_s_BufferedSocketReader, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_bufferedreader, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 187, __pyx_L1_error)
4757 __Pyx_GOTREF(__pyx_t_3);
4758
4759 /* "clickhouse_driver/bufferedreader.pyx":188
4760 *
4761 * class BufferedSocketReader(BufferedReader):
4762 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
4763 * self.sock = sock
4764 * super(BufferedSocketReader, self).__init__(bufsize)
4765 */
4766 __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_1__init__, 0, __pyx_n_s_BufferedSocketReader___init, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 188, __pyx_L1_error)
4767 __Pyx_GOTREF(__pyx_t_4);
4768 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 188, __pyx_L1_error)
4769 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4770
4771 /* "clickhouse_driver/bufferedreader.pyx":192
4772 * super(BufferedSocketReader, self).__init__(bufsize)
4773 *
4774 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4775 * self.current_buffer_size = self.sock.recv_into(self.buffer)
4776 *
4777 */
4778 __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_20BufferedSocketReader_3read_into_buffer, 0, __pyx_n_s_BufferedSocketReader_read_into_b, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 192, __pyx_L1_error)
4779 __Pyx_GOTREF(__pyx_t_4);
4780 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_into_buffer, __pyx_t_4) < 0) __PYX_ERR(0, 192, __pyx_L1_error)
4781 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4782
4783 /* "clickhouse_driver/bufferedreader.pyx":187
4784 *
4785 *
4786 * class BufferedSocketReader(BufferedReader): # <<<<<<<<<<<<<<
4787 * def __init__(self, sock, bufsize):
4788 * self.sock = sock
4789 */
4790 __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_BufferedSocketReader, __pyx_t_2, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 187, __pyx_L1_error)
4791 __Pyx_GOTREF(__pyx_t_4);
4792 if (PyDict_SetItem(__pyx_d, __pyx_n_s_BufferedSocketReader, __pyx_t_4) < 0) __PYX_ERR(0, 187, __pyx_L1_error)
4793 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4794 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8042 if (PyDict_SetItem(__pyx_d, __pyx_n_s_pyx_unpickle_CompressedBuffere, __pyx_t_1) < 0) __PYX_ERR(1, 1, __pyx_L1_error)
47958043 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4796 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4797
4798 /* "clickhouse_driver/bufferedreader.pyx":199
4799 *
4800 *
4801 * class CompressedBufferedReader(BufferedReader): # <<<<<<<<<<<<<<
4802 * def __init__(self, read_block, bufsize):
4803 * self.read_block = read_block
4804 */
4805 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BufferedReader); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
4806 __Pyx_GOTREF(__pyx_t_2);
4807 __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error)
4808 __Pyx_GOTREF(__pyx_t_1);
4809 __Pyx_GIVEREF(__pyx_t_2);
4810 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
4811 __pyx_t_2 = 0;
4812 __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 199, __pyx_L1_error)
4813 __Pyx_GOTREF(__pyx_t_2);
4814 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_CompressedBufferedReader, __pyx_n_s_CompressedBufferedReader, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_bufferedreader, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 199, __pyx_L1_error)
4815 __Pyx_GOTREF(__pyx_t_3);
4816
4817 /* "clickhouse_driver/bufferedreader.pyx":200
4818 *
4819 * class CompressedBufferedReader(BufferedReader):
4820 * def __init__(self, read_block, bufsize): # <<<<<<<<<<<<<<
4821 * self.read_block = read_block
4822 * super(CompressedBufferedReader, self).__init__(bufsize)
4823 */
4824 __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_1__init__, 0, __pyx_n_s_CompressedBufferedReader___init, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 200, __pyx_L1_error)
4825 __Pyx_GOTREF(__pyx_t_4);
4826 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) __PYX_ERR(0, 200, __pyx_L1_error)
4827 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4828
4829 /* "clickhouse_driver/bufferedreader.pyx":204
4830 * super(CompressedBufferedReader, self).__init__(bufsize)
4831 *
4832 * def read_into_buffer(self): # <<<<<<<<<<<<<<
4833 * self.buffer = bytearray(self.read_block())
4834 * self.current_buffer_size = len(self.buffer)
4835 */
4836 __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_14bufferedreader_24CompressedBufferedReader_3read_into_buffer, 0, __pyx_n_s_CompressedBufferedReader_read_in, NULL, __pyx_n_s_clickhouse_driver_bufferedreader, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 204, __pyx_L1_error)
4837 __Pyx_GOTREF(__pyx_t_4);
4838 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_into_buffer, __pyx_t_4) < 0) __PYX_ERR(0, 204, __pyx_L1_error)
4839 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4840
4841 /* "clickhouse_driver/bufferedreader.pyx":199
4842 *
4843 *
4844 * class CompressedBufferedReader(BufferedReader): # <<<<<<<<<<<<<<
4845 * def __init__(self, read_block, bufsize):
4846 * self.read_block = read_block
4847 */
4848 __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_CompressedBufferedReader, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 199, __pyx_L1_error)
4849 __Pyx_GOTREF(__pyx_t_4);
4850 if (PyDict_SetItem(__pyx_d, __pyx_n_s_CompressedBufferedReader, __pyx_t_4) < 0) __PYX_ERR(0, 199, __pyx_L1_error)
4851 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4852 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4853 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4854 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
48558044
48568045 /* "clickhouse_driver/bufferedreader.pyx":1
4857 * from cpython cimport Py_INCREF, PyBytes_FromStringAndSize # <<<<<<<<<<<<<<
8046 * from cpython cimport Py_INCREF, PyBytes_FromStringAndSize, PyBytes_AsString # <<<<<<<<<<<<<<
48588047 * from cpython.bytearray cimport PyByteArray_AsString
48598048 * # Using python's versions of pure c memory management functions for
48608049 */
48688057 goto __pyx_L0;
48698058 __pyx_L1_error:;
48708059 __Pyx_XDECREF(__pyx_t_1);
4871 __Pyx_XDECREF(__pyx_t_2);
4872 __Pyx_XDECREF(__pyx_t_3);
4873 __Pyx_XDECREF(__pyx_t_4);
48748060 if (__pyx_m) {
48758061 if (__pyx_d) {
48768062 __Pyx_AddTraceback("init clickhouse_driver.bufferedreader", __pyx_clineno, __pyx_lineno, __pyx_filename);
49348120 #endif
49358121 }
49368122 return result;
4937 }
4938
4939 /* PyErrFetchRestore */
4940 #if CYTHON_FAST_THREAD_STATE
4941 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
4942 PyObject *tmp_type, *tmp_value, *tmp_tb;
4943 tmp_type = tstate->curexc_type;
4944 tmp_value = tstate->curexc_value;
4945 tmp_tb = tstate->curexc_traceback;
4946 tstate->curexc_type = type;
4947 tstate->curexc_value = value;
4948 tstate->curexc_traceback = tb;
4949 Py_XDECREF(tmp_type);
4950 Py_XDECREF(tmp_value);
4951 Py_XDECREF(tmp_tb);
4952 }
4953 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
4954 *type = tstate->curexc_type;
4955 *value = tstate->curexc_value;
4956 *tb = tstate->curexc_traceback;
4957 tstate->curexc_type = 0;
4958 tstate->curexc_value = 0;
4959 tstate->curexc_traceback = 0;
4960 }
4961 #endif
4962
4963 /* WriteUnraisableException */
4964 static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno,
4965 CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename,
4966 int full_traceback, CYTHON_UNUSED int nogil) {
4967 PyObject *old_exc, *old_val, *old_tb;
4968 PyObject *ctx;
4969 __Pyx_PyThreadState_declare
4970 #ifdef WITH_THREAD
4971 PyGILState_STATE state;
4972 if (nogil)
4973 state = PyGILState_Ensure();
4974 #ifdef _MSC_VER
4975 else state = (PyGILState_STATE)-1;
4976 #endif
4977 #endif
4978 __Pyx_PyThreadState_assign
4979 __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
4980 if (full_traceback) {
4981 Py_XINCREF(old_exc);
4982 Py_XINCREF(old_val);
4983 Py_XINCREF(old_tb);
4984 __Pyx_ErrRestore(old_exc, old_val, old_tb);
4985 PyErr_PrintEx(1);
4986 }
4987 #if PY_MAJOR_VERSION < 3
4988 ctx = PyString_FromString(name);
4989 #else
4990 ctx = PyUnicode_FromString(name);
4991 #endif
4992 __Pyx_ErrRestore(old_exc, old_val, old_tb);
4993 if (!ctx) {
4994 PyErr_WriteUnraisable(Py_None);
4995 } else {
4996 PyErr_WriteUnraisable(ctx);
4997 Py_DECREF(ctx);
4998 }
4999 #ifdef WITH_THREAD
5000 if (nogil)
5001 PyGILState_Release(state);
5002 #endif
5003 }
5004
5005 /* RaiseArgTupleInvalid */
5006 static void __Pyx_RaiseArgtupleInvalid(
5007 const char* func_name,
5008 int exact,
5009 Py_ssize_t num_min,
5010 Py_ssize_t num_max,
5011 Py_ssize_t num_found)
5012 {
5013 Py_ssize_t num_expected;
5014 const char *more_or_less;
5015 if (num_found < num_min) {
5016 num_expected = num_min;
5017 more_or_less = "at least";
5018 } else {
5019 num_expected = num_max;
5020 more_or_less = "at most";
5021 }
5022 if (exact) {
5023 more_or_less = "exactly";
5024 }
5025 PyErr_Format(PyExc_TypeError,
5026 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
5027 func_name, more_or_less, num_expected,
5028 (num_expected == 1) ? "" : "s", num_found);
50298123 }
50308124
50318125 /* RaiseDoubleKeywords */
50648158 }
50658159 name = first_kw_arg;
50668160 #if PY_MAJOR_VERSION < 3
5067 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
8161 if (likely(PyString_Check(key))) {
50688162 while (*name) {
50698163 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
50708164 && _PyString_Eq(**name, key)) {
50918185 while (*name) {
50928186 int cmp = (**name == key) ? 0 :
50938187 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5094 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
8188 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
50958189 #endif
50968190 PyUnicode_Compare(**name, key);
50978191 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
51078201 while (argname != first_kw_arg) {
51088202 int cmp = (**argname == key) ? 0 :
51098203 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5110 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
8204 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
51118205 #endif
51128206 PyUnicode_Compare(**argname, key);
51138207 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
51448238 return -1;
51458239 }
51468240
8241 /* RaiseArgTupleInvalid */
8242 static void __Pyx_RaiseArgtupleInvalid(
8243 const char* func_name,
8244 int exact,
8245 Py_ssize_t num_min,
8246 Py_ssize_t num_max,
8247 Py_ssize_t num_found)
8248 {
8249 Py_ssize_t num_expected;
8250 const char *more_or_less;
8251 if (num_found < num_min) {
8252 num_expected = num_min;
8253 more_or_less = "at least";
8254 } else {
8255 num_expected = num_max;
8256 more_or_less = "at most";
8257 }
8258 if (exact) {
8259 more_or_less = "exactly";
8260 }
8261 PyErr_Format(PyExc_TypeError,
8262 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
8263 func_name, more_or_less, num_expected,
8264 (num_expected == 1) ? "" : "s", num_found);
8265 }
8266
51478267 /* PyCFunctionFastCall */
51488268 #if CYTHON_FAST_PYCCALL
51498269 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
53668486 }
53678487 #endif
53688488
5369 /* PyObjectSetAttrStr */
5370 #if CYTHON_USE_TYPE_SLOTS
5371 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
5372 PyTypeObject* tp = Py_TYPE(obj);
5373 if (likely(tp->tp_setattro))
5374 return tp->tp_setattro(obj, attr_name, value);
5375 #if PY_MAJOR_VERSION < 3
5376 if (likely(tp->tp_setattr))
5377 return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
5378 #endif
5379 return PyObject_SetAttr(obj, attr_name, value);
5380 }
5381 #endif
5382
5383 /* PyDictVersioning */
5384 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
5385 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
5386 PyObject *dict = Py_TYPE(obj)->tp_dict;
5387 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
5388 }
5389 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
5390 PyObject **dictptr = NULL;
5391 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
5392 if (offset) {
5393 #if CYTHON_COMPILING_IN_CPYTHON
5394 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
5395 #else
5396 dictptr = _PyObject_GetDictPtr(obj);
5397 #endif
5398 }
5399 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
5400 }
5401 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
5402 PyObject *dict = Py_TYPE(obj)->tp_dict;
5403 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
5404 return 0;
5405 return obj_dict_version == __Pyx_get_object_dict_version(obj);
5406 }
5407 #endif
5408
5409 /* GetModuleGlobalName */
5410 #if CYTHON_USE_DICT_VERSIONS
5411 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
5412 #else
5413 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
5414 #endif
5415 {
5416 PyObject *result;
5417 #if !CYTHON_AVOID_BORROWED_REFS
5418 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
5419 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
5420 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5421 if (likely(result)) {
5422 return __Pyx_NewRef(result);
5423 } else if (unlikely(PyErr_Occurred())) {
5424 return NULL;
5425 }
5426 #else
5427 result = PyDict_GetItem(__pyx_d, name);
5428 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5429 if (likely(result)) {
5430 return __Pyx_NewRef(result);
5431 }
5432 #endif
5433 #else
5434 result = PyObject_GetItem(__pyx_d, name);
5435 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5436 if (likely(result)) {
5437 return __Pyx_NewRef(result);
5438 }
5439 PyErr_Clear();
5440 #endif
5441 return __Pyx_GetBuiltinName(name);
5442 }
5443
54448489 /* PyObjectCallNoArg */
54458490 #if CYTHON_COMPILING_IN_CPYTHON
54468491 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
54608505 }
54618506 }
54628507 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
8508 }
8509 #endif
8510
8511 /* PyErrFetchRestore */
8512 #if CYTHON_FAST_THREAD_STATE
8513 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
8514 PyObject *tmp_type, *tmp_value, *tmp_tb;
8515 tmp_type = tstate->curexc_type;
8516 tmp_value = tstate->curexc_value;
8517 tmp_tb = tstate->curexc_traceback;
8518 tstate->curexc_type = type;
8519 tstate->curexc_value = value;
8520 tstate->curexc_traceback = tb;
8521 Py_XDECREF(tmp_type);
8522 Py_XDECREF(tmp_value);
8523 Py_XDECREF(tmp_tb);
8524 }
8525 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
8526 *type = tstate->curexc_type;
8527 *value = tstate->curexc_value;
8528 *tb = tstate->curexc_traceback;
8529 tstate->curexc_type = 0;
8530 tstate->curexc_value = 0;
8531 tstate->curexc_traceback = 0;
54638532 }
54648533 #endif
54658534
56228691 }
56238692 #endif
56248693
5625 /* SliceObject */
5626 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
5627 Py_ssize_t cstart, Py_ssize_t cstop,
5628 PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
5629 int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
8694 /* GetItemIntByteArray */
8695 static CYTHON_INLINE int __Pyx_GetItemInt_ByteArray_Fast(PyObject* string, Py_ssize_t i,
8696 int wraparound, int boundscheck) {
8697 Py_ssize_t length;
8698 if (wraparound | boundscheck) {
8699 length = PyByteArray_GET_SIZE(string);
8700 if (wraparound & unlikely(i < 0)) i += length;
8701 if ((!boundscheck) || likely(__Pyx_is_valid_index(i, length))) {
8702 return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
8703 } else {
8704 PyErr_SetString(PyExc_IndexError, "bytearray index out of range");
8705 return -1;
8706 }
8707 } else {
8708 return (unsigned char) (PyByteArray_AS_STRING(string)[i]);
8709 }
8710 }
8711
8712 /* PyObjectCall2Args */
8713 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
8714 PyObject *args, *result = NULL;
8715 #if CYTHON_FAST_PYCALL
8716 if (PyFunction_Check(function)) {
8717 PyObject *args[2] = {arg1, arg2};
8718 return __Pyx_PyFunction_FastCall(function, args, 2);
8719 }
8720 #endif
8721 #if CYTHON_FAST_PYCCALL
8722 if (__Pyx_PyFastCFunction_Check(function)) {
8723 PyObject *args[2] = {arg1, arg2};
8724 return __Pyx_PyCFunction_FastCall(function, args, 2);
8725 }
8726 #endif
8727 args = PyTuple_New(2);
8728 if (unlikely(!args)) goto done;
8729 Py_INCREF(arg1);
8730 PyTuple_SET_ITEM(args, 0, arg1);
8731 Py_INCREF(arg2);
8732 PyTuple_SET_ITEM(args, 1, arg2);
8733 Py_INCREF(function);
8734 result = __Pyx_PyObject_Call(function, args, NULL);
8735 Py_DECREF(args);
8736 Py_DECREF(function);
8737 done:
8738 return result;
8739 }
8740
8741 /* decode_c_string */
8742 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
8743 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
8744 const char* encoding, const char* errors,
8745 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
8746 Py_ssize_t length;
8747 if (unlikely((start < 0) | (stop < 0))) {
8748 size_t slen = strlen(cstring);
8749 if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
8750 PyErr_SetString(PyExc_OverflowError,
8751 "c-string too long to convert to Python");
8752 return NULL;
8753 }
8754 length = (Py_ssize_t) slen;
8755 if (start < 0) {
8756 start += length;
8757 if (start < 0)
8758 start = 0;
8759 }
8760 if (stop < 0)
8761 stop += length;
8762 }
8763 if (unlikely(stop <= start))
8764 return __Pyx_NewRef(__pyx_empty_unicode);
8765 length = stop - start;
8766 cstring += start;
8767 if (decode_func) {
8768 return decode_func(cstring, length, errors);
8769 } else {
8770 return PyUnicode_Decode(cstring, length, encoding, errors);
8771 }
8772 }
8773
8774 /* GetTopmostException */
8775 #if CYTHON_USE_EXC_INFO_STACK
8776 static _PyErr_StackItem *
8777 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
8778 {
8779 _PyErr_StackItem *exc_info = tstate->exc_info;
8780 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
8781 exc_info->previous_item != NULL)
8782 {
8783 exc_info = exc_info->previous_item;
8784 }
8785 return exc_info;
8786 }
8787 #endif
8788
8789 /* SaveResetException */
8790 #if CYTHON_FAST_THREAD_STATE
8791 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
8792 #if CYTHON_USE_EXC_INFO_STACK
8793 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
8794 *type = exc_info->exc_type;
8795 *value = exc_info->exc_value;
8796 *tb = exc_info->exc_traceback;
8797 #else
8798 *type = tstate->exc_type;
8799 *value = tstate->exc_value;
8800 *tb = tstate->exc_traceback;
8801 #endif
8802 Py_XINCREF(*type);
8803 Py_XINCREF(*value);
8804 Py_XINCREF(*tb);
8805 }
8806 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
8807 PyObject *tmp_type, *tmp_value, *tmp_tb;
8808 #if CYTHON_USE_EXC_INFO_STACK
8809 _PyErr_StackItem *exc_info = tstate->exc_info;
8810 tmp_type = exc_info->exc_type;
8811 tmp_value = exc_info->exc_value;
8812 tmp_tb = exc_info->exc_traceback;
8813 exc_info->exc_type = type;
8814 exc_info->exc_value = value;
8815 exc_info->exc_traceback = tb;
8816 #else
8817 tmp_type = tstate->exc_type;
8818 tmp_value = tstate->exc_value;
8819 tmp_tb = tstate->exc_traceback;
8820 tstate->exc_type = type;
8821 tstate->exc_value = value;
8822 tstate->exc_traceback = tb;
8823 #endif
8824 Py_XDECREF(tmp_type);
8825 Py_XDECREF(tmp_value);
8826 Py_XDECREF(tmp_tb);
8827 }
8828 #endif
8829
8830 /* PyErrExceptionMatches */
8831 #if CYTHON_FAST_THREAD_STATE
8832 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
8833 Py_ssize_t i, n;
8834 n = PyTuple_GET_SIZE(tuple);
8835 #if PY_MAJOR_VERSION >= 3
8836 for (i=0; i<n; i++) {
8837 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
8838 }
8839 #endif
8840 for (i=0; i<n; i++) {
8841 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
8842 }
8843 return 0;
8844 }
8845 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
8846 PyObject *exc_type = tstate->curexc_type;
8847 if (exc_type == err) return 1;
8848 if (unlikely(!exc_type)) return 0;
8849 if (unlikely(PyTuple_Check(err)))
8850 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
8851 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
8852 }
8853 #endif
8854
8855 /* GetException */
8856 #if CYTHON_FAST_THREAD_STATE
8857 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
8858 #else
8859 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
8860 #endif
8861 {
8862 PyObject *local_type, *local_value, *local_tb;
8863 #if CYTHON_FAST_THREAD_STATE
8864 PyObject *tmp_type, *tmp_value, *tmp_tb;
8865 local_type = tstate->curexc_type;
8866 local_value = tstate->curexc_value;
8867 local_tb = tstate->curexc_traceback;
8868 tstate->curexc_type = 0;
8869 tstate->curexc_value = 0;
8870 tstate->curexc_traceback = 0;
8871 #else
8872 PyErr_Fetch(&local_type, &local_value, &local_tb);
8873 #endif
8874 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
8875 #if CYTHON_FAST_THREAD_STATE
8876 if (unlikely(tstate->curexc_type))
8877 #else
8878 if (unlikely(PyErr_Occurred()))
8879 #endif
8880 goto bad;
8881 #if PY_MAJOR_VERSION >= 3
8882 if (local_tb) {
8883 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
8884 goto bad;
8885 }
8886 #endif
8887 Py_XINCREF(local_tb);
8888 Py_XINCREF(local_type);
8889 Py_XINCREF(local_value);
8890 *type = local_type;
8891 *value = local_value;
8892 *tb = local_tb;
8893 #if CYTHON_FAST_THREAD_STATE
8894 #if CYTHON_USE_EXC_INFO_STACK
8895 {
8896 _PyErr_StackItem *exc_info = tstate->exc_info;
8897 tmp_type = exc_info->exc_type;
8898 tmp_value = exc_info->exc_value;
8899 tmp_tb = exc_info->exc_traceback;
8900 exc_info->exc_type = local_type;
8901 exc_info->exc_value = local_value;
8902 exc_info->exc_traceback = local_tb;
8903 }
8904 #else
8905 tmp_type = tstate->exc_type;
8906 tmp_value = tstate->exc_value;
8907 tmp_tb = tstate->exc_traceback;
8908 tstate->exc_type = local_type;
8909 tstate->exc_value = local_value;
8910 tstate->exc_traceback = local_tb;
8911 #endif
8912 Py_XDECREF(tmp_type);
8913 Py_XDECREF(tmp_value);
8914 Py_XDECREF(tmp_tb);
8915 #else
8916 PyErr_SetExcInfo(local_type, local_value, local_tb);
8917 #endif
8918 return 0;
8919 bad:
8920 *type = 0;
8921 *value = 0;
8922 *tb = 0;
8923 Py_XDECREF(local_type);
8924 Py_XDECREF(local_value);
8925 Py_XDECREF(local_tb);
8926 return -1;
8927 }
8928
8929 /* GetAttr */
8930 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
56308931 #if CYTHON_USE_TYPE_SLOTS
5631 PyMappingMethods* mp;
5632 #if PY_MAJOR_VERSION < 3
5633 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
5634 if (likely(ms && ms->sq_slice)) {
5635 if (!has_cstart) {
5636 if (_py_start && (*_py_start != Py_None)) {
5637 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
5638 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
5639 } else
5640 cstart = 0;
8932 #if PY_MAJOR_VERSION >= 3
8933 if (likely(PyUnicode_Check(n)))
8934 #else
8935 if (likely(PyString_Check(n)))
8936 #endif
8937 return __Pyx_PyObject_GetAttrStr(o, n);
8938 #endif
8939 return PyObject_GetAttr(o, n);
8940 }
8941
8942 /* GetAttr3 */
8943 static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
8944 __Pyx_PyThreadState_declare
8945 __Pyx_PyThreadState_assign
8946 if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
8947 return NULL;
8948 __Pyx_PyErr_Clear();
8949 Py_INCREF(d);
8950 return d;
8951 }
8952 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
8953 PyObject *r = __Pyx_GetAttr(o, n);
8954 return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
8955 }
8956
8957 /* PyDictVersioning */
8958 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
8959 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
8960 PyObject *dict = Py_TYPE(obj)->tp_dict;
8961 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
8962 }
8963 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
8964 PyObject **dictptr = NULL;
8965 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
8966 if (offset) {
8967 #if CYTHON_COMPILING_IN_CPYTHON
8968 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
8969 #else
8970 dictptr = _PyObject_GetDictPtr(obj);
8971 #endif
8972 }
8973 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
8974 }
8975 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
8976 PyObject *dict = Py_TYPE(obj)->tp_dict;
8977 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
8978 return 0;
8979 return obj_dict_version == __Pyx_get_object_dict_version(obj);
8980 }
8981 #endif
8982
8983 /* GetModuleGlobalName */
8984 #if CYTHON_USE_DICT_VERSIONS
8985 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
8986 #else
8987 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
8988 #endif
8989 {
8990 PyObject *result;
8991 #if !CYTHON_AVOID_BORROWED_REFS
8992 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
8993 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
8994 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
8995 if (likely(result)) {
8996 return __Pyx_NewRef(result);
8997 } else if (unlikely(PyErr_Occurred())) {
8998 return NULL;
8999 }
9000 #else
9001 result = PyDict_GetItem(__pyx_d, name);
9002 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
9003 if (likely(result)) {
9004 return __Pyx_NewRef(result);
9005 }
9006 #endif
9007 #else
9008 result = PyObject_GetItem(__pyx_d, name);
9009 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
9010 if (likely(result)) {
9011 return __Pyx_NewRef(result);
9012 }
9013 PyErr_Clear();
9014 #endif
9015 return __Pyx_GetBuiltinName(name);
9016 }
9017
9018 /* Import */
9019 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
9020 PyObject *empty_list = 0;
9021 PyObject *module = 0;
9022 PyObject *global_dict = 0;
9023 PyObject *empty_dict = 0;
9024 PyObject *list;
9025 #if PY_MAJOR_VERSION < 3
9026 PyObject *py_import;
9027 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
9028 if (!py_import)
9029 goto bad;
9030 #endif
9031 if (from_list)
9032 list = from_list;
9033 else {
9034 empty_list = PyList_New(0);
9035 if (!empty_list)
9036 goto bad;
9037 list = empty_list;
9038 }
9039 global_dict = PyModule_GetDict(__pyx_m);
9040 if (!global_dict)
9041 goto bad;
9042 empty_dict = PyDict_New();
9043 if (!empty_dict)
9044 goto bad;
9045 {
9046 #if PY_MAJOR_VERSION >= 3
9047 if (level == -1) {
9048 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
9049 module = PyImport_ImportModuleLevelObject(
9050 name, global_dict, empty_dict, list, 1);
9051 if (!module) {
9052 if (!PyErr_ExceptionMatches(PyExc_ImportError))
9053 goto bad;
9054 PyErr_Clear();
9055 }
9056 }
9057 level = 0;
56419058 }
5642 if (!has_cstop) {
5643 if (_py_stop && (*_py_stop != Py_None)) {
5644 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
5645 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
5646 } else
5647 cstop = PY_SSIZE_T_MAX;
9059 #endif
9060 if (!module) {
9061 #if PY_MAJOR_VERSION < 3
9062 PyObject *py_level = PyInt_FromLong(level);
9063 if (!py_level)
9064 goto bad;
9065 module = PyObject_CallFunctionObjArgs(py_import,
9066 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
9067 Py_DECREF(py_level);
9068 #else
9069 module = PyImport_ImportModuleLevelObject(
9070 name, global_dict, empty_dict, list, level);
9071 #endif
56489072 }
5649 if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
5650 Py_ssize_t l = ms->sq_length(obj);
5651 if (likely(l >= 0)) {
5652 if (cstop < 0) {
5653 cstop += l;
5654 if (cstop < 0) cstop = 0;
5655 }
5656 if (cstart < 0) {
5657 cstart += l;
5658 if (cstart < 0) cstart = 0;
5659 }
5660 } else {
5661 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
5662 goto bad;
5663 PyErr_Clear();
5664 }
5665 }
5666 return ms->sq_slice(obj, cstart, cstop);
5667 }
5668 #endif
5669 mp = Py_TYPE(obj)->tp_as_mapping;
5670 if (likely(mp && mp->mp_subscript))
5671 #endif
5672 {
5673 PyObject* result;
5674 PyObject *py_slice, *py_start, *py_stop;
5675 if (_py_slice) {
5676 py_slice = *_py_slice;
5677 } else {
5678 PyObject* owned_start = NULL;
5679 PyObject* owned_stop = NULL;
5680 if (_py_start) {
5681 py_start = *_py_start;
5682 } else {
5683 if (has_cstart) {
5684 owned_start = py_start = PyInt_FromSsize_t(cstart);
5685 if (unlikely(!py_start)) goto bad;
5686 } else
5687 py_start = Py_None;
5688 }
5689 if (_py_stop) {
5690 py_stop = *_py_stop;
5691 } else {
5692 if (has_cstop) {
5693 owned_stop = py_stop = PyInt_FromSsize_t(cstop);
5694 if (unlikely(!py_stop)) {
5695 Py_XDECREF(owned_start);
5696 goto bad;
5697 }
5698 } else
5699 py_stop = Py_None;
5700 }
5701 py_slice = PySlice_New(py_start, py_stop, Py_None);
5702 Py_XDECREF(owned_start);
5703 Py_XDECREF(owned_stop);
5704 if (unlikely(!py_slice)) goto bad;
5705 }
5706 #if CYTHON_USE_TYPE_SLOTS
5707 result = mp->mp_subscript(obj, py_slice);
5708 #else
5709 result = PyObject_GetItem(obj, py_slice);
5710 #endif
5711 if (!_py_slice) {
5712 Py_DECREF(py_slice);
5713 }
5714 return result;
5715 }
5716 PyErr_Format(PyExc_TypeError,
5717 "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
9073 }
57189074 bad:
5719 return NULL;
9075 #if PY_MAJOR_VERSION < 3
9076 Py_XDECREF(py_import);
9077 #endif
9078 Py_XDECREF(empty_list);
9079 Py_XDECREF(empty_dict);
9080 return module;
9081 }
9082
9083 /* ImportFrom */
9084 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
9085 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
9086 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
9087 PyErr_Format(PyExc_ImportError,
9088 #if PY_MAJOR_VERSION < 3
9089 "cannot import name %.230s", PyString_AS_STRING(name));
9090 #else
9091 "cannot import name %S", name);
9092 #endif
9093 }
9094 return value;
57209095 }
57219096
57229097 /* GetItemInt */
58069181 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
58079182 }
58089183
5809 /* ObjectGetItem */
5810 #if CYTHON_USE_TYPE_SLOTS
5811 static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
5812 PyObject *runerr;
5813 Py_ssize_t key_value;
5814 PySequenceMethods *m = Py_TYPE(obj)->tp_as_sequence;
5815 if (unlikely(!(m && m->sq_item))) {
5816 PyErr_Format(PyExc_TypeError, "'%.200s' object is not subscriptable", Py_TYPE(obj)->tp_name);
5817 return NULL;
5818 }
5819 key_value = __Pyx_PyIndex_AsSsize_t(index);
5820 if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
5821 return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1);
5822 }
5823 if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
9184 /* HasAttr */
9185 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
9186 PyObject *r;
9187 if (unlikely(!__Pyx_PyBaseString_Check(n))) {
9188 PyErr_SetString(PyExc_TypeError,
9189 "hasattr(): attribute name must be string");
9190 return -1;
9191 }
9192 r = __Pyx_GetAttr(o, n);
9193 if (unlikely(!r)) {
58249194 PyErr_Clear();
5825 PyErr_Format(PyExc_IndexError, "cannot fit '%.200s' into an index-sized integer", Py_TYPE(index)->tp_name);
5826 }
9195 return 0;
9196 } else {
9197 Py_DECREF(r);
9198 return 1;
9199 }
9200 }
9201
9202 /* CallNextTpTraverse */
9203 static int __Pyx_call_next_tp_traverse(PyObject* obj, visitproc v, void *a, traverseproc current_tp_traverse) {
9204 PyTypeObject* type = Py_TYPE(obj);
9205 while (type && type->tp_traverse != current_tp_traverse)
9206 type = type->tp_base;
9207 while (type && type->tp_traverse == current_tp_traverse)
9208 type = type->tp_base;
9209 if (type && type->tp_traverse)
9210 return type->tp_traverse(obj, v, a);
9211 return 0;
9212 }
9213
9214 /* CallNextTpClear */
9215 static void __Pyx_call_next_tp_clear(PyObject* obj, inquiry current_tp_clear) {
9216 PyTypeObject* type = Py_TYPE(obj);
9217 while (type && type->tp_clear != current_tp_clear)
9218 type = type->tp_base;
9219 while (type && type->tp_clear == current_tp_clear)
9220 type = type->tp_base;
9221 if (type && type->tp_clear)
9222 type->tp_clear(obj);
9223 }
9224
9225 /* PyObject_GenericGetAttrNoDict */
9226 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
9227 static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, PyObject *attr_name) {
9228 PyErr_Format(PyExc_AttributeError,
9229 #if PY_MAJOR_VERSION >= 3
9230 "'%.50s' object has no attribute '%U'",
9231 tp->tp_name, attr_name);
9232 #else
9233 "'%.50s' object has no attribute '%.400s'",
9234 tp->tp_name, PyString_AS_STRING(attr_name));
9235 #endif
58279236 return NULL;
58289237 }
5829 static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
5830 PyMappingMethods *m = Py_TYPE(obj)->tp_as_mapping;
5831 if (likely(m && m->mp_subscript)) {
5832 return m->mp_subscript(obj, key);
5833 }
5834 return __Pyx_PyObject_GetIndex(obj, key);
5835 }
5836 #endif
5837
5838 /* PyIntBinop */
5839 #if !CYTHON_COMPILING_IN_PYPY
5840 static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, int inplace, int zerodivision_check) {
5841 (void)inplace;
5842 (void)zerodivision_check;
9238 static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObject* obj, PyObject* attr_name) {
9239 PyObject *descr;
9240 PyTypeObject *tp = Py_TYPE(obj);
9241 if (unlikely(!PyString_Check(attr_name))) {
9242 return PyObject_GenericGetAttr(obj, attr_name);
9243 }
9244 assert(!tp->tp_dictoffset);
9245 descr = _PyType_Lookup(tp, attr_name);
9246 if (unlikely(!descr)) {
9247 return __Pyx_RaiseGenericGetAttributeError(tp, attr_name);
9248 }
9249 Py_INCREF(descr);
58439250 #if PY_MAJOR_VERSION < 3
5844 if (likely(PyInt_CheckExact(op1))) {
5845 const long b = intval;
5846 long x;
5847 long a = PyInt_AS_LONG(op1);
5848 x = (long)((unsigned long)a + b);
5849 if (likely((x^a) >= 0 || (x^b) >= 0))
5850 return PyInt_FromLong(x);
5851 return PyLong_Type.tp_as_number->nb_add(op1, op2);
5852 }
9251 if (likely(PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_HAVE_CLASS)))
58539252 #endif
5854 #if CYTHON_USE_PYLONG_INTERNALS
5855 if (likely(PyLong_CheckExact(op1))) {
5856 const long b = intval;
5857 long a, x;
5858 #ifdef HAVE_LONG_LONG
5859 const PY_LONG_LONG llb = intval;
5860 PY_LONG_LONG lla, llx;
5861 #endif
5862 const digit* digits = ((PyLongObject*)op1)->ob_digit;
5863 const Py_ssize_t size = Py_SIZE(op1);
5864 if (likely(__Pyx_sst_abs(size) <= 1)) {
5865 a = likely(size) ? digits[0] : 0;
5866 if (size == -1) a = -a;
5867 } else {
5868 switch (size) {
5869 case -2:
5870 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5871 a = -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5872 break;
5873 #ifdef HAVE_LONG_LONG
5874 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
5875 lla = -(PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5876 goto long_long;
5877 #endif
5878 }
5879 CYTHON_FALLTHROUGH;
5880 case 2:
5881 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
5882 a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5883 break;
5884 #ifdef HAVE_LONG_LONG
5885 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
5886 lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5887 goto long_long;
5888 #endif
5889 }
5890 CYTHON_FALLTHROUGH;
5891 case -3:
5892 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5893 a = -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5894 break;
5895 #ifdef HAVE_LONG_LONG
5896 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
5897 lla = -(PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5898 goto long_long;
5899 #endif
5900 }
5901 CYTHON_FALLTHROUGH;
5902 case 3:
5903 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
5904 a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5905 break;
5906 #ifdef HAVE_LONG_LONG
5907 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
5908 lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5909 goto long_long;
5910 #endif
5911 }
5912 CYTHON_FALLTHROUGH;
5913 case -4:
5914 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5915 a = -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5916 break;
5917 #ifdef HAVE_LONG_LONG
5918 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
5919 lla = -(PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5920 goto long_long;
5921 #endif
5922 }
5923 CYTHON_FALLTHROUGH;
5924 case 4:
5925 if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
5926 a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
5927 break;
5928 #ifdef HAVE_LONG_LONG
5929 } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
5930 lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
5931 goto long_long;
5932 #endif
5933 }
5934 CYTHON_FALLTHROUGH;
5935 default: return PyLong_Type.tp_as_number->nb_add(op1, op2);
9253 {
9254 descrgetfunc f = Py_TYPE(descr)->tp_descr_get;
9255 if (unlikely(f)) {
9256 PyObject *res = f(descr, obj, (PyObject *)tp);
9257 Py_DECREF(descr);
9258 return res;
9259 }
9260 }
9261 return descr;
9262 }
9263 #endif
9264
9265 /* PyObject_GenericGetAttr */
9266 #if CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP && PY_VERSION_HEX < 0x03070000
9267 static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* attr_name) {
9268 if (unlikely(Py_TYPE(obj)->tp_dictoffset)) {
9269 return PyObject_GenericGetAttr(obj, attr_name);
9270 }
9271 return __Pyx_PyObject_GenericGetAttrNoDict(obj, attr_name);
9272 }
9273 #endif
9274
9275 /* PyObjectGetAttrStrNoError */
9276 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
9277 __Pyx_PyThreadState_declare
9278 __Pyx_PyThreadState_assign
9279 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
9280 __Pyx_PyErr_Clear();
9281 }
9282 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
9283 PyObject *result;
9284 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
9285 PyTypeObject* tp = Py_TYPE(obj);
9286 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
9287 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
9288 }
9289 #endif
9290 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
9291 if (unlikely(!result)) {
9292 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
9293 }
9294 return result;
9295 }
9296
9297 /* SetupReduce */
9298 static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
9299 int ret;
9300 PyObject *name_attr;
9301 name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_name);
9302 if (likely(name_attr)) {
9303 ret = PyObject_RichCompareBool(name_attr, name, Py_EQ);
9304 } else {
9305 ret = -1;
9306 }
9307 if (unlikely(ret < 0)) {
9308 PyErr_Clear();
9309 ret = 0;
9310 }
9311 Py_XDECREF(name_attr);
9312 return ret;
9313 }
9314 static int __Pyx_setup_reduce(PyObject* type_obj) {
9315 int ret = 0;
9316 PyObject *object_reduce = NULL;
9317 PyObject *object_reduce_ex = NULL;
9318 PyObject *reduce = NULL;
9319 PyObject *reduce_ex = NULL;
9320 PyObject *reduce_cython = NULL;
9321 PyObject *setstate = NULL;
9322 PyObject *setstate_cython = NULL;
9323 #if CYTHON_USE_PYTYPE_LOOKUP
9324 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
9325 #else
9326 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
9327 #endif
9328 #if CYTHON_USE_PYTYPE_LOOKUP
9329 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
9330 #else
9331 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
9332 #endif
9333 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
9334 if (reduce_ex == object_reduce_ex) {
9335 #if CYTHON_USE_PYTYPE_LOOKUP
9336 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
9337 #else
9338 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
9339 #endif
9340 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
9341 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
9342 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
9343 if (likely(reduce_cython)) {
9344 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
9345 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
9346 } else if (reduce == object_reduce || PyErr_Occurred()) {
9347 goto __PYX_BAD;
59369348 }
9349 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
9350 if (!setstate) PyErr_Clear();
9351 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
9352 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
9353 if (likely(setstate_cython)) {
9354 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
9355 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
9356 } else if (!setstate || PyErr_Occurred()) {
9357 goto __PYX_BAD;
9358 }
9359 }
9360 PyType_Modified((PyTypeObject*)type_obj);
59379361 }
5938 x = a + b;
5939 return PyLong_FromLong(x);
5940 #ifdef HAVE_LONG_LONG
5941 long_long:
5942 llx = lla + llb;
5943 return PyLong_FromLongLong(llx);
5944 #endif
5945
5946
5947 }
5948 #endif
5949 if (PyFloat_CheckExact(op1)) {
5950 const long b = intval;
5951 double a = PyFloat_AS_DOUBLE(op1);
5952 double result;
5953 PyFPE_START_PROTECT("add", return NULL)
5954 result = ((double)a) + (double)b;
5955 PyFPE_END_PROTECT(result)
5956 return PyFloat_FromDouble(result);
5957 }
5958 return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
5959 }
5960 #endif
5961
5962 /* None */
5963 static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
5964 PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
5965 }
5966
5967 /* decode_c_string */
5968 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
5969 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
5970 const char* encoding, const char* errors,
5971 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
5972 Py_ssize_t length;
5973 if (unlikely((start < 0) | (stop < 0))) {
5974 size_t slen = strlen(cstring);
5975 if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
5976 PyErr_SetString(PyExc_OverflowError,
5977 "c-string too long to convert to Python");
5978 return NULL;
5979 }
5980 length = (Py_ssize_t) slen;
5981 if (start < 0) {
5982 start += length;
5983 if (start < 0)
5984 start = 0;
5985 }
5986 if (stop < 0)
5987 stop += length;
5988 }
5989 length = stop - start;
5990 if (unlikely(length <= 0))
5991 return PyUnicode_FromUnicode(NULL, 0);
5992 cstring += start;
5993 if (decode_func) {
5994 return decode_func(cstring, length, errors);
5995 } else {
5996 return PyUnicode_Decode(cstring, length, encoding, errors);
5997 }
5998 }
5999
6000 /* GetTopmostException */
6001 #if CYTHON_USE_EXC_INFO_STACK
6002 static _PyErr_StackItem *
6003 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
6004 {
6005 _PyErr_StackItem *exc_info = tstate->exc_info;
6006 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
6007 exc_info->previous_item != NULL)
6008 {
6009 exc_info = exc_info->previous_item;
6010 }
6011 return exc_info;
6012 }
6013 #endif
6014
6015 /* SaveResetException */
6016 #if CYTHON_FAST_THREAD_STATE
6017 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
6018 #if CYTHON_USE_EXC_INFO_STACK
6019 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
6020 *type = exc_info->exc_type;
6021 *value = exc_info->exc_value;
6022 *tb = exc_info->exc_traceback;
6023 #else
6024 *type = tstate->exc_type;
6025 *value = tstate->exc_value;
6026 *tb = tstate->exc_traceback;
6027 #endif
6028 Py_XINCREF(*type);
6029 Py_XINCREF(*value);
6030 Py_XINCREF(*tb);
6031 }
6032 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
6033 PyObject *tmp_type, *tmp_value, *tmp_tb;
6034 #if CYTHON_USE_EXC_INFO_STACK
6035 _PyErr_StackItem *exc_info = tstate->exc_info;
6036 tmp_type = exc_info->exc_type;
6037 tmp_value = exc_info->exc_value;
6038 tmp_tb = exc_info->exc_traceback;
6039 exc_info->exc_type = type;
6040 exc_info->exc_value = value;
6041 exc_info->exc_traceback = tb;
6042 #else
6043 tmp_type = tstate->exc_type;
6044 tmp_value = tstate->exc_value;
6045 tmp_tb = tstate->exc_traceback;
6046 tstate->exc_type = type;
6047 tstate->exc_value = value;
6048 tstate->exc_traceback = tb;
6049 #endif
6050 Py_XDECREF(tmp_type);
6051 Py_XDECREF(tmp_value);
6052 Py_XDECREF(tmp_tb);
6053 }
6054 #endif
6055
6056 /* PyErrExceptionMatches */
6057 #if CYTHON_FAST_THREAD_STATE
6058 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
6059 Py_ssize_t i, n;
6060 n = PyTuple_GET_SIZE(tuple);
6061 #if PY_MAJOR_VERSION >= 3
6062 for (i=0; i<n; i++) {
6063 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
6064 }
6065 #endif
6066 for (i=0; i<n; i++) {
6067 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
6068 }
6069 return 0;
6070 }
6071 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
6072 PyObject *exc_type = tstate->curexc_type;
6073 if (exc_type == err) return 1;
6074 if (unlikely(!exc_type)) return 0;
6075 if (unlikely(PyTuple_Check(err)))
6076 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
6077 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
6078 }
6079 #endif
6080
6081 /* GetException */
6082 #if CYTHON_FAST_THREAD_STATE
6083 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
6084 #else
6085 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
6086 #endif
6087 {
6088 PyObject *local_type, *local_value, *local_tb;
6089 #if CYTHON_FAST_THREAD_STATE
6090 PyObject *tmp_type, *tmp_value, *tmp_tb;
6091 local_type = tstate->curexc_type;
6092 local_value = tstate->curexc_value;
6093 local_tb = tstate->curexc_traceback;
6094 tstate->curexc_type = 0;
6095 tstate->curexc_value = 0;
6096 tstate->curexc_traceback = 0;
6097 #else
6098 PyErr_Fetch(&local_type, &local_value, &local_tb);
6099 #endif
6100 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
6101 #if CYTHON_FAST_THREAD_STATE
6102 if (unlikely(tstate->curexc_type))
6103 #else
6104 if (unlikely(PyErr_Occurred()))
6105 #endif
6106 goto bad;
6107 #if PY_MAJOR_VERSION >= 3
6108 if (local_tb) {
6109 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
6110 goto bad;
6111 }
6112 #endif
6113 Py_XINCREF(local_tb);
6114 Py_XINCREF(local_type);
6115 Py_XINCREF(local_value);
6116 *type = local_type;
6117 *value = local_value;
6118 *tb = local_tb;
6119 #if CYTHON_FAST_THREAD_STATE
6120 #if CYTHON_USE_EXC_INFO_STACK
6121 {
6122 _PyErr_StackItem *exc_info = tstate->exc_info;
6123 tmp_type = exc_info->exc_type;
6124 tmp_value = exc_info->exc_value;
6125 tmp_tb = exc_info->exc_traceback;
6126 exc_info->exc_type = local_type;
6127 exc_info->exc_value = local_value;
6128 exc_info->exc_traceback = local_tb;
6129 }
6130 #else
6131 tmp_type = tstate->exc_type;
6132 tmp_value = tstate->exc_value;
6133 tmp_tb = tstate->exc_traceback;
6134 tstate->exc_type = local_type;
6135 tstate->exc_value = local_value;
6136 tstate->exc_traceback = local_tb;
6137 #endif
6138 Py_XDECREF(tmp_type);
6139 Py_XDECREF(tmp_value);
6140 Py_XDECREF(tmp_tb);
6141 #else
6142 PyErr_SetExcInfo(local_type, local_value, local_tb);
6143 #endif
6144 return 0;
6145 bad:
6146 *type = 0;
6147 *value = 0;
6148 *tb = 0;
6149 Py_XDECREF(local_type);
6150 Py_XDECREF(local_value);
6151 Py_XDECREF(local_tb);
6152 return -1;
6153 }
6154
6155 /* PyObjectCall2Args */
6156 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
6157 PyObject *args, *result = NULL;
6158 #if CYTHON_FAST_PYCALL
6159 if (PyFunction_Check(function)) {
6160 PyObject *args[2] = {arg1, arg2};
6161 return __Pyx_PyFunction_FastCall(function, args, 2);
6162 }
6163 #endif
6164 #if CYTHON_FAST_PYCCALL
6165 if (__Pyx_PyFastCFunction_Check(function)) {
6166 PyObject *args[2] = {arg1, arg2};
6167 return __Pyx_PyCFunction_FastCall(function, args, 2);
6168 }
6169 #endif
6170 args = PyTuple_New(2);
6171 if (unlikely(!args)) goto done;
6172 Py_INCREF(arg1);
6173 PyTuple_SET_ITEM(args, 0, arg1);
6174 Py_INCREF(arg2);
6175 PyTuple_SET_ITEM(args, 1, arg2);
6176 Py_INCREF(function);
6177 result = __Pyx_PyObject_Call(function, args, NULL);
6178 Py_DECREF(args);
6179 Py_DECREF(function);
6180 done:
6181 return result;
6182 }
6183
6184 /* PyIntCompare */
6185 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
6186 if (op1 == op2) {
6187 Py_RETURN_TRUE;
6188 }
6189 #if PY_MAJOR_VERSION < 3
6190 if (likely(PyInt_CheckExact(op1))) {
6191 const long b = intval;
6192 long a = PyInt_AS_LONG(op1);
6193 if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
6194 }
6195 #endif
6196 #if CYTHON_USE_PYLONG_INTERNALS
6197 if (likely(PyLong_CheckExact(op1))) {
6198 int unequal;
6199 unsigned long uintval;
6200 Py_ssize_t size = Py_SIZE(op1);
6201 const digit* digits = ((PyLongObject*)op1)->ob_digit;
6202 if (intval == 0) {
6203 if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
6204 } else if (intval < 0) {
6205 if (size >= 0)
6206 Py_RETURN_FALSE;
6207 intval = -intval;
6208 size = -size;
6209 } else {
6210 if (size <= 0)
6211 Py_RETURN_FALSE;
6212 }
6213 uintval = (unsigned long) intval;
6214 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
6215 if (uintval >> (PyLong_SHIFT * 4)) {
6216 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
6217 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
6218 } else
6219 #endif
6220 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
6221 if (uintval >> (PyLong_SHIFT * 3)) {
6222 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
6223 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
6224 } else
6225 #endif
6226 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
6227 if (uintval >> (PyLong_SHIFT * 2)) {
6228 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
6229 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
6230 } else
6231 #endif
6232 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
6233 if (uintval >> (PyLong_SHIFT * 1)) {
6234 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
6235 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
6236 } else
6237 #endif
6238 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
6239 if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
6240 }
6241 #endif
6242 if (PyFloat_CheckExact(op1)) {
6243 const long b = intval;
6244 double a = PyFloat_AS_DOUBLE(op1);
6245 if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
6246 }
6247 return (
6248 PyObject_RichCompare(op1, op2, Py_EQ));
9362 }
9363 goto __PYX_GOOD;
9364 __PYX_BAD:
9365 if (!PyErr_Occurred())
9366 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
9367 ret = -1;
9368 __PYX_GOOD:
9369 #if !CYTHON_USE_PYTYPE_LOOKUP
9370 Py_XDECREF(object_reduce);
9371 Py_XDECREF(object_reduce_ex);
9372 #endif
9373 Py_XDECREF(reduce);
9374 Py_XDECREF(reduce_ex);
9375 Py_XDECREF(reduce_cython);
9376 Py_XDECREF(setstate);
9377 Py_XDECREF(setstate_cython);
9378 return ret;
62499379 }
62509380
62519381 /* TypeImport */
63099439 }
63109440 #endif
63119441
6312 /* CalculateMetaclass */
6313 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
6314 Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
6315 for (i=0; i < nbases; i++) {
6316 PyTypeObject *tmptype;
6317 PyObject *tmp = PyTuple_GET_ITEM(bases, i);
6318 tmptype = Py_TYPE(tmp);
6319 #if PY_MAJOR_VERSION < 3
6320 if (tmptype == &PyClass_Type)
6321 continue;
6322 #endif
6323 if (!metaclass) {
6324 metaclass = tmptype;
6325 continue;
6326 }
6327 if (PyType_IsSubtype(metaclass, tmptype))
6328 continue;
6329 if (PyType_IsSubtype(tmptype, metaclass)) {
6330 metaclass = tmptype;
6331 continue;
6332 }
6333 PyErr_SetString(PyExc_TypeError,
6334 "metaclass conflict: "
6335 "the metaclass of a derived class "
6336 "must be a (non-strict) subclass "
6337 "of the metaclasses of all its bases");
6338 return NULL;
6339 }
6340 if (!metaclass) {
6341 #if PY_MAJOR_VERSION < 3
6342 metaclass = &PyClass_Type;
6343 #else
6344 metaclass = &PyType_Type;
6345 #endif
6346 }
6347 Py_INCREF((PyObject*) metaclass);
6348 return (PyObject*) metaclass;
6349 }
6350
6351 /* FetchCommonType */
6352 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
6353 PyObject* fake_module;
6354 PyTypeObject* cached_type = NULL;
6355 fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
6356 if (!fake_module) return NULL;
6357 Py_INCREF(fake_module);
6358 cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
6359 if (cached_type) {
6360 if (!PyType_Check((PyObject*)cached_type)) {
6361 PyErr_Format(PyExc_TypeError,
6362 "Shared Cython type %.200s is not a type object",
6363 type->tp_name);
6364 goto bad;
6365 }
6366 if (cached_type->tp_basicsize != type->tp_basicsize) {
6367 PyErr_Format(PyExc_TypeError,
6368 "Shared Cython type %.200s has the wrong size, try recompiling",
6369 type->tp_name);
6370 goto bad;
6371 }
6372 } else {
6373 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
6374 PyErr_Clear();
6375 if (PyType_Ready(type) < 0) goto bad;
6376 if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
6377 goto bad;
6378 Py_INCREF(type);
6379 cached_type = type;
6380 }
6381 done:
6382 Py_DECREF(fake_module);
6383 return cached_type;
6384 bad:
6385 Py_XDECREF(cached_type);
6386 cached_type = NULL;
6387 goto done;
6388 }
6389
6390 /* CythonFunction */
6391 #include <structmember.h>
6392 static PyObject *
6393 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
6394 {
6395 if (unlikely(op->func_doc == NULL)) {
6396 if (op->func.m_ml->ml_doc) {
6397 #if PY_MAJOR_VERSION >= 3
6398 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
6399 #else
6400 op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
6401 #endif
6402 if (unlikely(op->func_doc == NULL))
6403 return NULL;
6404 } else {
6405 Py_INCREF(Py_None);
6406 return Py_None;
6407 }
6408 }
6409 Py_INCREF(op->func_doc);
6410 return op->func_doc;
6411 }
6412 static int
6413 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6414 {
6415 PyObject *tmp = op->func_doc;
6416 if (value == NULL) {
6417 value = Py_None;
6418 }
6419 Py_INCREF(value);
6420 op->func_doc = value;
6421 Py_XDECREF(tmp);
6422 return 0;
6423 }
6424 static PyObject *
6425 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6426 {
6427 if (unlikely(op->func_name == NULL)) {
6428 #if PY_MAJOR_VERSION >= 3
6429 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
6430 #else
6431 op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
6432 #endif
6433 if (unlikely(op->func_name == NULL))
6434 return NULL;
6435 }
6436 Py_INCREF(op->func_name);
6437 return op->func_name;
6438 }
6439 static int
6440 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6441 {
6442 PyObject *tmp;
6443 #if PY_MAJOR_VERSION >= 3
6444 if (unlikely(value == NULL || !PyUnicode_Check(value)))
6445 #else
6446 if (unlikely(value == NULL || !PyString_Check(value)))
6447 #endif
6448 {
6449 PyErr_SetString(PyExc_TypeError,
6450 "__name__ must be set to a string object");
6451 return -1;
6452 }
6453 tmp = op->func_name;
6454 Py_INCREF(value);
6455 op->func_name = value;
6456 Py_XDECREF(tmp);
6457 return 0;
6458 }
6459 static PyObject *
6460 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6461 {
6462 Py_INCREF(op->func_qualname);
6463 return op->func_qualname;
6464 }
6465 static int
6466 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6467 {
6468 PyObject *tmp;
6469 #if PY_MAJOR_VERSION >= 3
6470 if (unlikely(value == NULL || !PyUnicode_Check(value)))
6471 #else
6472 if (unlikely(value == NULL || !PyString_Check(value)))
6473 #endif
6474 {
6475 PyErr_SetString(PyExc_TypeError,
6476 "__qualname__ must be set to a string object");
6477 return -1;
6478 }
6479 tmp = op->func_qualname;
6480 Py_INCREF(value);
6481 op->func_qualname = value;
6482 Py_XDECREF(tmp);
6483 return 0;
6484 }
6485 static PyObject *
6486 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
6487 {
6488 PyObject *self;
6489 self = m->func_closure;
6490 if (self == NULL)
6491 self = Py_None;
6492 Py_INCREF(self);
6493 return self;
6494 }
6495 static PyObject *
6496 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6497 {
6498 if (unlikely(op->func_dict == NULL)) {
6499 op->func_dict = PyDict_New();
6500 if (unlikely(op->func_dict == NULL))
6501 return NULL;
6502 }
6503 Py_INCREF(op->func_dict);
6504 return op->func_dict;
6505 }
6506 static int
6507 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6508 {
6509 PyObject *tmp;
6510 if (unlikely(value == NULL)) {
6511 PyErr_SetString(PyExc_TypeError,
6512 "function's dictionary may not be deleted");
6513 return -1;
6514 }
6515 if (unlikely(!PyDict_Check(value))) {
6516 PyErr_SetString(PyExc_TypeError,
6517 "setting function's dictionary to a non-dict");
6518 return -1;
6519 }
6520 tmp = op->func_dict;
6521 Py_INCREF(value);
6522 op->func_dict = value;
6523 Py_XDECREF(tmp);
6524 return 0;
6525 }
6526 static PyObject *
6527 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6528 {
6529 Py_INCREF(op->func_globals);
6530 return op->func_globals;
6531 }
6532 static PyObject *
6533 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6534 {
6535 Py_INCREF(Py_None);
6536 return Py_None;
6537 }
6538 static PyObject *
6539 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6540 {
6541 PyObject* result = (op->func_code) ? op->func_code : Py_None;
6542 Py_INCREF(result);
6543 return result;
6544 }
6545 static int
6546 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
6547 int result = 0;
6548 PyObject *res = op->defaults_getter((PyObject *) op);
6549 if (unlikely(!res))
6550 return -1;
6551 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6552 op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
6553 Py_INCREF(op->defaults_tuple);
6554 op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
6555 Py_INCREF(op->defaults_kwdict);
6556 #else
6557 op->defaults_tuple = PySequence_ITEM(res, 0);
6558 if (unlikely(!op->defaults_tuple)) result = -1;
6559 else {
6560 op->defaults_kwdict = PySequence_ITEM(res, 1);
6561 if (unlikely(!op->defaults_kwdict)) result = -1;
6562 }
6563 #endif
6564 Py_DECREF(res);
6565 return result;
6566 }
6567 static int
6568 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6569 PyObject* tmp;
6570 if (!value) {
6571 value = Py_None;
6572 } else if (value != Py_None && !PyTuple_Check(value)) {
6573 PyErr_SetString(PyExc_TypeError,
6574 "__defaults__ must be set to a tuple object");
6575 return -1;
6576 }
6577 Py_INCREF(value);
6578 tmp = op->defaults_tuple;
6579 op->defaults_tuple = value;
6580 Py_XDECREF(tmp);
6581 return 0;
6582 }
6583 static PyObject *
6584 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6585 PyObject* result = op->defaults_tuple;
6586 if (unlikely(!result)) {
6587 if (op->defaults_getter) {
6588 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
6589 result = op->defaults_tuple;
6590 } else {
6591 result = Py_None;
6592 }
6593 }
6594 Py_INCREF(result);
6595 return result;
6596 }
6597 static int
6598 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6599 PyObject* tmp;
6600 if (!value) {
6601 value = Py_None;
6602 } else if (value != Py_None && !PyDict_Check(value)) {
6603 PyErr_SetString(PyExc_TypeError,
6604 "__kwdefaults__ must be set to a dict object");
6605 return -1;
6606 }
6607 Py_INCREF(value);
6608 tmp = op->defaults_kwdict;
6609 op->defaults_kwdict = value;
6610 Py_XDECREF(tmp);
6611 return 0;
6612 }
6613 static PyObject *
6614 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6615 PyObject* result = op->defaults_kwdict;
6616 if (unlikely(!result)) {
6617 if (op->defaults_getter) {
6618 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
6619 result = op->defaults_kwdict;
6620 } else {
6621 result = Py_None;
6622 }
6623 }
6624 Py_INCREF(result);
6625 return result;
6626 }
6627 static int
6628 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6629 PyObject* tmp;
6630 if (!value || value == Py_None) {
6631 value = NULL;
6632 } else if (!PyDict_Check(value)) {
6633 PyErr_SetString(PyExc_TypeError,
6634 "__annotations__ must be set to a dict object");
6635 return -1;
6636 }
6637 Py_XINCREF(value);
6638 tmp = op->func_annotations;
6639 op->func_annotations = value;
6640 Py_XDECREF(tmp);
6641 return 0;
6642 }
6643 static PyObject *
6644 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6645 PyObject* result = op->func_annotations;
6646 if (unlikely(!result)) {
6647 result = PyDict_New();
6648 if (unlikely(!result)) return NULL;
6649 op->func_annotations = result;
6650 }
6651 Py_INCREF(result);
6652 return result;
6653 }
6654 static PyGetSetDef __pyx_CyFunction_getsets[] = {
6655 {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6656 {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6657 {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6658 {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6659 {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
6660 {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
6661 {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6662 {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6663 {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6664 {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6665 {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6666 {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6667 {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6668 {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6669 {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6670 {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6671 {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
6672 {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
6673 {0, 0, 0, 0, 0}
6674 };
6675 static PyMemberDef __pyx_CyFunction_members[] = {
6676 {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
6677 {0, 0, 0, 0, 0}
6678 };
6679 static PyObject *
6680 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
6681 {
6682 #if PY_MAJOR_VERSION >= 3
6683 return PyUnicode_FromString(m->func.m_ml->ml_name);
6684 #else
6685 return PyString_FromString(m->func.m_ml->ml_name);
6686 #endif
6687 }
6688 static PyMethodDef __pyx_CyFunction_methods[] = {
6689 {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
6690 {0, 0, 0, 0}
6691 };
6692 #if PY_VERSION_HEX < 0x030500A0
6693 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
6694 #else
6695 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
6696 #endif
6697 static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
6698 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
6699 __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
6700 if (op == NULL)
6701 return NULL;
6702 op->flags = flags;
6703 __Pyx_CyFunction_weakreflist(op) = NULL;
6704 op->func.m_ml = ml;
6705 op->func.m_self = (PyObject *) op;
6706 Py_XINCREF(closure);
6707 op->func_closure = closure;
6708 Py_XINCREF(module);
6709 op->func.m_module = module;
6710 op->func_dict = NULL;
6711 op->func_name = NULL;
6712 Py_INCREF(qualname);
6713 op->func_qualname = qualname;
6714 op->func_doc = NULL;
6715 op->func_classobj = NULL;
6716 op->func_globals = globals;
6717 Py_INCREF(op->func_globals);
6718 Py_XINCREF(code);
6719 op->func_code = code;
6720 op->defaults_pyobjects = 0;
6721 op->defaults = NULL;
6722 op->defaults_tuple = NULL;
6723 op->defaults_kwdict = NULL;
6724 op->defaults_getter = NULL;
6725 op->func_annotations = NULL;
6726 PyObject_GC_Track(op);
6727 return (PyObject *) op;
6728 }
6729 static int
6730 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
6731 {
6732 Py_CLEAR(m->func_closure);
6733 Py_CLEAR(m->func.m_module);
6734 Py_CLEAR(m->func_dict);
6735 Py_CLEAR(m->func_name);
6736 Py_CLEAR(m->func_qualname);
6737 Py_CLEAR(m->func_doc);
6738 Py_CLEAR(m->func_globals);
6739 Py_CLEAR(m->func_code);
6740 Py_CLEAR(m->func_classobj);
6741 Py_CLEAR(m->defaults_tuple);
6742 Py_CLEAR(m->defaults_kwdict);
6743 Py_CLEAR(m->func_annotations);
6744 if (m->defaults) {
6745 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
6746 int i;
6747 for (i = 0; i < m->defaults_pyobjects; i++)
6748 Py_XDECREF(pydefaults[i]);
6749 PyObject_Free(m->defaults);
6750 m->defaults = NULL;
6751 }
6752 return 0;
6753 }
6754 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
6755 {
6756 if (__Pyx_CyFunction_weakreflist(m) != NULL)
6757 PyObject_ClearWeakRefs((PyObject *) m);
6758 __Pyx_CyFunction_clear(m);
6759 PyObject_GC_Del(m);
6760 }
6761 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
6762 {
6763 PyObject_GC_UnTrack(m);
6764 __Pyx__CyFunction_dealloc(m);
6765 }
6766 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
6767 {
6768 Py_VISIT(m->func_closure);
6769 Py_VISIT(m->func.m_module);
6770 Py_VISIT(m->func_dict);
6771 Py_VISIT(m->func_name);
6772 Py_VISIT(m->func_qualname);
6773 Py_VISIT(m->func_doc);
6774 Py_VISIT(m->func_globals);
6775 Py_VISIT(m->func_code);
6776 Py_VISIT(m->func_classobj);
6777 Py_VISIT(m->defaults_tuple);
6778 Py_VISIT(m->defaults_kwdict);
6779 if (m->defaults) {
6780 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
6781 int i;
6782 for (i = 0; i < m->defaults_pyobjects; i++)
6783 Py_VISIT(pydefaults[i]);
6784 }
6785 return 0;
6786 }
6787 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
6788 {
6789 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6790 if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
6791 Py_INCREF(func);
6792 return func;
6793 }
6794 if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
6795 if (type == NULL)
6796 type = (PyObject *)(Py_TYPE(obj));
6797 return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
6798 }
6799 if (obj == Py_None)
6800 obj = NULL;
6801 return __Pyx_PyMethod_New(func, obj, type);
6802 }
6803 static PyObject*
6804 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
6805 {
6806 #if PY_MAJOR_VERSION >= 3
6807 return PyUnicode_FromFormat("<cyfunction %U at %p>",
6808 op->func_qualname, (void *)op);
6809 #else
6810 return PyString_FromFormat("<cyfunction %s at %p>",
6811 PyString_AsString(op->func_qualname), (void *)op);
6812 #endif
6813 }
6814 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
6815 PyCFunctionObject* f = (PyCFunctionObject*)func;
6816 PyCFunction meth = f->m_ml->ml_meth;
6817 Py_ssize_t size;
6818 switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
6819 case METH_VARARGS:
6820 if (likely(kw == NULL || PyDict_Size(kw) == 0))
6821 return (*meth)(self, arg);
6822 break;
6823 case METH_VARARGS | METH_KEYWORDS:
6824 return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
6825 case METH_NOARGS:
6826 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
6827 size = PyTuple_GET_SIZE(arg);
6828 if (likely(size == 0))
6829 return (*meth)(self, NULL);
6830 PyErr_Format(PyExc_TypeError,
6831 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
6832 f->m_ml->ml_name, size);
6833 return NULL;
6834 }
6835 break;
6836 case METH_O:
6837 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
6838 size = PyTuple_GET_SIZE(arg);
6839 if (likely(size == 1)) {
6840 PyObject *result, *arg0;
6841 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6842 arg0 = PyTuple_GET_ITEM(arg, 0);
6843 #else
6844 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
6845 #endif
6846 result = (*meth)(self, arg0);
6847 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
6848 Py_DECREF(arg0);
6849 #endif
6850 return result;
6851 }
6852 PyErr_Format(PyExc_TypeError,
6853 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
6854 f->m_ml->ml_name, size);
6855 return NULL;
6856 }
6857 break;
6858 default:
6859 PyErr_SetString(PyExc_SystemError, "Bad call flags in "
6860 "__Pyx_CyFunction_Call. METH_OLDARGS is no "
6861 "longer supported!");
6862 return NULL;
6863 }
6864 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
6865 f->m_ml->ml_name);
6866 return NULL;
6867 }
6868 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
6869 return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
6870 }
6871 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
6872 PyObject *result;
6873 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
6874 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
6875 Py_ssize_t argc;
6876 PyObject *new_args;
6877 PyObject *self;
6878 argc = PyTuple_GET_SIZE(args);
6879 new_args = PyTuple_GetSlice(args, 1, argc);
6880 if (unlikely(!new_args))
6881 return NULL;
6882 self = PyTuple_GetItem(args, 0);
6883 if (unlikely(!self)) {
6884 Py_DECREF(new_args);
6885 return NULL;
6886 }
6887 result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
6888 Py_DECREF(new_args);
6889 } else {
6890 result = __Pyx_CyFunction_Call(func, args, kw);
6891 }
6892 return result;
6893 }
6894 static PyTypeObject __pyx_CyFunctionType_type = {
6895 PyVarObject_HEAD_INIT(0, 0)
6896 "cython_function_or_method",
6897 sizeof(__pyx_CyFunctionObject),
6898 0,
6899 (destructor) __Pyx_CyFunction_dealloc,
6900 0,
6901 0,
6902 0,
6903 #if PY_MAJOR_VERSION < 3
6904 0,
6905 #else
6906 0,
6907 #endif
6908 (reprfunc) __Pyx_CyFunction_repr,
6909 0,
6910 0,
6911 0,
6912 0,
6913 __Pyx_CyFunction_CallAsMethod,
6914 0,
6915 0,
6916 0,
6917 0,
6918 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
6919 0,
6920 (traverseproc) __Pyx_CyFunction_traverse,
6921 (inquiry) __Pyx_CyFunction_clear,
6922 0,
6923 #if PY_VERSION_HEX < 0x030500A0
6924 offsetof(__pyx_CyFunctionObject, func_weakreflist),
6925 #else
6926 offsetof(PyCFunctionObject, m_weakreflist),
6927 #endif
6928 0,
6929 0,
6930 __pyx_CyFunction_methods,
6931 __pyx_CyFunction_members,
6932 __pyx_CyFunction_getsets,
6933 0,
6934 0,
6935 __Pyx_CyFunction_descr_get,
6936 0,
6937 offsetof(__pyx_CyFunctionObject, func_dict),
6938 0,
6939 0,
6940 0,
6941 0,
6942 0,
6943 0,
6944 0,
6945 0,
6946 0,
6947 0,
6948 0,
6949 0,
6950 #if PY_VERSION_HEX >= 0x030400a1
6951 0,
6952 #endif
6953 #if PY_VERSION_HEX >= 0x030800b1
6954 0,
6955 #endif
6956 };
6957 static int __pyx_CyFunction_init(void) {
6958 __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
6959 if (unlikely(__pyx_CyFunctionType == NULL)) {
6960 return -1;
6961 }
6962 return 0;
6963 }
6964 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
6965 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6966 m->defaults = PyObject_Malloc(size);
6967 if (unlikely(!m->defaults))
6968 return PyErr_NoMemory();
6969 memset(m->defaults, 0, size);
6970 m->defaults_pyobjects = pyobjects;
6971 return m->defaults;
6972 }
6973 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
6974 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6975 m->defaults_tuple = tuple;
6976 Py_INCREF(tuple);
6977 }
6978 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
6979 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6980 m->defaults_kwdict = dict;
6981 Py_INCREF(dict);
6982 }
6983 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
6984 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
6985 m->func_annotations = dict;
6986 Py_INCREF(dict);
6987 }
6988
6989 /* Py3ClassCreate */
6990 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
6991 PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
6992 PyObject *ns;
6993 if (metaclass) {
6994 PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
6995 if (prep) {
6996 PyObject *pargs = PyTuple_Pack(2, name, bases);
6997 if (unlikely(!pargs)) {
6998 Py_DECREF(prep);
6999 return NULL;
7000 }
7001 ns = PyObject_Call(prep, pargs, mkw);
7002 Py_DECREF(prep);
7003 Py_DECREF(pargs);
7004 } else {
7005 if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
7006 return NULL;
7007 PyErr_Clear();
7008 ns = PyDict_New();
7009 }
7010 } else {
7011 ns = PyDict_New();
7012 }
7013 if (unlikely(!ns))
7014 return NULL;
7015 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
7016 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
7017 if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
7018 return ns;
7019 bad:
7020 Py_DECREF(ns);
7021 return NULL;
7022 }
7023 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
7024 PyObject *dict, PyObject *mkw,
7025 int calculate_metaclass, int allow_py2_metaclass) {
7026 PyObject *result, *margs;
7027 PyObject *owned_metaclass = NULL;
7028 if (allow_py2_metaclass) {
7029 owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
7030 if (owned_metaclass) {
7031 metaclass = owned_metaclass;
7032 } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
7033 PyErr_Clear();
7034 } else {
7035 return NULL;
7036 }
7037 }
7038 if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
7039 metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
7040 Py_XDECREF(owned_metaclass);
7041 if (unlikely(!metaclass))
7042 return NULL;
7043 owned_metaclass = metaclass;
7044 }
7045 margs = PyTuple_Pack(3, name, bases, dict);
7046 if (unlikely(!margs)) {
7047 result = NULL;
7048 } else {
7049 result = PyObject_Call(metaclass, margs, mkw);
7050 Py_DECREF(margs);
7051 }
7052 Py_XDECREF(owned_metaclass);
7053 return result;
7054 }
7055
70569442 /* CLineInTraceback */
70579443 #ifndef CYTHON_CLINE_IN_TRACEBACK
7058 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
9444 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
70599445 PyObject *use_cline;
70609446 PyObject *ptype, *pvalue, *ptraceback;
70619447 #if CYTHON_COMPILING_IN_CPYTHON
71599545 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
71609546 int new_max = __pyx_code_cache.max_count + 64;
71619547 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
7162 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
9548 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
71639549 if (unlikely(!entries)) {
71649550 return;
71659551 }
72609646 Py_XDECREF(py_frame);
72619647 }
72629648
9649 /* CIntToPy */
9650 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) {
9651 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
9652 const int is_unsigned = neg_one > const_zero;
9653 if (is_unsigned) {
9654 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
9655 return PyInt_FromLong((long) value);
9656 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
9657 return PyLong_FromUnsignedLong((unsigned long) value);
9658 #ifdef HAVE_LONG_LONG
9659 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
9660 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
9661 #endif
9662 }
9663 } else {
9664 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
9665 return PyInt_FromLong((long) value);
9666 #ifdef HAVE_LONG_LONG
9667 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
9668 return PyLong_FromLongLong((PY_LONG_LONG) value);
9669 #endif
9670 }
9671 }
9672 {
9673 int one = 1; int little = (int)*(unsigned char *)&one;
9674 unsigned char *bytes = (unsigned char *)&value;
9675 return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG),
9676 little, !is_unsigned);
9677 }
9678 }
9679
72639680 /* CIntFromPyVerify */
72649681 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
72659682 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
72839700 }
72849701
72859702 /* CIntToPy */
7286 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
7287 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
9703 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_char(unsigned char value) {
9704 const unsigned char neg_one = (unsigned char) ((unsigned char) 0 - (unsigned char) 1), const_zero = (unsigned char) 0;
72889705 const int is_unsigned = neg_one > const_zero;
72899706 if (is_unsigned) {
7290 if (sizeof(int) < sizeof(long)) {
9707 if (sizeof(unsigned char) < sizeof(long)) {
72919708 return PyInt_FromLong((long) value);
7292 } else if (sizeof(int) <= sizeof(unsigned long)) {
9709 } else if (sizeof(unsigned char) <= sizeof(unsigned long)) {
72939710 return PyLong_FromUnsignedLong((unsigned long) value);
72949711 #ifdef HAVE_LONG_LONG
7295 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
9712 } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) {
72969713 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
72979714 #endif
72989715 }
72999716 } else {
7300 if (sizeof(int) <= sizeof(long)) {
9717 if (sizeof(unsigned char) <= sizeof(long)) {
73019718 return PyInt_FromLong((long) value);
73029719 #ifdef HAVE_LONG_LONG
7303 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
9720 } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) {
73049721 return PyLong_FromLongLong((PY_LONG_LONG) value);
73059722 #endif
73069723 }
73089725 {
73099726 int one = 1; int little = (int)*(unsigned char *)&one;
73109727 unsigned char *bytes = (unsigned char *)&value;
7311 return _PyLong_FromByteArray(bytes, sizeof(int),
9728 return _PyLong_FromByteArray(bytes, sizeof(unsigned char),
73129729 little, !is_unsigned);
73139730 }
9731 }
9732
9733 /* CIntToPy */
9734 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
9735 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
9736 const int is_unsigned = neg_one > const_zero;
9737 if (is_unsigned) {
9738 if (sizeof(long) < sizeof(long)) {
9739 return PyInt_FromLong((long) value);
9740 } else if (sizeof(long) <= sizeof(unsigned long)) {
9741 return PyLong_FromUnsignedLong((unsigned long) value);
9742 #ifdef HAVE_LONG_LONG
9743 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
9744 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
9745 #endif
9746 }
9747 } else {
9748 if (sizeof(long) <= sizeof(long)) {
9749 return PyInt_FromLong((long) value);
9750 #ifdef HAVE_LONG_LONG
9751 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
9752 return PyLong_FromLongLong((PY_LONG_LONG) value);
9753 #endif
9754 }
9755 }
9756 {
9757 int one = 1; int little = (int)*(unsigned char *)&one;
9758 unsigned char *bytes = (unsigned char *)&value;
9759 return _PyLong_FromByteArray(bytes, sizeof(long),
9760 little, !is_unsigned);
9761 }
9762 }
9763
9764 /* CIntFromPy */
9765 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
9766 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
9767 const int is_unsigned = neg_one > const_zero;
9768 #if PY_MAJOR_VERSION < 3
9769 if (likely(PyInt_Check(x))) {
9770 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
9771 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
9772 } else {
9773 long val = PyInt_AS_LONG(x);
9774 if (is_unsigned && unlikely(val < 0)) {
9775 goto raise_neg_overflow;
9776 }
9777 return (unsigned PY_LONG_LONG) val;
9778 }
9779 } else
9780 #endif
9781 if (likely(PyLong_Check(x))) {
9782 if (is_unsigned) {
9783 #if CYTHON_USE_PYLONG_INTERNALS
9784 const digit* digits = ((PyLongObject*)x)->ob_digit;
9785 switch (Py_SIZE(x)) {
9786 case 0: return (unsigned PY_LONG_LONG) 0;
9787 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
9788 case 2:
9789 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
9790 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9791 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9792 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
9793 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9794 }
9795 }
9796 break;
9797 case 3:
9798 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
9799 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9800 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9801 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
9802 return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9803 }
9804 }
9805 break;
9806 case 4:
9807 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
9808 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9809 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9810 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
9811 return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
9812 }
9813 }
9814 break;
9815 }
9816 #endif
9817 #if CYTHON_COMPILING_IN_CPYTHON
9818 if (unlikely(Py_SIZE(x) < 0)) {
9819 goto raise_neg_overflow;
9820 }
9821 #else
9822 {
9823 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
9824 if (unlikely(result < 0))
9825 return (unsigned PY_LONG_LONG) -1;
9826 if (unlikely(result == 1))
9827 goto raise_neg_overflow;
9828 }
9829 #endif
9830 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
9831 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
9832 #ifdef HAVE_LONG_LONG
9833 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
9834 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
9835 #endif
9836 }
9837 } else {
9838 #if CYTHON_USE_PYLONG_INTERNALS
9839 const digit* digits = ((PyLongObject*)x)->ob_digit;
9840 switch (Py_SIZE(x)) {
9841 case 0: return (unsigned PY_LONG_LONG) 0;
9842 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
9843 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
9844 case -2:
9845 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
9846 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9847 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9848 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
9849 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9850 }
9851 }
9852 break;
9853 case 2:
9854 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
9855 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9856 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9857 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
9858 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9859 }
9860 }
9861 break;
9862 case -3:
9863 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
9864 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9865 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9866 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
9867 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9868 }
9869 }
9870 break;
9871 case 3:
9872 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
9873 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9874 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9875 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
9876 return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9877 }
9878 }
9879 break;
9880 case -4:
9881 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
9882 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9883 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9884 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
9885 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9886 }
9887 }
9888 break;
9889 case 4:
9890 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
9891 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9892 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9893 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
9894 return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
9895 }
9896 }
9897 break;
9898 }
9899 #endif
9900 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
9901 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
9902 #ifdef HAVE_LONG_LONG
9903 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
9904 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
9905 #endif
9906 }
9907 }
9908 {
9909 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
9910 PyErr_SetString(PyExc_RuntimeError,
9911 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
9912 #else
9913 unsigned PY_LONG_LONG val;
9914 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
9915 #if PY_MAJOR_VERSION < 3
9916 if (likely(v) && !PyLong_Check(v)) {
9917 PyObject *tmp = v;
9918 v = PyNumber_Long(tmp);
9919 Py_DECREF(tmp);
9920 }
9921 #endif
9922 if (likely(v)) {
9923 int one = 1; int is_little = (int)*(unsigned char *)&one;
9924 unsigned char *bytes = (unsigned char *)&val;
9925 int ret = _PyLong_AsByteArray((PyLongObject *)v,
9926 bytes, sizeof(val),
9927 is_little, !is_unsigned);
9928 Py_DECREF(v);
9929 if (likely(!ret))
9930 return val;
9931 }
9932 #endif
9933 return (unsigned PY_LONG_LONG) -1;
9934 }
9935 } else {
9936 unsigned PY_LONG_LONG val;
9937 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
9938 if (!tmp) return (unsigned PY_LONG_LONG) -1;
9939 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
9940 Py_DECREF(tmp);
9941 return val;
9942 }
9943 raise_overflow:
9944 PyErr_SetString(PyExc_OverflowError,
9945 "value too large to convert to unsigned PY_LONG_LONG");
9946 return (unsigned PY_LONG_LONG) -1;
9947 raise_neg_overflow:
9948 PyErr_SetString(PyExc_OverflowError,
9949 "can't convert negative value to unsigned PY_LONG_LONG");
9950 return (unsigned PY_LONG_LONG) -1;
9951 }
9952
9953 /* CIntFromPy */
9954 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
9955 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
9956 const int is_unsigned = neg_one > const_zero;
9957 #if PY_MAJOR_VERSION < 3
9958 if (likely(PyInt_Check(x))) {
9959 if (sizeof(long) < sizeof(long)) {
9960 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
9961 } else {
9962 long val = PyInt_AS_LONG(x);
9963 if (is_unsigned && unlikely(val < 0)) {
9964 goto raise_neg_overflow;
9965 }
9966 return (long) val;
9967 }
9968 } else
9969 #endif
9970 if (likely(PyLong_Check(x))) {
9971 if (is_unsigned) {
9972 #if CYTHON_USE_PYLONG_INTERNALS
9973 const digit* digits = ((PyLongObject*)x)->ob_digit;
9974 switch (Py_SIZE(x)) {
9975 case 0: return (long) 0;
9976 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
9977 case 2:
9978 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
9979 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9980 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9981 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
9982 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
9983 }
9984 }
9985 break;
9986 case 3:
9987 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
9988 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9989 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9990 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
9991 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
9992 }
9993 }
9994 break;
9995 case 4:
9996 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
9997 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9998 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9999 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
10000 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
10001 }
10002 }
10003 break;
10004 }
10005 #endif
10006 #if CYTHON_COMPILING_IN_CPYTHON
10007 if (unlikely(Py_SIZE(x) < 0)) {
10008 goto raise_neg_overflow;
10009 }
10010 #else
10011 {
10012 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
10013 if (unlikely(result < 0))
10014 return (long) -1;
10015 if (unlikely(result == 1))
10016 goto raise_neg_overflow;
10017 }
10018 #endif
10019 if (sizeof(long) <= sizeof(unsigned long)) {
10020 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
10021 #ifdef HAVE_LONG_LONG
10022 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
10023 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
10024 #endif
10025 }
10026 } else {
10027 #if CYTHON_USE_PYLONG_INTERNALS
10028 const digit* digits = ((PyLongObject*)x)->ob_digit;
10029 switch (Py_SIZE(x)) {
10030 case 0: return (long) 0;
10031 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
10032 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
10033 case -2:
10034 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
10035 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10036 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10037 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
10038 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10039 }
10040 }
10041 break;
10042 case 2:
10043 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
10044 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
10045 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10046 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
10047 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10048 }
10049 }
10050 break;
10051 case -3:
10052 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
10053 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10054 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10055 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
10056 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10057 }
10058 }
10059 break;
10060 case 3:
10061 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
10062 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
10063 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10064 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
10065 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10066 }
10067 }
10068 break;
10069 case -4:
10070 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
10071 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10072 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10073 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
10074 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10075 }
10076 }
10077 break;
10078 case 4:
10079 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
10080 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
10081 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
10082 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
10083 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
10084 }
10085 }
10086 break;
10087 }
10088 #endif
10089 if (sizeof(long) <= sizeof(long)) {
10090 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
10091 #ifdef HAVE_LONG_LONG
10092 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
10093 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
10094 #endif
10095 }
10096 }
10097 {
10098 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
10099 PyErr_SetString(PyExc_RuntimeError,
10100 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
10101 #else
10102 long val;
10103 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
10104 #if PY_MAJOR_VERSION < 3
10105 if (likely(v) && !PyLong_Check(v)) {
10106 PyObject *tmp = v;
10107 v = PyNumber_Long(tmp);
10108 Py_DECREF(tmp);
10109 }
10110 #endif
10111 if (likely(v)) {
10112 int one = 1; int is_little = (int)*(unsigned char *)&one;
10113 unsigned char *bytes = (unsigned char *)&val;
10114 int ret = _PyLong_AsByteArray((PyLongObject *)v,
10115 bytes, sizeof(val),
10116 is_little, !is_unsigned);
10117 Py_DECREF(v);
10118 if (likely(!ret))
10119 return val;
10120 }
10121 #endif
10122 return (long) -1;
10123 }
10124 } else {
10125 long val;
10126 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
10127 if (!tmp) return (long) -1;
10128 val = __Pyx_PyInt_As_long(tmp);
10129 Py_DECREF(tmp);
10130 return val;
10131 }
10132 raise_overflow:
10133 PyErr_SetString(PyExc_OverflowError,
10134 "value too large to convert to long");
10135 return (long) -1;
10136 raise_neg_overflow:
10137 PyErr_SetString(PyExc_OverflowError,
10138 "can't convert negative value to long");
10139 return (long) -1;
731410140 }
731510141
731610142 /* CIntFromPy */
750210328 return (int) -1;
750310329 }
750410330
7505 /* CIntToPy */
7506 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
7507 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
7508 const int is_unsigned = neg_one > const_zero;
7509 if (is_unsigned) {
7510 if (sizeof(long) < sizeof(long)) {
7511 return PyInt_FromLong((long) value);
7512 } else if (sizeof(long) <= sizeof(unsigned long)) {
7513 return PyLong_FromUnsignedLong((unsigned long) value);
7514 #ifdef HAVE_LONG_LONG
7515 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7516 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7517 #endif
7518 }
7519 } else {
7520 if (sizeof(long) <= sizeof(long)) {
7521 return PyInt_FromLong((long) value);
7522 #ifdef HAVE_LONG_LONG
7523 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7524 return PyLong_FromLongLong((PY_LONG_LONG) value);
7525 #endif
7526 }
7527 }
7528 {
7529 int one = 1; int little = (int)*(unsigned char *)&one;
7530 unsigned char *bytes = (unsigned char *)&value;
7531 return _PyLong_FromByteArray(bytes, sizeof(long),
7532 little, !is_unsigned);
7533 }
7534 }
7535
7536 /* CIntFromPy */
7537 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
7538 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
7539 const int is_unsigned = neg_one > const_zero;
7540 #if PY_MAJOR_VERSION < 3
7541 if (likely(PyInt_Check(x))) {
7542 if (sizeof(long) < sizeof(long)) {
7543 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
7544 } else {
7545 long val = PyInt_AS_LONG(x);
7546 if (is_unsigned && unlikely(val < 0)) {
7547 goto raise_neg_overflow;
7548 }
7549 return (long) val;
7550 }
7551 } else
7552 #endif
7553 if (likely(PyLong_Check(x))) {
7554 if (is_unsigned) {
7555 #if CYTHON_USE_PYLONG_INTERNALS
7556 const digit* digits = ((PyLongObject*)x)->ob_digit;
7557 switch (Py_SIZE(x)) {
7558 case 0: return (long) 0;
7559 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
7560 case 2:
7561 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7562 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7563 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7564 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
7565 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7566 }
7567 }
7568 break;
7569 case 3:
7570 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7571 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7572 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7573 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
7574 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7575 }
7576 }
7577 break;
7578 case 4:
7579 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7580 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7581 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7582 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
7583 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7584 }
7585 }
7586 break;
7587 }
7588 #endif
7589 #if CYTHON_COMPILING_IN_CPYTHON
7590 if (unlikely(Py_SIZE(x) < 0)) {
7591 goto raise_neg_overflow;
7592 }
7593 #else
7594 {
7595 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7596 if (unlikely(result < 0))
7597 return (long) -1;
7598 if (unlikely(result == 1))
7599 goto raise_neg_overflow;
7600 }
7601 #endif
7602 if (sizeof(long) <= sizeof(unsigned long)) {
7603 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
7604 #ifdef HAVE_LONG_LONG
7605 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7606 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7607 #endif
7608 }
7609 } else {
7610 #if CYTHON_USE_PYLONG_INTERNALS
7611 const digit* digits = ((PyLongObject*)x)->ob_digit;
7612 switch (Py_SIZE(x)) {
7613 case 0: return (long) 0;
7614 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
7615 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
7616 case -2:
7617 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
7618 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7619 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7620 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7621 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7622 }
7623 }
7624 break;
7625 case 2:
7626 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7627 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7628 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7629 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7630 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7631 }
7632 }
7633 break;
7634 case -3:
7635 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7636 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7637 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7638 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7639 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7640 }
7641 }
7642 break;
7643 case 3:
7644 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7645 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7646 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7647 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7648 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7649 }
7650 }
7651 break;
7652 case -4:
7653 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7654 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7655 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7656 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7657 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7658 }
7659 }
7660 break;
7661 case 4:
7662 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7663 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7664 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7665 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7666 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7667 }
7668 }
7669 break;
7670 }
7671 #endif
7672 if (sizeof(long) <= sizeof(long)) {
7673 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
7674 #ifdef HAVE_LONG_LONG
7675 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7676 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
7677 #endif
7678 }
7679 }
7680 {
7681 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7682 PyErr_SetString(PyExc_RuntimeError,
7683 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7684 #else
7685 long val;
7686 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7687 #if PY_MAJOR_VERSION < 3
7688 if (likely(v) && !PyLong_Check(v)) {
7689 PyObject *tmp = v;
7690 v = PyNumber_Long(tmp);
7691 Py_DECREF(tmp);
7692 }
7693 #endif
7694 if (likely(v)) {
7695 int one = 1; int is_little = (int)*(unsigned char *)&one;
7696 unsigned char *bytes = (unsigned char *)&val;
7697 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7698 bytes, sizeof(val),
7699 is_little, !is_unsigned);
7700 Py_DECREF(v);
7701 if (likely(!ret))
7702 return val;
7703 }
7704 #endif
7705 return (long) -1;
7706 }
7707 } else {
7708 long val;
7709 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7710 if (!tmp) return (long) -1;
7711 val = __Pyx_PyInt_As_long(tmp);
7712 Py_DECREF(tmp);
7713 return val;
7714 }
7715 raise_overflow:
7716 PyErr_SetString(PyExc_OverflowError,
7717 "value too large to convert to long");
7718 return (long) -1;
7719 raise_neg_overflow:
7720 PyErr_SetString(PyExc_OverflowError,
7721 "can't convert negative value to long");
7722 return (long) -1;
7723 }
7724
772510331 /* FastTypeChecks */
772610332 #if CYTHON_COMPILING_IN_CPYTHON
772710333 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
0 from cpython cimport Py_INCREF, PyBytes_FromStringAndSize
0 from cpython cimport Py_INCREF, PyBytes_FromStringAndSize, PyBytes_AsString
11 from cpython.bytearray cimport PyByteArray_AsString
22 # Using python's versions of pure c memory management functions for
33 # proper memory statistics count.
66 from libc.string cimport memcpy
77
88
9 cdef char * maybe_resize_c_string(char *c_string, Py_ssize_t old_size,
10 Py_ssize_t new_size):
11 if new_size > old_size:
12 c_string = <char *> PyMem_Realloc(c_string, new_size)
13 if not c_string:
14 raise MemoryError()
15 return c_string
16
17
18 class BufferedReader(object):
9 cdef class BufferedReader(object):
10 cdef public unsigned long long position, current_buffer_size
11 cdef public bytearray buffer
12
1913 def __init__(self, bufsize):
2014 self.buffer = bytearray(bufsize)
2115
2721 def read_into_buffer(self):
2822 raise NotImplementedError
2923
30 def read(self, Py_ssize_t unread):
24 def read(self, unsigned long long unread):
3125 # When the buffer is large enough bytes read are almost
3226 # always hit the buffer.
33 next_position = unread + self.position
27 cdef unsigned long long next_position = unread + self.position
3428 if next_position < self.current_buffer_size:
3529 t = self.position
3630 self.position = next_position
37 return self.buffer[t:self.position]
31 return bytes(self.buffer[t:self.position])
3832
3933 cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
40 cdef Py_ssize_t read_bytes
41 cdef Py_ssize_t position = self.position
42 cdef Py_ssize_t current_buffer_size = self.current_buffer_size
34 cdef unsigned long long read_bytes
4335 rv = bytes()
4436
4537 while unread > 0:
46 if position == current_buffer_size:
38 if self.position == self.current_buffer_size:
4739 self.read_into_buffer()
4840 buffer_ptr = PyByteArray_AsString(self.buffer)
49 current_buffer_size = self.current_buffer_size
50 position = 0
51
52 read_bytes = min(unread, current_buffer_size - position)
53 rv += PyBytes_FromStringAndSize(&buffer_ptr[position], read_bytes)
54 position += read_bytes
41 self.position = 0
42
43 read_bytes = min(unread, self.current_buffer_size - self.position)
44 rv += PyBytes_FromStringAndSize(
45 &buffer_ptr[self.position], read_bytes
46 )
47 self.position += read_bytes
5548 unread -= read_bytes
5649
57 # Restore self-variables.
58 self.position = position
59 self.current_buffer_size = current_buffer_size
60
61 return bytearray(rv)
50 return rv
6251
6352 def read_one(self):
6453 if self.position == self.current_buffer_size:
6958 self.position += 1
7059 return rv
7160
72 def read_strings(self, Py_ssize_t n_items, int decode=0):
61 def read_strings(self, unsigned long long n_items, encoding=None):
7362 """
7463 Python has great overhead between function calls.
7564 We inline strings reading logic here to avoid this overhead.
7665 """
7766 items = PyTuple_New(n_items)
7867
79 # Reduce getattr(self, ...), calls.
80 buffer = self.buffer
81 cdef Py_ssize_t i
68 cdef unsigned long long i
8269 # Buffer vars
83 cdef char* buffer_ptr = PyByteArray_AsString(buffer)
84 cdef Py_ssize_t right, position = self.position
85 cdef Py_ssize_t current_buffer_size = self.current_buffer_size
70 cdef char* buffer_ptr = PyByteArray_AsString(self.buffer)
71 cdef unsigned long long right
8672 # String length vars
87 cdef Py_ssize_t size, shift
88 cdef unsigned char b
73 cdef unsigned long long size, shift, bytes_read
74 cdef unsigned long long b
8975
9076 # String for decode vars.
9177 cdef char *c_string = NULL
92 cdef Py_ssize_t c_string_size = 0, large_str_bytes
78 cdef unsigned long long c_string_size = 1024
79 cdef char *c_encoding = NULL
80 if encoding:
81 encoding = encoding.encode('utf-8')
82 c_encoding = encoding
83
84 cdef object rv = object()
85 # String for decode vars.
86 if c_encoding:
87 c_string = <char *> PyMem_Realloc(NULL, c_string_size)
9388
9489 for i in range(n_items):
9590 shift = size = 0
9691
9792 # Read string size
9893 while True:
99 if position == current_buffer_size:
94 if self.position == self.current_buffer_size:
10095 self.read_into_buffer()
101 # `read_into_buffer` can override
102 # buffer, current_buffer_size
103 # We need to restore them.
104 buffer = self.buffer
105 current_buffer_size = self.current_buffer_size
106 buffer_ptr = PyByteArray_AsString(buffer)
107 position = 0
108
109 b = buffer_ptr[position]
110 position += 1
96 # `read_into_buffer` can override buffer
97 buffer_ptr = PyByteArray_AsString(self.buffer)
98 self.position = 0
99
100 b = buffer_ptr[self.position]
101 self.position += 1
111102
112103 size |= (b & 0x7f) << shift
113104 if b < 0x80:
115106
116107 shift += 7
117108
118 right = position + size
119
120 if decode:
121 c_string = maybe_resize_c_string(c_string, c_string_size,
122 size + 1)
123 c_string_size = max(c_string_size, size + 1)
109 right = self.position + size
110
111 if c_encoding:
112 if size + 1 > c_string_size:
113 c_string_size = size + 1
114 c_string = <char *> PyMem_Realloc(c_string, c_string_size)
115 if c_string is NULL:
116 raise MemoryError()
124117 c_string[size] = 0
125118 bytes_read = 0
126119
127120 # Decoding pure c strings in Cython is faster than in pure Python.
128121 # We need to copy it into buffer for adding null symbol at the end.
129122 # In ClickHouse block there is no null
130 if right > current_buffer_size:
131 if decode:
132 memcpy(&c_string[bytes_read], &buffer_ptr[position],
133 current_buffer_size - position)
123 if right > self.current_buffer_size:
124 if c_encoding:
125 memcpy(&c_string[bytes_read], &buffer_ptr[self.position],
126 self.current_buffer_size - self.position)
134127 else:
135128 rv = PyBytes_FromStringAndSize(
136 &buffer_ptr[position], current_buffer_size - position
129 &buffer_ptr[self.position],
130 self.current_buffer_size - self.position
137131 )
138132
139 bytes_read = current_buffer_size - position
133 bytes_read = self.current_buffer_size - self.position
140134 # Read the rest of the string.
141135 while bytes_read != size:
142 position = size - bytes_read
136 self.position = size - bytes_read
143137
144138 self.read_into_buffer()
145 # `read_into_buffer` can override
146 # buffer, current_buffer_size
147 # We need to restore them.
148 buffer = self.buffer
149 current_buffer_size = self.current_buffer_size
150 buffer_ptr = PyByteArray_AsString(buffer)
139 # `read_into_buffer` can override buffer
140 buffer_ptr = PyByteArray_AsString(self.buffer)
151141 # There can be not enough data in buffer.
152 position = min(position, current_buffer_size)
153 if decode:
154 memcpy(&c_string[bytes_read], buffer_ptr, position)
142 self.position = min(
143 self.position, self.current_buffer_size
144 )
145 if c_encoding:
146 memcpy(
147 &c_string[bytes_read], buffer_ptr, self.position
148 )
155149 else:
156 rv += PyBytes_FromStringAndSize(buffer_ptr, position)
157 bytes_read += position
150 rv += PyBytes_FromStringAndSize(
151 buffer_ptr, self.position
152 )
153 bytes_read += self.position
158154
159155 else:
160 if decode:
161 memcpy(c_string, &buffer_ptr[position], size)
156 if c_encoding:
157 memcpy(c_string, &buffer_ptr[self.position], size)
162158 else:
163 rv = PyBytes_FromStringAndSize(&buffer_ptr[position], size)
164 position = right
165
166 if decode:
159 rv = PyBytes_FromStringAndSize(
160 &buffer_ptr[self.position], size
161 )
162 self.position = right
163
164 if c_encoding:
167165 try:
168 rv = c_string[:size].decode('utf-8')
166 rv = c_string[:size].decode(c_encoding)
169167 except UnicodeDecodeError:
170168 rv = PyBytes_FromStringAndSize(c_string, size)
171169
175173 if c_string:
176174 PyMem_Free(c_string)
177175
178 # Restore self-variables.
179 self.buffer = buffer
180 self.position = position
181 self.current_buffer_size = current_buffer_size
182
183176 return items
184177
185
186 class BufferedSocketReader(BufferedReader):
178 def read_fixed_strings_as_bytes(self, Py_ssize_t n_items,
179 Py_ssize_t length):
180 cdef Py_ssize_t i
181 data = self.read(length * n_items)
182 cdef char* data_ptr = PyBytes_AsString(data)
183
184 items = PyTuple_New(n_items)
185 for i in range(n_items):
186 item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
187 Py_INCREF(item)
188 PyTuple_SET_ITEM(items, i, item)
189 return items
190
191 def read_fixed_strings(self, Py_ssize_t n_items, Py_ssize_t length,
192 encoding=None):
193 if encoding is None:
194 return self.read_fixed_strings_as_bytes(n_items, length)
195
196 cdef Py_ssize_t i, j
197 encoding = encoding.encode('utf-8')
198 cdef char* c_encoding = encoding
199 data = self.read(length * n_items)
200 cdef char* data_ptr = PyBytes_AsString(data)
201
202 cdef char* c_string = <char *>PyMem_Malloc(length + 1)
203 if not c_string:
204 raise MemoryError()
205 c_string[length] = 0
206
207 items = PyTuple_New(n_items)
208 for i in range(n_items):
209 memcpy(c_string, &data_ptr[i * length], length)
210
211 # Get last non zero byte of string from the end.
212 j = length - 1
213 while j >= 0 and not c_string[j]:
214 j -= 1
215
216 try:
217 item = c_string[:j + 1].decode(c_encoding)
218 except UnicodeDecodeError:
219 item = PyBytes_FromStringAndSize(c_string, length)
220 Py_INCREF(item)
221 PyTuple_SET_ITEM(items, i, item)
222
223 PyMem_Free(c_string)
224
225 return items
226
227
228 cdef class BufferedSocketReader(BufferedReader):
229 cdef object sock
230
187231 def __init__(self, sock, bufsize):
188232 self.sock = sock
189233 super(BufferedSocketReader, self).__init__(bufsize)
195239 raise EOFError('Unexpected EOF while reading bytes')
196240
197241
198 class CompressedBufferedReader(BufferedReader):
242 cdef class CompressedBufferedReader(BufferedReader):
243 cdef object read_block
244
199245 def __init__(self, read_block, bufsize):
200246 self.read_block = read_block
201247 super(CompressedBufferedReader, self).__init__(bufsize)
0 /* Generated by Cython 0.29.13 */
0 /* Generated by Cython 0.29.21 */
11
22 /* BEGIN: Cython Metadata
33 {
44 "distutils": {
5 "depends": [],
6 "name": "clickhouse_driver.bufferedwriter",
5 "depends": [],
6 "name": "clickhouse_driver.bufferedwriter",
77 "sources": [
88 "clickhouse_driver/bufferedwriter.pyx"
99 ]
10 },
10 },
1111 "module_name": "clickhouse_driver.bufferedwriter"
1212 }
1313 END: Cython Metadata */
1919 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
2020 #error Cython requires Python 2.6+ or Python 3.3+.
2121 #else
22 #define CYTHON_ABI "0_29_13"
23 #define CYTHON_HEX_VERSION 0x001D0DF0
22 #define CYTHON_ABI "0_29_21"
23 #define CYTHON_HEX_VERSION 0x001D15F0
2424 #define CYTHON_FUTURE_DIVISION 1
2525 #include <stddef.h>
2626 #ifndef offsetof
447447 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
448448 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
449449 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
450 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
450451 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
452 #else
453 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
454 #endif
451455 #else
452456 #define CYTHON_PEP393_ENABLED 0
453457 #define PyUnicode_1BYTE_KIND 1
496500 #define PyString_Type PyUnicode_Type
497501 #define PyString_Check PyUnicode_Check
498502 #define PyString_CheckExact PyUnicode_CheckExact
503 #ifndef PyObject_Unicode
499504 #define PyObject_Unicode PyObject_Str
505 #endif
500506 #endif
501507 #if PY_MAJOR_VERSION >= 3
502508 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
507513 #endif
508514 #ifndef PySet_CheckExact
509515 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
516 #endif
517 #if PY_VERSION_HEX >= 0x030900A4
518 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
519 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
520 #else
521 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
522 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
510523 #endif
511524 #if CYTHON_ASSUME_SAFE_MACROS
512525 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
547560 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
548561 #endif
549562 #if PY_MAJOR_VERSION >= 3
550 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
563 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
551564 #else
552565 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
553566 #endif
588601 #define __Pyx_truncl truncl
589602 #endif
590603
591
604 #define __PYX_MARK_ERR_POS(f_index, lineno) \
605 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
592606 #define __PYX_ERR(f_index, lineno, Ln_error) \
593 { \
594 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
595 }
607 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596608
597609 #ifndef __PYX_EXTERN_C
598610 #ifdef __cplusplus
828840 struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter;
829841 struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter;
830842
831 /* "clickhouse_driver/bufferedwriter.pyx":11
843 /* "clickhouse_driver/bufferedwriter.pyx":10
832844 *
833845 *
834846 * cdef class BufferedWriter(object): # <<<<<<<<<<<<<<
835847 * cdef char* buffer
836 * cdef Py_ssize_t position, buffer_size
848 * cdef unsigned long long position, buffer_size
837849 */
838850 struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter {
839851 PyObject_HEAD
840852 struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_vtab;
841853 char *buffer;
842 Py_ssize_t position;
843 Py_ssize_t buffer_size;
854 unsigned PY_LONG_LONG position;
855 unsigned PY_LONG_LONG buffer_size;
844856 };
845857
846858
847 /* "clickhouse_driver/bufferedwriter.pyx":65
859 /* "clickhouse_driver/bufferedwriter.pyx":119
848860 *
849861 *
850862 * cdef class BufferedSocketWriter(BufferedWriter): # <<<<<<<<<<<<<<
857869 };
858870
859871
860 /* "clickhouse_driver/bufferedwriter.pyx":79
872 /* "clickhouse_driver/bufferedwriter.pyx":133
861873 *
862874 *
863875 * cdef class CompressedBufferedWriter(BufferedWriter): # <<<<<<<<<<<<<<
871883
872884
873885
874 /* "clickhouse_driver/bufferedwriter.pyx":11
886 /* "clickhouse_driver/bufferedwriter.pyx":10
875887 *
876888 *
877889 * cdef class BufferedWriter(object): # <<<<<<<<<<<<<<
878890 * cdef char* buffer
879 * cdef Py_ssize_t position, buffer_size
891 * cdef unsigned long long position, buffer_size
880892 */
881893
882894 struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter {
886898 static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter;
887899
888900
889 /* "clickhouse_driver/bufferedwriter.pyx":65
901 /* "clickhouse_driver/bufferedwriter.pyx":119
890902 *
891903 *
892904 * cdef class BufferedSocketWriter(BufferedWriter): # <<<<<<<<<<<<<<
900912 static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter;
901913
902914
903 /* "clickhouse_driver/bufferedwriter.pyx":79
915 /* "clickhouse_driver/bufferedwriter.pyx":133
904916 *
905917 *
906918 * cdef class CompressedBufferedWriter(BufferedWriter): # <<<<<<<<<<<<<<
11401152 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
11411153 #endif
11421154
1155 /* PyErrExceptionMatches.proto */
1156 #if CYTHON_FAST_THREAD_STATE
1157 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1158 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1159 #else
1160 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1161 #endif
1162
1163 /* GetAttr.proto */
1164 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1165
1166 /* GetAttr3.proto */
1167 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1168
1169 /* Import.proto */
1170 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1171
1172 /* ImportFrom.proto */
1173 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1174
11431175 /* GetItemInt.proto */
11441176 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
11451177 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
11621194 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
11631195 int is_list, int wraparound, int boundscheck);
11641196
1165 /* PyErrExceptionMatches.proto */
1166 #if CYTHON_FAST_THREAD_STATE
1167 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1168 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1169 #else
1170 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1171 #endif
1172
1173 /* GetAttr.proto */
1174 static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *, PyObject *);
1175
1176 /* GetAttr3.proto */
1177 static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);
1178
1179 /* Import.proto */
1180 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1181
1182 /* ImportFrom.proto */
1183 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1184
11851197 /* HasAttr.proto */
11861198 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
11871199
12071219
12081220 /* SetVTable.proto */
12091221 static int __Pyx_SetVtable(PyObject *dict, void *vtable);
1222
1223 /* PyObjectGetAttrStrNoError.proto */
1224 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);
12101225
12111226 /* SetupReduce.proto */
12121227 static int __Pyx_setup_reduce(PyObject* type_obj);
12491264 int py_line, const char *filename);
12501265
12511266 /* CIntToPy.proto */
1267 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value);
1268
1269 /* CIntToPy.proto */
12521270 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1271
1272 /* CIntFromPy.proto */
1273 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
1274
1275 /* CIntFromPy.proto */
1276 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
12531277
12541278 /* CIntFromPy.proto */
12551279 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1256
1257 /* CIntFromPy.proto */
1258 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
12591280
12601281 /* FastTypeChecks.proto */
12611282 #if CYTHON_COMPILING_IN_CPYTHON
13641385
13651386 /* Module declarations from 'cpython' */
13661387
1367 /* Module declarations from 'cpython.bytearray' */
1368
13691388 /* Module declarations from 'clickhouse_driver.bufferedwriter' */
13701389 static PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter = 0;
13711390 static PyTypeObject *__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = 0;
13811400 static PyObject *__pyx_builtin_MemoryError;
13821401 static PyObject *__pyx_builtin_super;
13831402 static PyObject *__pyx_builtin_NotImplementedError;
1403 static PyObject *__pyx_builtin_ValueError;
1404 static const char __pyx_k__2[] = "";
13841405 static const char __pyx_k_new[] = "__new__";
13851406 static const char __pyx_k_dict[] = "__dict__";
13861407 static const char __pyx_k_init[] = "__init__";
13911412 static const char __pyx_k_items[] = "items";
13921413 static const char __pyx_k_super[] = "super";
13931414 static const char __pyx_k_write[] = "write";
1394 static const char __pyx_k_codecs[] = "codecs";
13951415 static const char __pyx_k_encode[] = "encode";
1416 static const char __pyx_k_errors[] = "errors";
13961417 static const char __pyx_k_import[] = "__import__";
1418 static const char __pyx_k_length[] = "length";
13971419 static const char __pyx_k_pickle[] = "pickle";
13981420 static const char __pyx_k_reduce[] = "__reduce__";
13991421 static const char __pyx_k_update[] = "update";
14001422 static const char __pyx_k_varint[] = "varint";
14011423 static const char __pyx_k_bufsize[] = "bufsize";
14021424 static const char __pyx_k_sendall[] = "sendall";
1425 static const char __pyx_k_encoding[] = "encoding";
14031426 static const char __pyx_k_getstate[] = "__getstate__";
14041427 static const char __pyx_k_pyx_type[] = "__pyx_type";
14051428 static const char __pyx_k_setstate[] = "__setstate__";
14061429 static const char __pyx_k_pyx_state[] = "__pyx_state";
14071430 static const char __pyx_k_reduce_ex[] = "__reduce_ex__";
1431 static const char __pyx_k_ValueError[] = "ValueError";
14081432 static const char __pyx_k_compressor[] = "compressor";
14091433 static const char __pyx_k_pyx_result[] = "__pyx_result";
14101434 static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
14111435 static const char __pyx_k_MemoryError[] = "MemoryError";
14121436 static const char __pyx_k_PickleError[] = "PickleError";
1437 static const char __pyx_k_make_varint[] = "make_varint";
14131438 static const char __pyx_k_pyx_checksum[] = "__pyx_checksum";
14141439 static const char __pyx_k_stringsource[] = "stringsource";
1415 static const char __pyx_k_utf_8_encode[] = "utf_8_encode";
1416 static const char __pyx_k_write_varint[] = "write_varint";
14171440 static const char __pyx_k_reduce_cython[] = "__reduce_cython__";
14181441 static const char __pyx_k_BufferedWriter[] = "BufferedWriter";
14191442 static const char __pyx_k_pyx_PickleError[] = "__pyx_PickleError";
14201443 static const char __pyx_k_setstate_cython[] = "__setstate_cython__";
14211444 static const char __pyx_k_write_into_stream[] = "write_into_stream";
1445 static const char __pyx_k_TooLargeStringSize[] = "TooLargeStringSize";
14221446 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
14231447 static const char __pyx_k_NotImplementedError[] = "NotImplementedError";
14241448 static const char __pyx_k_BufferedSocketWriter[] = "BufferedSocketWriter";
1449 static const char __pyx_k_bytes_object_expected[] = "bytes object expected";
14251450 static const char __pyx_k_CompressedBufferedWriter[] = "CompressedBufferedWriter";
14261451 static const char __pyx_k_pyx_unpickle_BufferedWriter[] = "__pyx_unpickle_BufferedWriter";
1452 static const char __pyx_k_write_fixed_strings_as_bytes[] = "write_fixed_strings_as_bytes";
14271453 static const char __pyx_k_pyx_unpickle_BufferedSocketWri[] = "__pyx_unpickle_BufferedSocketWriter";
14281454 static const char __pyx_k_pyx_unpickle_CompressedBuffere[] = "__pyx_unpickle_CompressedBufferedWriter";
14291455 static const char __pyx_k_Incompatible_checksums_s_vs_0x10[] = "Incompatible checksums (%s vs 0x108d208 = (buffer, buffer_size, compressor, position))";
14391465 static PyObject *__pyx_n_s_MemoryError;
14401466 static PyObject *__pyx_n_s_NotImplementedError;
14411467 static PyObject *__pyx_n_s_PickleError;
1468 static PyObject *__pyx_n_s_TooLargeStringSize;
1469 static PyObject *__pyx_n_s_ValueError;
1470 static PyObject *__pyx_n_s__2;
14421471 static PyObject *__pyx_n_s_bufsize;
1472 static PyObject *__pyx_kp_u_bytes_object_expected;
14431473 static PyObject *__pyx_n_s_clickhouse_driver_bufferedwriter;
14441474 static PyObject *__pyx_n_s_cline_in_traceback;
1445 static PyObject *__pyx_n_s_codecs;
14461475 static PyObject *__pyx_n_s_compressor;
14471476 static PyObject *__pyx_n_s_dict;
14481477 static PyObject *__pyx_n_s_encode;
1478 static PyObject *__pyx_n_s_encoding;
1479 static PyObject *__pyx_n_s_errors;
14491480 static PyObject *__pyx_n_s_getstate;
14501481 static PyObject *__pyx_n_s_import;
14511482 static PyObject *__pyx_n_s_init;
14521483 static PyObject *__pyx_n_s_items;
1484 static PyObject *__pyx_n_s_length;
14531485 static PyObject *__pyx_n_s_main;
1486 static PyObject *__pyx_n_s_make_varint;
14541487 static PyObject *__pyx_n_s_name;
14551488 static PyObject *__pyx_n_s_new;
14561489 static PyObject *__pyx_n_s_pickle;
14741507 static PyObject *__pyx_n_s_super;
14751508 static PyObject *__pyx_n_s_test;
14761509 static PyObject *__pyx_n_s_update;
1477 static PyObject *__pyx_n_s_utf_8_encode;
14781510 static PyObject *__pyx_n_s_varint;
14791511 static PyObject *__pyx_n_s_write;
1512 static PyObject *__pyx_n_s_write_fixed_strings_as_bytes;
14801513 static PyObject *__pyx_n_s_write_into_stream;
1481 static PyObject *__pyx_n_s_write_varint;
1482 static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, Py_ssize_t __pyx_v_bufsize); /* proto */
1514 static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_bufsize); /* proto */
14831515 static void __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_2__dealloc__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */
14841516 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_4write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */
14851517 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_6write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
14861518 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_8flush(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */
1487 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, int __pyx_v_encode); /* proto */
1488 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */
1489 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
1519 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_encoding); /* proto */
1520 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length); /* proto */
1521 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding); /* proto */
1522 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self); /* proto */
1523 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state); /* proto */
14901524 static int __pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self, PyObject *__pyx_v_sock, PyObject *__pyx_v_bufsize); /* proto */
14911525 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_2write_into_stream(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self); /* proto */
14921526 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_4__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter *__pyx_v_self); /* proto */
15081542 static PyObject *__pyx_tuple_;
15091543 static PyObject *__pyx_tuple__3;
15101544 static PyObject *__pyx_tuple__5;
1511 static PyObject *__pyx_codeobj__2;
1545 static PyObject *__pyx_tuple__7;
15121546 static PyObject *__pyx_codeobj__4;
15131547 static PyObject *__pyx_codeobj__6;
1548 static PyObject *__pyx_codeobj__8;
15141549 /* Late includes */
15151550
1516 /* "clickhouse_driver/bufferedwriter.pyx":15
1517 * cdef Py_ssize_t position, buffer_size
1518 *
1519 * def __init__(self, Py_ssize_t bufsize): # <<<<<<<<<<<<<<
1551 /* "clickhouse_driver/bufferedwriter.pyx":14
1552 * cdef unsigned long long position, buffer_size
1553 *
1554 * def __init__(self, unsigned long long bufsize): # <<<<<<<<<<<<<<
15201555 * self.buffer = <char *> PyMem_Malloc(bufsize)
15211556 * if not self.buffer:
15221557 */
15241559 /* Python wrapper */
15251560 static int __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
15261561 static int __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1527 Py_ssize_t __pyx_v_bufsize;
1562 unsigned PY_LONG_LONG __pyx_v_bufsize;
1563 int __pyx_lineno = 0;
1564 const char *__pyx_filename = NULL;
1565 int __pyx_clineno = 0;
15281566 int __pyx_r;
15291567 __Pyx_RefNannyDeclarations
15301568 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
15471585 else goto __pyx_L5_argtuple_error;
15481586 }
15491587 if (unlikely(kw_args > 0)) {
1550 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 15, __pyx_L3_error)
1588 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 14, __pyx_L3_error)
15511589 }
15521590 } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
15531591 goto __pyx_L5_argtuple_error;
15541592 } else {
15551593 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15561594 }
1557 __pyx_v_bufsize = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_bufsize == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 15, __pyx_L3_error)
1595 __pyx_v_bufsize = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_bufsize == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 14, __pyx_L3_error)
15581596 }
15591597 goto __pyx_L4_argument_unpacking_done;
15601598 __pyx_L5_argtuple_error:;
1561 __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 15, __pyx_L3_error)
1599 __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 14, __pyx_L3_error)
15621600 __pyx_L3_error:;
15631601 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
15641602 __Pyx_RefNannyFinishContext();
15711609 return __pyx_r;
15721610 }
15731611
1574 static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, Py_ssize_t __pyx_v_bufsize) {
1612 static int __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter___init__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, unsigned PY_LONG_LONG __pyx_v_bufsize) {
15751613 int __pyx_r;
15761614 __Pyx_RefNannyDeclarations
15771615 int __pyx_t_1;
15781616 PyObject *__pyx_t_2 = NULL;
15791617 PyObject *__pyx_t_3 = NULL;
15801618 PyObject *__pyx_t_4 = NULL;
1619 int __pyx_lineno = 0;
1620 const char *__pyx_filename = NULL;
1621 int __pyx_clineno = 0;
15811622 __Pyx_RefNannySetupContext("__init__", 0);
15821623
1583 /* "clickhouse_driver/bufferedwriter.pyx":16
1584 *
1585 * def __init__(self, Py_ssize_t bufsize):
1624 /* "clickhouse_driver/bufferedwriter.pyx":15
1625 *
1626 * def __init__(self, unsigned long long bufsize):
15861627 * self.buffer = <char *> PyMem_Malloc(bufsize) # <<<<<<<<<<<<<<
15871628 * if not self.buffer:
15881629 * raise MemoryError()
15891630 */
15901631 __pyx_v_self->buffer = ((char *)PyMem_Malloc(__pyx_v_bufsize));
15911632
1592 /* "clickhouse_driver/bufferedwriter.pyx":17
1593 * def __init__(self, Py_ssize_t bufsize):
1633 /* "clickhouse_driver/bufferedwriter.pyx":16
1634 * def __init__(self, unsigned long long bufsize):
15941635 * self.buffer = <char *> PyMem_Malloc(bufsize)
15951636 * if not self.buffer: # <<<<<<<<<<<<<<
15961637 * raise MemoryError()
15991640 __pyx_t_1 = ((!(__pyx_v_self->buffer != 0)) != 0);
16001641 if (unlikely(__pyx_t_1)) {
16011642
1602 /* "clickhouse_driver/bufferedwriter.pyx":18
1643 /* "clickhouse_driver/bufferedwriter.pyx":17
16031644 * self.buffer = <char *> PyMem_Malloc(bufsize)
16041645 * if not self.buffer:
16051646 * raise MemoryError() # <<<<<<<<<<<<<<
16061647 *
16071648 * self.position = 0
16081649 */
1609 PyErr_NoMemory(); __PYX_ERR(0, 18, __pyx_L1_error)
1610
1611 /* "clickhouse_driver/bufferedwriter.pyx":17
1612 * def __init__(self, Py_ssize_t bufsize):
1650 PyErr_NoMemory(); __PYX_ERR(0, 17, __pyx_L1_error)
1651
1652 /* "clickhouse_driver/bufferedwriter.pyx":16
1653 * def __init__(self, unsigned long long bufsize):
16131654 * self.buffer = <char *> PyMem_Malloc(bufsize)
16141655 * if not self.buffer: # <<<<<<<<<<<<<<
16151656 * raise MemoryError()
16171658 */
16181659 }
16191660
1620 /* "clickhouse_driver/bufferedwriter.pyx":20
1661 /* "clickhouse_driver/bufferedwriter.pyx":19
16211662 * raise MemoryError()
16221663 *
16231664 * self.position = 0 # <<<<<<<<<<<<<<
16261667 */
16271668 __pyx_v_self->position = 0;
16281669
1629 /* "clickhouse_driver/bufferedwriter.pyx":21
1670 /* "clickhouse_driver/bufferedwriter.pyx":20
16301671 *
16311672 * self.position = 0
16321673 * self.buffer_size = bufsize # <<<<<<<<<<<<<<
16351676 */
16361677 __pyx_v_self->buffer_size = __pyx_v_bufsize;
16371678
1638 /* "clickhouse_driver/bufferedwriter.pyx":23
1679 /* "clickhouse_driver/bufferedwriter.pyx":22
16391680 * self.buffer_size = bufsize
16401681 *
16411682 * super(BufferedWriter, self).__init__() # <<<<<<<<<<<<<<
16421683 *
16431684 * def __dealloc__(self):
16441685 */
1645 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)
1686 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
16461687 __Pyx_GOTREF(__pyx_t_3);
16471688 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter));
16481689 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter));
16501691 __Pyx_INCREF(((PyObject *)__pyx_v_self));
16511692 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
16521693 PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_v_self));
1653 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)
1694 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error)
16541695 __Pyx_GOTREF(__pyx_t_4);
16551696 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1656 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 23, __pyx_L1_error)
1697 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 22, __pyx_L1_error)
16571698 __Pyx_GOTREF(__pyx_t_3);
16581699 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16591700 __pyx_t_4 = NULL;
16681709 }
16691710 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
16701711 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1671 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error)
1712 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error)
16721713 __Pyx_GOTREF(__pyx_t_2);
16731714 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16741715 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16751716
1676 /* "clickhouse_driver/bufferedwriter.pyx":15
1677 * cdef Py_ssize_t position, buffer_size
1678 *
1679 * def __init__(self, Py_ssize_t bufsize): # <<<<<<<<<<<<<<
1717 /* "clickhouse_driver/bufferedwriter.pyx":14
1718 * cdef unsigned long long position, buffer_size
1719 *
1720 * def __init__(self, unsigned long long bufsize): # <<<<<<<<<<<<<<
16801721 * self.buffer = <char *> PyMem_Malloc(bufsize)
16811722 * if not self.buffer:
16821723 */
16951736 return __pyx_r;
16961737 }
16971738
1698 /* "clickhouse_driver/bufferedwriter.pyx":25
1739 /* "clickhouse_driver/bufferedwriter.pyx":24
16991740 * super(BufferedWriter, self).__init__()
17001741 *
17011742 * def __dealloc__(self): # <<<<<<<<<<<<<<
17181759 __Pyx_RefNannyDeclarations
17191760 __Pyx_RefNannySetupContext("__dealloc__", 0);
17201761
1721 /* "clickhouse_driver/bufferedwriter.pyx":26
1762 /* "clickhouse_driver/bufferedwriter.pyx":25
17221763 *
17231764 * def __dealloc__(self):
17241765 * PyMem_Free(self.buffer) # <<<<<<<<<<<<<<
17271768 */
17281769 PyMem_Free(__pyx_v_self->buffer);
17291770
1730 /* "clickhouse_driver/bufferedwriter.pyx":25
1771 /* "clickhouse_driver/bufferedwriter.pyx":24
17311772 * super(BufferedWriter, self).__init__()
17321773 *
17331774 * def __dealloc__(self): # <<<<<<<<<<<<<<
17391780 __Pyx_RefNannyFinishContext();
17401781 }
17411782
1742 /* "clickhouse_driver/bufferedwriter.pyx":28
1783 /* "clickhouse_driver/bufferedwriter.pyx":27
17431784 * PyMem_Free(self.buffer)
17441785 *
17451786 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
17551796 PyObject *__pyx_t_2 = NULL;
17561797 PyObject *__pyx_t_3 = NULL;
17571798 PyObject *__pyx_t_4 = NULL;
1799 int __pyx_lineno = 0;
1800 const char *__pyx_filename = NULL;
1801 int __pyx_clineno = 0;
17581802 __Pyx_RefNannySetupContext("write_into_stream", 0);
17591803 /* Check if called by wrapper */
17601804 if (unlikely(__pyx_skip_dispatch)) ;
17651809 if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
17661810 PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
17671811 #endif
1768 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
1812 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
17691813 __Pyx_GOTREF(__pyx_t_1);
17701814 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_5write_into_stream)) {
17711815 __Pyx_XDECREF(__pyx_r);
17821826 }
17831827 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
17841828 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1785 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 28, __pyx_L1_error)
1829 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error)
17861830 __Pyx_GOTREF(__pyx_t_2);
17871831 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
17881832 __pyx_r = __pyx_t_2;
18031847 #endif
18041848 }
18051849
1806 /* "clickhouse_driver/bufferedwriter.pyx":29
1850 /* "clickhouse_driver/bufferedwriter.pyx":28
18071851 *
18081852 * cpdef write_into_stream(self):
18091853 * raise NotImplementedError # <<<<<<<<<<<<<<
18111855 * cpdef write(self, data):
18121856 */
18131857 __Pyx_Raise(__pyx_builtin_NotImplementedError, 0, 0, 0);
1814 __PYX_ERR(0, 29, __pyx_L1_error)
1815
1816 /* "clickhouse_driver/bufferedwriter.pyx":28
1858 __PYX_ERR(0, 28, __pyx_L1_error)
1859
1860 /* "clickhouse_driver/bufferedwriter.pyx":27
18171861 * PyMem_Free(self.buffer)
18181862 *
18191863 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
18521896 PyObject *__pyx_r = NULL;
18531897 __Pyx_RefNannyDeclarations
18541898 PyObject *__pyx_t_1 = NULL;
1899 int __pyx_lineno = 0;
1900 const char *__pyx_filename = NULL;
1901 int __pyx_clineno = 0;
18551902 __Pyx_RefNannySetupContext("write_into_stream", 0);
18561903 __Pyx_XDECREF(__pyx_r);
1857 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
1904 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
18581905 __Pyx_GOTREF(__pyx_t_1);
18591906 __pyx_r = __pyx_t_1;
18601907 __pyx_t_1 = 0;
18711918 return __pyx_r;
18721919 }
18731920
1874 /* "clickhouse_driver/bufferedwriter.pyx":31
1921 /* "clickhouse_driver/bufferedwriter.pyx":30
18751922 * raise NotImplementedError
18761923 *
18771924 * cpdef write(self, data): # <<<<<<<<<<<<<<
1878 * cdef Py_ssize_t written = 0
1879 * cdef Py_ssize_t to_write, size
1925 * cdef unsigned long long size, written = 0
1926 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data)
18801927 */
18811928
18821929 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write(PyObject *__pyx_v_self, PyObject *__pyx_v_data); /*proto*/
18831930 static PyObject *__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_data, int __pyx_skip_dispatch) {
1884 Py_ssize_t __pyx_v_written;
1885 Py_ssize_t __pyx_v_size;
1886 Py_ssize_t __pyx_v_data_len;
1931 unsigned PY_LONG_LONG __pyx_v_size;
1932 unsigned PY_LONG_LONG __pyx_v_written;
1933 unsigned PY_LONG_LONG __pyx_v_data_len;
18871934 char *__pyx_v_c_data;
18881935 PyObject *__pyx_r = NULL;
18891936 __Pyx_RefNannyDeclarations
18911938 PyObject *__pyx_t_2 = NULL;
18921939 PyObject *__pyx_t_3 = NULL;
18931940 PyObject *__pyx_t_4 = NULL;
1894 Py_ssize_t __pyx_t_5;
1895 int __pyx_t_6;
1896 char *__pyx_t_7;
1897 Py_ssize_t __pyx_t_8;
1898 Py_ssize_t __pyx_t_9;
1941 int __pyx_t_5;
1942 unsigned PY_LONG_LONG __pyx_t_6;
1943 unsigned PY_LONG_LONG __pyx_t_7;
1944 unsigned PY_LONG_LONG __pyx_t_8;
1945 int __pyx_lineno = 0;
1946 const char *__pyx_filename = NULL;
1947 int __pyx_clineno = 0;
18991948 __Pyx_RefNannySetupContext("write", 0);
19001949 /* Check if called by wrapper */
19011950 if (unlikely(__pyx_skip_dispatch)) ;
19061955 if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
19071956 PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
19081957 #endif
1909 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
1958 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
19101959 __Pyx_GOTREF(__pyx_t_1);
19111960 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write)) {
19121961 __Pyx_XDECREF(__pyx_r);
19231972 }
19241973 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_data) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_data);
19251974 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1926 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 31, __pyx_L1_error)
1975 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 30, __pyx_L1_error)
19271976 __Pyx_GOTREF(__pyx_t_2);
19281977 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
19291978 __pyx_r = __pyx_t_2;
19441993 #endif
19451994 }
19461995
1996 /* "clickhouse_driver/bufferedwriter.pyx":31
1997 *
1998 * cpdef write(self, data):
1999 * cdef unsigned long long size, written = 0 # <<<<<<<<<<<<<<
2000 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data)
2001 * cdef char* c_data = PyBytes_AS_STRING(data)
2002 */
2003 __pyx_v_written = 0;
2004
19472005 /* "clickhouse_driver/bufferedwriter.pyx":32
1948 *
19492006 * cpdef write(self, data):
1950 * cdef Py_ssize_t written = 0 # <<<<<<<<<<<<<<
1951 * cdef Py_ssize_t to_write, size
1952 * cdef Py_ssize_t data_len = len(data)
1953 */
1954 __pyx_v_written = 0;
1955
1956 /* "clickhouse_driver/bufferedwriter.pyx":34
1957 * cdef Py_ssize_t written = 0
1958 * cdef Py_ssize_t to_write, size
1959 * cdef Py_ssize_t data_len = len(data) # <<<<<<<<<<<<<<
1960 * cdef char* c_data
1961 *
1962 */
1963 __pyx_t_5 = PyObject_Length(__pyx_v_data); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 34, __pyx_L1_error)
1964 __pyx_v_data_len = __pyx_t_5;
1965
1966 /* "clickhouse_driver/bufferedwriter.pyx":37
1967 * cdef char* c_data
1968 *
1969 * if PyBytes_Check(data): # <<<<<<<<<<<<<<
1970 * c_data = PyBytes_AsString(data)
1971 * else:
1972 */
1973 __pyx_t_6 = (PyBytes_Check(__pyx_v_data) != 0);
1974 if (__pyx_t_6) {
1975
1976 /* "clickhouse_driver/bufferedwriter.pyx":38
1977 *
1978 * if PyBytes_Check(data):
1979 * c_data = PyBytes_AsString(data) # <<<<<<<<<<<<<<
1980 * else:
1981 * c_data = PyByteArray_AsString(data)
1982 */
1983 __pyx_t_7 = PyBytes_AsString(__pyx_v_data); if (unlikely(__pyx_t_7 == ((char *)NULL))) __PYX_ERR(0, 38, __pyx_L1_error)
1984 __pyx_v_c_data = __pyx_t_7;
1985
1986 /* "clickhouse_driver/bufferedwriter.pyx":37
1987 * cdef char* c_data
1988 *
1989 * if PyBytes_Check(data): # <<<<<<<<<<<<<<
1990 * c_data = PyBytes_AsString(data)
1991 * else:
1992 */
1993 goto __pyx_L3;
1994 }
1995
1996 /* "clickhouse_driver/bufferedwriter.pyx":40
1997 * c_data = PyBytes_AsString(data)
1998 * else:
1999 * c_data = PyByteArray_AsString(data) # <<<<<<<<<<<<<<
2007 * cdef unsigned long long size, written = 0
2008 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data) # <<<<<<<<<<<<<<
2009 * cdef char* c_data = PyBytes_AS_STRING(data)
2010 *
2011 */
2012 __pyx_v_data_len = PyBytes_GET_SIZE(__pyx_v_data);
2013
2014 /* "clickhouse_driver/bufferedwriter.pyx":33
2015 * cdef unsigned long long size, written = 0
2016 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data)
2017 * cdef char* c_data = PyBytes_AS_STRING(data) # <<<<<<<<<<<<<<
20002018 *
20012019 * while written < data_len:
20022020 */
2003 /*else*/ {
2004 __pyx_v_c_data = PyByteArray_AsString(__pyx_v_data);
2005 }
2006 __pyx_L3:;
2007
2008 /* "clickhouse_driver/bufferedwriter.pyx":42
2009 * c_data = PyByteArray_AsString(data)
2021 __pyx_v_c_data = PyBytes_AS_STRING(__pyx_v_data);
2022
2023 /* "clickhouse_driver/bufferedwriter.pyx":35
2024 * cdef char* c_data = PyBytes_AS_STRING(data)
20102025 *
20112026 * while written < data_len: # <<<<<<<<<<<<<<
20122027 * size = min(data_len - written, self.buffer_size - self.position)
20132028 * memcpy(&self.buffer[self.position], &c_data[written], size)
20142029 */
20152030 while (1) {
2016 __pyx_t_6 = ((__pyx_v_written < __pyx_v_data_len) != 0);
2017 if (!__pyx_t_6) break;
2018
2019 /* "clickhouse_driver/bufferedwriter.pyx":43
2031 __pyx_t_5 = ((__pyx_v_written < __pyx_v_data_len) != 0);
2032 if (!__pyx_t_5) break;
2033
2034 /* "clickhouse_driver/bufferedwriter.pyx":36
20202035 *
20212036 * while written < data_len:
20222037 * size = min(data_len - written, self.buffer_size - self.position) # <<<<<<<<<<<<<<
20232038 * memcpy(&self.buffer[self.position], &c_data[written], size)
20242039 *
20252040 */
2026 __pyx_t_5 = (__pyx_v_self->buffer_size - __pyx_v_self->position);
2027 __pyx_t_8 = (__pyx_v_data_len - __pyx_v_written);
2028 if (((__pyx_t_5 < __pyx_t_8) != 0)) {
2029 __pyx_t_9 = __pyx_t_5;
2041 __pyx_t_6 = (__pyx_v_self->buffer_size - __pyx_v_self->position);
2042 __pyx_t_7 = (__pyx_v_data_len - __pyx_v_written);
2043 if (((__pyx_t_6 < __pyx_t_7) != 0)) {
2044 __pyx_t_8 = __pyx_t_6;
20302045 } else {
2031 __pyx_t_9 = __pyx_t_8;
2032 }
2033 __pyx_v_size = __pyx_t_9;
2034
2035 /* "clickhouse_driver/bufferedwriter.pyx":44
2046 __pyx_t_8 = __pyx_t_7;
2047 }
2048 __pyx_v_size = __pyx_t_8;
2049
2050 /* "clickhouse_driver/bufferedwriter.pyx":37
20362051 * while written < data_len:
20372052 * size = min(data_len - written, self.buffer_size - self.position)
20382053 * memcpy(&self.buffer[self.position], &c_data[written], size) # <<<<<<<<<<<<<<
20412056 */
20422057 (void)(memcpy((&(__pyx_v_self->buffer[__pyx_v_self->position])), (&(__pyx_v_c_data[__pyx_v_written])), __pyx_v_size));
20432058
2044 /* "clickhouse_driver/bufferedwriter.pyx":46
2059 /* "clickhouse_driver/bufferedwriter.pyx":39
20452060 * memcpy(&self.buffer[self.position], &c_data[written], size)
20462061 *
20472062 * if self.position == self.buffer_size: # <<<<<<<<<<<<<<
20482063 * self.write_into_stream()
20492064 *
20502065 */
2051 __pyx_t_6 = ((__pyx_v_self->position == __pyx_v_self->buffer_size) != 0);
2052 if (__pyx_t_6) {
2053
2054 /* "clickhouse_driver/bufferedwriter.pyx":47
2066 __pyx_t_5 = ((__pyx_v_self->position == __pyx_v_self->buffer_size) != 0);
2067 if (__pyx_t_5) {
2068
2069 /* "clickhouse_driver/bufferedwriter.pyx":40
20552070 *
20562071 * if self.position == self.buffer_size:
20572072 * self.write_into_stream() # <<<<<<<<<<<<<<
20582073 *
20592074 * self.position += size
20602075 */
2061 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error)
2076 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
20622077 __Pyx_GOTREF(__pyx_t_1);
20632078 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20642079
2065 /* "clickhouse_driver/bufferedwriter.pyx":46
2080 /* "clickhouse_driver/bufferedwriter.pyx":39
20662081 * memcpy(&self.buffer[self.position], &c_data[written], size)
20672082 *
20682083 * if self.position == self.buffer_size: # <<<<<<<<<<<<<<
20712086 */
20722087 }
20732088
2074 /* "clickhouse_driver/bufferedwriter.pyx":49
2089 /* "clickhouse_driver/bufferedwriter.pyx":42
20752090 * self.write_into_stream()
20762091 *
20772092 * self.position += size # <<<<<<<<<<<<<<
20802095 */
20812096 __pyx_v_self->position = (__pyx_v_self->position + __pyx_v_size);
20822097
2083 /* "clickhouse_driver/bufferedwriter.pyx":50
2098 /* "clickhouse_driver/bufferedwriter.pyx":43
20842099 *
20852100 * self.position += size
20862101 * written += size # <<<<<<<<<<<<<<
20902105 __pyx_v_written = (__pyx_v_written + __pyx_v_size);
20912106 }
20922107
2093 /* "clickhouse_driver/bufferedwriter.pyx":31
2108 /* "clickhouse_driver/bufferedwriter.pyx":30
20942109 * raise NotImplementedError
20952110 *
20962111 * cpdef write(self, data): # <<<<<<<<<<<<<<
2097 * cdef Py_ssize_t written = 0
2098 * cdef Py_ssize_t to_write, size
2112 * cdef unsigned long long size, written = 0
2113 * cdef unsigned long long data_len = PyBytes_GET_SIZE(data)
20992114 */
21002115
21012116 /* function exit code */
21312146 PyObject *__pyx_r = NULL;
21322147 __Pyx_RefNannyDeclarations
21332148 PyObject *__pyx_t_1 = NULL;
2149 int __pyx_lineno = 0;
2150 const char *__pyx_filename = NULL;
2151 int __pyx_clineno = 0;
21342152 __Pyx_RefNannySetupContext("write", 0);
21352153 __Pyx_XDECREF(__pyx_r);
2136 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(__pyx_v_self, __pyx_v_data, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
2154 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write(__pyx_v_self, __pyx_v_data, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
21372155 __Pyx_GOTREF(__pyx_t_1);
21382156 __pyx_r = __pyx_t_1;
21392157 __pyx_t_1 = 0;
21502168 return __pyx_r;
21512169 }
21522170
2153 /* "clickhouse_driver/bufferedwriter.pyx":52
2171 /* "clickhouse_driver/bufferedwriter.pyx":45
21542172 * written += size
21552173 *
21562174 * def flush(self): # <<<<<<<<<<<<<<
21752193 PyObject *__pyx_r = NULL;
21762194 __Pyx_RefNannyDeclarations
21772195 PyObject *__pyx_t_1 = NULL;
2196 int __pyx_lineno = 0;
2197 const char *__pyx_filename = NULL;
2198 int __pyx_clineno = 0;
21782199 __Pyx_RefNannySetupContext("flush", 0);
21792200
2180 /* "clickhouse_driver/bufferedwriter.pyx":53
2201 /* "clickhouse_driver/bufferedwriter.pyx":46
21812202 *
21822203 * def flush(self):
21832204 * self.write_into_stream() # <<<<<<<<<<<<<<
21842205 *
2185 * def write_strings(self, items, int encode=0):
2186 */
2187 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
2206 * def write_strings(self, items, encoding=None):
2207 */
2208 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write_into_stream(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 46, __pyx_L1_error)
21882209 __Pyx_GOTREF(__pyx_t_1);
21892210 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21902211
2191 /* "clickhouse_driver/bufferedwriter.pyx":52
2212 /* "clickhouse_driver/bufferedwriter.pyx":45
21922213 * written += size
21932214 *
21942215 * def flush(self): # <<<<<<<<<<<<<<
22092230 return __pyx_r;
22102231 }
22112232
2212 /* "clickhouse_driver/bufferedwriter.pyx":55
2233 /* "clickhouse_driver/bufferedwriter.pyx":48
22132234 * self.write_into_stream()
22142235 *
2215 * def write_strings(self, items, int encode=0): # <<<<<<<<<<<<<<
2216 * for value in items:
2217 * if encode:
2236 * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<<
2237 * cdef int do_encode = encoding is not None
2238 *
22182239 */
22192240
22202241 /* Python wrapper */
22212242 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
22222243 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
22232244 PyObject *__pyx_v_items = 0;
2224 int __pyx_v_encode;
2245 PyObject *__pyx_v_encoding = 0;
2246 int __pyx_lineno = 0;
2247 const char *__pyx_filename = NULL;
2248 int __pyx_clineno = 0;
22252249 PyObject *__pyx_r = 0;
22262250 __Pyx_RefNannyDeclarations
22272251 __Pyx_RefNannySetupContext("write_strings (wrapper)", 0);
22282252 {
2229 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_encode,0};
2253 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_encoding,0};
2254 PyObject* values[2] = {0,0};
2255 values[1] = ((PyObject *)Py_None);
2256 if (unlikely(__pyx_kwds)) {
2257 Py_ssize_t kw_args;
2258 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2259 switch (pos_args) {
2260 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2261 CYTHON_FALLTHROUGH;
2262 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2263 CYTHON_FALLTHROUGH;
2264 case 0: break;
2265 default: goto __pyx_L5_argtuple_error;
2266 }
2267 kw_args = PyDict_Size(__pyx_kwds);
2268 switch (pos_args) {
2269 case 0:
2270 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
2271 else goto __pyx_L5_argtuple_error;
2272 CYTHON_FALLTHROUGH;
2273 case 1:
2274 if (kw_args > 0) {
2275 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoding);
2276 if (value) { values[1] = value; kw_args--; }
2277 }
2278 }
2279 if (unlikely(kw_args > 0)) {
2280 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_strings") < 0)) __PYX_ERR(0, 48, __pyx_L3_error)
2281 }
2282 } else {
2283 switch (PyTuple_GET_SIZE(__pyx_args)) {
2284 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2285 CYTHON_FALLTHROUGH;
2286 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2287 break;
2288 default: goto __pyx_L5_argtuple_error;
2289 }
2290 }
2291 __pyx_v_items = values[0];
2292 __pyx_v_encoding = values[1];
2293 }
2294 goto __pyx_L4_argument_unpacking_done;
2295 __pyx_L5_argtuple_error:;
2296 __Pyx_RaiseArgtupleInvalid("write_strings", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 48, __pyx_L3_error)
2297 __pyx_L3_error:;
2298 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2299 __Pyx_RefNannyFinishContext();
2300 return NULL;
2301 __pyx_L4_argument_unpacking_done:;
2302 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_encoding);
2303
2304 /* function exit code */
2305 __Pyx_RefNannyFinishContext();
2306 return __pyx_r;
2307 }
2308
2309 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_encoding) {
2310 int __pyx_v_do_encode;
2311 PyObject *__pyx_v_value = NULL;
2312 PyObject *__pyx_r = NULL;
2313 __Pyx_RefNannyDeclarations
2314 int __pyx_t_1;
2315 PyObject *__pyx_t_2 = NULL;
2316 Py_ssize_t __pyx_t_3;
2317 PyObject *(*__pyx_t_4)(PyObject *);
2318 PyObject *__pyx_t_5 = NULL;
2319 PyObject *__pyx_t_6 = NULL;
2320 PyObject *__pyx_t_7 = NULL;
2321 PyObject *__pyx_t_8 = NULL;
2322 int __pyx_lineno = 0;
2323 const char *__pyx_filename = NULL;
2324 int __pyx_clineno = 0;
2325 __Pyx_RefNannySetupContext("write_strings", 0);
2326
2327 /* "clickhouse_driver/bufferedwriter.pyx":49
2328 *
2329 * def write_strings(self, items, encoding=None):
2330 * cdef int do_encode = encoding is not None # <<<<<<<<<<<<<<
2331 *
2332 * for value in items:
2333 */
2334 __pyx_t_1 = (__pyx_v_encoding != Py_None);
2335 __pyx_v_do_encode = __pyx_t_1;
2336
2337 /* "clickhouse_driver/bufferedwriter.pyx":51
2338 * cdef int do_encode = encoding is not None
2339 *
2340 * for value in items: # <<<<<<<<<<<<<<
2341 * if not PyBytes_Check(value):
2342 * if do_encode:
2343 */
2344 if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
2345 __pyx_t_2 = __pyx_v_items; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
2346 __pyx_t_4 = NULL;
2347 } else {
2348 __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 51, __pyx_L1_error)
2349 __Pyx_GOTREF(__pyx_t_2);
2350 __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
2351 }
2352 for (;;) {
2353 if (likely(!__pyx_t_4)) {
2354 if (likely(PyList_CheckExact(__pyx_t_2))) {
2355 if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
2356 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2357 __pyx_t_5 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error)
2358 #else
2359 __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2360 __Pyx_GOTREF(__pyx_t_5);
2361 #endif
2362 } else {
2363 if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
2364 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2365 __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_5); __pyx_t_3++; if (unlikely(0 < 0)) __PYX_ERR(0, 51, __pyx_L1_error)
2366 #else
2367 __pyx_t_5 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 51, __pyx_L1_error)
2368 __Pyx_GOTREF(__pyx_t_5);
2369 #endif
2370 }
2371 } else {
2372 __pyx_t_5 = __pyx_t_4(__pyx_t_2);
2373 if (unlikely(!__pyx_t_5)) {
2374 PyObject* exc_type = PyErr_Occurred();
2375 if (exc_type) {
2376 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2377 else __PYX_ERR(0, 51, __pyx_L1_error)
2378 }
2379 break;
2380 }
2381 __Pyx_GOTREF(__pyx_t_5);
2382 }
2383 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5);
2384 __pyx_t_5 = 0;
2385
2386 /* "clickhouse_driver/bufferedwriter.pyx":52
2387 *
2388 * for value in items:
2389 * if not PyBytes_Check(value): # <<<<<<<<<<<<<<
2390 * if do_encode:
2391 * value = value.encode(encoding)
2392 */
2393 __pyx_t_1 = ((!(PyBytes_Check(__pyx_v_value) != 0)) != 0);
2394 if (__pyx_t_1) {
2395
2396 /* "clickhouse_driver/bufferedwriter.pyx":53
2397 * for value in items:
2398 * if not PyBytes_Check(value):
2399 * if do_encode: # <<<<<<<<<<<<<<
2400 * value = value.encode(encoding)
2401 * else:
2402 */
2403 __pyx_t_1 = (__pyx_v_do_encode != 0);
2404 if (likely(__pyx_t_1)) {
2405
2406 /* "clickhouse_driver/bufferedwriter.pyx":54
2407 * if not PyBytes_Check(value):
2408 * if do_encode:
2409 * value = value.encode(encoding) # <<<<<<<<<<<<<<
2410 * else:
2411 * raise ValueError('bytes object expected')
2412 */
2413 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_encode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 54, __pyx_L1_error)
2414 __Pyx_GOTREF(__pyx_t_6);
2415 __pyx_t_7 = NULL;
2416 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) {
2417 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
2418 if (likely(__pyx_t_7)) {
2419 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2420 __Pyx_INCREF(__pyx_t_7);
2421 __Pyx_INCREF(function);
2422 __Pyx_DECREF_SET(__pyx_t_6, function);
2423 }
2424 }
2425 __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_7, __pyx_v_encoding) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_encoding);
2426 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2427 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 54, __pyx_L1_error)
2428 __Pyx_GOTREF(__pyx_t_5);
2429 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2430 __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_5);
2431 __pyx_t_5 = 0;
2432
2433 /* "clickhouse_driver/bufferedwriter.pyx":53
2434 * for value in items:
2435 * if not PyBytes_Check(value):
2436 * if do_encode: # <<<<<<<<<<<<<<
2437 * value = value.encode(encoding)
2438 * else:
2439 */
2440 goto __pyx_L6;
2441 }
2442
2443 /* "clickhouse_driver/bufferedwriter.pyx":56
2444 * value = value.encode(encoding)
2445 * else:
2446 * raise ValueError('bytes object expected') # <<<<<<<<<<<<<<
2447 *
2448 * self.write(make_varint(PyBytes_GET_SIZE(value)))
2449 */
2450 /*else*/ {
2451 __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 56, __pyx_L1_error)
2452 __Pyx_GOTREF(__pyx_t_5);
2453 __Pyx_Raise(__pyx_t_5, 0, 0, 0);
2454 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2455 __PYX_ERR(0, 56, __pyx_L1_error)
2456 }
2457 __pyx_L6:;
2458
2459 /* "clickhouse_driver/bufferedwriter.pyx":52
2460 *
2461 * for value in items:
2462 * if not PyBytes_Check(value): # <<<<<<<<<<<<<<
2463 * if do_encode:
2464 * value = value.encode(encoding)
2465 */
2466 }
2467
2468 /* "clickhouse_driver/bufferedwriter.pyx":58
2469 * raise ValueError('bytes object expected')
2470 *
2471 * self.write(make_varint(PyBytes_GET_SIZE(value))) # <<<<<<<<<<<<<<
2472 * self.write(value)
2473 *
2474 */
2475 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_make_varint); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
2476 __Pyx_GOTREF(__pyx_t_6);
2477 __pyx_t_7 = PyInt_FromSsize_t(PyBytes_GET_SIZE(__pyx_v_value)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 58, __pyx_L1_error)
2478 __Pyx_GOTREF(__pyx_t_7);
2479 __pyx_t_8 = NULL;
2480 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
2481 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
2482 if (likely(__pyx_t_8)) {
2483 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2484 __Pyx_INCREF(__pyx_t_8);
2485 __Pyx_INCREF(function);
2486 __Pyx_DECREF_SET(__pyx_t_6, function);
2487 }
2488 }
2489 __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7);
2490 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2491 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2492 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 58, __pyx_L1_error)
2493 __Pyx_GOTREF(__pyx_t_5);
2494 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2495 __pyx_t_6 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_5, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 58, __pyx_L1_error)
2496 __Pyx_GOTREF(__pyx_t_6);
2497 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2498 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2499
2500 /* "clickhouse_driver/bufferedwriter.pyx":59
2501 *
2502 * self.write(make_varint(PyBytes_GET_SIZE(value)))
2503 * self.write(value) # <<<<<<<<<<<<<<
2504 *
2505 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length):
2506 */
2507 __pyx_t_6 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_v_value, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 59, __pyx_L1_error)
2508 __Pyx_GOTREF(__pyx_t_6);
2509 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2510
2511 /* "clickhouse_driver/bufferedwriter.pyx":51
2512 * cdef int do_encode = encoding is not None
2513 *
2514 * for value in items: # <<<<<<<<<<<<<<
2515 * if not PyBytes_Check(value):
2516 * if do_encode:
2517 */
2518 }
2519 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2520
2521 /* "clickhouse_driver/bufferedwriter.pyx":48
2522 * self.write_into_stream()
2523 *
2524 * def write_strings(self, items, encoding=None): # <<<<<<<<<<<<<<
2525 * cdef int do_encode = encoding is not None
2526 *
2527 */
2528
2529 /* function exit code */
2530 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2531 goto __pyx_L0;
2532 __pyx_L1_error:;
2533 __Pyx_XDECREF(__pyx_t_2);
2534 __Pyx_XDECREF(__pyx_t_5);
2535 __Pyx_XDECREF(__pyx_t_6);
2536 __Pyx_XDECREF(__pyx_t_7);
2537 __Pyx_XDECREF(__pyx_t_8);
2538 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2539 __pyx_r = NULL;
2540 __pyx_L0:;
2541 __Pyx_XDECREF(__pyx_v_value);
2542 __Pyx_XGIVEREF(__pyx_r);
2543 __Pyx_RefNannyFinishContext();
2544 return __pyx_r;
2545 }
2546
2547 /* "clickhouse_driver/bufferedwriter.pyx":61
2548 * self.write(value)
2549 *
2550 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): # <<<<<<<<<<<<<<
2551 * cdef Py_ssize_t buf_pos = 0
2552 * cdef Py_ssize_t items_buf_size = length * len(items)
2553 */
2554
2555 /* Python wrapper */
2556 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2557 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2558 PyObject *__pyx_v_items = 0;
2559 Py_ssize_t __pyx_v_length;
2560 int __pyx_lineno = 0;
2561 const char *__pyx_filename = NULL;
2562 int __pyx_clineno = 0;
2563 PyObject *__pyx_r = 0;
2564 __Pyx_RefNannyDeclarations
2565 __Pyx_RefNannySetupContext("write_fixed_strings_as_bytes (wrapper)", 0);
2566 {
2567 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_length,0};
22302568 PyObject* values[2] = {0,0};
22312569 if (unlikely(__pyx_kwds)) {
22322570 Py_ssize_t kw_args;
22462584 else goto __pyx_L5_argtuple_error;
22472585 CYTHON_FALLTHROUGH;
22482586 case 1:
2249 if (kw_args > 0) {
2250 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encode);
2251 if (value) { values[1] = value; kw_args--; }
2587 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_length)) != 0)) kw_args--;
2588 else {
2589 __Pyx_RaiseArgtupleInvalid("write_fixed_strings_as_bytes", 1, 2, 2, 1); __PYX_ERR(0, 61, __pyx_L3_error)
22522590 }
22532591 }
22542592 if (unlikely(kw_args > 0)) {
2255 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_strings") < 0)) __PYX_ERR(0, 55, __pyx_L3_error)
2593 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_fixed_strings_as_bytes") < 0)) __PYX_ERR(0, 61, __pyx_L3_error)
22562594 }
2595 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2596 goto __pyx_L5_argtuple_error;
22572597 } else {
2258 switch (PyTuple_GET_SIZE(__pyx_args)) {
2259 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2260 CYTHON_FALLTHROUGH;
2261 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2262 break;
2263 default: goto __pyx_L5_argtuple_error;
2264 }
2598 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2599 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
22652600 }
22662601 __pyx_v_items = values[0];
2267 if (values[1]) {
2268 __pyx_v_encode = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_encode == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 55, __pyx_L3_error)
2269 } else {
2270 __pyx_v_encode = ((int)0);
2271 }
2602 __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 61, __pyx_L3_error)
22722603 }
22732604 goto __pyx_L4_argument_unpacking_done;
22742605 __pyx_L5_argtuple_error:;
2275 __Pyx_RaiseArgtupleInvalid("write_strings", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 55, __pyx_L3_error)
2606 __Pyx_RaiseArgtupleInvalid("write_fixed_strings_as_bytes", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 61, __pyx_L3_error)
22762607 __pyx_L3_error:;
2277 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2608 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
22782609 __Pyx_RefNannyFinishContext();
22792610 return NULL;
22802611 __pyx_L4_argument_unpacking_done:;
2281 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_encode);
2612 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_length);
22822613
22832614 /* function exit code */
22842615 __Pyx_RefNannyFinishContext();
22852616 return __pyx_r;
22862617 }
22872618
2288 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_10write_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, int __pyx_v_encode) {
2619 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12write_fixed_strings_as_bytes(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length) {
2620 Py_ssize_t __pyx_v_buf_pos;
2621 Py_ssize_t __pyx_v_items_buf_size;
2622 char *__pyx_v_c_value;
2623 char *__pyx_v_items_buf;
22892624 PyObject *__pyx_v_value = NULL;
2625 Py_ssize_t __pyx_v_value_len;
22902626 PyObject *__pyx_r = NULL;
22912627 __Pyx_RefNannyDeclarations
2292 PyObject *__pyx_t_1 = NULL;
2293 Py_ssize_t __pyx_t_2;
2294 PyObject *(*__pyx_t_3)(PyObject *);
2295 PyObject *__pyx_t_4 = NULL;
2296 int __pyx_t_5;
2297 int __pyx_t_6;
2628 Py_ssize_t __pyx_t_1;
2629 int __pyx_t_2;
2630 PyObject *__pyx_t_3 = NULL;
2631 PyObject *(*__pyx_t_4)(PyObject *);
2632 PyObject *__pyx_t_5 = NULL;
2633 Py_ssize_t __pyx_t_6;
22982634 PyObject *__pyx_t_7 = NULL;
22992635 PyObject *__pyx_t_8 = NULL;
2300 Py_ssize_t __pyx_t_9;
2301 PyObject *__pyx_t_10 = NULL;
2302 int __pyx_t_11;
2303 PyObject *__pyx_t_12 = NULL;
2304 __Pyx_RefNannySetupContext("write_strings", 0);
2305
2306 /* "clickhouse_driver/bufferedwriter.pyx":56
2307 *
2308 * def write_strings(self, items, int encode=0):
2636 char *__pyx_t_9;
2637 int __pyx_lineno = 0;
2638 const char *__pyx_filename = NULL;
2639 int __pyx_clineno = 0;
2640 __Pyx_RefNannySetupContext("write_fixed_strings_as_bytes", 0);
2641
2642 /* "clickhouse_driver/bufferedwriter.pyx":62
2643 *
2644 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length):
2645 * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<<
2646 * cdef Py_ssize_t items_buf_size = length * len(items)
2647 *
2648 */
2649 __pyx_v_buf_pos = 0;
2650
2651 /* "clickhouse_driver/bufferedwriter.pyx":63
2652 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length):
2653 * cdef Py_ssize_t buf_pos = 0
2654 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<<
2655 *
2656 * cdef char* c_value
2657 */
2658 __pyx_t_1 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 63, __pyx_L1_error)
2659 __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_1);
2660
2661 /* "clickhouse_driver/bufferedwriter.pyx":66
2662 *
2663 * cdef char* c_value
2664 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<<
2665 * if not items_buf:
2666 * raise MemoryError()
2667 */
2668 __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size));
2669
2670 /* "clickhouse_driver/bufferedwriter.pyx":67
2671 * cdef char* c_value
2672 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2673 * if not items_buf: # <<<<<<<<<<<<<<
2674 * raise MemoryError()
2675 *
2676 */
2677 __pyx_t_2 = ((!(__pyx_v_items_buf != 0)) != 0);
2678 if (unlikely(__pyx_t_2)) {
2679
2680 /* "clickhouse_driver/bufferedwriter.pyx":68
2681 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2682 * if not items_buf:
2683 * raise MemoryError() # <<<<<<<<<<<<<<
2684 *
2685 * memset(items_buf, 0, items_buf_size)
2686 */
2687 PyErr_NoMemory(); __PYX_ERR(0, 68, __pyx_L1_error)
2688
2689 /* "clickhouse_driver/bufferedwriter.pyx":67
2690 * cdef char* c_value
2691 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2692 * if not items_buf: # <<<<<<<<<<<<<<
2693 * raise MemoryError()
2694 *
2695 */
2696 }
2697
2698 /* "clickhouse_driver/bufferedwriter.pyx":70
2699 * raise MemoryError()
2700 *
2701 * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<<
2702 *
2703 * for value in items:
2704 */
2705 (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size));
2706
2707 /* "clickhouse_driver/bufferedwriter.pyx":72
2708 * memset(items_buf, 0, items_buf_size)
2709 *
23092710 * for value in items: # <<<<<<<<<<<<<<
2310 * if encode:
2311 * if not isinstance(value, bytes):
2711 * value_len = len(value)
2712 * if length < value_len:
23122713 */
23132714 if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
2314 __pyx_t_1 = __pyx_v_items; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
2315 __pyx_t_3 = NULL;
2715 __pyx_t_3 = __pyx_v_items; __Pyx_INCREF(__pyx_t_3); __pyx_t_1 = 0;
2716 __pyx_t_4 = NULL;
23162717 } else {
2317 __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
2318 __Pyx_GOTREF(__pyx_t_1);
2319 __pyx_t_3 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 56, __pyx_L1_error)
2718 __pyx_t_1 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 72, __pyx_L1_error)
2719 __Pyx_GOTREF(__pyx_t_3);
2720 __pyx_t_4 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 72, __pyx_L1_error)
23202721 }
23212722 for (;;) {
2322 if (likely(!__pyx_t_3)) {
2323 if (likely(PyList_CheckExact(__pyx_t_1))) {
2324 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
2723 if (likely(!__pyx_t_4)) {
2724 if (likely(PyList_CheckExact(__pyx_t_3))) {
2725 if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_3)) break;
23252726 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2326 __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 56, __pyx_L1_error)
2727 __pyx_t_5 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
23272728 #else
2328 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
2329 __Pyx_GOTREF(__pyx_t_4);
2729 __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error)
2730 __Pyx_GOTREF(__pyx_t_5);
23302731 #endif
23312732 } else {
2332 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
2733 if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
23332734 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2334 __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_4); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 56, __pyx_L1_error)
2735 __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_1); __Pyx_INCREF(__pyx_t_5); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 72, __pyx_L1_error)
23352736 #else
2336 __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
2337 __Pyx_GOTREF(__pyx_t_4);
2737 __pyx_t_5 = PySequence_ITEM(__pyx_t_3, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L1_error)
2738 __Pyx_GOTREF(__pyx_t_5);
23382739 #endif
23392740 }
23402741 } else {
2341 __pyx_t_4 = __pyx_t_3(__pyx_t_1);
2342 if (unlikely(!__pyx_t_4)) {
2742 __pyx_t_5 = __pyx_t_4(__pyx_t_3);
2743 if (unlikely(!__pyx_t_5)) {
23432744 PyObject* exc_type = PyErr_Occurred();
23442745 if (exc_type) {
23452746 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2346 else __PYX_ERR(0, 56, __pyx_L1_error)
2747 else __PYX_ERR(0, 72, __pyx_L1_error)
23472748 }
23482749 break;
23492750 }
2350 __Pyx_GOTREF(__pyx_t_4);
2351 }
2352 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4);
2353 __pyx_t_4 = 0;
2354
2355 /* "clickhouse_driver/bufferedwriter.pyx":57
2356 * def write_strings(self, items, int encode=0):
2751 __Pyx_GOTREF(__pyx_t_5);
2752 }
2753 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5);
2754 __pyx_t_5 = 0;
2755
2756 /* "clickhouse_driver/bufferedwriter.pyx":73
2757 *
23572758 * for value in items:
2358 * if encode: # <<<<<<<<<<<<<<
2359 * if not isinstance(value, bytes):
2360 * value = utf_8_encode(value)[0]
2361 */
2362 __pyx_t_5 = (__pyx_v_encode != 0);
2363 if (__pyx_t_5) {
2364
2365 /* "clickhouse_driver/bufferedwriter.pyx":58
2759 * value_len = len(value) # <<<<<<<<<<<<<<
2760 * if length < value_len:
2761 * raise errors.TooLargeStringSize()
2762 */
2763 __pyx_t_6 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 73, __pyx_L1_error)
2764 __pyx_v_value_len = __pyx_t_6;
2765
2766 /* "clickhouse_driver/bufferedwriter.pyx":74
23662767 * for value in items:
2367 * if encode:
2368 * if not isinstance(value, bytes): # <<<<<<<<<<<<<<
2369 * value = utf_8_encode(value)[0]
2370 *
2371 */
2372 __pyx_t_5 = PyBytes_Check(__pyx_v_value);
2373 __pyx_t_6 = ((!(__pyx_t_5 != 0)) != 0);
2374 if (__pyx_t_6) {
2375
2376 /* "clickhouse_driver/bufferedwriter.pyx":59
2377 * if encode:
2378 * if not isinstance(value, bytes):
2379 * value = utf_8_encode(value)[0] # <<<<<<<<<<<<<<
2380 *
2381 * write_varint(len(value), self)
2382 */
2383 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_utf_8_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error)
2384 __Pyx_GOTREF(__pyx_t_7);
2385 __pyx_t_8 = NULL;
2386 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
2387 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
2388 if (likely(__pyx_t_8)) {
2389 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2390 __Pyx_INCREF(__pyx_t_8);
2391 __Pyx_INCREF(function);
2392 __Pyx_DECREF_SET(__pyx_t_7, function);
2393 }
2768 * value_len = len(value)
2769 * if length < value_len: # <<<<<<<<<<<<<<
2770 * raise errors.TooLargeStringSize()
2771 *
2772 */
2773 __pyx_t_2 = ((__pyx_v_length < __pyx_v_value_len) != 0);
2774 if (unlikely(__pyx_t_2)) {
2775
2776 /* "clickhouse_driver/bufferedwriter.pyx":75
2777 * value_len = len(value)
2778 * if length < value_len:
2779 * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<<
2780 *
2781 * c_value = PyBytes_AsString(value)
2782 */
2783 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_errors); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 75, __pyx_L1_error)
2784 __Pyx_GOTREF(__pyx_t_7);
2785 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_TooLargeStringSize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 75, __pyx_L1_error)
2786 __Pyx_GOTREF(__pyx_t_8);
2787 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2788 __pyx_t_7 = NULL;
2789 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
2790 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
2791 if (likely(__pyx_t_7)) {
2792 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
2793 __Pyx_INCREF(__pyx_t_7);
2794 __Pyx_INCREF(function);
2795 __Pyx_DECREF_SET(__pyx_t_8, function);
23942796 }
2395 __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_value) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_value);
2396 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2397 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 59, __pyx_L1_error)
2398 __Pyx_GOTREF(__pyx_t_4);
2399 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2400 __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 59, __pyx_L1_error)
2401 __Pyx_GOTREF(__pyx_t_7);
2402 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2403 __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_7);
2404 __pyx_t_7 = 0;
2405
2406 /* "clickhouse_driver/bufferedwriter.pyx":58
2797 }
2798 __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
2799 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2800 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error)
2801 __Pyx_GOTREF(__pyx_t_5);
2802 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2803 __Pyx_Raise(__pyx_t_5, 0, 0, 0);
2804 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2805 __PYX_ERR(0, 75, __pyx_L1_error)
2806
2807 /* "clickhouse_driver/bufferedwriter.pyx":74
24072808 * for value in items:
2408 * if encode:
2409 * if not isinstance(value, bytes): # <<<<<<<<<<<<<<
2410 * value = utf_8_encode(value)[0]
2411 *
2412 */
2413 }
2414
2415 /* "clickhouse_driver/bufferedwriter.pyx":57
2416 * def write_strings(self, items, int encode=0):
2417 * for value in items:
2418 * if encode: # <<<<<<<<<<<<<<
2419 * if not isinstance(value, bytes):
2420 * value = utf_8_encode(value)[0]
2421 */
2422 }
2423
2424 /* "clickhouse_driver/bufferedwriter.pyx":61
2425 * value = utf_8_encode(value)[0]
2426 *
2427 * write_varint(len(value), self) # <<<<<<<<<<<<<<
2809 * value_len = len(value)
2810 * if length < value_len: # <<<<<<<<<<<<<<
2811 * raise errors.TooLargeStringSize()
2812 *
2813 */
2814 }
2815
2816 /* "clickhouse_driver/bufferedwriter.pyx":77
2817 * raise errors.TooLargeStringSize()
2818 *
2819 * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<<
2820 *
2821 * memcpy(&items_buf[buf_pos], c_value, value_len)
2822 */
2823 __pyx_t_9 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(0, 77, __pyx_L1_error)
2824 __pyx_v_c_value = __pyx_t_9;
2825
2826 /* "clickhouse_driver/bufferedwriter.pyx":79
2827 * c_value = PyBytes_AsString(value)
2828 *
2829 * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<<
2830 * buf_pos += length
2831 *
2832 */
2833 (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len));
2834
2835 /* "clickhouse_driver/bufferedwriter.pyx":80
2836 *
2837 * memcpy(&items_buf[buf_pos], c_value, value_len)
2838 * buf_pos += length # <<<<<<<<<<<<<<
2839 *
2840 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
2841 */
2842 __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length);
2843
2844 /* "clickhouse_driver/bufferedwriter.pyx":72
2845 * memset(items_buf, 0, items_buf_size)
2846 *
2847 * for value in items: # <<<<<<<<<<<<<<
2848 * value_len = len(value)
2849 * if length < value_len:
2850 */
2851 }
2852 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2853
2854 /* "clickhouse_driver/bufferedwriter.pyx":82
2855 * buf_pos += length
2856 *
2857 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<<
2858 *
2859 * PyMem_Free(items_buf)
2860 */
2861 __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 82, __pyx_L1_error)
2862 __Pyx_GOTREF(__pyx_t_3);
2863 __pyx_t_5 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_3, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error)
2864 __Pyx_GOTREF(__pyx_t_5);
2865 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2866 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2867
2868 /* "clickhouse_driver/bufferedwriter.pyx":84
2869 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
2870 *
2871 * PyMem_Free(items_buf) # <<<<<<<<<<<<<<
2872 *
2873 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None):
2874 */
2875 PyMem_Free(__pyx_v_items_buf);
2876
2877 /* "clickhouse_driver/bufferedwriter.pyx":61
24282878 * self.write(value)
24292879 *
2430 */
2431 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_write_varint); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error)
2432 __Pyx_GOTREF(__pyx_t_4);
2433 __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 61, __pyx_L1_error)
2434 __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 61, __pyx_L1_error)
2435 __Pyx_GOTREF(__pyx_t_8);
2436 __pyx_t_10 = NULL;
2437 __pyx_t_11 = 0;
2438 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
2439 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
2440 if (likely(__pyx_t_10)) {
2441 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2442 __Pyx_INCREF(__pyx_t_10);
2443 __Pyx_INCREF(function);
2444 __Pyx_DECREF_SET(__pyx_t_4, function);
2445 __pyx_t_11 = 1;
2446 }
2447 }
2448 #if CYTHON_FAST_PYCALL
2449 if (PyFunction_Check(__pyx_t_4)) {
2450 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, ((PyObject *)__pyx_v_self)};
2451 __pyx_t_7 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 61, __pyx_L1_error)
2452 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2453 __Pyx_GOTREF(__pyx_t_7);
2454 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2455 } else
2456 #endif
2457 #if CYTHON_FAST_PYCCALL
2458 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
2459 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_8, ((PyObject *)__pyx_v_self)};
2460 __pyx_t_7 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 61, __pyx_L1_error)
2461 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2462 __Pyx_GOTREF(__pyx_t_7);
2463 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2464 } else
2465 #endif
2466 {
2467 __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 61, __pyx_L1_error)
2468 __Pyx_GOTREF(__pyx_t_12);
2469 if (__pyx_t_10) {
2470 __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
2471 }
2472 __Pyx_GIVEREF(__pyx_t_8);
2473 PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_8);
2474 __Pyx_INCREF(((PyObject *)__pyx_v_self));
2475 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
2476 PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, ((PyObject *)__pyx_v_self));
2477 __pyx_t_8 = 0;
2478 __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 61, __pyx_L1_error)
2479 __Pyx_GOTREF(__pyx_t_7);
2480 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
2481 }
2482 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2483 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2484
2485 /* "clickhouse_driver/bufferedwriter.pyx":62
2486 *
2487 * write_varint(len(value), self)
2488 * self.write(value) # <<<<<<<<<<<<<<
2489 *
2490 *
2491 */
2492 __pyx_t_7 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_v_value, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 62, __pyx_L1_error)
2493 __Pyx_GOTREF(__pyx_t_7);
2494 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2495
2496 /* "clickhouse_driver/bufferedwriter.pyx":56
2497 *
2498 * def write_strings(self, items, int encode=0):
2499 * for value in items: # <<<<<<<<<<<<<<
2500 * if encode:
2501 * if not isinstance(value, bytes):
2502 */
2503 }
2504 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2505
2506 /* "clickhouse_driver/bufferedwriter.pyx":55
2507 * self.write_into_stream()
2508 *
2509 * def write_strings(self, items, int encode=0): # <<<<<<<<<<<<<<
2510 * for value in items:
2511 * if encode:
2880 * def write_fixed_strings_as_bytes(self, items, Py_ssize_t length): # <<<<<<<<<<<<<<
2881 * cdef Py_ssize_t buf_pos = 0
2882 * cdef Py_ssize_t items_buf_size = length * len(items)
25122883 */
25132884
25142885 /* function exit code */
25152886 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25162887 goto __pyx_L0;
25172888 __pyx_L1_error:;
2518 __Pyx_XDECREF(__pyx_t_1);
2519 __Pyx_XDECREF(__pyx_t_4);
2889 __Pyx_XDECREF(__pyx_t_3);
2890 __Pyx_XDECREF(__pyx_t_5);
25202891 __Pyx_XDECREF(__pyx_t_7);
25212892 __Pyx_XDECREF(__pyx_t_8);
2522 __Pyx_XDECREF(__pyx_t_10);
2523 __Pyx_XDECREF(__pyx_t_12);
2524 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2893 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings_as_bytes", __pyx_clineno, __pyx_lineno, __pyx_filename);
25252894 __pyx_r = NULL;
25262895 __pyx_L0:;
25272896 __Pyx_XDECREF(__pyx_v_value);
25302899 return __pyx_r;
25312900 }
25322901
2902 /* "clickhouse_driver/bufferedwriter.pyx":86
2903 * PyMem_Free(items_buf)
2904 *
2905 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): # <<<<<<<<<<<<<<
2906 * if encoding is None:
2907 * self.write_fixed_strings_as_bytes(items, length)
2908 */
2909
2910 /* Python wrapper */
2911 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2912 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2913 PyObject *__pyx_v_items = 0;
2914 Py_ssize_t __pyx_v_length;
2915 PyObject *__pyx_v_encoding = 0;
2916 int __pyx_lineno = 0;
2917 const char *__pyx_filename = NULL;
2918 int __pyx_clineno = 0;
2919 PyObject *__pyx_r = 0;
2920 __Pyx_RefNannyDeclarations
2921 __Pyx_RefNannySetupContext("write_fixed_strings (wrapper)", 0);
2922 {
2923 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_items,&__pyx_n_s_length,&__pyx_n_s_encoding,0};
2924 PyObject* values[3] = {0,0,0};
2925 values[2] = ((PyObject *)Py_None);
2926 if (unlikely(__pyx_kwds)) {
2927 Py_ssize_t kw_args;
2928 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2929 switch (pos_args) {
2930 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2931 CYTHON_FALLTHROUGH;
2932 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2933 CYTHON_FALLTHROUGH;
2934 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2935 CYTHON_FALLTHROUGH;
2936 case 0: break;
2937 default: goto __pyx_L5_argtuple_error;
2938 }
2939 kw_args = PyDict_Size(__pyx_kwds);
2940 switch (pos_args) {
2941 case 0:
2942 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
2943 else goto __pyx_L5_argtuple_error;
2944 CYTHON_FALLTHROUGH;
2945 case 1:
2946 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_length)) != 0)) kw_args--;
2947 else {
2948 __Pyx_RaiseArgtupleInvalid("write_fixed_strings", 0, 2, 3, 1); __PYX_ERR(0, 86, __pyx_L3_error)
2949 }
2950 CYTHON_FALLTHROUGH;
2951 case 2:
2952 if (kw_args > 0) {
2953 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_encoding);
2954 if (value) { values[2] = value; kw_args--; }
2955 }
2956 }
2957 if (unlikely(kw_args > 0)) {
2958 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_fixed_strings") < 0)) __PYX_ERR(0, 86, __pyx_L3_error)
2959 }
2960 } else {
2961 switch (PyTuple_GET_SIZE(__pyx_args)) {
2962 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2963 CYTHON_FALLTHROUGH;
2964 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2965 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2966 break;
2967 default: goto __pyx_L5_argtuple_error;
2968 }
2969 }
2970 __pyx_v_items = values[0];
2971 __pyx_v_length = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_length == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 86, __pyx_L3_error)
2972 __pyx_v_encoding = values[2];
2973 }
2974 goto __pyx_L4_argument_unpacking_done;
2975 __pyx_L5_argtuple_error:;
2976 __Pyx_RaiseArgtupleInvalid("write_fixed_strings", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 86, __pyx_L3_error)
2977 __pyx_L3_error:;
2978 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
2979 __Pyx_RefNannyFinishContext();
2980 return NULL;
2981 __pyx_L4_argument_unpacking_done:;
2982 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), __pyx_v_items, __pyx_v_length, __pyx_v_encoding);
2983
2984 /* function exit code */
2985 __Pyx_RefNannyFinishContext();
2986 return __pyx_r;
2987 }
2988
2989 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14write_fixed_strings(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v_items, Py_ssize_t __pyx_v_length, PyObject *__pyx_v_encoding) {
2990 Py_ssize_t __pyx_v_buf_pos;
2991 Py_ssize_t __pyx_v_items_buf_size;
2992 char *__pyx_v_c_value;
2993 char *__pyx_v_items_buf;
2994 PyObject *__pyx_v_value = NULL;
2995 Py_ssize_t __pyx_v_value_len;
2996 PyObject *__pyx_r = NULL;
2997 __Pyx_RefNannyDeclarations
2998 int __pyx_t_1;
2999 int __pyx_t_2;
3000 PyObject *__pyx_t_3 = NULL;
3001 PyObject *__pyx_t_4 = NULL;
3002 PyObject *__pyx_t_5 = NULL;
3003 PyObject *__pyx_t_6 = NULL;
3004 int __pyx_t_7;
3005 PyObject *__pyx_t_8 = NULL;
3006 Py_ssize_t __pyx_t_9;
3007 PyObject *(*__pyx_t_10)(PyObject *);
3008 Py_ssize_t __pyx_t_11;
3009 char *__pyx_t_12;
3010 int __pyx_lineno = 0;
3011 const char *__pyx_filename = NULL;
3012 int __pyx_clineno = 0;
3013 __Pyx_RefNannySetupContext("write_fixed_strings", 0);
3014
3015 /* "clickhouse_driver/bufferedwriter.pyx":87
3016 *
3017 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None):
3018 * if encoding is None: # <<<<<<<<<<<<<<
3019 * self.write_fixed_strings_as_bytes(items, length)
3020 * return
3021 */
3022 __pyx_t_1 = (__pyx_v_encoding == Py_None);
3023 __pyx_t_2 = (__pyx_t_1 != 0);
3024 if (__pyx_t_2) {
3025
3026 /* "clickhouse_driver/bufferedwriter.pyx":88
3027 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None):
3028 * if encoding is None:
3029 * self.write_fixed_strings_as_bytes(items, length) # <<<<<<<<<<<<<<
3030 * return
3031 *
3032 */
3033 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_fixed_strings_as_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
3034 __Pyx_GOTREF(__pyx_t_4);
3035 __pyx_t_5 = PyInt_FromSsize_t(__pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
3036 __Pyx_GOTREF(__pyx_t_5);
3037 __pyx_t_6 = NULL;
3038 __pyx_t_7 = 0;
3039 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
3040 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
3041 if (likely(__pyx_t_6)) {
3042 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3043 __Pyx_INCREF(__pyx_t_6);
3044 __Pyx_INCREF(function);
3045 __Pyx_DECREF_SET(__pyx_t_4, function);
3046 __pyx_t_7 = 1;
3047 }
3048 }
3049 #if CYTHON_FAST_PYCALL
3050 if (PyFunction_Check(__pyx_t_4)) {
3051 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_items, __pyx_t_5};
3052 __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
3053 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3054 __Pyx_GOTREF(__pyx_t_3);
3055 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3056 } else
3057 #endif
3058 #if CYTHON_FAST_PYCCALL
3059 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
3060 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_items, __pyx_t_5};
3061 __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
3062 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3063 __Pyx_GOTREF(__pyx_t_3);
3064 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3065 } else
3066 #endif
3067 {
3068 __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 88, __pyx_L1_error)
3069 __Pyx_GOTREF(__pyx_t_8);
3070 if (__pyx_t_6) {
3071 __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
3072 }
3073 __Pyx_INCREF(__pyx_v_items);
3074 __Pyx_GIVEREF(__pyx_v_items);
3075 PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_v_items);
3076 __Pyx_GIVEREF(__pyx_t_5);
3077 PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_5);
3078 __pyx_t_5 = 0;
3079 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
3080 __Pyx_GOTREF(__pyx_t_3);
3081 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3082 }
3083 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3084 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3085
3086 /* "clickhouse_driver/bufferedwriter.pyx":89
3087 * if encoding is None:
3088 * self.write_fixed_strings_as_bytes(items, length)
3089 * return # <<<<<<<<<<<<<<
3090 *
3091 * cdef Py_ssize_t buf_pos = 0
3092 */
3093 __Pyx_XDECREF(__pyx_r);
3094 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3095 goto __pyx_L0;
3096
3097 /* "clickhouse_driver/bufferedwriter.pyx":87
3098 *
3099 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None):
3100 * if encoding is None: # <<<<<<<<<<<<<<
3101 * self.write_fixed_strings_as_bytes(items, length)
3102 * return
3103 */
3104 }
3105
3106 /* "clickhouse_driver/bufferedwriter.pyx":91
3107 * return
3108 *
3109 * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<<
3110 * cdef Py_ssize_t items_buf_size = length * len(items)
3111 *
3112 */
3113 __pyx_v_buf_pos = 0;
3114
3115 /* "clickhouse_driver/bufferedwriter.pyx":92
3116 *
3117 * cdef Py_ssize_t buf_pos = 0
3118 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<<
3119 *
3120 * cdef char* c_value
3121 */
3122 __pyx_t_9 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 92, __pyx_L1_error)
3123 __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_9);
3124
3125 /* "clickhouse_driver/bufferedwriter.pyx":95
3126 *
3127 * cdef char* c_value
3128 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<<
3129 * if not items_buf:
3130 * raise MemoryError()
3131 */
3132 __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size));
3133
3134 /* "clickhouse_driver/bufferedwriter.pyx":96
3135 * cdef char* c_value
3136 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3137 * if not items_buf: # <<<<<<<<<<<<<<
3138 * raise MemoryError()
3139 *
3140 */
3141 __pyx_t_2 = ((!(__pyx_v_items_buf != 0)) != 0);
3142 if (unlikely(__pyx_t_2)) {
3143
3144 /* "clickhouse_driver/bufferedwriter.pyx":97
3145 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3146 * if not items_buf:
3147 * raise MemoryError() # <<<<<<<<<<<<<<
3148 *
3149 * memset(items_buf, 0, items_buf_size)
3150 */
3151 PyErr_NoMemory(); __PYX_ERR(0, 97, __pyx_L1_error)
3152
3153 /* "clickhouse_driver/bufferedwriter.pyx":96
3154 * cdef char* c_value
3155 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3156 * if not items_buf: # <<<<<<<<<<<<<<
3157 * raise MemoryError()
3158 *
3159 */
3160 }
3161
3162 /* "clickhouse_driver/bufferedwriter.pyx":99
3163 * raise MemoryError()
3164 *
3165 * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<<
3166 *
3167 * for value in items:
3168 */
3169 (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size));
3170
3171 /* "clickhouse_driver/bufferedwriter.pyx":101
3172 * memset(items_buf, 0, items_buf_size)
3173 *
3174 * for value in items: # <<<<<<<<<<<<<<
3175 * if not PyBytes_Check(value):
3176 * value = value.encode(encoding)
3177 */
3178 if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
3179 __pyx_t_3 = __pyx_v_items; __Pyx_INCREF(__pyx_t_3); __pyx_t_9 = 0;
3180 __pyx_t_10 = NULL;
3181 } else {
3182 __pyx_t_9 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error)
3183 __Pyx_GOTREF(__pyx_t_3);
3184 __pyx_t_10 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 101, __pyx_L1_error)
3185 }
3186 for (;;) {
3187 if (likely(!__pyx_t_10)) {
3188 if (likely(PyList_CheckExact(__pyx_t_3))) {
3189 if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_3)) break;
3190 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3191 __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 101, __pyx_L1_error)
3192 #else
3193 __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
3194 __Pyx_GOTREF(__pyx_t_4);
3195 #endif
3196 } else {
3197 if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
3198 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3199 __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 101, __pyx_L1_error)
3200 #else
3201 __pyx_t_4 = PySequence_ITEM(__pyx_t_3, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error)
3202 __Pyx_GOTREF(__pyx_t_4);
3203 #endif
3204 }
3205 } else {
3206 __pyx_t_4 = __pyx_t_10(__pyx_t_3);
3207 if (unlikely(!__pyx_t_4)) {
3208 PyObject* exc_type = PyErr_Occurred();
3209 if (exc_type) {
3210 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3211 else __PYX_ERR(0, 101, __pyx_L1_error)
3212 }
3213 break;
3214 }
3215 __Pyx_GOTREF(__pyx_t_4);
3216 }
3217 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_4);
3218 __pyx_t_4 = 0;
3219
3220 /* "clickhouse_driver/bufferedwriter.pyx":102
3221 *
3222 * for value in items:
3223 * if not PyBytes_Check(value): # <<<<<<<<<<<<<<
3224 * value = value.encode(encoding)
3225 *
3226 */
3227 __pyx_t_2 = ((!(PyBytes_Check(__pyx_v_value) != 0)) != 0);
3228 if (__pyx_t_2) {
3229
3230 /* "clickhouse_driver/bufferedwriter.pyx":103
3231 * for value in items:
3232 * if not PyBytes_Check(value):
3233 * value = value.encode(encoding) # <<<<<<<<<<<<<<
3234 *
3235 * value_len = len(value)
3236 */
3237 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_encode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 103, __pyx_L1_error)
3238 __Pyx_GOTREF(__pyx_t_8);
3239 __pyx_t_5 = NULL;
3240 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
3241 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
3242 if (likely(__pyx_t_5)) {
3243 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
3244 __Pyx_INCREF(__pyx_t_5);
3245 __Pyx_INCREF(function);
3246 __Pyx_DECREF_SET(__pyx_t_8, function);
3247 }
3248 }
3249 __pyx_t_4 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_5, __pyx_v_encoding) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_v_encoding);
3250 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3251 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 103, __pyx_L1_error)
3252 __Pyx_GOTREF(__pyx_t_4);
3253 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3254 __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_4);
3255 __pyx_t_4 = 0;
3256
3257 /* "clickhouse_driver/bufferedwriter.pyx":102
3258 *
3259 * for value in items:
3260 * if not PyBytes_Check(value): # <<<<<<<<<<<<<<
3261 * value = value.encode(encoding)
3262 *
3263 */
3264 }
3265
3266 /* "clickhouse_driver/bufferedwriter.pyx":105
3267 * value = value.encode(encoding)
3268 *
3269 * value_len = len(value) # <<<<<<<<<<<<<<
3270 * if length < value_len:
3271 * raise errors.TooLargeStringSize()
3272 */
3273 __pyx_t_11 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 105, __pyx_L1_error)
3274 __pyx_v_value_len = __pyx_t_11;
3275
3276 /* "clickhouse_driver/bufferedwriter.pyx":106
3277 *
3278 * value_len = len(value)
3279 * if length < value_len: # <<<<<<<<<<<<<<
3280 * raise errors.TooLargeStringSize()
3281 *
3282 */
3283 __pyx_t_2 = ((__pyx_v_length < __pyx_v_value_len) != 0);
3284 if (unlikely(__pyx_t_2)) {
3285
3286 /* "clickhouse_driver/bufferedwriter.pyx":107
3287 * value_len = len(value)
3288 * if length < value_len:
3289 * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<<
3290 *
3291 * c_value = PyBytes_AsString(value)
3292 */
3293 __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_n_s_errors); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 107, __pyx_L1_error)
3294 __Pyx_GOTREF(__pyx_t_8);
3295 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_TooLargeStringSize); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 107, __pyx_L1_error)
3296 __Pyx_GOTREF(__pyx_t_5);
3297 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3298 __pyx_t_8 = NULL;
3299 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
3300 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
3301 if (likely(__pyx_t_8)) {
3302 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
3303 __Pyx_INCREF(__pyx_t_8);
3304 __Pyx_INCREF(function);
3305 __Pyx_DECREF_SET(__pyx_t_5, function);
3306 }
3307 }
3308 __pyx_t_4 = (__pyx_t_8) ? __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8) : __Pyx_PyObject_CallNoArg(__pyx_t_5);
3309 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
3310 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 107, __pyx_L1_error)
3311 __Pyx_GOTREF(__pyx_t_4);
3312 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3313 __Pyx_Raise(__pyx_t_4, 0, 0, 0);
3314 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3315 __PYX_ERR(0, 107, __pyx_L1_error)
3316
3317 /* "clickhouse_driver/bufferedwriter.pyx":106
3318 *
3319 * value_len = len(value)
3320 * if length < value_len: # <<<<<<<<<<<<<<
3321 * raise errors.TooLargeStringSize()
3322 *
3323 */
3324 }
3325
3326 /* "clickhouse_driver/bufferedwriter.pyx":109
3327 * raise errors.TooLargeStringSize()
3328 *
3329 * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<<
3330 *
3331 * memcpy(&items_buf[buf_pos], c_value, value_len)
3332 */
3333 __pyx_t_12 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_12 == ((char *)NULL))) __PYX_ERR(0, 109, __pyx_L1_error)
3334 __pyx_v_c_value = __pyx_t_12;
3335
3336 /* "clickhouse_driver/bufferedwriter.pyx":111
3337 * c_value = PyBytes_AsString(value)
3338 *
3339 * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<<
3340 * buf_pos += length
3341 *
3342 */
3343 (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len));
3344
3345 /* "clickhouse_driver/bufferedwriter.pyx":112
3346 *
3347 * memcpy(&items_buf[buf_pos], c_value, value_len)
3348 * buf_pos += length # <<<<<<<<<<<<<<
3349 *
3350 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3351 */
3352 __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length);
3353
3354 /* "clickhouse_driver/bufferedwriter.pyx":101
3355 * memset(items_buf, 0, items_buf_size)
3356 *
3357 * for value in items: # <<<<<<<<<<<<<<
3358 * if not PyBytes_Check(value):
3359 * value = value.encode(encoding)
3360 */
3361 }
3362 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3363
3364 /* "clickhouse_driver/bufferedwriter.pyx":114
3365 * buf_pos += length
3366 *
3367 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<<
3368 *
3369 * PyMem_Free(items_buf)
3370 */
3371 __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 114, __pyx_L1_error)
3372 __Pyx_GOTREF(__pyx_t_3);
3373 __pyx_t_4 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_t_3, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error)
3374 __Pyx_GOTREF(__pyx_t_4);
3375 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3376 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3377
3378 /* "clickhouse_driver/bufferedwriter.pyx":116
3379 * self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3380 *
3381 * PyMem_Free(items_buf) # <<<<<<<<<<<<<<
3382 *
3383 *
3384 */
3385 PyMem_Free(__pyx_v_items_buf);
3386
3387 /* "clickhouse_driver/bufferedwriter.pyx":86
3388 * PyMem_Free(items_buf)
3389 *
3390 * def write_fixed_strings(self, items, Py_ssize_t length, encoding=None): # <<<<<<<<<<<<<<
3391 * if encoding is None:
3392 * self.write_fixed_strings_as_bytes(items, length)
3393 */
3394
3395 /* function exit code */
3396 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3397 goto __pyx_L0;
3398 __pyx_L1_error:;
3399 __Pyx_XDECREF(__pyx_t_3);
3400 __Pyx_XDECREF(__pyx_t_4);
3401 __Pyx_XDECREF(__pyx_t_5);
3402 __Pyx_XDECREF(__pyx_t_6);
3403 __Pyx_XDECREF(__pyx_t_8);
3404 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedWriter.write_fixed_strings", __pyx_clineno, __pyx_lineno, __pyx_filename);
3405 __pyx_r = NULL;
3406 __pyx_L0:;
3407 __Pyx_XDECREF(__pyx_v_value);
3408 __Pyx_XGIVEREF(__pyx_r);
3409 __Pyx_RefNannyFinishContext();
3410 return __pyx_r;
3411 }
3412
25333413 /* "(tree fragment)":1
25343414 * def __reduce_cython__(self): # <<<<<<<<<<<<<<
25353415 * cdef tuple state
25373417 */
25383418
25393419 /* Python wrapper */
2540 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
2541 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3420 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
3421 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
25423422 PyObject *__pyx_r = 0;
25433423 __Pyx_RefNannyDeclarations
25443424 __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0);
2545 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self));
3425 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self));
25463426
25473427 /* function exit code */
25483428 __Pyx_RefNannyFinishContext();
25493429 return __pyx_r;
25503430 }
25513431
2552 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_12__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) {
3432 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_16__reduce_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self) {
25533433 PyObject *__pyx_v_state = 0;
25543434 PyObject *__pyx_v__dict = 0;
25553435 int __pyx_v_use_setstate;
25613441 PyObject *__pyx_t_4 = NULL;
25623442 int __pyx_t_5;
25633443 int __pyx_t_6;
3444 int __pyx_lineno = 0;
3445 const char *__pyx_filename = NULL;
3446 int __pyx_clineno = 0;
25643447 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
25653448
25663449 /* "(tree fragment)":5
25723455 */
25733456 __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
25743457 __Pyx_GOTREF(__pyx_t_1);
2575 __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
3458 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
25763459 __Pyx_GOTREF(__pyx_t_2);
2577 __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
3460 __pyx_t_3 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
25783461 __Pyx_GOTREF(__pyx_t_3);
25793462 __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
25803463 __Pyx_GOTREF(__pyx_t_4);
27823665 */
27833666
27843667 /* Python wrapper */
2785 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
2786 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3668 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/
3669 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
27873670 PyObject *__pyx_r = 0;
27883671 __Pyx_RefNannyDeclarations
27893672 __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0);
2790 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
3673 __pyx_r = __pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state));
27913674
27923675 /* function exit code */
27933676 __Pyx_RefNannyFinishContext();
27943677 return __pyx_r;
27953678 }
27963679
2797 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_14__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
3680 static PyObject *__pyx_pf_17clickhouse_driver_14bufferedwriter_14BufferedWriter_18__setstate_cython__(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *__pyx_v_self, PyObject *__pyx_v___pyx_state) {
27983681 PyObject *__pyx_r = NULL;
27993682 __Pyx_RefNannyDeclarations
28003683 PyObject *__pyx_t_1 = NULL;
3684 int __pyx_lineno = 0;
3685 const char *__pyx_filename = NULL;
3686 int __pyx_clineno = 0;
28013687 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
28023688
28033689 /* "(tree fragment)":17
28303716 return __pyx_r;
28313717 }
28323718
2833 /* "clickhouse_driver/bufferedwriter.pyx":68
3719 /* "clickhouse_driver/bufferedwriter.pyx":122
28343720 * cdef object sock
28353721 *
28363722 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
28433729 static int __pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
28443730 PyObject *__pyx_v_sock = 0;
28453731 PyObject *__pyx_v_bufsize = 0;
3732 int __pyx_lineno = 0;
3733 const char *__pyx_filename = NULL;
3734 int __pyx_clineno = 0;
28463735 int __pyx_r;
28473736 __Pyx_RefNannyDeclarations
28483737 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
28693758 case 1:
28703759 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
28713760 else {
2872 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 68, __pyx_L3_error)
3761 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 122, __pyx_L3_error)
28733762 }
28743763 }
28753764 if (unlikely(kw_args > 0)) {
2876 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 68, __pyx_L3_error)
3765 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 122, __pyx_L3_error)
28773766 }
28783767 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
28793768 goto __pyx_L5_argtuple_error;
28863775 }
28873776 goto __pyx_L4_argument_unpacking_done;
28883777 __pyx_L5_argtuple_error:;
2889 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 68, __pyx_L3_error)
3778 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 122, __pyx_L3_error)
28903779 __pyx_L3_error:;
28913780 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.BufferedSocketWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
28923781 __Pyx_RefNannyFinishContext();
29053794 PyObject *__pyx_t_1 = NULL;
29063795 PyObject *__pyx_t_2 = NULL;
29073796 PyObject *__pyx_t_3 = NULL;
3797 int __pyx_lineno = 0;
3798 const char *__pyx_filename = NULL;
3799 int __pyx_clineno = 0;
29083800 __Pyx_RefNannySetupContext("__init__", 0);
29093801
2910 /* "clickhouse_driver/bufferedwriter.pyx":69
3802 /* "clickhouse_driver/bufferedwriter.pyx":123
29113803 *
29123804 * def __init__(self, sock, bufsize):
29133805 * self.sock = sock # <<<<<<<<<<<<<<
29203812 __Pyx_DECREF(__pyx_v_self->sock);
29213813 __pyx_v_self->sock = __pyx_v_sock;
29223814
2923 /* "clickhouse_driver/bufferedwriter.pyx":70
3815 /* "clickhouse_driver/bufferedwriter.pyx":124
29243816 * def __init__(self, sock, bufsize):
29253817 * self.sock = sock
29263818 * super(BufferedSocketWriter, self).__init__(bufsize) # <<<<<<<<<<<<<<
29273819 *
29283820 * cpdef write_into_stream(self):
29293821 */
2930 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
3822 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
29313823 __Pyx_GOTREF(__pyx_t_2);
29323824 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter));
29333825 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter));
29353827 __Pyx_INCREF(((PyObject *)__pyx_v_self));
29363828 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
29373829 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
2938 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 70, __pyx_L1_error)
3830 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 124, __pyx_L1_error)
29393831 __Pyx_GOTREF(__pyx_t_3);
29403832 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2941 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
3833 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 124, __pyx_L1_error)
29423834 __Pyx_GOTREF(__pyx_t_2);
29433835 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
29443836 __pyx_t_3 = NULL;
29533845 }
29543846 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_bufsize);
29553847 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2956 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
3848 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
29573849 __Pyx_GOTREF(__pyx_t_1);
29583850 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29593851 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29603852
2961 /* "clickhouse_driver/bufferedwriter.pyx":68
3853 /* "clickhouse_driver/bufferedwriter.pyx":122
29623854 * cdef object sock
29633855 *
29643856 * def __init__(self, sock, bufsize): # <<<<<<<<<<<<<<
29803872 return __pyx_r;
29813873 }
29823874
2983 /* "clickhouse_driver/bufferedwriter.pyx":72
3875 /* "clickhouse_driver/bufferedwriter.pyx":126
29843876 * super(BufferedSocketWriter, self).__init__(bufsize)
29853877 *
29863878 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
29873879 * self.sock.sendall(
2988 * PyByteArray_FromStringAndSize(self.buffer, self.position)
3880 * PyBytes_FromStringAndSize(self.buffer, self.position)
29893881 */
29903882
29913883 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
29963888 PyObject *__pyx_t_2 = NULL;
29973889 PyObject *__pyx_t_3 = NULL;
29983890 PyObject *__pyx_t_4 = NULL;
3891 int __pyx_lineno = 0;
3892 const char *__pyx_filename = NULL;
3893 int __pyx_clineno = 0;
29993894 __Pyx_RefNannySetupContext("write_into_stream", 0);
30003895 /* Check if called by wrapper */
30013896 if (unlikely(__pyx_skip_dispatch)) ;
30063901 if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
30073902 PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
30083903 #endif
3009 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
3904 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
30103905 __Pyx_GOTREF(__pyx_t_1);
30113906 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_3write_into_stream)) {
30123907 __Pyx_XDECREF(__pyx_r);
30233918 }
30243919 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
30253920 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3026 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
3921 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error)
30273922 __Pyx_GOTREF(__pyx_t_2);
30283923 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30293924 __pyx_r = __pyx_t_2;
30443939 #endif
30453940 }
30463941
3047 /* "clickhouse_driver/bufferedwriter.pyx":73
3942 /* "clickhouse_driver/bufferedwriter.pyx":127
30483943 *
30493944 * cpdef write_into_stream(self):
30503945 * self.sock.sendall( # <<<<<<<<<<<<<<
3051 * PyByteArray_FromStringAndSize(self.buffer, self.position)
3946 * PyBytes_FromStringAndSize(self.buffer, self.position)
30523947 * )
30533948 */
3054 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sock, __pyx_n_s_sendall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 73, __pyx_L1_error)
3949 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->sock, __pyx_n_s_sendall); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
30553950 __Pyx_GOTREF(__pyx_t_2);
30563951
3057 /* "clickhouse_driver/bufferedwriter.pyx":74
3952 /* "clickhouse_driver/bufferedwriter.pyx":128
30583953 * cpdef write_into_stream(self):
30593954 * self.sock.sendall(
3060 * PyByteArray_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<<
3955 * PyBytes_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<<
30613956 * )
30623957 * self.position = 0
30633958 */
3064 __pyx_t_3 = PyByteArray_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error)
3959 __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 128, __pyx_L1_error)
30653960 __Pyx_GOTREF(__pyx_t_3);
30663961 __pyx_t_4 = NULL;
30673962 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
30763971 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
30773972 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
30783973 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3079 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error)
3974 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
30803975 __Pyx_GOTREF(__pyx_t_1);
30813976 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30823977 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30833978
3084 /* "clickhouse_driver/bufferedwriter.pyx":76
3085 * PyByteArray_FromStringAndSize(self.buffer, self.position)
3979 /* "clickhouse_driver/bufferedwriter.pyx":130
3980 * PyBytes_FromStringAndSize(self.buffer, self.position)
30863981 * )
30873982 * self.position = 0 # <<<<<<<<<<<<<<
30883983 *
30903985 */
30913986 __pyx_v_self->__pyx_base.position = 0;
30923987
3093 /* "clickhouse_driver/bufferedwriter.pyx":72
3988 /* "clickhouse_driver/bufferedwriter.pyx":126
30943989 * super(BufferedSocketWriter, self).__init__(bufsize)
30953990 *
30963991 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
30973992 * self.sock.sendall(
3098 * PyByteArray_FromStringAndSize(self.buffer, self.position)
3993 * PyBytes_FromStringAndSize(self.buffer, self.position)
30993994 */
31003995
31013996 /* function exit code */
31314026 PyObject *__pyx_r = NULL;
31324027 __Pyx_RefNannyDeclarations
31334028 PyObject *__pyx_t_1 = NULL;
4029 int __pyx_lineno = 0;
4030 const char *__pyx_filename = NULL;
4031 int __pyx_clineno = 0;
31344032 __Pyx_RefNannySetupContext("write_into_stream", 0);
31354033 __Pyx_XDECREF(__pyx_r);
3136 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error)
4034 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error)
31374035 __Pyx_GOTREF(__pyx_t_1);
31384036 __pyx_r = __pyx_t_1;
31394037 __pyx_t_1 = 0;
31814079 PyObject *__pyx_t_4 = NULL;
31824080 int __pyx_t_5;
31834081 int __pyx_t_6;
4082 int __pyx_lineno = 0;
4083 const char *__pyx_filename = NULL;
4084 int __pyx_clineno = 0;
31844085 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
31854086
31864087 /* "(tree fragment)":5
31924093 */
31934094 __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->__pyx_base.buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
31944095 __Pyx_GOTREF(__pyx_t_1);
3195 __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
4096 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
31964097 __Pyx_GOTREF(__pyx_t_2);
3197 __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
4098 __pyx_t_3 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
31984099 __Pyx_GOTREF(__pyx_t_3);
31994100 __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
32004101 __Pyx_GOTREF(__pyx_t_4);
34224323 PyObject *__pyx_r = NULL;
34234324 __Pyx_RefNannyDeclarations
34244325 PyObject *__pyx_t_1 = NULL;
4326 int __pyx_lineno = 0;
4327 const char *__pyx_filename = NULL;
4328 int __pyx_clineno = 0;
34254329 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
34264330
34274331 /* "(tree fragment)":17
34544358 return __pyx_r;
34554359 }
34564360
3457 /* "clickhouse_driver/bufferedwriter.pyx":82
4361 /* "clickhouse_driver/bufferedwriter.pyx":136
34584362 * cdef object compressor
34594363 *
34604364 * def __init__(self, compressor, bufsize): # <<<<<<<<<<<<<<
34674371 static int __pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
34684372 PyObject *__pyx_v_compressor = 0;
34694373 PyObject *__pyx_v_bufsize = 0;
4374 int __pyx_lineno = 0;
4375 const char *__pyx_filename = NULL;
4376 int __pyx_clineno = 0;
34704377 int __pyx_r;
34714378 __Pyx_RefNannyDeclarations
34724379 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
34934400 case 1:
34944401 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bufsize)) != 0)) kw_args--;
34954402 else {
3496 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 82, __pyx_L3_error)
4403 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 136, __pyx_L3_error)
34974404 }
34984405 }
34994406 if (unlikely(kw_args > 0)) {
3500 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 82, __pyx_L3_error)
4407 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 136, __pyx_L3_error)
35014408 }
35024409 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
35034410 goto __pyx_L5_argtuple_error;
35104417 }
35114418 goto __pyx_L4_argument_unpacking_done;
35124419 __pyx_L5_argtuple_error:;
3513 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 82, __pyx_L3_error)
4420 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 136, __pyx_L3_error)
35144421 __pyx_L3_error:;
35154422 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.CompressedBufferedWriter.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
35164423 __Pyx_RefNannyFinishContext();
35294436 PyObject *__pyx_t_1 = NULL;
35304437 PyObject *__pyx_t_2 = NULL;
35314438 PyObject *__pyx_t_3 = NULL;
4439 int __pyx_lineno = 0;
4440 const char *__pyx_filename = NULL;
4441 int __pyx_clineno = 0;
35324442 __Pyx_RefNannySetupContext("__init__", 0);
35334443
3534 /* "clickhouse_driver/bufferedwriter.pyx":83
4444 /* "clickhouse_driver/bufferedwriter.pyx":137
35354445 *
35364446 * def __init__(self, compressor, bufsize):
35374447 * self.compressor = compressor # <<<<<<<<<<<<<<
35444454 __Pyx_DECREF(__pyx_v_self->compressor);
35454455 __pyx_v_self->compressor = __pyx_v_compressor;
35464456
3547 /* "clickhouse_driver/bufferedwriter.pyx":84
4457 /* "clickhouse_driver/bufferedwriter.pyx":138
35484458 * def __init__(self, compressor, bufsize):
35494459 * self.compressor = compressor
35504460 * super(CompressedBufferedWriter, self).__init__(bufsize) # <<<<<<<<<<<<<<
35514461 *
35524462 * cpdef write_into_stream(self):
35534463 */
3554 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
4464 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
35554465 __Pyx_GOTREF(__pyx_t_2);
35564466 __Pyx_INCREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter));
35574467 __Pyx_GIVEREF(((PyObject *)__pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter));
35594469 __Pyx_INCREF(((PyObject *)__pyx_v_self));
35604470 __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
35614471 PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_v_self));
3562 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
4472 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error)
35634473 __Pyx_GOTREF(__pyx_t_3);
35644474 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3565 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 84, __pyx_L1_error)
4475 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error)
35664476 __Pyx_GOTREF(__pyx_t_2);
35674477 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
35684478 __pyx_t_3 = NULL;
35774487 }
35784488 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_bufsize) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_bufsize);
35794489 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
3580 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error)
4490 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 138, __pyx_L1_error)
35814491 __Pyx_GOTREF(__pyx_t_1);
35824492 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
35834493 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
35844494
3585 /* "clickhouse_driver/bufferedwriter.pyx":82
4495 /* "clickhouse_driver/bufferedwriter.pyx":136
35864496 * cdef object compressor
35874497 *
35884498 * def __init__(self, compressor, bufsize): # <<<<<<<<<<<<<<
36044514 return __pyx_r;
36054515 }
36064516
3607 /* "clickhouse_driver/bufferedwriter.pyx":86
4517 /* "clickhouse_driver/bufferedwriter.pyx":140
36084518 * super(CompressedBufferedWriter, self).__init__(bufsize)
36094519 *
36104520 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
36114521 * self.compressor.write(
3612 * PyByteArray_FromStringAndSize(self.buffer, self.position)
4522 * PyBytes_FromStringAndSize(self.buffer, self.position)
36134523 */
36144524
36154525 static PyObject *__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
36204530 PyObject *__pyx_t_2 = NULL;
36214531 PyObject *__pyx_t_3 = NULL;
36224532 PyObject *__pyx_t_4 = NULL;
4533 int __pyx_lineno = 0;
4534 const char *__pyx_filename = NULL;
4535 int __pyx_clineno = 0;
36234536 __Pyx_RefNannySetupContext("write_into_stream", 0);
36244537 /* Check if called by wrapper */
36254538 if (unlikely(__pyx_skip_dispatch)) ;
36304543 if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) {
36314544 PY_UINT64_T __pyx_type_dict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self));
36324545 #endif
3633 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
4546 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write_into_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
36344547 __Pyx_GOTREF(__pyx_t_1);
36354548 if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)(void*)__pyx_pw_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_3write_into_stream)) {
36364549 __Pyx_XDECREF(__pyx_r);
36474560 }
36484561 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
36494562 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3650 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error)
4563 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
36514564 __Pyx_GOTREF(__pyx_t_2);
36524565 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36534566 __pyx_r = __pyx_t_2;
36684581 #endif
36694582 }
36704583
3671 /* "clickhouse_driver/bufferedwriter.pyx":87
4584 /* "clickhouse_driver/bufferedwriter.pyx":141
36724585 *
36734586 * cpdef write_into_stream(self):
36744587 * self.compressor.write( # <<<<<<<<<<<<<<
3675 * PyByteArray_FromStringAndSize(self.buffer, self.position)
4588 * PyBytes_FromStringAndSize(self.buffer, self.position)
36764589 * )
36774590 */
3678 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->compressor, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 87, __pyx_L1_error)
4591 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->compressor, __pyx_n_s_write); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error)
36794592 __Pyx_GOTREF(__pyx_t_2);
36804593
3681 /* "clickhouse_driver/bufferedwriter.pyx":88
4594 /* "clickhouse_driver/bufferedwriter.pyx":142
36824595 * cpdef write_into_stream(self):
36834596 * self.compressor.write(
3684 * PyByteArray_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<<
4597 * PyBytes_FromStringAndSize(self.buffer, self.position) # <<<<<<<<<<<<<<
36854598 * )
36864599 * self.position = 0
36874600 */
3688 __pyx_t_3 = PyByteArray_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
4601 __pyx_t_3 = PyBytes_FromStringAndSize(__pyx_v_self->__pyx_base.buffer, __pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
36894602 __Pyx_GOTREF(__pyx_t_3);
36904603 __pyx_t_4 = NULL;
36914604 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
37004613 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
37014614 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
37024615 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3703 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error)
4616 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error)
37044617 __Pyx_GOTREF(__pyx_t_1);
37054618 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37064619 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37074620
3708 /* "clickhouse_driver/bufferedwriter.pyx":90
3709 * PyByteArray_FromStringAndSize(self.buffer, self.position)
4621 /* "clickhouse_driver/bufferedwriter.pyx":144
4622 * PyBytes_FromStringAndSize(self.buffer, self.position)
37104623 * )
37114624 * self.position = 0 # <<<<<<<<<<<<<<
37124625 *
37144627 */
37154628 __pyx_v_self->__pyx_base.position = 0;
37164629
3717 /* "clickhouse_driver/bufferedwriter.pyx":86
4630 /* "clickhouse_driver/bufferedwriter.pyx":140
37184631 * super(CompressedBufferedWriter, self).__init__(bufsize)
37194632 *
37204633 * cpdef write_into_stream(self): # <<<<<<<<<<<<<<
37214634 * self.compressor.write(
3722 * PyByteArray_FromStringAndSize(self.buffer, self.position)
4635 * PyBytes_FromStringAndSize(self.buffer, self.position)
37234636 */
37244637
37254638 /* function exit code */
37554668 PyObject *__pyx_r = NULL;
37564669 __Pyx_RefNannyDeclarations
37574670 PyObject *__pyx_t_1 = NULL;
4671 int __pyx_lineno = 0;
4672 const char *__pyx_filename = NULL;
4673 int __pyx_clineno = 0;
37584674 __Pyx_RefNannySetupContext("write_into_stream", 0);
37594675 __Pyx_XDECREF(__pyx_r);
3760 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 86, __pyx_L1_error)
4676 __pyx_t_1 = __pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
37614677 __Pyx_GOTREF(__pyx_t_1);
37624678 __pyx_r = __pyx_t_1;
37634679 __pyx_t_1 = 0;
37744690 return __pyx_r;
37754691 }
37764692
3777 /* "clickhouse_driver/bufferedwriter.pyx":92
4693 /* "clickhouse_driver/bufferedwriter.pyx":146
37784694 * self.position = 0
37794695 *
37804696 * def flush(self): # <<<<<<<<<<<<<<
37984714 PyObject *__pyx_r = NULL;
37994715 __Pyx_RefNannyDeclarations
38004716 PyObject *__pyx_t_1 = NULL;
4717 int __pyx_lineno = 0;
4718 const char *__pyx_filename = NULL;
4719 int __pyx_clineno = 0;
38014720 __Pyx_RefNannySetupContext("flush", 0);
38024721
3803 /* "clickhouse_driver/bufferedwriter.pyx":93
4722 /* "clickhouse_driver/bufferedwriter.pyx":147
38044723 *
38054724 * def flush(self):
38064725 * self.write_into_stream() # <<<<<<<<<<<<<<
38074726 */
3808 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 93, __pyx_L1_error)
4727 __pyx_t_1 = ((struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.write_into_stream(((struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *)__pyx_v_self), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 147, __pyx_L1_error)
38094728 __Pyx_GOTREF(__pyx_t_1);
38104729 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
38114730
3812 /* "clickhouse_driver/bufferedwriter.pyx":92
4731 /* "clickhouse_driver/bufferedwriter.pyx":146
38134732 * self.position = 0
38144733 *
38154734 * def flush(self): # <<<<<<<<<<<<<<
38604779 PyObject *__pyx_t_4 = NULL;
38614780 int __pyx_t_5;
38624781 int __pyx_t_6;
4782 int __pyx_lineno = 0;
4783 const char *__pyx_filename = NULL;
4784 int __pyx_clineno = 0;
38634785 __Pyx_RefNannySetupContext("__reduce_cython__", 0);
38644786
38654787 /* "(tree fragment)":5
38714793 */
38724794 __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_self->__pyx_base.buffer); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 5, __pyx_L1_error)
38734795 __Pyx_GOTREF(__pyx_t_1);
3874 __pyx_t_2 = PyInt_FromSsize_t(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
4796 __pyx_t_2 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.buffer_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(1, 5, __pyx_L1_error)
38754797 __Pyx_GOTREF(__pyx_t_2);
3876 __pyx_t_3 = PyInt_FromSsize_t(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
4798 __pyx_t_3 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_self->__pyx_base.position); if (unlikely(!__pyx_t_3)) __PYX_ERR(1, 5, __pyx_L1_error)
38774799 __Pyx_GOTREF(__pyx_t_3);
38784800 __pyx_t_4 = PyTuple_New(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(1, 5, __pyx_L1_error)
38794801 __Pyx_GOTREF(__pyx_t_4);
41015023 PyObject *__pyx_r = NULL;
41025024 __Pyx_RefNannyDeclarations
41035025 PyObject *__pyx_t_1 = NULL;
5026 int __pyx_lineno = 0;
5027 const char *__pyx_filename = NULL;
5028 int __pyx_clineno = 0;
41045029 __Pyx_RefNannySetupContext("__setstate_cython__", 0);
41055030
41065031 /* "(tree fragment)":17
41465071 PyObject *__pyx_v___pyx_type = 0;
41475072 long __pyx_v___pyx_checksum;
41485073 PyObject *__pyx_v___pyx_state = 0;
5074 int __pyx_lineno = 0;
5075 const char *__pyx_filename = NULL;
5076 int __pyx_clineno = 0;
41495077 PyObject *__pyx_r = 0;
41505078 __Pyx_RefNannyDeclarations
41515079 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter (wrapper)", 0);
42235151 PyObject *__pyx_t_4 = NULL;
42245152 PyObject *__pyx_t_5 = NULL;
42255153 int __pyx_t_6;
5154 int __pyx_lineno = 0;
5155 const char *__pyx_filename = NULL;
5156 int __pyx_clineno = 0;
42265157 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter", 0);
42275158
42285159 /* "(tree fragment)":4
44055336 __Pyx_RefNannyDeclarations
44065337 PyObject *__pyx_t_1 = NULL;
44075338 char *__pyx_t_2;
4408 Py_ssize_t __pyx_t_3;
5339 unsigned PY_LONG_LONG __pyx_t_3;
44095340 int __pyx_t_4;
4410 int __pyx_t_5;
5341 Py_ssize_t __pyx_t_5;
44115342 int __pyx_t_6;
4412 PyObject *__pyx_t_7 = NULL;
5343 int __pyx_t_7;
44135344 PyObject *__pyx_t_8 = NULL;
44145345 PyObject *__pyx_t_9 = NULL;
5346 PyObject *__pyx_t_10 = NULL;
5347 int __pyx_lineno = 0;
5348 const char *__pyx_filename = NULL;
5349 int __pyx_clineno = 0;
44155350 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedWriter__set_state", 0);
44165351
44175352 /* "(tree fragment)":12
44365371 }
44375372 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
44385373 __Pyx_GOTREF(__pyx_t_1);
4439 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5374 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
44405375 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
44415376 __pyx_v___pyx_result->buffer_size = __pyx_t_3;
44425377 if (unlikely(__pyx_v___pyx_state == Py_None)) {
44455380 }
44465381 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
44475382 __Pyx_GOTREF(__pyx_t_1);
4448 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5383 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
44495384 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
44505385 __pyx_v___pyx_result->position = __pyx_t_3;
44515386
44595394 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
44605395 __PYX_ERR(1, 13, __pyx_L1_error)
44615396 }
4462 __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4463 __pyx_t_5 = ((__pyx_t_3 > 3) != 0);
4464 if (__pyx_t_5) {
5397 __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5398 __pyx_t_6 = ((__pyx_t_5 > 3) != 0);
5399 if (__pyx_t_6) {
44655400 } else {
4466 __pyx_t_4 = __pyx_t_5;
5401 __pyx_t_4 = __pyx_t_6;
44675402 goto __pyx_L4_bool_binop_done;
44685403 }
4469 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4470 __pyx_t_6 = (__pyx_t_5 != 0);
4471 __pyx_t_4 = __pyx_t_6;
5404 __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5405 __pyx_t_7 = (__pyx_t_6 != 0);
5406 __pyx_t_4 = __pyx_t_7;
44725407 __pyx_L4_bool_binop_done:;
44735408 if (__pyx_t_4) {
44745409
44775412 * if len(__pyx_state) > 3 and hasattr(__pyx_result, '__dict__'):
44785413 * __pyx_result.__dict__.update(__pyx_state[3]) # <<<<<<<<<<<<<<
44795414 */
4480 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4481 __Pyx_GOTREF(__pyx_t_7);
4482 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
5415 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
44835416 __Pyx_GOTREF(__pyx_t_8);
4484 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5417 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
5418 __Pyx_GOTREF(__pyx_t_9);
5419 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
44855420 if (unlikely(__pyx_v___pyx_state == Py_None)) {
44865421 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
44875422 __PYX_ERR(1, 14, __pyx_L1_error)
44885423 }
4489 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4490 __Pyx_GOTREF(__pyx_t_7);
4491 __pyx_t_9 = NULL;
4492 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
4493 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
4494 if (likely(__pyx_t_9)) {
4495 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
4496 __Pyx_INCREF(__pyx_t_9);
5424 __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
5425 __Pyx_GOTREF(__pyx_t_8);
5426 __pyx_t_10 = NULL;
5427 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
5428 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
5429 if (likely(__pyx_t_10)) {
5430 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
5431 __Pyx_INCREF(__pyx_t_10);
44975432 __Pyx_INCREF(function);
4498 __Pyx_DECREF_SET(__pyx_t_8, function);
5433 __Pyx_DECREF_SET(__pyx_t_9, function);
44995434 }
45005435 }
4501 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
4502 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
4503 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5436 __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
5437 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
5438 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
45045439 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
45055440 __Pyx_GOTREF(__pyx_t_1);
4506 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5441 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
45075442 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
45085443
45095444 /* "(tree fragment)":13
45275462 goto __pyx_L0;
45285463 __pyx_L1_error:;
45295464 __Pyx_XDECREF(__pyx_t_1);
4530 __Pyx_XDECREF(__pyx_t_7);
45315465 __Pyx_XDECREF(__pyx_t_8);
45325466 __Pyx_XDECREF(__pyx_t_9);
5467 __Pyx_XDECREF(__pyx_t_10);
45335468 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
45345469 __pyx_r = 0;
45355470 __pyx_L0:;
45515486 PyObject *__pyx_v___pyx_type = 0;
45525487 long __pyx_v___pyx_checksum;
45535488 PyObject *__pyx_v___pyx_state = 0;
5489 int __pyx_lineno = 0;
5490 const char *__pyx_filename = NULL;
5491 int __pyx_clineno = 0;
45545492 PyObject *__pyx_r = 0;
45555493 __Pyx_RefNannyDeclarations
45565494 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter (wrapper)", 0);
46285566 PyObject *__pyx_t_4 = NULL;
46295567 PyObject *__pyx_t_5 = NULL;
46305568 int __pyx_t_6;
5569 int __pyx_lineno = 0;
5570 const char *__pyx_filename = NULL;
5571 int __pyx_clineno = 0;
46315572 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter", 0);
46325573
46335574 /* "(tree fragment)":4
48105751 __Pyx_RefNannyDeclarations
48115752 PyObject *__pyx_t_1 = NULL;
48125753 char *__pyx_t_2;
4813 Py_ssize_t __pyx_t_3;
5754 unsigned PY_LONG_LONG __pyx_t_3;
48145755 int __pyx_t_4;
4815 int __pyx_t_5;
5756 Py_ssize_t __pyx_t_5;
48165757 int __pyx_t_6;
4817 PyObject *__pyx_t_7 = NULL;
5758 int __pyx_t_7;
48185759 PyObject *__pyx_t_8 = NULL;
48195760 PyObject *__pyx_t_9 = NULL;
5761 PyObject *__pyx_t_10 = NULL;
5762 int __pyx_lineno = 0;
5763 const char *__pyx_filename = NULL;
5764 int __pyx_clineno = 0;
48205765 __Pyx_RefNannySetupContext("__pyx_unpickle_BufferedSocketWriter__set_state", 0);
48215766
48225767 /* "(tree fragment)":12
48415786 }
48425787 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
48435788 __Pyx_GOTREF(__pyx_t_1);
4844 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5789 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
48455790 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
48465791 __pyx_v___pyx_result->__pyx_base.buffer_size = __pyx_t_3;
48475792 if (unlikely(__pyx_v___pyx_state == Py_None)) {
48505795 }
48515796 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
48525797 __Pyx_GOTREF(__pyx_t_1);
4853 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
5798 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
48545799 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
48555800 __pyx_v___pyx_result->__pyx_base.position = __pyx_t_3;
48565801 if (unlikely(__pyx_v___pyx_state == Py_None)) {
48755820 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
48765821 __PYX_ERR(1, 13, __pyx_L1_error)
48775822 }
4878 __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4879 __pyx_t_5 = ((__pyx_t_3 > 4) != 0);
4880 if (__pyx_t_5) {
5823 __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5824 __pyx_t_6 = ((__pyx_t_5 > 4) != 0);
5825 if (__pyx_t_6) {
48815826 } else {
4882 __pyx_t_4 = __pyx_t_5;
5827 __pyx_t_4 = __pyx_t_6;
48835828 goto __pyx_L4_bool_binop_done;
48845829 }
4885 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
4886 __pyx_t_6 = (__pyx_t_5 != 0);
4887 __pyx_t_4 = __pyx_t_6;
5830 __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5831 __pyx_t_7 = (__pyx_t_6 != 0);
5832 __pyx_t_4 = __pyx_t_7;
48885833 __pyx_L4_bool_binop_done:;
48895834 if (__pyx_t_4) {
48905835
48935838 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
48945839 * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<<
48955840 */
4896 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4897 __Pyx_GOTREF(__pyx_t_7);
4898 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
5841 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
48995842 __Pyx_GOTREF(__pyx_t_8);
4900 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5843 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
5844 __Pyx_GOTREF(__pyx_t_9);
5845 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
49015846 if (unlikely(__pyx_v___pyx_state == Py_None)) {
49025847 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
49035848 __PYX_ERR(1, 14, __pyx_L1_error)
49045849 }
4905 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
4906 __Pyx_GOTREF(__pyx_t_7);
4907 __pyx_t_9 = NULL;
4908 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
4909 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
4910 if (likely(__pyx_t_9)) {
4911 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
4912 __Pyx_INCREF(__pyx_t_9);
5850 __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
5851 __Pyx_GOTREF(__pyx_t_8);
5852 __pyx_t_10 = NULL;
5853 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
5854 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
5855 if (likely(__pyx_t_10)) {
5856 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
5857 __Pyx_INCREF(__pyx_t_10);
49135858 __Pyx_INCREF(function);
4914 __Pyx_DECREF_SET(__pyx_t_8, function);
5859 __Pyx_DECREF_SET(__pyx_t_9, function);
49155860 }
49165861 }
4917 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
4918 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
4919 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
5862 __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
5863 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
5864 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
49205865 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
49215866 __Pyx_GOTREF(__pyx_t_1);
4922 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
5867 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
49235868 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
49245869
49255870 /* "(tree fragment)":13
49435888 goto __pyx_L0;
49445889 __pyx_L1_error:;
49455890 __Pyx_XDECREF(__pyx_t_1);
4946 __Pyx_XDECREF(__pyx_t_7);
49475891 __Pyx_XDECREF(__pyx_t_8);
49485892 __Pyx_XDECREF(__pyx_t_9);
5893 __Pyx_XDECREF(__pyx_t_10);
49495894 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_BufferedSocketWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
49505895 __pyx_r = 0;
49515896 __pyx_L0:;
49675912 PyObject *__pyx_v___pyx_type = 0;
49685913 long __pyx_v___pyx_checksum;
49695914 PyObject *__pyx_v___pyx_state = 0;
5915 int __pyx_lineno = 0;
5916 const char *__pyx_filename = NULL;
5917 int __pyx_clineno = 0;
49705918 PyObject *__pyx_r = 0;
49715919 __Pyx_RefNannyDeclarations
49725920 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter (wrapper)", 0);
50445992 PyObject *__pyx_t_4 = NULL;
50455993 PyObject *__pyx_t_5 = NULL;
50465994 int __pyx_t_6;
5995 int __pyx_lineno = 0;
5996 const char *__pyx_filename = NULL;
5997 int __pyx_clineno = 0;
50475998 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter", 0);
50485999
50496000 /* "(tree fragment)":4
52266177 __Pyx_RefNannyDeclarations
52276178 PyObject *__pyx_t_1 = NULL;
52286179 char *__pyx_t_2;
5229 Py_ssize_t __pyx_t_3;
6180 unsigned PY_LONG_LONG __pyx_t_3;
52306181 int __pyx_t_4;
5231 int __pyx_t_5;
6182 Py_ssize_t __pyx_t_5;
52326183 int __pyx_t_6;
5233 PyObject *__pyx_t_7 = NULL;
6184 int __pyx_t_7;
52346185 PyObject *__pyx_t_8 = NULL;
52356186 PyObject *__pyx_t_9 = NULL;
6187 PyObject *__pyx_t_10 = NULL;
6188 int __pyx_lineno = 0;
6189 const char *__pyx_filename = NULL;
6190 int __pyx_clineno = 0;
52366191 __Pyx_RefNannySetupContext("__pyx_unpickle_CompressedBufferedWriter__set_state", 0);
52376192
52386193 /* "(tree fragment)":12
52576212 }
52586213 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
52596214 __Pyx_GOTREF(__pyx_t_1);
5260 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
6215 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
52616216 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
52626217 __pyx_v___pyx_result->__pyx_base.buffer_size = __pyx_t_3;
52636218 if (unlikely(__pyx_v___pyx_state == Py_None)) {
52776232 }
52786233 __pyx_t_1 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 12, __pyx_L1_error)
52796234 __Pyx_GOTREF(__pyx_t_1);
5280 __pyx_t_3 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_3 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
6235 __pyx_t_3 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_3 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(1, 12, __pyx_L1_error)
52816236 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
52826237 __pyx_v___pyx_result->__pyx_base.position = __pyx_t_3;
52836238
52916246 PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
52926247 __PYX_ERR(1, 13, __pyx_L1_error)
52936248 }
5294 __pyx_t_3 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5295 __pyx_t_5 = ((__pyx_t_3 > 4) != 0);
5296 if (__pyx_t_5) {
6249 __pyx_t_5 = PyTuple_GET_SIZE(__pyx_v___pyx_state); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6250 __pyx_t_6 = ((__pyx_t_5 > 4) != 0);
6251 if (__pyx_t_6) {
52976252 } else {
5298 __pyx_t_4 = __pyx_t_5;
6253 __pyx_t_4 = __pyx_t_6;
52996254 goto __pyx_L4_bool_binop_done;
53006255 }
5301 __pyx_t_5 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
5302 __pyx_t_6 = (__pyx_t_5 != 0);
5303 __pyx_t_4 = __pyx_t_6;
6256 __pyx_t_6 = __Pyx_HasAttr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(1, 13, __pyx_L1_error)
6257 __pyx_t_7 = (__pyx_t_6 != 0);
6258 __pyx_t_4 = __pyx_t_7;
53046259 __pyx_L4_bool_binop_done:;
53056260 if (__pyx_t_4) {
53066261
53096264 * if len(__pyx_state) > 4 and hasattr(__pyx_result, '__dict__'):
53106265 * __pyx_result.__dict__.update(__pyx_state[4]) # <<<<<<<<<<<<<<
53116266 */
5312 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
5313 __Pyx_GOTREF(__pyx_t_7);
5314 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_update); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
6267 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v___pyx_result), __pyx_n_s_dict); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
53156268 __Pyx_GOTREF(__pyx_t_8);
5316 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6269 __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_n_s_update); if (unlikely(!__pyx_t_9)) __PYX_ERR(1, 14, __pyx_L1_error)
6270 __Pyx_GOTREF(__pyx_t_9);
6271 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
53176272 if (unlikely(__pyx_v___pyx_state == Py_None)) {
53186273 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
53196274 __PYX_ERR(1, 14, __pyx_L1_error)
53206275 }
5321 __pyx_t_7 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(1, 14, __pyx_L1_error)
5322 __Pyx_GOTREF(__pyx_t_7);
5323 __pyx_t_9 = NULL;
5324 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) {
5325 __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
5326 if (likely(__pyx_t_9)) {
5327 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
5328 __Pyx_INCREF(__pyx_t_9);
6276 __pyx_t_8 = __Pyx_GetItemInt_Tuple(__pyx_v___pyx_state, 4, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_8)) __PYX_ERR(1, 14, __pyx_L1_error)
6277 __Pyx_GOTREF(__pyx_t_8);
6278 __pyx_t_10 = NULL;
6279 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) {
6280 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
6281 if (likely(__pyx_t_10)) {
6282 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
6283 __Pyx_INCREF(__pyx_t_10);
53296284 __Pyx_INCREF(function);
5330 __Pyx_DECREF_SET(__pyx_t_8, function);
6285 __Pyx_DECREF_SET(__pyx_t_9, function);
53316286 }
53326287 }
5333 __pyx_t_1 = (__pyx_t_9) ? __Pyx_PyObject_Call2Args(__pyx_t_8, __pyx_t_9, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7);
5334 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
5335 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
6288 __pyx_t_1 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8);
6289 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
6290 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
53366291 if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 14, __pyx_L1_error)
53376292 __Pyx_GOTREF(__pyx_t_1);
5338 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6293 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
53396294 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
53406295
53416296 /* "(tree fragment)":13
53596314 goto __pyx_L0;
53606315 __pyx_L1_error:;
53616316 __Pyx_XDECREF(__pyx_t_1);
5362 __Pyx_XDECREF(__pyx_t_7);
53636317 __Pyx_XDECREF(__pyx_t_8);
53646318 __Pyx_XDECREF(__pyx_t_9);
6319 __Pyx_XDECREF(__pyx_t_10);
53656320 __Pyx_AddTraceback("clickhouse_driver.bufferedwriter.__pyx_unpickle_CompressedBufferedWriter__set_state", __pyx_clineno, __pyx_lineno, __pyx_filename);
53666321 __pyx_r = 0;
53676322 __pyx_L0:;
53946349 {
53956350 PyObject *etype, *eval, *etb;
53966351 PyErr_Fetch(&etype, &eval, &etb);
5397 ++Py_REFCNT(o);
6352 __Pyx_SET_REFCNT(o, Py_REFCNT(o) + 1);
53986353 __pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_3__dealloc__(o);
5399 --Py_REFCNT(o);
6354 __Pyx_SET_REFCNT(o, Py_REFCNT(o) - 1);
54006355 PyErr_Restore(etype, eval, etb);
54016356 }
54026357 (*Py_TYPE(o)->tp_free)(o);
54076362 {"write", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_7write, METH_O, 0},
54086363 {"flush", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_9flush, METH_NOARGS, 0},
54096364 {"write_strings", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_11write_strings, METH_VARARGS|METH_KEYWORDS, 0},
5410 {"__reduce_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13__reduce_cython__, METH_NOARGS, 0},
5411 {"__setstate_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15__setstate_cython__, METH_O, 0},
6365 {"write_fixed_strings_as_bytes", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_13write_fixed_strings_as_bytes, METH_VARARGS|METH_KEYWORDS, 0},
6366 {"write_fixed_strings", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_15write_fixed_strings, METH_VARARGS|METH_KEYWORDS, 0},
6367 {"__reduce_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_17__reduce_cython__, METH_NOARGS, 0},
6368 {"__setstate_cython__", (PyCFunction)__pyx_pw_17clickhouse_driver_14bufferedwriter_14BufferedWriter_19__setstate_cython__, METH_O, 0},
54126369 {0, 0, 0, 0}
54136370 };
54146371
54186375 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter), /*tp_basicsize*/
54196376 0, /*tp_itemsize*/
54206377 __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedWriter, /*tp_dealloc*/
6378 #if PY_VERSION_HEX < 0x030800b4
54216379 0, /*tp_print*/
6380 #endif
6381 #if PY_VERSION_HEX >= 0x030800b4
6382 0, /*tp_vectorcall_offset*/
6383 #endif
54226384 0, /*tp_getattr*/
54236385 0, /*tp_setattr*/
54246386 #if PY_MAJOR_VERSION < 3
54716433 #if PY_VERSION_HEX >= 0x030800b1
54726434 0, /*tp_vectorcall*/
54736435 #endif
6436 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6437 0, /*tp_print*/
6438 #endif
54746439 };
54756440 static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter;
54766441
55336498 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter), /*tp_basicsize*/
55346499 0, /*tp_itemsize*/
55356500 __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter, /*tp_dealloc*/
6501 #if PY_VERSION_HEX < 0x030800b4
55366502 0, /*tp_print*/
6503 #endif
6504 #if PY_VERSION_HEX >= 0x030800b4
6505 0, /*tp_vectorcall_offset*/
6506 #endif
55376507 0, /*tp_getattr*/
55386508 0, /*tp_setattr*/
55396509 #if PY_MAJOR_VERSION < 3
55866556 #if PY_VERSION_HEX >= 0x030800b1
55876557 0, /*tp_vectorcall*/
55886558 #endif
6559 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6560 0, /*tp_print*/
6561 #endif
55896562 };
55906563 static struct __pyx_vtabstruct_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter;
55916564
56496622 sizeof(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter), /*tp_basicsize*/
56506623 0, /*tp_itemsize*/
56516624 __pyx_tp_dealloc_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter, /*tp_dealloc*/
6625 #if PY_VERSION_HEX < 0x030800b4
56526626 0, /*tp_print*/
6627 #endif
6628 #if PY_VERSION_HEX >= 0x030800b4
6629 0, /*tp_vectorcall_offset*/
6630 #endif
56536631 0, /*tp_getattr*/
56546632 0, /*tp_setattr*/
56556633 #if PY_MAJOR_VERSION < 3
57026680 #if PY_VERSION_HEX >= 0x030800b1
57036681 0, /*tp_vectorcall*/
57046682 #endif
6683 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
6684 0, /*tp_print*/
6685 #endif
57056686 };
57066687
57076688 static PyMethodDef __pyx_methods[] = {
57596740 {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
57606741 {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
57616742 {&__pyx_n_s_PickleError, __pyx_k_PickleError, sizeof(__pyx_k_PickleError), 0, 0, 1, 1},
6743 {&__pyx_n_s_TooLargeStringSize, __pyx_k_TooLargeStringSize, sizeof(__pyx_k_TooLargeStringSize), 0, 0, 1, 1},
6744 {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
6745 {&__pyx_n_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 1},
57626746 {&__pyx_n_s_bufsize, __pyx_k_bufsize, sizeof(__pyx_k_bufsize), 0, 0, 1, 1},
6747 {&__pyx_kp_u_bytes_object_expected, __pyx_k_bytes_object_expected, sizeof(__pyx_k_bytes_object_expected), 0, 1, 0, 0},
57636748 {&__pyx_n_s_clickhouse_driver_bufferedwriter, __pyx_k_clickhouse_driver_bufferedwriter, sizeof(__pyx_k_clickhouse_driver_bufferedwriter), 0, 0, 1, 1},
57646749 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
5765 {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
57666750 {&__pyx_n_s_compressor, __pyx_k_compressor, sizeof(__pyx_k_compressor), 0, 0, 1, 1},
57676751 {&__pyx_n_s_dict, __pyx_k_dict, sizeof(__pyx_k_dict), 0, 0, 1, 1},
57686752 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
6753 {&__pyx_n_s_encoding, __pyx_k_encoding, sizeof(__pyx_k_encoding), 0, 0, 1, 1},
6754 {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
57696755 {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1},
57706756 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
57716757 {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
57726758 {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
6759 {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
57736760 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
6761 {&__pyx_n_s_make_varint, __pyx_k_make_varint, sizeof(__pyx_k_make_varint), 0, 0, 1, 1},
57746762 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
57756763 {&__pyx_n_s_new, __pyx_k_new, sizeof(__pyx_k_new), 0, 0, 1, 1},
57766764 {&__pyx_n_s_pickle, __pyx_k_pickle, sizeof(__pyx_k_pickle), 0, 0, 1, 1},
57946782 {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
57956783 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
57966784 {&__pyx_n_s_update, __pyx_k_update, sizeof(__pyx_k_update), 0, 0, 1, 1},
5797 {&__pyx_n_s_utf_8_encode, __pyx_k_utf_8_encode, sizeof(__pyx_k_utf_8_encode), 0, 0, 1, 1},
57986785 {&__pyx_n_s_varint, __pyx_k_varint, sizeof(__pyx_k_varint), 0, 0, 1, 1},
57996786 {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
6787 {&__pyx_n_s_write_fixed_strings_as_bytes, __pyx_k_write_fixed_strings_as_bytes, sizeof(__pyx_k_write_fixed_strings_as_bytes), 0, 0, 1, 1},
58006788 {&__pyx_n_s_write_into_stream, __pyx_k_write_into_stream, sizeof(__pyx_k_write_into_stream), 0, 0, 1, 1},
5801 {&__pyx_n_s_write_varint, __pyx_k_write_varint, sizeof(__pyx_k_write_varint), 0, 0, 1, 1},
58026789 {0, 0, 0, 0, 0, 0, 0}
58036790 };
58046791 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
5805 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 18, __pyx_L1_error)
5806 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 23, __pyx_L1_error)
5807 __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 29, __pyx_L1_error)
6792 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 17, __pyx_L1_error)
6793 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 22, __pyx_L1_error)
6794 __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) __PYX_ERR(0, 28, __pyx_L1_error)
6795 __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 56, __pyx_L1_error)
58086796 return 0;
58096797 __pyx_L1_error:;
58106798 return -1;
58136801 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
58146802 __Pyx_RefNannyDeclarations
58156803 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
6804
6805 /* "clickhouse_driver/bufferedwriter.pyx":56
6806 * value = value.encode(encoding)
6807 * else:
6808 * raise ValueError('bytes object expected') # <<<<<<<<<<<<<<
6809 *
6810 * self.write(make_varint(PyBytes_GET_SIZE(value)))
6811 */
6812 __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_u_bytes_object_expected); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 56, __pyx_L1_error)
6813 __Pyx_GOTREF(__pyx_tuple_);
6814 __Pyx_GIVEREF(__pyx_tuple_);
58166815
58176816 /* "(tree fragment)":1
58186817 * def __pyx_unpickle_BufferedWriter(__pyx_type, long __pyx_checksum, __pyx_state): # <<<<<<<<<<<<<<
58196818 * cdef object __pyx_PickleError
58206819 * cdef object __pyx_result
58216820 */
5822 __pyx_tuple_ = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 1, __pyx_L1_error)
5823 __Pyx_GOTREF(__pyx_tuple_);
5824 __Pyx_GIVEREF(__pyx_tuple_);
5825 __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedWriter, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(1, 1, __pyx_L1_error)
58266821 __pyx_tuple__3 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 1, __pyx_L1_error)
58276822 __Pyx_GOTREF(__pyx_tuple__3);
58286823 __Pyx_GIVEREF(__pyx_tuple__3);
5829 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedSocketWri, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(1, 1, __pyx_L1_error)
6824 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedWriter, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(1, 1, __pyx_L1_error)
58306825 __pyx_tuple__5 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(1, 1, __pyx_L1_error)
58316826 __Pyx_GOTREF(__pyx_tuple__5);
58326827 __Pyx_GIVEREF(__pyx_tuple__5);
5833 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_CompressedBuffere, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(1, 1, __pyx_L1_error)
6828 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_BufferedSocketWri, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(1, 1, __pyx_L1_error)
6829 __pyx_tuple__7 = PyTuple_Pack(5, __pyx_n_s_pyx_type, __pyx_n_s_pyx_checksum, __pyx_n_s_pyx_state, __pyx_n_s_pyx_PickleError, __pyx_n_s_pyx_result); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 1, __pyx_L1_error)
6830 __Pyx_GOTREF(__pyx_tuple__7);
6831 __Pyx_GIVEREF(__pyx_tuple__7);
6832 __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_stringsource, __pyx_n_s_pyx_unpickle_CompressedBuffere, 1, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(1, 1, __pyx_L1_error)
58346833 __Pyx_RefNannyFinishContext();
58356834 return 0;
58366835 __pyx_L1_error:;
58826881
58836882 static int __Pyx_modinit_type_init_code(void) {
58846883 __Pyx_RefNannyDeclarations
6884 int __pyx_lineno = 0;
6885 const char *__pyx_filename = NULL;
6886 int __pyx_clineno = 0;
58856887 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
58866888 /*--- Type init code ---*/
58876889 __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter;
58886890 __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write_into_stream;
58896891 __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedWriter.write = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, PyObject *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_14BufferedWriter_write;
5890 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
6892 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
58916893 #if PY_VERSION_HEX < 0x030800B1
58926894 __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_print = 0;
58936895 #endif
58946896 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_getattro == PyObject_GenericGetAttr)) {
58956897 __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
58966898 }
5897 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
5898 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
5899 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
6899 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
6900 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
6901 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
59006902 __pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedWriter;
59016903 __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter;
59026904 __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.__pyx_base = *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter;
59036905 __pyx_vtable_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.__pyx_base.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_20BufferedSocketWriter_write_into_stream;
59046906 __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_base = __pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter;
5905 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
6907 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
59066908 #if PY_VERSION_HEX < 0x030800B1
59076909 __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_print = 0;
59086910 #endif
59096911 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_getattro == PyObject_GenericGetAttr)) {
59106912 __pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
59116913 }
5912 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
5913 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedSocketWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
5914 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
6914 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
6915 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_BufferedSocketWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
6916 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter) < 0) __PYX_ERR(0, 119, __pyx_L1_error)
59156917 __pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_BufferedSocketWriter;
59166918 __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = &__pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter;
59176919 __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.__pyx_base = *__pyx_vtabptr_17clickhouse_driver_14bufferedwriter_BufferedWriter;
59186920 __pyx_vtable_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.__pyx_base.write_into_stream = (PyObject *(*)(struct __pyx_obj_17clickhouse_driver_14bufferedwriter_BufferedWriter *, int __pyx_skip_dispatch))__pyx_f_17clickhouse_driver_14bufferedwriter_24CompressedBufferedWriter_write_into_stream;
59196921 __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_base = __pyx_ptype_17clickhouse_driver_14bufferedwriter_BufferedWriter;
5920 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
6922 if (PyType_Ready(&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
59216923 #if PY_VERSION_HEX < 0x030800B1
59226924 __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_print = 0;
59236925 #endif
59246926 if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_dictoffset && __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_getattro == PyObject_GenericGetAttr)) {
59256927 __pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_getattro = __Pyx_PyObject_GenericGetAttr;
59266928 }
5927 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
5928 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CompressedBufferedWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
5929 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 79, __pyx_L1_error)
6929 if (__Pyx_SetVtable(__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter.tp_dict, __pyx_vtabptr_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
6930 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_CompressedBufferedWriter, (PyObject *)&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
6931 if (__Pyx_setup_reduce((PyObject*)&__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter) < 0) __PYX_ERR(0, 133, __pyx_L1_error)
59306932 __pyx_ptype_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter = &__pyx_type_17clickhouse_driver_14bufferedwriter_CompressedBufferedWriter;
59316933 __Pyx_RefNannyFinishContext();
59326934 return 0;
59386940 static int __Pyx_modinit_type_import_code(void) {
59396941 __Pyx_RefNannyDeclarations
59406942 PyObject *__pyx_t_1 = NULL;
6943 int __pyx_lineno = 0;
6944 const char *__pyx_filename = NULL;
6945 int __pyx_clineno = 0;
59416946 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
59426947 /*--- Type import code ---*/
59436948 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 9, __pyx_L1_error)
59866991 }
59876992
59886993
5989 #if PY_MAJOR_VERSION < 3
5990 #ifdef CYTHON_NO_PYINIT_EXPORT
6994 #ifndef CYTHON_NO_PYINIT_EXPORT
6995 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
6996 #elif PY_MAJOR_VERSION < 3
6997 #ifdef __cplusplus
6998 #define __Pyx_PyMODINIT_FUNC extern "C" void
6999 #else
59917000 #define __Pyx_PyMODINIT_FUNC void
7001 #endif
59927002 #else
5993 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
5994 #endif
7003 #ifdef __cplusplus
7004 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
59957005 #else
5996 #ifdef CYTHON_NO_PYINIT_EXPORT
59977006 #define __Pyx_PyMODINIT_FUNC PyObject *
5998 #else
5999 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
60007007 #endif
60017008 #endif
60027009
60797086 {
60807087 PyObject *__pyx_t_1 = NULL;
60817088 PyObject *__pyx_t_2 = NULL;
7089 int __pyx_lineno = 0;
7090 const char *__pyx_filename = NULL;
7091 int __pyx_clineno = 0;
60827092 __Pyx_RefNannyDeclarations
60837093 #if CYTHON_PEP489_MULTI_PHASE_INIT
60847094 if (__pyx_m) {
61677177 }
61687178 #endif
61697179 /*--- Builtin init code ---*/
6170 if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
7180 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
61717181 /*--- Constants init code ---*/
6172 if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
7182 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
61737183 /*--- Global type/function init code ---*/
61747184 (void)__Pyx_modinit_global_init_code();
61757185 (void)__Pyx_modinit_variable_export_code();
61767186 (void)__Pyx_modinit_function_export_code();
6177 if (unlikely(__Pyx_modinit_type_init_code() != 0)) goto __pyx_L1_error;
6178 if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
7187 if (unlikely(__Pyx_modinit_type_init_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
7188 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
61797189 (void)__Pyx_modinit_variable_import_code();
61807190 (void)__Pyx_modinit_function_import_code();
61817191 /*--- Execution code ---*/
61847194 #endif
61857195
61867196 /* "clickhouse_driver/bufferedwriter.pyx":6
6187 * from libc.string cimport memcpy
6188 *
6189 * from codecs import utf_8_encode # <<<<<<<<<<<<<<
6190 *
6191 * from .varint import write_varint
7197 * from libc.string cimport memcpy, memset
7198 *
7199 * from . import errors # <<<<<<<<<<<<<<
7200 * from .varint import make_varint
7201 *
61927202 */
61937203 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
61947204 __Pyx_GOTREF(__pyx_t_1);
6195 __Pyx_INCREF(__pyx_n_s_utf_8_encode);
6196 __Pyx_GIVEREF(__pyx_n_s_utf_8_encode);
6197 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_utf_8_encode);
6198 __pyx_t_2 = __Pyx_Import(__pyx_n_s_codecs, __pyx_t_1, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
7205 __Pyx_INCREF(__pyx_n_s_errors);
7206 __Pyx_GIVEREF(__pyx_n_s_errors);
7207 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_errors);
7208 __pyx_t_2 = __Pyx_Import(__pyx_n_s__2, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6, __pyx_L1_error)
61997209 __Pyx_GOTREF(__pyx_t_2);
62007210 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6201 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_utf_8_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
7211 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
62027212 __Pyx_GOTREF(__pyx_t_1);
6203 if (PyDict_SetItem(__pyx_d, __pyx_n_s_utf_8_encode, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
7213 if (PyDict_SetItem(__pyx_d, __pyx_n_s_errors, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
62047214 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
62057215 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
62067216
6207 /* "clickhouse_driver/bufferedwriter.pyx":8
6208 * from codecs import utf_8_encode
6209 *
6210 * from .varint import write_varint # <<<<<<<<<<<<<<
6211 *
6212 *
6213 */
6214 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
7217 /* "clickhouse_driver/bufferedwriter.pyx":7
7218 *
7219 * from . import errors
7220 * from .varint import make_varint # <<<<<<<<<<<<<<
7221 *
7222 *
7223 */
7224 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
62157225 __Pyx_GOTREF(__pyx_t_2);
6216 __Pyx_INCREF(__pyx_n_s_write_varint);
6217 __Pyx_GIVEREF(__pyx_n_s_write_varint);
6218 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_write_varint);
6219 __pyx_t_1 = __Pyx_Import(__pyx_n_s_varint, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
7226 __Pyx_INCREF(__pyx_n_s_make_varint);
7227 __Pyx_GIVEREF(__pyx_n_s_make_varint);
7228 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_make_varint);
7229 __pyx_t_1 = __Pyx_Import(__pyx_n_s_varint, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
62207230 __Pyx_GOTREF(__pyx_t_1);
62217231 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6222 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_write_varint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
7232 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_make_varint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 7, __pyx_L1_error)
62237233 __Pyx_GOTREF(__pyx_t_2);
6224 if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_varint, __pyx_t_2) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
7234 if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_varint, __pyx_t_2) < 0) __PYX_ERR(0, 7, __pyx_L1_error)
62257235 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
62267236 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
62277237
62587268 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
62597269
62607270 /* "clickhouse_driver/bufferedwriter.pyx":1
6261 * from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, PyBytes_Check # <<<<<<<<<<<<<<
6262 * from cpython.bytearray cimport PyByteArray_AsString, \
6263 * PyByteArray_FromStringAndSize
7271 * from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, \ # <<<<<<<<<<<<<<
7272 * PyBytes_Check, PyBytes_FromStringAndSize, PyBytes_AS_STRING, \
7273 * PyBytes_GET_SIZE
62647274 */
62657275 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
62667276 __Pyx_GOTREF(__pyx_t_1);
63747384 }
63757385 name = first_kw_arg;
63767386 #if PY_MAJOR_VERSION < 3
6377 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
7387 if (likely(PyString_Check(key))) {
63787388 while (*name) {
63797389 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
63807390 && _PyString_Eq(**name, key)) {
64017411 while (*name) {
64027412 int cmp = (**name == key) ? 0 :
64037413 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
6404 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
7414 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
64057415 #endif
64067416 PyUnicode_Compare(**name, key);
64077417 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
64177427 while (argname != first_kw_arg) {
64187428 int cmp = (**argname == key) ? 0 :
64197429 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
6420 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
7430 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
64217431 #endif
64227432 PyUnicode_Compare(**argname, key);
64237433 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
69978007 return __Pyx_GetBuiltinName(name);
69988008 }
69998009
7000 /* GetItemInt */
7001 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
7002 PyObject *r;
7003 if (!j) return NULL;
7004 r = PyObject_GetItem(o, j);
7005 Py_DECREF(j);
7006 return r;
7007 }
7008 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
7009 CYTHON_NCP_UNUSED int wraparound,
7010 CYTHON_NCP_UNUSED int boundscheck) {
7011 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7012 Py_ssize_t wrapped_i = i;
7013 if (wraparound & unlikely(i < 0)) {
7014 wrapped_i += PyList_GET_SIZE(o);
7015 }
7016 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
7017 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
7018 Py_INCREF(r);
7019 return r;
7020 }
7021 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
7022 #else
7023 return PySequence_GetItem(o, i);
7024 #endif
7025 }
7026 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
7027 CYTHON_NCP_UNUSED int wraparound,
7028 CYTHON_NCP_UNUSED int boundscheck) {
7029 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7030 Py_ssize_t wrapped_i = i;
7031 if (wraparound & unlikely(i < 0)) {
7032 wrapped_i += PyTuple_GET_SIZE(o);
7033 }
7034 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
7035 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
7036 Py_INCREF(r);
7037 return r;
7038 }
7039 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
7040 #else
7041 return PySequence_GetItem(o, i);
7042 #endif
7043 }
7044 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
7045 CYTHON_NCP_UNUSED int wraparound,
7046 CYTHON_NCP_UNUSED int boundscheck) {
7047 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
7048 if (is_list || PyList_CheckExact(o)) {
7049 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
7050 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
7051 PyObject *r = PyList_GET_ITEM(o, n);
7052 Py_INCREF(r);
7053 return r;
7054 }
7055 }
7056 else if (PyTuple_CheckExact(o)) {
7057 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
7058 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
7059 PyObject *r = PyTuple_GET_ITEM(o, n);
7060 Py_INCREF(r);
7061 return r;
7062 }
7063 } else {
7064 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
7065 if (likely(m && m->sq_item)) {
7066 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
7067 Py_ssize_t l = m->sq_length(o);
7068 if (likely(l >= 0)) {
7069 i += l;
7070 } else {
7071 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
7072 return NULL;
7073 PyErr_Clear();
7074 }
7075 }
7076 return m->sq_item(o, i);
7077 }
7078 }
7079 #else
7080 if (is_list || PySequence_Check(o)) {
7081 return PySequence_GetItem(o, i);
7082 }
7083 #endif
7084 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
7085 }
7086
70878010 /* PyErrExceptionMatches */
70888011 #if CYTHON_FAST_THREAD_STATE
70898012 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
71678090 {
71688091 #if PY_MAJOR_VERSION >= 3
71698092 if (level == -1) {
7170 if (strchr(__Pyx_MODULE_NAME, '.')) {
8093 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
71718094 module = PyImport_ImportModuleLevelObject(
71728095 name, global_dict, empty_dict, list, 1);
71738096 if (!module) {
72168139 return value;
72178140 }
72188141
8142 /* GetItemInt */
8143 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
8144 PyObject *r;
8145 if (!j) return NULL;
8146 r = PyObject_GetItem(o, j);
8147 Py_DECREF(j);
8148 return r;
8149 }
8150 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
8151 CYTHON_NCP_UNUSED int wraparound,
8152 CYTHON_NCP_UNUSED int boundscheck) {
8153 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8154 Py_ssize_t wrapped_i = i;
8155 if (wraparound & unlikely(i < 0)) {
8156 wrapped_i += PyList_GET_SIZE(o);
8157 }
8158 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
8159 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
8160 Py_INCREF(r);
8161 return r;
8162 }
8163 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8164 #else
8165 return PySequence_GetItem(o, i);
8166 #endif
8167 }
8168 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
8169 CYTHON_NCP_UNUSED int wraparound,
8170 CYTHON_NCP_UNUSED int boundscheck) {
8171 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
8172 Py_ssize_t wrapped_i = i;
8173 if (wraparound & unlikely(i < 0)) {
8174 wrapped_i += PyTuple_GET_SIZE(o);
8175 }
8176 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
8177 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
8178 Py_INCREF(r);
8179 return r;
8180 }
8181 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8182 #else
8183 return PySequence_GetItem(o, i);
8184 #endif
8185 }
8186 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
8187 CYTHON_NCP_UNUSED int wraparound,
8188 CYTHON_NCP_UNUSED int boundscheck) {
8189 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
8190 if (is_list || PyList_CheckExact(o)) {
8191 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
8192 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
8193 PyObject *r = PyList_GET_ITEM(o, n);
8194 Py_INCREF(r);
8195 return r;
8196 }
8197 }
8198 else if (PyTuple_CheckExact(o)) {
8199 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
8200 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
8201 PyObject *r = PyTuple_GET_ITEM(o, n);
8202 Py_INCREF(r);
8203 return r;
8204 }
8205 } else {
8206 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
8207 if (likely(m && m->sq_item)) {
8208 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
8209 Py_ssize_t l = m->sq_length(o);
8210 if (likely(l >= 0)) {
8211 i += l;
8212 } else {
8213 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
8214 return NULL;
8215 PyErr_Clear();
8216 }
8217 }
8218 return m->sq_item(o, i);
8219 }
8220 }
8221 #else
8222 if (is_list || PySequence_Check(o)) {
8223 return PySequence_GetItem(o, i);
8224 }
8225 #endif
8226 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
8227 }
8228
72198229 /* HasAttr */
72208230 static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
72218231 PyObject *r;
73238333 bad:
73248334 Py_XDECREF(ob);
73258335 return -1;
8336 }
8337
8338 /* PyObjectGetAttrStrNoError */
8339 static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
8340 __Pyx_PyThreadState_declare
8341 __Pyx_PyThreadState_assign
8342 if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
8343 __Pyx_PyErr_Clear();
8344 }
8345 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
8346 PyObject *result;
8347 #if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS && PY_VERSION_HEX >= 0x030700B1
8348 PyTypeObject* tp = Py_TYPE(obj);
8349 if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
8350 return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
8351 }
8352 #endif
8353 result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
8354 if (unlikely(!result)) {
8355 __Pyx_PyObject_GetAttrStr_ClearAttributeError();
8356 }
8357 return result;
73268358 }
73278359
73288360 /* SetupReduce */
73528384 PyObject *setstate = NULL;
73538385 PyObject *setstate_cython = NULL;
73548386 #if CYTHON_USE_PYTYPE_LOOKUP
7355 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD;
8387 if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
73568388 #else
7357 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD;
8389 if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto __PYX_GOOD;
73588390 #endif
73598391 #if CYTHON_USE_PYTYPE_LOOKUP
7360 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
8392 object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
73618393 #else
7362 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD;
7363 #endif
7364 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD;
8394 object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto __PYX_BAD;
8395 #endif
8396 reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto __PYX_BAD;
73658397 if (reduce_ex == object_reduce_ex) {
73668398 #if CYTHON_USE_PYTYPE_LOOKUP
7367 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
8399 object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
73688400 #else
7369 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD;
7370 #endif
7371 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD;
8401 object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto __PYX_BAD;
8402 #endif
8403 reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto __PYX_BAD;
73728404 if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) {
7373 reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD;
7374 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD;
7375 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD;
8405 reduce_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_reduce_cython);
8406 if (likely(reduce_cython)) {
8407 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8408 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8409 } else if (reduce == object_reduce || PyErr_Occurred()) {
8410 goto __PYX_BAD;
8411 }
73768412 setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate);
73778413 if (!setstate) PyErr_Clear();
73788414 if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) {
7379 setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD;
7380 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD;
7381 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD;
8415 setstate_cython = __Pyx_PyObject_GetAttrStrNoError(type_obj, __pyx_n_s_setstate_cython);
8416 if (likely(setstate_cython)) {
8417 ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8418 ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto __PYX_BAD;
8419 } else if (!setstate || PyErr_Occurred()) {
8420 goto __PYX_BAD;
8421 }
73828422 }
73838423 PyType_Modified((PyTypeObject*)type_obj);
73848424 }
73858425 }
7386 goto GOOD;
7387 BAD:
8426 goto __PYX_GOOD;
8427 __PYX_BAD:
73888428 if (!PyErr_Occurred())
73898429 PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name);
73908430 ret = -1;
7391 GOOD:
8431 __PYX_GOOD:
73928432 #if !CYTHON_USE_PYTYPE_LOOKUP
73938433 Py_XDECREF(object_reduce);
73948434 Py_XDECREF(object_reduce_ex);
74648504
74658505 /* CLineInTraceback */
74668506 #ifndef CYTHON_CLINE_IN_TRACEBACK
7467 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
8507 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
74688508 PyObject *use_cline;
74698509 PyObject *ptype, *pvalue, *ptraceback;
74708510 #if CYTHON_COMPILING_IN_CPYTHON
75688608 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
75698609 int new_max = __pyx_code_cache.max_count + 64;
75708610 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
7571 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
8611 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
75728612 if (unlikely(!entries)) {
75738613 return;
75748614 }
76698709 Py_XDECREF(py_frame);
76708710 }
76718711
8712 /* CIntToPy */
8713 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) {
8714 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
8715 const int is_unsigned = neg_one > const_zero;
8716 if (is_unsigned) {
8717 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
8718 return PyInt_FromLong((long) value);
8719 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
8720 return PyLong_FromUnsignedLong((unsigned long) value);
8721 #ifdef HAVE_LONG_LONG
8722 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
8723 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
8724 #endif
8725 }
8726 } else {
8727 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
8728 return PyInt_FromLong((long) value);
8729 #ifdef HAVE_LONG_LONG
8730 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
8731 return PyLong_FromLongLong((PY_LONG_LONG) value);
8732 #endif
8733 }
8734 }
8735 {
8736 int one = 1; int little = (int)*(unsigned char *)&one;
8737 unsigned char *bytes = (unsigned char *)&value;
8738 return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG),
8739 little, !is_unsigned);
8740 }
8741 }
8742
76728743 /* CIntFromPyVerify */
76738744 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
76748745 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
77208791 return _PyLong_FromByteArray(bytes, sizeof(long),
77218792 little, !is_unsigned);
77228793 }
8794 }
8795
8796 /* CIntFromPy */
8797 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
8798 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
8799 const int is_unsigned = neg_one > const_zero;
8800 #if PY_MAJOR_VERSION < 3
8801 if (likely(PyInt_Check(x))) {
8802 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
8803 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
8804 } else {
8805 long val = PyInt_AS_LONG(x);
8806 if (is_unsigned && unlikely(val < 0)) {
8807 goto raise_neg_overflow;
8808 }
8809 return (unsigned PY_LONG_LONG) val;
8810 }
8811 } else
8812 #endif
8813 if (likely(PyLong_Check(x))) {
8814 if (is_unsigned) {
8815 #if CYTHON_USE_PYLONG_INTERNALS
8816 const digit* digits = ((PyLongObject*)x)->ob_digit;
8817 switch (Py_SIZE(x)) {
8818 case 0: return (unsigned PY_LONG_LONG) 0;
8819 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
8820 case 2:
8821 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
8822 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8823 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8824 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
8825 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
8826 }
8827 }
8828 break;
8829 case 3:
8830 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
8831 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8832 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8833 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
8834 return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
8835 }
8836 }
8837 break;
8838 case 4:
8839 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
8840 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8841 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8842 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
8843 return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
8844 }
8845 }
8846 break;
8847 }
8848 #endif
8849 #if CYTHON_COMPILING_IN_CPYTHON
8850 if (unlikely(Py_SIZE(x) < 0)) {
8851 goto raise_neg_overflow;
8852 }
8853 #else
8854 {
8855 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
8856 if (unlikely(result < 0))
8857 return (unsigned PY_LONG_LONG) -1;
8858 if (unlikely(result == 1))
8859 goto raise_neg_overflow;
8860 }
8861 #endif
8862 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
8863 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
8864 #ifdef HAVE_LONG_LONG
8865 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
8866 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
8867 #endif
8868 }
8869 } else {
8870 #if CYTHON_USE_PYLONG_INTERNALS
8871 const digit* digits = ((PyLongObject*)x)->ob_digit;
8872 switch (Py_SIZE(x)) {
8873 case 0: return (unsigned PY_LONG_LONG) 0;
8874 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
8875 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
8876 case -2:
8877 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
8878 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8879 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8880 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8881 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8882 }
8883 }
8884 break;
8885 case 2:
8886 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
8887 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8888 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8889 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8890 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8891 }
8892 }
8893 break;
8894 case -3:
8895 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
8896 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8897 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8898 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8899 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8900 }
8901 }
8902 break;
8903 case 3:
8904 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
8905 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8906 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8907 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8908 return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8909 }
8910 }
8911 break;
8912 case -4:
8913 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
8914 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8915 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8916 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
8917 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8918 }
8919 }
8920 break;
8921 case 4:
8922 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
8923 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8924 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8925 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
8926 return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
8927 }
8928 }
8929 break;
8930 }
8931 #endif
8932 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
8933 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
8934 #ifdef HAVE_LONG_LONG
8935 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
8936 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
8937 #endif
8938 }
8939 }
8940 {
8941 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
8942 PyErr_SetString(PyExc_RuntimeError,
8943 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
8944 #else
8945 unsigned PY_LONG_LONG val;
8946 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
8947 #if PY_MAJOR_VERSION < 3
8948 if (likely(v) && !PyLong_Check(v)) {
8949 PyObject *tmp = v;
8950 v = PyNumber_Long(tmp);
8951 Py_DECREF(tmp);
8952 }
8953 #endif
8954 if (likely(v)) {
8955 int one = 1; int is_little = (int)*(unsigned char *)&one;
8956 unsigned char *bytes = (unsigned char *)&val;
8957 int ret = _PyLong_AsByteArray((PyLongObject *)v,
8958 bytes, sizeof(val),
8959 is_little, !is_unsigned);
8960 Py_DECREF(v);
8961 if (likely(!ret))
8962 return val;
8963 }
8964 #endif
8965 return (unsigned PY_LONG_LONG) -1;
8966 }
8967 } else {
8968 unsigned PY_LONG_LONG val;
8969 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
8970 if (!tmp) return (unsigned PY_LONG_LONG) -1;
8971 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
8972 Py_DECREF(tmp);
8973 return val;
8974 }
8975 raise_overflow:
8976 PyErr_SetString(PyExc_OverflowError,
8977 "value too large to convert to unsigned PY_LONG_LONG");
8978 return (unsigned PY_LONG_LONG) -1;
8979 raise_neg_overflow:
8980 PyErr_SetString(PyExc_OverflowError,
8981 "can't convert negative value to unsigned PY_LONG_LONG");
8982 return (unsigned PY_LONG_LONG) -1;
8983 }
8984
8985 /* CIntFromPy */
8986 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
8987 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
8988 const int is_unsigned = neg_one > const_zero;
8989 #if PY_MAJOR_VERSION < 3
8990 if (likely(PyInt_Check(x))) {
8991 if (sizeof(long) < sizeof(long)) {
8992 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
8993 } else {
8994 long val = PyInt_AS_LONG(x);
8995 if (is_unsigned && unlikely(val < 0)) {
8996 goto raise_neg_overflow;
8997 }
8998 return (long) val;
8999 }
9000 } else
9001 #endif
9002 if (likely(PyLong_Check(x))) {
9003 if (is_unsigned) {
9004 #if CYTHON_USE_PYLONG_INTERNALS
9005 const digit* digits = ((PyLongObject*)x)->ob_digit;
9006 switch (Py_SIZE(x)) {
9007 case 0: return (long) 0;
9008 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
9009 case 2:
9010 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
9011 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9012 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9013 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
9014 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
9015 }
9016 }
9017 break;
9018 case 3:
9019 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
9020 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9021 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9022 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
9023 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
9024 }
9025 }
9026 break;
9027 case 4:
9028 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
9029 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9030 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9031 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
9032 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
9033 }
9034 }
9035 break;
9036 }
9037 #endif
9038 #if CYTHON_COMPILING_IN_CPYTHON
9039 if (unlikely(Py_SIZE(x) < 0)) {
9040 goto raise_neg_overflow;
9041 }
9042 #else
9043 {
9044 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
9045 if (unlikely(result < 0))
9046 return (long) -1;
9047 if (unlikely(result == 1))
9048 goto raise_neg_overflow;
9049 }
9050 #endif
9051 if (sizeof(long) <= sizeof(unsigned long)) {
9052 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
9053 #ifdef HAVE_LONG_LONG
9054 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
9055 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
9056 #endif
9057 }
9058 } else {
9059 #if CYTHON_USE_PYLONG_INTERNALS
9060 const digit* digits = ((PyLongObject*)x)->ob_digit;
9061 switch (Py_SIZE(x)) {
9062 case 0: return (long) 0;
9063 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
9064 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
9065 case -2:
9066 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
9067 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9068 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9069 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
9070 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9071 }
9072 }
9073 break;
9074 case 2:
9075 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
9076 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
9077 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9078 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
9079 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9080 }
9081 }
9082 break;
9083 case -3:
9084 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
9085 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9086 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9087 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
9088 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9089 }
9090 }
9091 break;
9092 case 3:
9093 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
9094 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
9095 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9096 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
9097 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9098 }
9099 }
9100 break;
9101 case -4:
9102 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
9103 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9104 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9105 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
9106 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9107 }
9108 }
9109 break;
9110 case 4:
9111 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
9112 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
9113 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
9114 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
9115 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
9116 }
9117 }
9118 break;
9119 }
9120 #endif
9121 if (sizeof(long) <= sizeof(long)) {
9122 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
9123 #ifdef HAVE_LONG_LONG
9124 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
9125 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
9126 #endif
9127 }
9128 }
9129 {
9130 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
9131 PyErr_SetString(PyExc_RuntimeError,
9132 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
9133 #else
9134 long val;
9135 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
9136 #if PY_MAJOR_VERSION < 3
9137 if (likely(v) && !PyLong_Check(v)) {
9138 PyObject *tmp = v;
9139 v = PyNumber_Long(tmp);
9140 Py_DECREF(tmp);
9141 }
9142 #endif
9143 if (likely(v)) {
9144 int one = 1; int is_little = (int)*(unsigned char *)&one;
9145 unsigned char *bytes = (unsigned char *)&val;
9146 int ret = _PyLong_AsByteArray((PyLongObject *)v,
9147 bytes, sizeof(val),
9148 is_little, !is_unsigned);
9149 Py_DECREF(v);
9150 if (likely(!ret))
9151 return val;
9152 }
9153 #endif
9154 return (long) -1;
9155 }
9156 } else {
9157 long val;
9158 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
9159 if (!tmp) return (long) -1;
9160 val = __Pyx_PyInt_As_long(tmp);
9161 Py_DECREF(tmp);
9162 return val;
9163 }
9164 raise_overflow:
9165 PyErr_SetString(PyExc_OverflowError,
9166 "value too large to convert to long");
9167 return (long) -1;
9168 raise_neg_overflow:
9169 PyErr_SetString(PyExc_OverflowError,
9170 "can't convert negative value to long");
9171 return (long) -1;
77239172 }
77249173
77259174 /* CIntFromPy */
79119360 return (int) -1;
79129361 }
79139362
7914 /* CIntFromPy */
7915 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
7916 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
7917 const int is_unsigned = neg_one > const_zero;
7918 #if PY_MAJOR_VERSION < 3
7919 if (likely(PyInt_Check(x))) {
7920 if (sizeof(long) < sizeof(long)) {
7921 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
7922 } else {
7923 long val = PyInt_AS_LONG(x);
7924 if (is_unsigned && unlikely(val < 0)) {
7925 goto raise_neg_overflow;
7926 }
7927 return (long) val;
7928 }
7929 } else
7930 #endif
7931 if (likely(PyLong_Check(x))) {
7932 if (is_unsigned) {
7933 #if CYTHON_USE_PYLONG_INTERNALS
7934 const digit* digits = ((PyLongObject*)x)->ob_digit;
7935 switch (Py_SIZE(x)) {
7936 case 0: return (long) 0;
7937 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
7938 case 2:
7939 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7940 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7941 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7942 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
7943 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7944 }
7945 }
7946 break;
7947 case 3:
7948 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7949 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7950 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7951 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
7952 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7953 }
7954 }
7955 break;
7956 case 4:
7957 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7958 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7959 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7960 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
7961 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7962 }
7963 }
7964 break;
7965 }
7966 #endif
7967 #if CYTHON_COMPILING_IN_CPYTHON
7968 if (unlikely(Py_SIZE(x) < 0)) {
7969 goto raise_neg_overflow;
7970 }
7971 #else
7972 {
7973 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7974 if (unlikely(result < 0))
7975 return (long) -1;
7976 if (unlikely(result == 1))
7977 goto raise_neg_overflow;
7978 }
7979 #endif
7980 if (sizeof(long) <= sizeof(unsigned long)) {
7981 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
7982 #ifdef HAVE_LONG_LONG
7983 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7984 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7985 #endif
7986 }
7987 } else {
7988 #if CYTHON_USE_PYLONG_INTERNALS
7989 const digit* digits = ((PyLongObject*)x)->ob_digit;
7990 switch (Py_SIZE(x)) {
7991 case 0: return (long) 0;
7992 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
7993 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
7994 case -2:
7995 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
7996 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7997 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7998 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7999 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8000 }
8001 }
8002 break;
8003 case 2:
8004 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
8005 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
8006 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8007 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
8008 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8009 }
8010 }
8011 break;
8012 case -3:
8013 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
8014 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8015 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8016 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8017 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8018 }
8019 }
8020 break;
8021 case 3:
8022 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
8023 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
8024 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8025 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8026 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8027 }
8028 }
8029 break;
8030 case -4:
8031 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
8032 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8033 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8034 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
8035 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8036 }
8037 }
8038 break;
8039 case 4:
8040 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
8041 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
8042 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
8043 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
8044 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
8045 }
8046 }
8047 break;
8048 }
8049 #endif
8050 if (sizeof(long) <= sizeof(long)) {
8051 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
8052 #ifdef HAVE_LONG_LONG
8053 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
8054 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
8055 #endif
8056 }
8057 }
8058 {
8059 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
8060 PyErr_SetString(PyExc_RuntimeError,
8061 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
8062 #else
8063 long val;
8064 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
8065 #if PY_MAJOR_VERSION < 3
8066 if (likely(v) && !PyLong_Check(v)) {
8067 PyObject *tmp = v;
8068 v = PyNumber_Long(tmp);
8069 Py_DECREF(tmp);
8070 }
8071 #endif
8072 if (likely(v)) {
8073 int one = 1; int is_little = (int)*(unsigned char *)&one;
8074 unsigned char *bytes = (unsigned char *)&val;
8075 int ret = _PyLong_AsByteArray((PyLongObject *)v,
8076 bytes, sizeof(val),
8077 is_little, !is_unsigned);
8078 Py_DECREF(v);
8079 if (likely(!ret))
8080 return val;
8081 }
8082 #endif
8083 return (long) -1;
8084 }
8085 } else {
8086 long val;
8087 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
8088 if (!tmp) return (long) -1;
8089 val = __Pyx_PyInt_As_long(tmp);
8090 Py_DECREF(tmp);
8091 return val;
8092 }
8093 raise_overflow:
8094 PyErr_SetString(PyExc_OverflowError,
8095 "value too large to convert to long");
8096 return (long) -1;
8097 raise_neg_overflow:
8098 PyErr_SetString(PyExc_OverflowError,
8099 "can't convert negative value to long");
8100 return (long) -1;
8101 }
8102
81039363 /* FastTypeChecks */
81049364 #if CYTHON_COMPILING_IN_CPYTHON
81059365 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
0 from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, PyBytes_Check
1 from cpython.bytearray cimport PyByteArray_AsString, \
2 PyByteArray_FromStringAndSize
3 from libc.string cimport memcpy
0 from cpython cimport PyMem_Malloc, PyMem_Free, PyBytes_AsString, \
1 PyBytes_Check, PyBytes_FromStringAndSize, PyBytes_AS_STRING, \
2 PyBytes_GET_SIZE
3 from libc.string cimport memcpy, memset
44
5 from codecs import utf_8_encode
6
7 from .varint import write_varint
5 from . import errors
6 from .varint import make_varint
87
98
109 cdef class BufferedWriter(object):
1110 cdef char* buffer
12 cdef Py_ssize_t position, buffer_size
11 cdef unsigned long long position, buffer_size
1312
14 def __init__(self, Py_ssize_t bufsize):
13 def __init__(self, unsigned long long bufsize):
1514 self.buffer = <char *> PyMem_Malloc(bufsize)
1615 if not self.buffer:
1716 raise MemoryError()
2827 raise NotImplementedError
2928
3029 cpdef write(self, data):
31 cdef Py_ssize_t written = 0
32 cdef Py_ssize_t to_write, size
33 cdef Py_ssize_t data_len = len(data)
34 cdef char* c_data
35
36 if PyBytes_Check(data):
37 c_data = PyBytes_AsString(data)
38 else:
39 c_data = PyByteArray_AsString(data)
30 cdef unsigned long long size, written = 0
31 cdef unsigned long long data_len = PyBytes_GET_SIZE(data)
32 cdef char* c_data = PyBytes_AS_STRING(data)
4033
4134 while written < data_len:
4235 size = min(data_len - written, self.buffer_size - self.position)
5144 def flush(self):
5245 self.write_into_stream()
5346
54 def write_strings(self, items, int encode=0):
47 def write_strings(self, items, encoding=None):
48 cdef int do_encode = encoding is not None
49
5550 for value in items:
56 if encode:
57 if not isinstance(value, bytes):
58 value = utf_8_encode(value)[0]
51 if not PyBytes_Check(value):
52 if do_encode:
53 value = value.encode(encoding)
54 else:
55 raise ValueError('bytes object expected')
5956
60 write_varint(len(value), self)
57 self.write(make_varint(PyBytes_GET_SIZE(value)))
6158 self.write(value)
59
60 def write_fixed_strings_as_bytes(self, items, Py_ssize_t length):
61 cdef Py_ssize_t buf_pos = 0
62 cdef Py_ssize_t items_buf_size = length * len(items)
63
64 cdef char* c_value
65 cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
66 if not items_buf:
67 raise MemoryError()
68
69 memset(items_buf, 0, items_buf_size)
70
71 for value in items:
72 value_len = len(value)
73 if length < value_len:
74 raise errors.TooLargeStringSize()
75
76 c_value = PyBytes_AsString(value)
77
78 memcpy(&items_buf[buf_pos], c_value, value_len)
79 buf_pos += length
80
81 self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
82
83 PyMem_Free(items_buf)
84
85 def write_fixed_strings(self, items, Py_ssize_t length, encoding=None):
86 if encoding is None:
87 self.write_fixed_strings_as_bytes(items, length)
88 return
89
90 cdef Py_ssize_t buf_pos = 0
91 cdef Py_ssize_t items_buf_size = length * len(items)
92
93 cdef char* c_value
94 cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
95 if not items_buf:
96 raise MemoryError()
97
98 memset(items_buf, 0, items_buf_size)
99
100 for value in items:
101 if not PyBytes_Check(value):
102 value = value.encode(encoding)
103
104 value_len = len(value)
105 if length < value_len:
106 raise errors.TooLargeStringSize()
107
108 c_value = PyBytes_AsString(value)
109
110 memcpy(&items_buf[buf_pos], c_value, value_len)
111 buf_pos += length
112
113 self.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
114
115 PyMem_Free(items_buf)
62116
63117
64118 cdef class BufferedSocketWriter(BufferedWriter):
70124
71125 cpdef write_into_stream(self):
72126 self.sock.sendall(
73 PyByteArray_FromStringAndSize(self.buffer, self.position)
127 PyBytes_FromStringAndSize(self.buffer, self.position)
74128 )
75129 self.position = 0
76130
84138
85139 cpdef write_into_stream(self):
86140 self.compressor.write(
87 PyByteArray_FromStringAndSize(self.buffer, self.position)
141 PyBytes_FromStringAndSize(self.buffer, self.position)
88142 )
89143 self.position = 0
90144
0 import re
01 import ssl
12 from time import time
23 import types
45 from . import errors, defines
56 from .block import ColumnOrientedBlock, RowOrientedBlock
67 from .connection import Connection
8 from .log import log_block
79 from .protocol import ServerPacketTypes
810 from .result import (
911 IterQueryResult, ProgressQueryResult, QueryResult, QueryInfo
1012 )
11 from .util.compat import urlparse, parse_qs, asbool
13 from .util.compat import urlparse, parse_qs, asbool, unquote
1214 from .util.escape import escape_params
1315 from .util.helpers import column_chunks, chunks
1416
3032
3133 * strings_as_bytes -- turns off string column encoding/decoding.
3234
35 * strings_encoding -- specifies string encoding. UTF-8 by default.
36
37 * use_numpy -- Use numpy for columns reading. New in version *0.2.0*.
38
3339 """
3440
3541 available_client_settings = (
3642 'insert_block_size', # TODO: rename to max_insert_block_size
37 'strings_as_bytes'
43 'strings_as_bytes',
44 'strings_encoding',
45 'use_numpy'
3846 )
3947
4048 def __init__(self, *args, **kwargs):
4654 )),
4755 'strings_as_bytes': self.settings.pop(
4856 'strings_as_bytes', False
57 ),
58 'strings_encoding': self.settings.pop(
59 'strings_encoding', defines.STRINGS_ENCODING
60 ),
61 'use_numpy': self.settings.pop(
62 'use_numpy', False
4963 )
5064 }
65
66 if self.client_settings['use_numpy']:
67 try:
68 from .numpy.result import (
69 NumpyIterQueryResult, NumpyProgressQueryResult,
70 NumpyQueryResult
71 )
72 self.query_result_cls = NumpyQueryResult
73 self.iter_query_result_cls = NumpyIterQueryResult
74 self.progress_query_result_cls = NumpyProgressQueryResult
75 except ImportError:
76 raise RuntimeError('Extras for NumPy must be installed')
77 else:
78 self.query_result_cls = QueryResult
79 self.iter_query_result_cls = IterQueryResult
80 self.progress_query_result_cls = ProgressQueryResult
5181
5282 self.connection = Connection(*args, **kwargs)
5383 self.connection.context.settings = self.settings
71101 gen = self.packet_generator()
72102
73103 if progress:
74 return ProgressQueryResult(
104 return self.progress_query_result_cls(
75105 gen, with_column_types=with_column_types, columnar=columnar
76106 )
77107
78108 else:
79 result = QueryResult(
109 result = self.query_result_cls(
80110 gen, with_column_types=with_column_types, columnar=columnar
81111 )
82112 return result.get_result()
84114 def iter_receive_result(self, with_column_types=False):
85115 gen = self.packet_generator()
86116
87 for rows in IterQueryResult(gen, with_column_types=with_column_types):
117 result = self.iter_query_result_cls(
118 gen, with_column_types=with_column_types
119 )
120
121 for rows in result:
88122 for row in rows:
89123 yield row
90124
134168 return True
135169
136170 def make_query_settings(self, settings):
137 settings = settings or {}
171 settings = dict(settings or {})
138172
139173 # Pick client-related settings.
140174 client_settings = self.client_settings.copy()
311345 self.disconnect()
312346 raise
313347
348 def query_dataframe(
349 self, query, params=None, external_tables=None, query_id=None,
350 settings=None):
351 """
352 *New in version 0.2.0.*
353
354 Queries DataFrame with specified SELECT query.
355
356 :param query: query that will be send to server.
357 :param params: substitution parameters.
358 Defaults to ``None`` (no parameters or data).
359 :param external_tables: external tables to send.
360 Defaults to ``None`` (no external tables).
361 :param query_id: the query identifier. If no query id specified
362 ClickHouse server will generate it.
363 :param settings: dictionary of query settings.
364 Defaults to ``None`` (no additional settings).
365 :return: pandas DataFrame.
366 """
367
368 try:
369 import pandas as pd
370 except ImportError:
371 raise RuntimeError('Extras for NumPy must be installed')
372
373 data, columns = self.execute(
374 query, columnar=True, with_column_types=True, params=params,
375 external_tables=external_tables, query_id=query_id,
376 settings=settings
377 )
378
379 return pd.DataFrame(
380 {re.sub(r'\W', '_', col[0]): d for d, col in zip(data, columns)}
381 )
382
383 def insert_dataframe(
384 self, query, dataframe, transpose=True, external_tables=None,
385 query_id=None, settings=None):
386 """
387 *New in version 0.2.0.*
388
389 Inserts pandas DataFrame with specified query.
390
391 :param query: query that will be send to server.
392 :param dataframe: pandas DataFrame.
393 :param transpose: whether or not transpose DataFrame before sending.
394 This is necessary action as DataFrame can be sent in
395 columnar form. If DataFrame is already in columnar
396 form set this parameter to ``False``.
397 Defaults to ``True``.
398 :param external_tables: external tables to send.
399 Defaults to ``None`` (no external tables).
400 :param query_id: the query identifier. If no query id specified
401 ClickHouse server will generate it.
402 :param settings: dictionary of query settings.
403 Defaults to ``None`` (no additional settings).
404 :return: number of inserted rows.
405 """
406
407 try:
408 import pandas as pd # noqa: F401
409 except ImportError:
410 raise RuntimeError('Extras for NumPy must be installed')
411
412 frame = dataframe.transpose() if transpose else dataframe
413 columns = list(frame.values)
414
415 return self.execute(
416 query, columns, columnar=True, external_tables=external_tables,
417 query_id=query_id, settings=settings
418 )
419
314420 def process_ordinary_query_with_progress(
315421 self, query, params=None, with_column_types=False,
316422 external_tables=None, query_id=None,
363469 if sample_block:
364470 rv = self.send_data(sample_block, data,
365471 types_check=types_check, columnar=columnar)
366 packet = self.connection.receive_packet()
367 if packet.exception:
368 raise packet.exception
472 self.receive_end_of_query()
369473 return rv
370474
371475 def receive_sample_block(self):
378482 elif packet.type == ServerPacketTypes.EXCEPTION:
379483 raise packet.exception
380484
485 elif packet.type == ServerPacketTypes.LOG:
486 log_block(packet.block)
487
381488 elif packet.type == ServerPacketTypes.TABLE_COLUMNS:
382489 pass
383490
384491 else:
385492 message = self.connection.unexpected_packet_message(
386 'Data, Exception or TableColumns', packet.type
493 'Data, Exception, Log or TableColumns', packet.type
387494 )
388495 raise errors.UnexpectedPacketFromServerError(message)
389496
392499
393500 client_settings = self.connection.context.client_settings
394501 block_cls = ColumnOrientedBlock if columnar else RowOrientedBlock
395 slicer = column_chunks if columnar else chunks
502
503 if client_settings['use_numpy']:
504 try:
505 from .numpy.helpers import column_chunks as numpy_column_chunks
506
507 if columnar:
508 slicer = numpy_column_chunks
509 else:
510 raise ValueError(
511 'NumPy inserts is only allowed with columnar=True'
512 )
513
514 except ImportError:
515 raise RuntimeError('Extras for NumPy must be installed')
516
517 else:
518 slicer = column_chunks if columnar else chunks
396519
397520 for chunk in slicer(data, client_settings['insert_block_size']):
398521 block = block_cls(sample_block.columns_with_types, chunk,
404527 self.connection.send_data(block_cls())
405528 return inserted_rows
406529
530 def receive_end_of_query(self):
531 while True:
532 packet = self.connection.receive_packet()
533
534 if packet.type == ServerPacketTypes.END_OF_STREAM:
535 break
536
537 elif packet.type == ServerPacketTypes.EXCEPTION:
538 raise packet.exception
539
540 elif packet.type == ServerPacketTypes.LOG:
541 log_block(packet.block)
542
543 elif packet.type == ServerPacketTypes.TABLE_COLUMNS:
544 pass
545
546 else:
547 message = self.connection.unexpected_packet_message(
548 'Exception, EndOfStream or Log', packet.type
549 )
550 raise errors.UnexpectedPacketFromServerError(message)
551
407552 def cancel(self, with_column_types=False):
408553 # TODO: Add warning if already cancelled.
409554 self.connection.send_cancel()
449594 kwargs['database'] = path
450595
451596 if url.username is not None:
452 kwargs['user'] = url.username
597 kwargs['user'] = unquote(url.username)
453598
454599 if url.password is not None:
455 kwargs['password'] = url.password
600 kwargs['password'] = unquote(url.password)
456601
457602 if url.scheme == 'clickhouses':
458603 kwargs['secure'] = True
480625 elif name == 'secure':
481626 kwargs[name] = asbool(value)
482627
628 elif name == 'use_numpy':
629 settings[name] = asbool(value)
630
483631 elif name == 'client_name':
484632 kwargs[name] = value
485633
488636
489637 elif name == 'compress_block_size':
490638 kwargs[name] = int(value)
639
640 elif name == 'settings_is_important':
641 kwargs[name] = asbool(value)
491642
492643 # ssl
493644 elif name == 'verify':
0
0 from collections import deque
1 from itertools import chain
12 from struct import Struct
23
3 from ..util import compat
44 from .base import Column
55 from .intcolumn import UInt64Column
6
7 if compat.PY3:
8 from queue import Queue
9 else:
10 from Queue import Queue
6 from ..util.helpers import pairwise
117
128
139 class ArrayColumn(Column):
3026 After sizes info comes flatten data: 3 -> 4 -> 5 -> 6
3127 """
3228 py_types = (list, tuple)
33 size_struct = Struct('<Q')
3429
3530 def __init__(self, nested_column, **kwargs):
3631 self.size_column = UInt64Column()
3732 self.nested_column = nested_column
3833 self._write_depth_0_size = True
3934 super(ArrayColumn, self).__init__(**kwargs)
40
41 def size_pack(self, value):
42 return self.size_struct.pack(value)
43
44 def size_unpack(self, buf):
45 return self.size_struct.unpack(buf.read(self.size_struct.size))[0]
4635
4736 def write_data(self, data, buf):
4837 # Column of Array(T) is stored in "compact" format and passed to server
6049 return self._read(rows, buf)
6150
6251 def _write_sizes(self, value, buf):
63 q = Queue()
64 q.put((self, value, 0))
65
66 cur_depth = 0
67 offset = 0
6852 nulls_map = []
6953
70 while not q.empty():
71 column, value, depth = q.get_nowait()
54 column = self
55 sizes = [len(value)] if self._write_depth_0_size else []
7256
73 if cur_depth != depth:
74 cur_depth = depth
75 offset = 0
57 while True:
58 nested_column = column.nested_column
59 if not isinstance(nested_column, ArrayColumn):
7660 if column.nullable:
77 self._write_nulls_map(nulls_map, buf)
61 nulls_map = [x is None for x in value]
62 break
7863
79 nulls_map = []
64 offset = 0
65 new_value = []
66 for x in value:
67 offset += len(x)
68 sizes.append(offset)
69 new_value.extend(x)
8070
81 if column.nullable:
82 value = value or []
71 value = new_value
72 column = nested_column
8373
84 offset += len(value)
85 if (cur_depth == 0 and self._write_depth_0_size) or cur_depth > 0:
86 buf.write(self.size_pack(offset))
74 if nulls_map:
75 self._write_nulls_map(nulls_map, buf)
8776
88 nested_column = column.nested_column
89 if isinstance(nested_column, ArrayColumn):
90 for x in value:
91 q.put((nested_column, x, cur_depth + 1))
92 nulls_map.append(None if x is None else False)
77 ns = Struct('<{}Q'.format(len(sizes)))
78 buf.write(ns.pack(*sizes))
9379
9480 def _write_data(self, value, buf):
9581 if self.nullable:
9682 value = value or []
9783
9884 if isinstance(self.nested_column, ArrayColumn):
99 for x in value:
100 self.nested_column._write_data(list(x), buf)
101 else:
102 self.nested_column._write_data(value, buf)
85 value = list(chain.from_iterable(value))
86
87 self.nested_column._write_data(value, buf)
10388
10489 def _write_nulls_data(self, value, buf):
10590 if self.nullable:
10691 value = value or []
10792
10893 if isinstance(self.nested_column, ArrayColumn):
109 for x in value:
110 self.nested_column._write_nulls_data(x, buf)
94 value = list(chain.from_iterable(value))
95 self.nested_column._write_nulls_data(value, buf)
11196 else:
11297 if self.nested_column.nullable:
11398 self.nested_column._write_nulls_map(value, buf)
124109 self.nested_column.write_state_prefix(buf)
125110
126111 def _read(self, size, buf):
127 q = Queue()
128 q.put((self, size, 0))
112 q = deque()
113 q.appendleft((self, [size], 0))
129114
130 data = []
131115 slices_series = []
116 slices = []
132117
133118 cur_depth = 0
134 prev_offset = 0
135 slices = []
136119
137 if self.nested_column.nullable:
138 nulls_map = self._read_nulls_map(size, buf)
139 else:
140 nulls_map = [0] * size
120 nulls_map = None
121 nested_column = self.nested_column
122 n_items = 0
141123
142124 # Read and store info about slices.
143 while not q.empty():
144 column, size, depth = q.get_nowait()
125 while q:
126 column, sizes, depth = q.pop()
145127
146128 nested_column = column.nested_column
147129
148130 if cur_depth != depth:
149131 cur_depth = depth
150132
151 slices_series.append((slices, nulls_map))
133 slices_series.append(slices)
152134
135 # The last element in slice is index(number) of the last
136 # element in current level. On the last iteration this
137 # represents number of elements in fully flatten array.
138 n_items = slices[-1]
153139 if nested_column.nullable:
154 nulls_map = self._read_nulls_map(prev_offset, buf)
155 else:
156 nulls_map = [0] * prev_offset
140 nulls_map = self._read_nulls_map(n_items, buf)
157141
158 prev_offset = 0
159142 slices = []
160143
161144 if isinstance(nested_column, ArrayColumn):
162 for _i in range(size):
163 offset = self.size_unpack(buf)
164 q.put((nested_column, offset - prev_offset, cur_depth + 1))
165 slices.append((prev_offset, offset))
166 prev_offset = offset
145 slices.append(0)
146 prev = 0
147 for size in sizes:
148 ns = Struct('<{}Q'.format(size - prev))
149 nested_sizes = ns.unpack(buf.read(ns.size))
150 slices.extend(nested_sizes)
151 prev = size
167152
168 # Read data
169 else:
170 data.extend(
171 nested_column._read_data(
172 size, buf,
173 nulls_map=nulls_map[prev_offset:prev_offset + size]
174 )
175 )
176 prev_offset += size
153 q.appendleft((nested_column, nested_sizes, cur_depth + 1))
177154
178 # Build nested tuple structure.
179 for slices, nulls_map in reversed(slices_series):
180 nested_data = []
181 for (slice_from, slice_to), is_null in zip(slices, nulls_map):
182 nested_data.append(
183 None if is_null else tuple(data[slice_from:slice_to])
184 )
155 data = []
156 if n_items:
157 data = list(nested_column._read_data(
158 n_items, buf, nulls_map=nulls_map
159 ))
185160
186 data = nested_data
161 # Build nested structure.
162 for slices in reversed(slices_series):
163 data = [data[begin:end] for begin, end in pairwise(slices)]
187164
188165 return tuple(data)
189166
0 from calendar import timegm
10 from datetime import datetime
21 from time import mktime
32
43 from pytz import timezone as get_timezone, utc
54 from tzlocal import get_localzone
65
6 from ..util import compat
77 from .base import FormatColumn
8
9
10 EPOCH = datetime(1970, 1, 1, tzinfo=utc)
811
912
1013 class DateTimeColumn(FormatColumn):
1720 self.offset_naive = offset_naive
1821 super(DateTimeColumn, self).__init__(**kwargs)
1922
23 def timestamp_py2(self, dt):
24 """Return POSIX timestamp as float"""
25 if dt.tzinfo is None:
26 return mktime((dt.year, dt.month, dt.day,
27 dt.hour, dt.minute, dt.second,
28 -1, -1, -1))
29 else:
30 return (dt - EPOCH).total_seconds()
31
2032 def after_read_items(self, items, nulls_map=None):
2133 tz = self.timezone
2234 fromts = datetime.fromtimestamp
5769 def before_write_items(self, items, nulls_map=None):
5870 timezone = self.timezone
5971 null_value = self.null_value
72 to_timestamp = datetime.timestamp if compat.PY3 else self.timestamp_py2
6073
6174 for i, item in enumerate(items):
6275 if nulls_map and nulls_map[i]:
7487 item = timezone.localize(item)
7588
7689 item = item.astimezone(utc)
77 items[i] = int(timegm(item.timetuple()))
7890
7991 else:
8092 # If datetime is offset-aware use it's timezone.
8193 if item.tzinfo is not None:
8294 item = item.astimezone(utc)
83 items[i] = int(timegm(item.timetuple()))
84
85 else:
86 items[i] = int(mktime(item.timetuple()))
95
96 items[i] = int(to_timestamp(item))
8797
8898
8999 class DateTime64Column(DateTimeColumn):
95105 def __init__(self, scale=0, **kwargs):
96106 self.scale = scale
97107 super(DateTime64Column, self).__init__(**kwargs)
108
109 def timestamp_py2(self, dt):
110 """Return POSIX timestamp as float"""
111 if dt.tzinfo is None:
112 return mktime((dt.year, dt.month, dt.day,
113 dt.hour, dt.minute, dt.second,
114 -1, -1, -1)) + dt.microsecond / 1e6
115 else:
116 return (dt - EPOCH).total_seconds()
98117
99118 def after_read_items(self, items, nulls_map=None):
100119 scale = float(10 ** self.scale)
141160
142161 timezone = self.timezone
143162 null_value = self.null_value
163 to_timestamp = datetime.timestamp if compat.PY3 else self.timestamp_py2
144164
145165 for i, item in enumerate(items):
146166 if nulls_map and nulls_map[i]:
158178 item = timezone.localize(item)
159179
160180 item = item.astimezone(utc)
161 items[i] = (
162 int(timegm(item.timetuple())) * scale +
163 int(item.microsecond / frac_scale)
164 )
165181
166182 else:
167183 # If datetime is offset-aware use it's timezone.
168184 if item.tzinfo is not None:
169185 item = item.astimezone(utc)
170 items[i] = (
171 int(timegm(item.timetuple())) * scale +
172 int(item.microsecond / frac_scale)
173 )
174
175 else:
176 items[i] = (
177 int(mktime(item.timetuple())) * scale +
178 int(item.microsecond / frac_scale)
179 )
186
187 items[i] = (
188 int(to_timestamp(item)) * scale +
189 int(item.microsecond / frac_scale)
190 )
180191
181192
182193 def create_datetime_column(spec, column_options):
77 py_types = (float, ) + compat.integer_types
88
99
10 class Float32(FloatColumn):
10 class Float32Column(FloatColumn):
1111 ch_type = 'Float32'
1212 format = 'f'
1313
1414 def __init__(self, types_check=False, **kwargs):
15 super(Float32, self).__init__(types_check=types_check, **kwargs)
15 super(Float32Column, self).__init__(types_check=types_check, **kwargs)
1616
1717 if types_check:
1818 # Chop only bytes that fit current type.
2929 self.before_write_items = before_write_items
3030
3131
32 class Float64(FloatColumn):
32 class Float64Column(FloatColumn):
3333 ch_type = 'Float64'
3434 format = 'd'
0 import numpy as np
1
2 from ..base import Column
3
4
5 class NumpyColumn(Column):
6 dtype = None
7
8 def read_items(self, n_items, buf):
9 data = buf.read(n_items * self.dtype.itemsize)
10 return np.frombuffer(data, self.dtype, n_items)
11
12 def write_items(self, items, buf):
13 buf.write(items.astype(self.dtype).tobytes())
0 import numpy as np
1
2 from .base import NumpyColumn
3
4
5 class NumpyDateColumn(NumpyColumn):
6 dtype = np.dtype(np.uint16)
7 ch_type = 'Date'
8
9 def read_items(self, n_items, buf):
10 data = super(NumpyDateColumn, self).read_items(n_items, buf)
11 return data.astype('datetime64[D]')
0 import numpy as np
1 import pandas as pd
2 from pytz import timezone as get_timezone
3 from tzlocal import get_localzone
4
5 from .base import NumpyColumn
6
7
8 class NumpyDateTimeColumnBase(NumpyColumn):
9 datetime_dtype = None
10
11 def __init__(self, timezone=None, offset_naive=True, local_timezone=None,
12 **kwargs):
13 self.timezone = timezone
14 self.offset_naive = offset_naive
15 self.local_timezone = local_timezone
16 super(NumpyDateTimeColumnBase, self).__init__(**kwargs)
17
18 def apply_timezones_after_read(self, dt):
19 timezone = self.timezone if self.timezone else self.local_timezone
20
21 ts = pd.to_datetime(dt, utc=True).tz_convert(timezone)
22
23 if self.offset_naive:
24 ts = ts.tz_localize(None)
25
26 return ts.to_numpy(self.datetime_dtype)
27
28 def apply_timezones_before_write(self, items):
29 if isinstance(items, pd.DatetimeIndex):
30 ts = items
31 else:
32 timezone = self.timezone if self.timezone else self.local_timezone
33 ts = pd.to_datetime(items).tz_localize(timezone)
34
35 ts = ts.tz_convert('UTC')
36 return ts.tz_localize(None).to_numpy(self.datetime_dtype)
37
38 def is_items_integer(self, items):
39 return (
40 isinstance(items, np.ndarray) and
41 np.issubdtype(items.dtype, np.integer)
42 )
43
44
45 class NumpyDateTimeColumn(NumpyDateTimeColumnBase):
46 dtype = np.dtype(np.uint32)
47 datetime_dtype = 'datetime64[s]'
48
49 def write_items(self, items, buf):
50 # write int 'as is'.
51 if self.is_items_integer(items):
52 super(NumpyDateTimeColumn, self).write_items(items, buf)
53 return
54
55 items = self.apply_timezones_before_write(items)
56
57 super(NumpyDateTimeColumn, self).write_items(items, buf)
58
59 def read_items(self, n_items, buf):
60 items = super(NumpyDateTimeColumn, self).read_items(n_items, buf)
61 return self.apply_timezones_after_read(items.astype('datetime64[s]'))
62
63
64 class NumpyDateTime64Column(NumpyDateTimeColumnBase):
65 dtype = np.dtype(np.uint64)
66 datetime_dtype = 'datetime64[ns]'
67
68 max_scale = 6
69
70 def __init__(self, scale=0, **kwargs):
71 self.scale = scale
72 super(NumpyDateTime64Column, self).__init__(**kwargs)
73
74 def read_items(self, n_items, buf):
75 scale = 10 ** self.scale
76 frac_scale = 10 ** (self.max_scale - self.scale)
77
78 items = super(NumpyDateTime64Column, self).read_items(n_items, buf)
79
80 seconds = (items // scale).astype('datetime64[s]')
81 microseconds = ((items % scale) * frac_scale).astype('timedelta64[us]')
82
83 dt = seconds + microseconds
84 return self.apply_timezones_after_read(dt)
85
86 def write_items(self, items, buf):
87 # write int 'as is'.
88 if self.is_items_integer(items):
89 super(NumpyDateTime64Column, self).write_items(items, buf)
90 return
91
92 scale = 10 ** self.scale
93 frac_scale = 10 ** (self.max_scale - self.scale)
94
95 items = self.apply_timezones_before_write(items)
96
97 seconds = items.astype('datetime64[s]')
98 microseconds = (items - seconds).astype(dtype='timedelta64[us]') \
99 .astype(np.uint32) // frac_scale
100
101 items = seconds.astype(self.dtype) * scale + microseconds
102
103 super(NumpyDateTime64Column, self).write_items(items, buf)
104
105
106 def create_numpy_datetime_column(spec, column_options):
107 if spec.startswith('DateTime64'):
108 cls = NumpyDateTime64Column
109 spec = spec[11:-1]
110 params = spec.split(',', 1)
111 column_options['scale'] = int(params[0])
112 if len(params) > 1:
113 spec = params[1].strip() + ')'
114 else:
115 cls = NumpyDateTimeColumn
116 spec = spec[9:]
117
118 context = column_options['context']
119
120 tz_name = timezone = None
121 offset_naive = True
122 local_timezone = None
123
124 # As Numpy do not use local timezone for converting timestamp to
125 # datetime we need always detect local timezone for manual converting.
126 try:
127 local_timezone = get_localzone().zone
128 except Exception:
129 pass
130
131 # Use column's timezone if it's specified.
132 if spec and spec[-1] == ')':
133 tz_name = spec[1:-2]
134 offset_naive = False
135 else:
136 if not context.settings.get('use_client_time_zone', False):
137 if local_timezone != context.server_info.timezone:
138 tz_name = context.server_info.timezone
139
140 if tz_name:
141 timezone = get_timezone(tz_name)
142
143 return cls(timezone=timezone, offset_naive=offset_naive,
144 local_timezone=local_timezone, **column_options)
0 import numpy as np
1
2 from .base import NumpyColumn
3
4
5 class NumpyFloat32Column(NumpyColumn):
6 dtype = np.dtype(np.float32)
7 ch_type = 'Float32'
8
9
10 class NumpyFloat64Column(NumpyColumn):
11 dtype = np.dtype(np.float64)
12 ch_type = 'Float64'
0 import numpy as np
1
2 from .base import NumpyColumn
3
4
5 class NumpyInt8Column(NumpyColumn):
6 dtype = np.dtype(np.int8)
7 ch_type = 'Int8'
8
9
10 class NumpyUInt8Column(NumpyColumn):
11 dtype = np.dtype(np.uint8)
12 ch_type = 'UInt8'
13
14
15 class NumpyInt16Column(NumpyColumn):
16 dtype = np.dtype(np.int16)
17 ch_type = 'Int16'
18
19
20 class NumpyUInt16Column(NumpyColumn):
21 dtype = np.dtype(np.uint16)
22 ch_type = 'UInt16'
23
24
25 class NumpyInt32Column(NumpyColumn):
26 dtype = np.dtype(np.int32)
27 ch_type = 'Int32'
28
29
30 class NumpyUInt32Column(NumpyColumn):
31 dtype = np.dtype(np.uint32)
32 ch_type = 'UInt32'
33
34
35 class NumpyInt64Column(NumpyColumn):
36 dtype = np.dtype(np.int64)
37 ch_type = 'Int64'
38
39
40 class NumpyUInt64Column(NumpyColumn):
41 dtype = np.dtype(np.uint64)
42 ch_type = 'UInt64'
0 from math import log
1
2 import pandas as pd
3
4 from ..lowcardinalitycolumn import LowCardinalityColumn
5 from ...reader import read_binary_uint64
6 from ...writer import write_binary_int64
7 from .intcolumn import (
8 NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column
9 )
10
11
12 class NumpyLowCardinalityColumn(LowCardinalityColumn):
13 int_types = {
14 0: NumpyUInt8Column,
15 1: NumpyUInt16Column,
16 2: NumpyUInt32Column,
17 3: NumpyUInt64Column
18 }
19
20 def __init__(self, nested_column, **kwargs):
21 super(NumpyLowCardinalityColumn, self).__init__(nested_column,
22 **kwargs)
23
24 def _write_data(self, items, buf):
25 # TODO: nullable support
26
27 # Do not write anything for empty column.
28 # May happen while writing empty arrays.
29 if not len(items):
30 return
31
32 c = pd.Categorical(items)
33
34 int_type = int(log(len(c.codes), 2) / 8)
35 int_column = self.int_types[int_type]()
36
37 serialization_type = self.serialization_type | int_type
38
39 index = c.categories
40 keys = c.codes
41
42 write_binary_int64(serialization_type, buf)
43 write_binary_int64(len(index), buf)
44
45 self.nested_column.write_data(index.to_numpy(items.dtype), buf)
46 write_binary_int64(len(items), buf)
47 int_column.write_data(keys, buf)
48
49 def _read_data(self, n_items, buf, nulls_map=None):
50 if not n_items:
51 return tuple()
52
53 serialization_type = read_binary_uint64(buf)
54
55 # Lowest byte contains info about key type.
56 key_type = serialization_type & 0xf
57 keys_column = self.int_types[key_type]()
58
59 nullable = self.nested_column.nullable
60 # Prevent null map reading. Reset nested column nullable flag.
61 self.nested_column.nullable = False
62
63 index_size = read_binary_uint64(buf)
64 index = self.nested_column.read_data(index_size, buf)
65
66 read_binary_uint64(buf) # number of keys
67 keys = keys_column.read_data(n_items, buf)
68
69 if nullable:
70 # Shift all codes by one ("No value" code is -1 for pandas
71 # categorical) and drop corresponding first index
72 # this is analog of original operation:
73 # index = (None, ) + index[1:]
74 keys = keys - 1
75 index = index[1:]
76 return pd.Categorical.from_codes(keys, index)
77
78
79 def create_numpy_low_cardinality_column(spec, column_by_spec_getter):
80 inner = spec[15:-1]
81 nested = column_by_spec_getter(inner)
82 return NumpyLowCardinalityColumn(nested)
0 from ... import errors
1 from ..arraycolumn import create_array_column
2 from .datecolumn import NumpyDateColumn
3 from .datetimecolumn import create_numpy_datetime_column
4 from ..decimalcolumn import create_decimal_column
5 from ..enumcolumn import create_enum_column
6 from .floatcolumn import NumpyFloat32Column, NumpyFloat64Column
7 from .intcolumn import (
8 NumpyInt8Column, NumpyInt16Column, NumpyInt32Column, NumpyInt64Column,
9 NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column
10 )
11 from .lowcardinalitycolumn import create_numpy_low_cardinality_column
12 from ..nothingcolumn import NothingColumn
13 from ..nullcolumn import NullColumn
14 # from .nullablecolumn import create_nullable_column
15 from ..simpleaggregatefunctioncolumn import (
16 create_simple_aggregate_function_column
17 )
18 from .stringcolumn import create_string_column
19 from ..tuplecolumn import create_tuple_column
20 from ..uuidcolumn import UUIDColumn
21 from ..intervalcolumn import (
22 IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn,
23 IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn,
24 IntervalSecondColumn
25 )
26 from ..ipcolumn import IPv4Column, IPv6Column
27
28 column_by_type = {c.ch_type: c for c in [
29 NumpyDateColumn,
30 NumpyFloat32Column, NumpyFloat64Column,
31 NumpyInt8Column, NumpyInt16Column, NumpyInt32Column, NumpyInt64Column,
32 NumpyUInt8Column, NumpyUInt16Column, NumpyUInt32Column, NumpyUInt64Column,
33 NothingColumn, NullColumn, UUIDColumn,
34 IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn,
35 IntervalDayColumn, IntervalHourColumn, IntervalMinuteColumn,
36 IntervalSecondColumn, IPv4Column, IPv6Column
37 ]}
38
39
40 def get_numpy_column_by_spec(spec, column_options):
41 def create_column_with_options(x):
42 return get_numpy_column_by_spec(x, column_options)
43
44 if spec == 'String' or spec.startswith('FixedString'):
45 return create_string_column(spec, column_options)
46
47 elif spec.startswith('Enum'):
48 return create_enum_column(spec, column_options)
49
50 elif spec.startswith('DateTime'):
51 return create_numpy_datetime_column(spec, column_options)
52
53 elif spec.startswith('Decimal'):
54 return create_decimal_column(spec, column_options)
55
56 elif spec.startswith('Array'):
57 return create_array_column(spec, create_column_with_options)
58
59 elif spec.startswith('Tuple'):
60 return create_tuple_column(spec, create_column_with_options)
61
62 # elif spec.startswith('Nullable'):
63 # return create_nullable_column(spec, create_column_with_options)
64
65 elif spec.startswith('LowCardinality'):
66 return create_numpy_low_cardinality_column(spec,
67 create_column_with_options)
68
69 elif spec.startswith('SimpleAggregateFunction'):
70 return create_simple_aggregate_function_column(
71 spec, create_column_with_options)
72
73 else:
74 try:
75 cls = column_by_type[spec]
76 return cls(**column_options)
77
78 except KeyError as e:
79 raise errors.UnknownTypeError('Unknown type {}'.format(e.args[0]))
0 import numpy as np
1
2 from ... import defines
3 from .base import NumpyColumn
4
5
6 class NumpyStringColumn(NumpyColumn):
7 dtype = np.dtype('object')
8
9 default_encoding = defines.STRINGS_ENCODING
10
11 def __init__(self, encoding=default_encoding, **kwargs):
12 self.encoding = encoding
13 super(NumpyStringColumn, self).__init__(**kwargs)
14
15 def read_items(self, n_items, buf):
16 return np.array(
17 buf.read_strings(n_items, encoding=self.encoding), dtype=self.dtype
18 )
19
20 def write_items(self, items, buf):
21 return buf.write_strings(items.tolist(), encoding=self.encoding)
22
23
24 class NumpyByteStringColumn(NumpyColumn):
25 def read_items(self, n_items, buf):
26 return np.array(buf.read_strings(n_items), dtype=self.dtype)
27
28 def write_items(self, items, buf):
29 return buf.write_strings(items.tolist())
30
31
32 class NumpyFixedString(NumpyStringColumn):
33 def __init__(self, length, **kwargs):
34 self.length = length
35 super(NumpyFixedString, self).__init__(**kwargs)
36
37 def read_items(self, n_items, buf):
38 return np.array(buf.read_fixed_strings(
39 n_items, self.length, encoding=self.encoding
40 ), dtype=self.dtype)
41
42 def write_items(self, items, buf):
43 return buf.write_fixed_strings(
44 items.tolist(), self.length, encoding=self.encoding
45 )
46
47
48 class NumpyByteFixedString(NumpyByteStringColumn):
49 def __init__(self, length, **kwargs):
50 self.length = length
51 super(NumpyByteFixedString, self).__init__(**kwargs)
52
53 def read_items(self, n_items, buf):
54 return np.array(
55 buf.read_fixed_strings(n_items, self.length), dtype=self.dtype
56 )
57
58 def write_items(self, items, buf):
59 return buf.write_fixed_strings(items.tolist(), self.length)
60
61
62 def create_string_column(spec, column_options):
63 client_settings = column_options['context'].client_settings
64 strings_as_bytes = client_settings['strings_as_bytes']
65 encoding = client_settings.get(
66 'strings_encoding', NumpyStringColumn.default_encoding
67 )
68
69 if spec == 'String':
70 cls = NumpyByteStringColumn if strings_as_bytes else NumpyStringColumn
71 return cls(encoding=encoding, **column_options)
72 else:
73 length = int(spec[12:-1])
74 cls = NumpyByteFixedString if strings_as_bytes else NumpyFixedString
75 return cls(length, encoding=encoding, **column_options)
44 from .decimalcolumn import create_decimal_column
55 from . import exceptions as column_exceptions
66 from .enumcolumn import create_enum_column
7 from .floatcolumn import Float32, Float64
7 from .floatcolumn import Float32Column, Float64Column
88 from .intcolumn import (
99 Int8Column, Int16Column, Int32Column, Int64Column,
1010 UInt8Column, UInt16Column, UInt32Column, UInt64Column
1717 create_simple_aggregate_function_column
1818 )
1919 from .stringcolumn import create_string_column
20 from .tuplecolumn import create_tuple_column
2021 from .uuidcolumn import UUIDColumn
2122 from .intervalcolumn import (
2223 IntervalYearColumn, IntervalMonthColumn, IntervalWeekColumn,
2728
2829
2930 column_by_type = {c.ch_type: c for c in [
30 DateColumn, Float32, Float64,
31 DateColumn, Float32Column, Float64Column,
3132 Int8Column, Int16Column, Int32Column, Int64Column,
3233 UInt8Column, UInt16Column, UInt32Column, UInt64Column,
3334 NothingColumn, NullColumn, UUIDColumn,
3738 ]}
3839
3940
40 def get_column_by_spec(spec, column_options=None):
41 column_options = column_options or {}
41 def get_column_by_spec(spec, column_options):
42 context = column_options['context']
43 use_numpy = context.client_settings['use_numpy'] if context else False
44
45 if use_numpy:
46 from .numpy.service import get_numpy_column_by_spec
47 return get_numpy_column_by_spec(spec, column_options)
4248
4349 def create_column_with_options(x):
4450 return get_column_by_spec(x, column_options)
5763
5864 elif spec.startswith('Array'):
5965 return create_array_column(spec, create_column_with_options)
66
67 elif spec.startswith('Tuple'):
68 return create_tuple_column(spec, create_column_with_options)
6069
6170 elif spec.startswith('Nullable'):
6271 return create_nullable_column(spec, create_column_with_options)
7988
8089 def read_column(context, column_spec, n_items, buf):
8190 column_options = {'context': context}
82 column = get_column_by_spec(column_spec, column_options=column_options)
91 column = get_column_by_spec(column_spec, column_options)
8392 column.read_state_prefix(buf)
8493 return column.read_data(n_items, buf)
8594
11
22 def create_simple_aggregate_function_column(spec, column_by_spec_getter):
33 # SimpleAggregateFunction(Func, Type) -> Type
4 inner = spec[24:-1].split(',')[1].strip()
4 inner = spec[24:-1].split(',', 1)[1].strip()
55 nested = column_by_spec_getter(inner)
66 return nested
+0
-8356
clickhouse_driver/columns/stringcolumn.c less more
0 /* Generated by Cython 0.29.13 */
1
2 /* BEGIN: Cython Metadata
3 {
4 "distutils": {
5 "depends": [],
6 "name": "clickhouse_driver.columns.stringcolumn",
7 "sources": [
8 "clickhouse_driver/columns/stringcolumn.pyx"
9 ]
10 },
11 "module_name": "clickhouse_driver.columns.stringcolumn"
12 }
13 END: Cython Metadata */
14
15 #define PY_SSIZE_T_CLEAN
16 #include "Python.h"
17 #ifndef Py_PYTHON_H
18 #error Python headers needed to compile C extensions, please install development version of Python.
19 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
20 #error Cython requires Python 2.6+ or Python 3.3+.
21 #else
22 #define CYTHON_ABI "0_29_13"
23 #define CYTHON_HEX_VERSION 0x001D0DF0
24 #define CYTHON_FUTURE_DIVISION 1
25 #include <stddef.h>
26 #ifndef offsetof
27 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
28 #endif
29 #if !defined(WIN32) && !defined(MS_WINDOWS)
30 #ifndef __stdcall
31 #define __stdcall
32 #endif
33 #ifndef __cdecl
34 #define __cdecl
35 #endif
36 #ifndef __fastcall
37 #define __fastcall
38 #endif
39 #endif
40 #ifndef DL_IMPORT
41 #define DL_IMPORT(t) t
42 #endif
43 #ifndef DL_EXPORT
44 #define DL_EXPORT(t) t
45 #endif
46 #define __PYX_COMMA ,
47 #ifndef HAVE_LONG_LONG
48 #if PY_VERSION_HEX >= 0x02070000
49 #define HAVE_LONG_LONG
50 #endif
51 #endif
52 #ifndef PY_LONG_LONG
53 #define PY_LONG_LONG LONG_LONG
54 #endif
55 #ifndef Py_HUGE_VAL
56 #define Py_HUGE_VAL HUGE_VAL
57 #endif
58 #ifdef PYPY_VERSION
59 #define CYTHON_COMPILING_IN_PYPY 1
60 #define CYTHON_COMPILING_IN_PYSTON 0
61 #define CYTHON_COMPILING_IN_CPYTHON 0
62 #undef CYTHON_USE_TYPE_SLOTS
63 #define CYTHON_USE_TYPE_SLOTS 0
64 #undef CYTHON_USE_PYTYPE_LOOKUP
65 #define CYTHON_USE_PYTYPE_LOOKUP 0
66 #if PY_VERSION_HEX < 0x03050000
67 #undef CYTHON_USE_ASYNC_SLOTS
68 #define CYTHON_USE_ASYNC_SLOTS 0
69 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
70 #define CYTHON_USE_ASYNC_SLOTS 1
71 #endif
72 #undef CYTHON_USE_PYLIST_INTERNALS
73 #define CYTHON_USE_PYLIST_INTERNALS 0
74 #undef CYTHON_USE_UNICODE_INTERNALS
75 #define CYTHON_USE_UNICODE_INTERNALS 0
76 #undef CYTHON_USE_UNICODE_WRITER
77 #define CYTHON_USE_UNICODE_WRITER 0
78 #undef CYTHON_USE_PYLONG_INTERNALS
79 #define CYTHON_USE_PYLONG_INTERNALS 0
80 #undef CYTHON_AVOID_BORROWED_REFS
81 #define CYTHON_AVOID_BORROWED_REFS 1
82 #undef CYTHON_ASSUME_SAFE_MACROS
83 #define CYTHON_ASSUME_SAFE_MACROS 0
84 #undef CYTHON_UNPACK_METHODS
85 #define CYTHON_UNPACK_METHODS 0
86 #undef CYTHON_FAST_THREAD_STATE
87 #define CYTHON_FAST_THREAD_STATE 0
88 #undef CYTHON_FAST_PYCALL
89 #define CYTHON_FAST_PYCALL 0
90 #undef CYTHON_PEP489_MULTI_PHASE_INIT
91 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
92 #undef CYTHON_USE_TP_FINALIZE
93 #define CYTHON_USE_TP_FINALIZE 0
94 #undef CYTHON_USE_DICT_VERSIONS
95 #define CYTHON_USE_DICT_VERSIONS 0
96 #undef CYTHON_USE_EXC_INFO_STACK
97 #define CYTHON_USE_EXC_INFO_STACK 0
98 #elif defined(PYSTON_VERSION)
99 #define CYTHON_COMPILING_IN_PYPY 0
100 #define CYTHON_COMPILING_IN_PYSTON 1
101 #define CYTHON_COMPILING_IN_CPYTHON 0
102 #ifndef CYTHON_USE_TYPE_SLOTS
103 #define CYTHON_USE_TYPE_SLOTS 1
104 #endif
105 #undef CYTHON_USE_PYTYPE_LOOKUP
106 #define CYTHON_USE_PYTYPE_LOOKUP 0
107 #undef CYTHON_USE_ASYNC_SLOTS
108 #define CYTHON_USE_ASYNC_SLOTS 0
109 #undef CYTHON_USE_PYLIST_INTERNALS
110 #define CYTHON_USE_PYLIST_INTERNALS 0
111 #ifndef CYTHON_USE_UNICODE_INTERNALS
112 #define CYTHON_USE_UNICODE_INTERNALS 1
113 #endif
114 #undef CYTHON_USE_UNICODE_WRITER
115 #define CYTHON_USE_UNICODE_WRITER 0
116 #undef CYTHON_USE_PYLONG_INTERNALS
117 #define CYTHON_USE_PYLONG_INTERNALS 0
118 #ifndef CYTHON_AVOID_BORROWED_REFS
119 #define CYTHON_AVOID_BORROWED_REFS 0
120 #endif
121 #ifndef CYTHON_ASSUME_SAFE_MACROS
122 #define CYTHON_ASSUME_SAFE_MACROS 1
123 #endif
124 #ifndef CYTHON_UNPACK_METHODS
125 #define CYTHON_UNPACK_METHODS 1
126 #endif
127 #undef CYTHON_FAST_THREAD_STATE
128 #define CYTHON_FAST_THREAD_STATE 0
129 #undef CYTHON_FAST_PYCALL
130 #define CYTHON_FAST_PYCALL 0
131 #undef CYTHON_PEP489_MULTI_PHASE_INIT
132 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
133 #undef CYTHON_USE_TP_FINALIZE
134 #define CYTHON_USE_TP_FINALIZE 0
135 #undef CYTHON_USE_DICT_VERSIONS
136 #define CYTHON_USE_DICT_VERSIONS 0
137 #undef CYTHON_USE_EXC_INFO_STACK
138 #define CYTHON_USE_EXC_INFO_STACK 0
139 #else
140 #define CYTHON_COMPILING_IN_PYPY 0
141 #define CYTHON_COMPILING_IN_PYSTON 0
142 #define CYTHON_COMPILING_IN_CPYTHON 1
143 #ifndef CYTHON_USE_TYPE_SLOTS
144 #define CYTHON_USE_TYPE_SLOTS 1
145 #endif
146 #if PY_VERSION_HEX < 0x02070000
147 #undef CYTHON_USE_PYTYPE_LOOKUP
148 #define CYTHON_USE_PYTYPE_LOOKUP 0
149 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
150 #define CYTHON_USE_PYTYPE_LOOKUP 1
151 #endif
152 #if PY_MAJOR_VERSION < 3
153 #undef CYTHON_USE_ASYNC_SLOTS
154 #define CYTHON_USE_ASYNC_SLOTS 0
155 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
156 #define CYTHON_USE_ASYNC_SLOTS 1
157 #endif
158 #if PY_VERSION_HEX < 0x02070000
159 #undef CYTHON_USE_PYLONG_INTERNALS
160 #define CYTHON_USE_PYLONG_INTERNALS 0
161 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
162 #define CYTHON_USE_PYLONG_INTERNALS 1
163 #endif
164 #ifndef CYTHON_USE_PYLIST_INTERNALS
165 #define CYTHON_USE_PYLIST_INTERNALS 1
166 #endif
167 #ifndef CYTHON_USE_UNICODE_INTERNALS
168 #define CYTHON_USE_UNICODE_INTERNALS 1
169 #endif
170 #if PY_VERSION_HEX < 0x030300F0
171 #undef CYTHON_USE_UNICODE_WRITER
172 #define CYTHON_USE_UNICODE_WRITER 0
173 #elif !defined(CYTHON_USE_UNICODE_WRITER)
174 #define CYTHON_USE_UNICODE_WRITER 1
175 #endif
176 #ifndef CYTHON_AVOID_BORROWED_REFS
177 #define CYTHON_AVOID_BORROWED_REFS 0
178 #endif
179 #ifndef CYTHON_ASSUME_SAFE_MACROS
180 #define CYTHON_ASSUME_SAFE_MACROS 1
181 #endif
182 #ifndef CYTHON_UNPACK_METHODS
183 #define CYTHON_UNPACK_METHODS 1
184 #endif
185 #ifndef CYTHON_FAST_THREAD_STATE
186 #define CYTHON_FAST_THREAD_STATE 1
187 #endif
188 #ifndef CYTHON_FAST_PYCALL
189 #define CYTHON_FAST_PYCALL 1
190 #endif
191 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
192 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
193 #endif
194 #ifndef CYTHON_USE_TP_FINALIZE
195 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
196 #endif
197 #ifndef CYTHON_USE_DICT_VERSIONS
198 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
199 #endif
200 #ifndef CYTHON_USE_EXC_INFO_STACK
201 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
202 #endif
203 #endif
204 #if !defined(CYTHON_FAST_PYCCALL)
205 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
206 #endif
207 #if CYTHON_USE_PYLONG_INTERNALS
208 #include "longintrepr.h"
209 #undef SHIFT
210 #undef BASE
211 #undef MASK
212 #ifdef SIZEOF_VOID_P
213 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
214 #endif
215 #endif
216 #ifndef __has_attribute
217 #define __has_attribute(x) 0
218 #endif
219 #ifndef __has_cpp_attribute
220 #define __has_cpp_attribute(x) 0
221 #endif
222 #ifndef CYTHON_RESTRICT
223 #if defined(__GNUC__)
224 #define CYTHON_RESTRICT __restrict__
225 #elif defined(_MSC_VER) && _MSC_VER >= 1400
226 #define CYTHON_RESTRICT __restrict
227 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
228 #define CYTHON_RESTRICT restrict
229 #else
230 #define CYTHON_RESTRICT
231 #endif
232 #endif
233 #ifndef CYTHON_UNUSED
234 # if defined(__GNUC__)
235 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
236 # define CYTHON_UNUSED __attribute__ ((__unused__))
237 # else
238 # define CYTHON_UNUSED
239 # endif
240 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
241 # define CYTHON_UNUSED __attribute__ ((__unused__))
242 # else
243 # define CYTHON_UNUSED
244 # endif
245 #endif
246 #ifndef CYTHON_MAYBE_UNUSED_VAR
247 # if defined(__cplusplus)
248 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
249 # else
250 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
251 # endif
252 #endif
253 #ifndef CYTHON_NCP_UNUSED
254 # if CYTHON_COMPILING_IN_CPYTHON
255 # define CYTHON_NCP_UNUSED
256 # else
257 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
258 # endif
259 #endif
260 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
261 #ifdef _MSC_VER
262 #ifndef _MSC_STDINT_H_
263 #if _MSC_VER < 1300
264 typedef unsigned char uint8_t;
265 typedef unsigned int uint32_t;
266 #else
267 typedef unsigned __int8 uint8_t;
268 typedef unsigned __int32 uint32_t;
269 #endif
270 #endif
271 #else
272 #include <stdint.h>
273 #endif
274 #ifndef CYTHON_FALLTHROUGH
275 #if defined(__cplusplus) && __cplusplus >= 201103L
276 #if __has_cpp_attribute(fallthrough)
277 #define CYTHON_FALLTHROUGH [[fallthrough]]
278 #elif __has_cpp_attribute(clang::fallthrough)
279 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
280 #elif __has_cpp_attribute(gnu::fallthrough)
281 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
282 #endif
283 #endif
284 #ifndef CYTHON_FALLTHROUGH
285 #if __has_attribute(fallthrough)
286 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
287 #else
288 #define CYTHON_FALLTHROUGH
289 #endif
290 #endif
291 #if defined(__clang__ ) && defined(__apple_build_version__)
292 #if __apple_build_version__ < 7000000
293 #undef CYTHON_FALLTHROUGH
294 #define CYTHON_FALLTHROUGH
295 #endif
296 #endif
297 #endif
298
299 #ifndef CYTHON_INLINE
300 #if defined(__clang__)
301 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
302 #elif defined(__GNUC__)
303 #define CYTHON_INLINE __inline__
304 #elif defined(_MSC_VER)
305 #define CYTHON_INLINE __inline
306 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
307 #define CYTHON_INLINE inline
308 #else
309 #define CYTHON_INLINE
310 #endif
311 #endif
312
313 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
314 #define Py_OptimizeFlag 0
315 #endif
316 #define __PYX_BUILD_PY_SSIZE_T "n"
317 #define CYTHON_FORMAT_SSIZE_T "z"
318 #if PY_MAJOR_VERSION < 3
319 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
320 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
321 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
322 #define __Pyx_DefaultClassType PyClass_Type
323 #else
324 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
325 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
326 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
327 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
328 #else
329 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
330 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
331 #endif
332 #define __Pyx_DefaultClassType PyType_Type
333 #endif
334 #ifndef Py_TPFLAGS_CHECKTYPES
335 #define Py_TPFLAGS_CHECKTYPES 0
336 #endif
337 #ifndef Py_TPFLAGS_HAVE_INDEX
338 #define Py_TPFLAGS_HAVE_INDEX 0
339 #endif
340 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
341 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
342 #endif
343 #ifndef Py_TPFLAGS_HAVE_FINALIZE
344 #define Py_TPFLAGS_HAVE_FINALIZE 0
345 #endif
346 #ifndef METH_STACKLESS
347 #define METH_STACKLESS 0
348 #endif
349 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
350 #ifndef METH_FASTCALL
351 #define METH_FASTCALL 0x80
352 #endif
353 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
354 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
355 Py_ssize_t nargs, PyObject *kwnames);
356 #else
357 #define __Pyx_PyCFunctionFast _PyCFunctionFast
358 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
359 #endif
360 #if CYTHON_FAST_PYCCALL
361 #define __Pyx_PyFastCFunction_Check(func)\
362 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
363 #else
364 #define __Pyx_PyFastCFunction_Check(func) 0
365 #endif
366 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
367 #define PyObject_Malloc(s) PyMem_Malloc(s)
368 #define PyObject_Free(p) PyMem_Free(p)
369 #define PyObject_Realloc(p) PyMem_Realloc(p)
370 #endif
371 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
372 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
373 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
374 #define PyMem_RawFree(p) PyMem_Free(p)
375 #endif
376 #if CYTHON_COMPILING_IN_PYSTON
377 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
378 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
379 #else
380 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
381 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
382 #endif
383 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
384 #define __Pyx_PyThreadState_Current PyThreadState_GET()
385 #elif PY_VERSION_HEX >= 0x03060000
386 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
387 #elif PY_VERSION_HEX >= 0x03000000
388 #define __Pyx_PyThreadState_Current PyThreadState_GET()
389 #else
390 #define __Pyx_PyThreadState_Current _PyThreadState_Current
391 #endif
392 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
393 #include "pythread.h"
394 #define Py_tss_NEEDS_INIT 0
395 typedef int Py_tss_t;
396 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
397 *key = PyThread_create_key();
398 return 0;
399 }
400 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
401 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
402 *key = Py_tss_NEEDS_INIT;
403 return key;
404 }
405 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
406 PyObject_Free(key);
407 }
408 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
409 return *key != Py_tss_NEEDS_INIT;
410 }
411 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
412 PyThread_delete_key(*key);
413 *key = Py_tss_NEEDS_INIT;
414 }
415 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
416 return PyThread_set_key_value(*key, value);
417 }
418 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
419 return PyThread_get_key_value(*key);
420 }
421 #endif
422 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
423 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
424 #else
425 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
426 #endif
427 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
428 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
429 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
430 #else
431 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
432 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
433 #endif
434 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
435 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
436 #else
437 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
438 #endif
439 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
440 #define CYTHON_PEP393_ENABLED 1
441 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
442 0 : _PyUnicode_Ready((PyObject *)(op)))
443 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
444 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
445 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
446 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
447 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
448 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
449 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
450 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
451 #else
452 #define CYTHON_PEP393_ENABLED 0
453 #define PyUnicode_1BYTE_KIND 1
454 #define PyUnicode_2BYTE_KIND 2
455 #define PyUnicode_4BYTE_KIND 4
456 #define __Pyx_PyUnicode_READY(op) (0)
457 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
458 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
459 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
460 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
461 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
462 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
463 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
464 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
465 #endif
466 #if CYTHON_COMPILING_IN_PYPY
467 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
468 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
469 #else
470 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
471 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
472 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
473 #endif
474 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
475 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
476 #endif
477 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
478 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
479 #endif
480 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
481 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
482 #endif
483 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
484 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
485 #if PY_MAJOR_VERSION >= 3
486 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
487 #else
488 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
489 #endif
490 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
491 #define PyObject_ASCII(o) PyObject_Repr(o)
492 #endif
493 #if PY_MAJOR_VERSION >= 3
494 #define PyBaseString_Type PyUnicode_Type
495 #define PyStringObject PyUnicodeObject
496 #define PyString_Type PyUnicode_Type
497 #define PyString_Check PyUnicode_Check
498 #define PyString_CheckExact PyUnicode_CheckExact
499 #define PyObject_Unicode PyObject_Str
500 #endif
501 #if PY_MAJOR_VERSION >= 3
502 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
503 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
504 #else
505 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
506 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
507 #endif
508 #ifndef PySet_CheckExact
509 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
510 #endif
511 #if CYTHON_ASSUME_SAFE_MACROS
512 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
513 #else
514 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
515 #endif
516 #if PY_MAJOR_VERSION >= 3
517 #define PyIntObject PyLongObject
518 #define PyInt_Type PyLong_Type
519 #define PyInt_Check(op) PyLong_Check(op)
520 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
521 #define PyInt_FromString PyLong_FromString
522 #define PyInt_FromUnicode PyLong_FromUnicode
523 #define PyInt_FromLong PyLong_FromLong
524 #define PyInt_FromSize_t PyLong_FromSize_t
525 #define PyInt_FromSsize_t PyLong_FromSsize_t
526 #define PyInt_AsLong PyLong_AsLong
527 #define PyInt_AS_LONG PyLong_AS_LONG
528 #define PyInt_AsSsize_t PyLong_AsSsize_t
529 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
530 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
531 #define PyNumber_Int PyNumber_Long
532 #endif
533 #if PY_MAJOR_VERSION >= 3
534 #define PyBoolObject PyLongObject
535 #endif
536 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
537 #ifndef PyUnicode_InternFromString
538 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
539 #endif
540 #endif
541 #if PY_VERSION_HEX < 0x030200A4
542 typedef long Py_hash_t;
543 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
544 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
545 #else
546 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
547 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
548 #endif
549 #if PY_MAJOR_VERSION >= 3
550 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
551 #else
552 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
553 #endif
554 #if CYTHON_USE_ASYNC_SLOTS
555 #if PY_VERSION_HEX >= 0x030500B1
556 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
557 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
558 #else
559 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
560 #endif
561 #else
562 #define __Pyx_PyType_AsAsync(obj) NULL
563 #endif
564 #ifndef __Pyx_PyAsyncMethodsStruct
565 typedef struct {
566 unaryfunc am_await;
567 unaryfunc am_aiter;
568 unaryfunc am_anext;
569 } __Pyx_PyAsyncMethodsStruct;
570 #endif
571
572 #if defined(WIN32) || defined(MS_WINDOWS)
573 #define _USE_MATH_DEFINES
574 #endif
575 #include <math.h>
576 #ifdef NAN
577 #define __PYX_NAN() ((float) NAN)
578 #else
579 static CYTHON_INLINE float __PYX_NAN() {
580 float value;
581 memset(&value, 0xFF, sizeof(value));
582 return value;
583 }
584 #endif
585 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
586 #define __Pyx_truncl trunc
587 #else
588 #define __Pyx_truncl truncl
589 #endif
590
591
592 #define __PYX_ERR(f_index, lineno, Ln_error) \
593 { \
594 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
595 }
596
597 #ifndef __PYX_EXTERN_C
598 #ifdef __cplusplus
599 #define __PYX_EXTERN_C extern "C"
600 #else
601 #define __PYX_EXTERN_C extern
602 #endif
603 #endif
604
605 #define __PYX_HAVE__clickhouse_driver__columns__stringcolumn
606 #define __PYX_HAVE_API__clickhouse_driver__columns__stringcolumn
607 /* Early includes */
608 #include <string.h>
609 #include <stdio.h>
610 #include "pythread.h"
611 #ifdef _OPENMP
612 #include <omp.h>
613 #endif /* _OPENMP */
614
615 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
616 #define CYTHON_WITHOUT_ASSERTIONS
617 #endif
618
619 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
620 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
621
622 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
623 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
625 #define __PYX_DEFAULT_STRING_ENCODING ""
626 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
627 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
628 #define __Pyx_uchar_cast(c) ((unsigned char)c)
629 #define __Pyx_long_cast(x) ((long)x)
630 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
631 (sizeof(type) < sizeof(Py_ssize_t)) ||\
632 (sizeof(type) > sizeof(Py_ssize_t) &&\
633 likely(v < (type)PY_SSIZE_T_MAX ||\
634 v == (type)PY_SSIZE_T_MAX) &&\
635 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
636 v == (type)PY_SSIZE_T_MIN))) ||\
637 (sizeof(type) == sizeof(Py_ssize_t) &&\
638 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
639 v == (type)PY_SSIZE_T_MAX))) )
640 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
641 return (size_t) i < (size_t) limit;
642 }
643 #if defined (__cplusplus) && __cplusplus >= 201103L
644 #include <cstdlib>
645 #define __Pyx_sst_abs(value) std::abs(value)
646 #elif SIZEOF_INT >= SIZEOF_SIZE_T
647 #define __Pyx_sst_abs(value) abs(value)
648 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
649 #define __Pyx_sst_abs(value) labs(value)
650 #elif defined (_MSC_VER)
651 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
652 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
653 #define __Pyx_sst_abs(value) llabs(value)
654 #elif defined (__GNUC__)
655 #define __Pyx_sst_abs(value) __builtin_llabs(value)
656 #else
657 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
658 #endif
659 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
660 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
661 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
662 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
663 #define __Pyx_PyBytes_FromString PyBytes_FromString
664 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
665 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
666 #if PY_MAJOR_VERSION < 3
667 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
668 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
669 #else
670 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
671 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
672 #endif
673 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
674 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
675 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
680 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
681 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
685 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
686 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
687 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
688 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
689 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
690 const Py_UNICODE *u_end = u;
691 while (*u_end++) ;
692 return (size_t)(u_end - u - 1);
693 }
694 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
695 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
696 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
697 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
698 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
699 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
700 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
701 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
702 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
703 #define __Pyx_PySequence_Tuple(obj)\
704 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
705 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
706 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
707 #if CYTHON_ASSUME_SAFE_MACROS
708 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
709 #else
710 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
711 #endif
712 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
713 #if PY_MAJOR_VERSION >= 3
714 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
715 #else
716 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
717 #endif
718 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
719 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
720 static int __Pyx_sys_getdefaultencoding_not_ascii;
721 static int __Pyx_init_sys_getdefaultencoding_params(void) {
722 PyObject* sys;
723 PyObject* default_encoding = NULL;
724 PyObject* ascii_chars_u = NULL;
725 PyObject* ascii_chars_b = NULL;
726 const char* default_encoding_c;
727 sys = PyImport_ImportModule("sys");
728 if (!sys) goto bad;
729 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
730 Py_DECREF(sys);
731 if (!default_encoding) goto bad;
732 default_encoding_c = PyBytes_AsString(default_encoding);
733 if (!default_encoding_c) goto bad;
734 if (strcmp(default_encoding_c, "ascii") == 0) {
735 __Pyx_sys_getdefaultencoding_not_ascii = 0;
736 } else {
737 char ascii_chars[128];
738 int c;
739 for (c = 0; c < 128; c++) {
740 ascii_chars[c] = c;
741 }
742 __Pyx_sys_getdefaultencoding_not_ascii = 1;
743 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
744 if (!ascii_chars_u) goto bad;
745 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
746 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
747 PyErr_Format(
748 PyExc_ValueError,
749 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
750 default_encoding_c);
751 goto bad;
752 }
753 Py_DECREF(ascii_chars_u);
754 Py_DECREF(ascii_chars_b);
755 }
756 Py_DECREF(default_encoding);
757 return 0;
758 bad:
759 Py_XDECREF(default_encoding);
760 Py_XDECREF(ascii_chars_u);
761 Py_XDECREF(ascii_chars_b);
762 return -1;
763 }
764 #endif
765 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
766 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
767 #else
768 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
769 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
770 static char* __PYX_DEFAULT_STRING_ENCODING;
771 static int __Pyx_init_sys_getdefaultencoding_params(void) {
772 PyObject* sys;
773 PyObject* default_encoding = NULL;
774 char* default_encoding_c;
775 sys = PyImport_ImportModule("sys");
776 if (!sys) goto bad;
777 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
778 Py_DECREF(sys);
779 if (!default_encoding) goto bad;
780 default_encoding_c = PyBytes_AsString(default_encoding);
781 if (!default_encoding_c) goto bad;
782 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
783 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
784 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
785 Py_DECREF(default_encoding);
786 return 0;
787 bad:
788 Py_XDECREF(default_encoding);
789 return -1;
790 }
791 #endif
792 #endif
793
794
795 /* Test for GCC > 2.95 */
796 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
797 #define likely(x) __builtin_expect(!!(x), 1)
798 #define unlikely(x) __builtin_expect(!!(x), 0)
799 #else /* !__GNUC__ or GCC < 2.95 */
800 #define likely(x) (x)
801 #define unlikely(x) (x)
802 #endif /* __GNUC__ */
803 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
804
805 static PyObject *__pyx_m = NULL;
806 static PyObject *__pyx_d;
807 static PyObject *__pyx_b;
808 static PyObject *__pyx_cython_runtime = NULL;
809 static PyObject *__pyx_empty_tuple;
810 static PyObject *__pyx_empty_bytes;
811 static PyObject *__pyx_empty_unicode;
812 static int __pyx_lineno;
813 static int __pyx_clineno = 0;
814 static const char * __pyx_cfilenm= __FILE__;
815 static const char *__pyx_filename;
816
817
818 static const char *__pyx_f[] = {
819 "clickhouse_driver/columns/stringcolumn.pyx",
820 "type.pxd",
821 "bool.pxd",
822 "complex.pxd",
823 };
824
825 /*--- Type declarations ---*/
826
827 /* --- Runtime support code (head) --- */
828 /* Refnanny.proto */
829 #ifndef CYTHON_REFNANNY
830 #define CYTHON_REFNANNY 0
831 #endif
832 #if CYTHON_REFNANNY
833 typedef struct {
834 void (*INCREF)(void*, PyObject*, int);
835 void (*DECREF)(void*, PyObject*, int);
836 void (*GOTREF)(void*, PyObject*, int);
837 void (*GIVEREF)(void*, PyObject*, int);
838 void* (*SetupContext)(const char*, int, const char*);
839 void (*FinishContext)(void**);
840 } __Pyx_RefNannyAPIStruct;
841 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
842 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
843 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
844 #ifdef WITH_THREAD
845 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
846 if (acquire_gil) {\
847 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
848 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
849 PyGILState_Release(__pyx_gilstate_save);\
850 } else {\
851 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
852 }
853 #else
854 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
855 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
856 #endif
857 #define __Pyx_RefNannyFinishContext()\
858 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
859 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
860 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
861 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
862 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
863 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
864 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
865 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
866 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
867 #else
868 #define __Pyx_RefNannyDeclarations
869 #define __Pyx_RefNannySetupContext(name, acquire_gil)
870 #define __Pyx_RefNannyFinishContext()
871 #define __Pyx_INCREF(r) Py_INCREF(r)
872 #define __Pyx_DECREF(r) Py_DECREF(r)
873 #define __Pyx_GOTREF(r)
874 #define __Pyx_GIVEREF(r)
875 #define __Pyx_XINCREF(r) Py_XINCREF(r)
876 #define __Pyx_XDECREF(r) Py_XDECREF(r)
877 #define __Pyx_XGOTREF(r)
878 #define __Pyx_XGIVEREF(r)
879 #endif
880 #define __Pyx_XDECREF_SET(r, v) do {\
881 PyObject *tmp = (PyObject *) r;\
882 r = v; __Pyx_XDECREF(tmp);\
883 } while (0)
884 #define __Pyx_DECREF_SET(r, v) do {\
885 PyObject *tmp = (PyObject *) r;\
886 r = v; __Pyx_DECREF(tmp);\
887 } while (0)
888 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
889 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
890
891 /* PyObjectGetAttrStr.proto */
892 #if CYTHON_USE_TYPE_SLOTS
893 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
894 #else
895 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
896 #endif
897
898 /* GetBuiltinName.proto */
899 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
900
901 /* RaiseArgTupleInvalid.proto */
902 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
903 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
904
905 /* RaiseDoubleKeywords.proto */
906 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
907
908 /* ParseKeywords.proto */
909 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
910 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
911 const char* function_name);
912
913 /* PyObjectCall.proto */
914 #if CYTHON_COMPILING_IN_CPYTHON
915 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
916 #else
917 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
918 #endif
919
920 /* PyCFunctionFastCall.proto */
921 #if CYTHON_FAST_PYCCALL
922 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
923 #else
924 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
925 #endif
926
927 /* PyFunctionFastCall.proto */
928 #if CYTHON_FAST_PYCALL
929 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
930 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
931 #if 1 || PY_VERSION_HEX < 0x030600B1
932 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
933 #else
934 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
935 #endif
936 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
937 (sizeof(char [1 - 2*!(cond)]) - 1)
938 #ifndef Py_MEMBER_SIZE
939 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
940 #endif
941 static size_t __pyx_pyframe_localsplus_offset = 0;
942 #include "frameobject.h"
943 #define __Pxy_PyFrame_Initialize_Offsets()\
944 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
945 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
946 #define __Pyx_PyFrame_GetLocalsplus(frame)\
947 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
948 #endif
949
950 /* PyObjectCall2Args.proto */
951 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
952
953 /* PyObjectCallMethO.proto */
954 #if CYTHON_COMPILING_IN_CPYTHON
955 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
956 #endif
957
958 /* PyObjectCallOneArg.proto */
959 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
960
961 /* PyObjectSetAttrStr.proto */
962 #if CYTHON_USE_TYPE_SLOTS
963 #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
964 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
965 #else
966 #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
967 #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
968 #endif
969
970 /* PyDictVersioning.proto */
971 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
972 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
973 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
974 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
975 (version_var) = __PYX_GET_DICT_VERSION(dict);\
976 (cache_var) = (value);
977 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
978 static PY_UINT64_T __pyx_dict_version = 0;\
979 static PyObject *__pyx_dict_cached_value = NULL;\
980 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
981 (VAR) = __pyx_dict_cached_value;\
982 } else {\
983 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
984 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
985 }\
986 }
987 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
988 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
989 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
990 #else
991 #define __PYX_GET_DICT_VERSION(dict) (0)
992 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
993 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
994 #endif
995
996 /* GetModuleGlobalName.proto */
997 #if CYTHON_USE_DICT_VERSIONS
998 #define __Pyx_GetModuleGlobalName(var, name) {\
999 static PY_UINT64_T __pyx_dict_version = 0;\
1000 static PyObject *__pyx_dict_cached_value = NULL;\
1001 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
1002 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
1003 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1004 }
1005 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
1006 PY_UINT64_T __pyx_dict_version;\
1007 PyObject *__pyx_dict_cached_value;\
1008 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
1009 }
1010 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
1011 #else
1012 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1013 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
1014 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
1015 #endif
1016
1017 /* IncludeStringH.proto */
1018 #include <string.h>
1019
1020 /* decode_c_string_utf16.proto */
1021 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1022 int byteorder = 0;
1023 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1024 }
1025 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1026 int byteorder = -1;
1027 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1028 }
1029 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1030 int byteorder = 1;
1031 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1032 }
1033
1034 /* decode_c_string.proto */
1035 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1036 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1037 const char* encoding, const char* errors,
1038 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1039
1040 /* GetTopmostException.proto */
1041 #if CYTHON_USE_EXC_INFO_STACK
1042 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1043 #endif
1044
1045 /* PyThreadStateGet.proto */
1046 #if CYTHON_FAST_THREAD_STATE
1047 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1048 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1049 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1050 #else
1051 #define __Pyx_PyThreadState_declare
1052 #define __Pyx_PyThreadState_assign
1053 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1054 #endif
1055
1056 /* SaveResetException.proto */
1057 #if CYTHON_FAST_THREAD_STATE
1058 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1059 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1060 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1061 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1062 #else
1063 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1064 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1065 #endif
1066
1067 /* PyErrExceptionMatches.proto */
1068 #if CYTHON_FAST_THREAD_STATE
1069 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1070 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1071 #else
1072 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1073 #endif
1074
1075 /* GetException.proto */
1076 #if CYTHON_FAST_THREAD_STATE
1077 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1078 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1079 #else
1080 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1081 #endif
1082
1083 /* GetItemInt.proto */
1084 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1085 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1086 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1087 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1088 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1089 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1090 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1091 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1092 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1093 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1094 int wraparound, int boundscheck);
1095 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1096 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1097 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1098 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1099 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1100 int wraparound, int boundscheck);
1101 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1102 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1103 int is_list, int wraparound, int boundscheck);
1104
1105 /* PyObjectCallNoArg.proto */
1106 #if CYTHON_COMPILING_IN_CPYTHON
1107 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1108 #else
1109 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1110 #endif
1111
1112 /* PyErrFetchRestore.proto */
1113 #if CYTHON_FAST_THREAD_STATE
1114 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1115 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1116 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1117 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1118 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1119 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1120 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1121 #if CYTHON_COMPILING_IN_CPYTHON
1122 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1123 #else
1124 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1125 #endif
1126 #else
1127 #define __Pyx_PyErr_Clear() PyErr_Clear()
1128 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1129 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1130 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1131 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1132 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1133 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1134 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1135 #endif
1136
1137 /* RaiseException.proto */
1138 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1139
1140 /* DictGetItem.proto */
1141 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
1142 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
1143 #define __Pyx_PyObject_Dict_GetItem(obj, name)\
1144 (likely(PyDict_CheckExact(obj)) ?\
1145 __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
1146 #else
1147 #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1148 #define __Pyx_PyObject_Dict_GetItem(obj, name) PyObject_GetItem(obj, name)
1149 #endif
1150
1151 /* BytesEquals.proto */
1152 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1153
1154 /* UnicodeEquals.proto */
1155 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1156
1157 /* SliceObject.proto */
1158 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1159 PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1160 PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1161 int has_cstart, int has_cstop, int wraparound);
1162
1163 /* TypeImport.proto */
1164 #ifndef __PYX_HAVE_RT_ImportType_proto
1165 #define __PYX_HAVE_RT_ImportType_proto
1166 enum __Pyx_ImportType_CheckSize {
1167 __Pyx_ImportType_CheckSize_Error = 0,
1168 __Pyx_ImportType_CheckSize_Warn = 1,
1169 __Pyx_ImportType_CheckSize_Ignore = 2
1170 };
1171 static PyTypeObject *__Pyx_ImportType(PyObject* module, const char *module_name, const char *class_name, size_t size, enum __Pyx_ImportType_CheckSize check_size);
1172 #endif
1173
1174 /* Import.proto */
1175 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1176
1177 /* ImportFrom.proto */
1178 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1179
1180 /* CalculateMetaclass.proto */
1181 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
1182
1183 /* SetNameInClass.proto */
1184 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
1185 #define __Pyx_SetNameInClass(ns, name, value)\
1186 (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
1187 #elif CYTHON_COMPILING_IN_CPYTHON
1188 #define __Pyx_SetNameInClass(ns, name, value)\
1189 (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
1190 #else
1191 #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
1192 #endif
1193
1194 /* FetchCommonType.proto */
1195 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1196
1197 /* CythonFunction.proto */
1198 #define __Pyx_CyFunction_USED 1
1199 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
1200 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
1201 #define __Pyx_CYFUNCTION_CCLASS 0x04
1202 #define __Pyx_CyFunction_GetClosure(f)\
1203 (((__pyx_CyFunctionObject *) (f))->func_closure)
1204 #define __Pyx_CyFunction_GetClassObj(f)\
1205 (((__pyx_CyFunctionObject *) (f))->func_classobj)
1206 #define __Pyx_CyFunction_Defaults(type, f)\
1207 ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1208 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1209 ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1210 typedef struct {
1211 PyCFunctionObject func;
1212 #if PY_VERSION_HEX < 0x030500A0
1213 PyObject *func_weakreflist;
1214 #endif
1215 PyObject *func_dict;
1216 PyObject *func_name;
1217 PyObject *func_qualname;
1218 PyObject *func_doc;
1219 PyObject *func_globals;
1220 PyObject *func_code;
1221 PyObject *func_closure;
1222 PyObject *func_classobj;
1223 void *defaults;
1224 int defaults_pyobjects;
1225 int flags;
1226 PyObject *defaults_tuple;
1227 PyObject *defaults_kwdict;
1228 PyObject *(*defaults_getter)(PyObject *);
1229 PyObject *func_annotations;
1230 } __pyx_CyFunctionObject;
1231 static PyTypeObject *__pyx_CyFunctionType = 0;
1232 #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1233 #define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code)\
1234 __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
1235 static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
1236 int flags, PyObject* qualname,
1237 PyObject *self,
1238 PyObject *module, PyObject *globals,
1239 PyObject* code);
1240 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1241 size_t size,
1242 int pyobjects);
1243 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1244 PyObject *tuple);
1245 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1246 PyObject *dict);
1247 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1248 PyObject *dict);
1249 static int __pyx_CyFunction_init(void);
1250
1251 /* Py3ClassCreate.proto */
1252 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
1253 PyObject *mkw, PyObject *modname, PyObject *doc);
1254 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
1255 PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
1256
1257 /* CLineInTraceback.proto */
1258 #ifdef CYTHON_CLINE_IN_TRACEBACK
1259 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1260 #else
1261 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1262 #endif
1263
1264 /* CodeObjectCache.proto */
1265 typedef struct {
1266 PyCodeObject* code_object;
1267 int code_line;
1268 } __Pyx_CodeObjectCacheEntry;
1269 struct __Pyx_CodeObjectCache {
1270 int count;
1271 int max_count;
1272 __Pyx_CodeObjectCacheEntry* entries;
1273 };
1274 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1275 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1276 static PyCodeObject *__pyx_find_code_object(int code_line);
1277 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1278
1279 /* AddTraceback.proto */
1280 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1281 int py_line, const char *filename);
1282
1283 /* CIntToPy.proto */
1284 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1285
1286 /* CIntFromPy.proto */
1287 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1288
1289 /* CIntFromPy.proto */
1290 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1291
1292 /* FastTypeChecks.proto */
1293 #if CYTHON_COMPILING_IN_CPYTHON
1294 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1295 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1296 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1297 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1298 #else
1299 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1300 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1301 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1302 #endif
1303 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1304
1305 /* CheckBinaryVersion.proto */
1306 static int __Pyx_check_binary_version(void);
1307
1308 /* InitStrings.proto */
1309 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1310
1311
1312 /* Module declarations from 'cpython.version' */
1313
1314 /* Module declarations from '__builtin__' */
1315
1316 /* Module declarations from 'cpython.type' */
1317 static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
1318
1319 /* Module declarations from 'libc.string' */
1320
1321 /* Module declarations from 'libc.stdio' */
1322
1323 /* Module declarations from 'cpython.object' */
1324
1325 /* Module declarations from 'cpython.ref' */
1326
1327 /* Module declarations from 'cpython.exc' */
1328
1329 /* Module declarations from 'cpython.module' */
1330
1331 /* Module declarations from 'cpython.mem' */
1332
1333 /* Module declarations from 'cpython.tuple' */
1334
1335 /* Module declarations from 'cpython.list' */
1336
1337 /* Module declarations from 'cpython.sequence' */
1338
1339 /* Module declarations from 'cpython.mapping' */
1340
1341 /* Module declarations from 'cpython.iterator' */
1342
1343 /* Module declarations from 'cpython.number' */
1344
1345 /* Module declarations from 'cpython.int' */
1346
1347 /* Module declarations from '__builtin__' */
1348
1349 /* Module declarations from 'cpython.bool' */
1350 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1351
1352 /* Module declarations from 'cpython.long' */
1353
1354 /* Module declarations from 'cpython.float' */
1355
1356 /* Module declarations from '__builtin__' */
1357
1358 /* Module declarations from 'cpython.complex' */
1359 static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
1360
1361 /* Module declarations from 'cpython.string' */
1362
1363 /* Module declarations from 'cpython.unicode' */
1364
1365 /* Module declarations from 'cpython.dict' */
1366
1367 /* Module declarations from 'cpython.instance' */
1368
1369 /* Module declarations from 'cpython.function' */
1370
1371 /* Module declarations from 'cpython.method' */
1372
1373 /* Module declarations from 'cpython.weakref' */
1374
1375 /* Module declarations from 'cpython.getargs' */
1376
1377 /* Module declarations from 'cpython.pythread' */
1378
1379 /* Module declarations from 'cpython.pystate' */
1380
1381 /* Module declarations from 'cpython.cobject' */
1382
1383 /* Module declarations from 'cpython.oldbuffer' */
1384
1385 /* Module declarations from 'cpython.set' */
1386
1387 /* Module declarations from 'cpython.buffer' */
1388
1389 /* Module declarations from 'cpython.bytes' */
1390
1391 /* Module declarations from 'cpython.pycapsule' */
1392
1393 /* Module declarations from 'cpython' */
1394
1395 /* Module declarations from 'cpython.bytearray' */
1396
1397 /* Module declarations from 'clickhouse_driver.columns.stringcolumn' */
1398 #define __Pyx_MODULE_NAME "clickhouse_driver.columns.stringcolumn"
1399 extern int __pyx_module_is_main_clickhouse_driver__columns__stringcolumn;
1400 int __pyx_module_is_main_clickhouse_driver__columns__stringcolumn = 0;
1401
1402 /* Implementation of 'clickhouse_driver.columns.stringcolumn' */
1403 static PyObject *__pyx_builtin_super;
1404 static PyObject *__pyx_builtin_MemoryError;
1405 static PyObject *__pyx_builtin_range;
1406 static PyObject *__pyx_builtin_UnicodeDecodeError;
1407 static const char __pyx_k_i[] = "i";
1408 static const char __pyx_k_j[] = "j";
1409 static const char __pyx_k__2[] = "";
1410 static const char __pyx_k_buf[] = "buf";
1411 static const char __pyx_k_cls[] = "cls";
1412 static const char __pyx_k_doc[] = "__doc__";
1413 static const char __pyx_k_base[] = "base";
1414 static const char __pyx_k_data[] = "data";
1415 static const char __pyx_k_init[] = "__init__";
1416 static const char __pyx_k_item[] = "item";
1417 static const char __pyx_k_main[] = "__main__";
1418 static const char __pyx_k_name[] = "__name__";
1419 static const char __pyx_k_read[] = "read";
1420 static const char __pyx_k_self[] = "self";
1421 static const char __pyx_k_spec[] = "spec";
1422 static const char __pyx_k_test[] = "__test__";
1423 static const char __pyx_k_util[] = "util";
1424 static const char __pyx_k_items[] = "items";
1425 static const char __pyx_k_range[] = "range";
1426 static const char __pyx_k_super[] = "super";
1427 static const char __pyx_k_value[] = "value";
1428 static const char __pyx_k_write[] = "write";
1429 static const char __pyx_k_Column[] = "Column";
1430 static const char __pyx_k_String[] = "String";
1431 static const char __pyx_k_codecs[] = "codecs";
1432 static const char __pyx_k_compat[] = "compat";
1433 static const char __pyx_k_decode[] = "decode";
1434 static const char __pyx_k_encode[] = "encode";
1435 static const char __pyx_k_errors[] = "errors";
1436 static const char __pyx_k_import[] = "__import__";
1437 static const char __pyx_k_kwargs[] = "kwargs";
1438 static const char __pyx_k_length[] = "length";
1439 static const char __pyx_k_module[] = "__module__";
1440 static const char __pyx_k_buf_pos[] = "buf_pos";
1441 static const char __pyx_k_c_value[] = "c_value";
1442 static const char __pyx_k_ch_type[] = "ch_type";
1443 static const char __pyx_k_context[] = "context";
1444 static const char __pyx_k_n_items[] = "n_items";
1445 static const char __pyx_k_prepare[] = "__prepare__";
1446 static const char __pyx_k_c_string[] = "c_string";
1447 static const char __pyx_k_data_ptr[] = "data_ptr";
1448 static const char __pyx_k_py_types[] = "py_types";
1449 static const char __pyx_k_qualname[] = "__qualname__";
1450 static const char __pyx_k_items_buf[] = "items_buf";
1451 static const char __pyx_k_metaclass[] = "__metaclass__";
1452 static const char __pyx_k_value_len[] = "value_len";
1453 static const char __pyx_k_ByteString[] = "ByteString";
1454 static const char __pyx_k_null_value[] = "null_value";
1455 static const char __pyx_k_read_items[] = "read_items";
1456 static const char __pyx_k_FixedString[] = "FixedString";
1457 static const char __pyx_k_MemoryError[] = "MemoryError";
1458 static const char __pyx_k_write_items[] = "write_items";
1459 static const char __pyx_k_read_strings[] = "read_strings";
1460 static const char __pyx_k_string_types[] = "string_types";
1461 static const char __pyx_k_utf_8_encode[] = "utf_8_encode";
1462 static const char __pyx_k_write_strings[] = "write_strings";
1463 static const char __pyx_k_column_options[] = "column_options";
1464 static const char __pyx_k_items_buf_size[] = "items_buf_size";
1465 static const char __pyx_k_ByteFixedString[] = "ByteFixedString";
1466 static const char __pyx_k_client_settings[] = "client_settings";
1467 static const char __pyx_k_strings_as_bytes[] = "strings_as_bytes";
1468 static const char __pyx_k_String_read_items[] = "String.read_items";
1469 static const char __pyx_k_FixedString___init[] = "FixedString.__init__";
1470 static const char __pyx_k_String_write_items[] = "String.write_items";
1471 static const char __pyx_k_TooLargeStringSize[] = "TooLargeStringSize";
1472 static const char __pyx_k_UnicodeDecodeError[] = "UnicodeDecodeError";
1473 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1474 static const char __pyx_k_create_string_column[] = "create_string_column";
1475 static const char __pyx_k_ByteString_read_items[] = "ByteString.read_items";
1476 static const char __pyx_k_ByteString_write_items[] = "ByteString.write_items";
1477 static const char __pyx_k_FixedString_read_items[] = "FixedString.read_items";
1478 static const char __pyx_k_FixedString_write_items[] = "FixedString.write_items";
1479 static const char __pyx_k_ByteFixedString_read_items[] = "ByteFixedString.read_items";
1480 static const char __pyx_k_ByteFixedString_write_items[] = "ByteFixedString.write_items";
1481 static const char __pyx_k_clickhouse_driver_columns_string[] = "clickhouse_driver.columns.stringcolumn";
1482 static const char __pyx_k_clickhouse_driver_columns_string_2[] = "clickhouse_driver/columns/stringcolumn.pyx";
1483 static PyObject *__pyx_n_s_ByteFixedString;
1484 static PyObject *__pyx_n_s_ByteFixedString_read_items;
1485 static PyObject *__pyx_n_s_ByteFixedString_write_items;
1486 static PyObject *__pyx_n_s_ByteString;
1487 static PyObject *__pyx_n_s_ByteString_read_items;
1488 static PyObject *__pyx_n_s_ByteString_write_items;
1489 static PyObject *__pyx_n_s_Column;
1490 static PyObject *__pyx_n_s_FixedString;
1491 static PyObject *__pyx_n_u_FixedString;
1492 static PyObject *__pyx_n_s_FixedString___init;
1493 static PyObject *__pyx_n_s_FixedString_read_items;
1494 static PyObject *__pyx_n_s_FixedString_write_items;
1495 static PyObject *__pyx_n_s_MemoryError;
1496 static PyObject *__pyx_n_s_String;
1497 static PyObject *__pyx_n_u_String;
1498 static PyObject *__pyx_n_s_String_read_items;
1499 static PyObject *__pyx_n_s_String_write_items;
1500 static PyObject *__pyx_n_s_TooLargeStringSize;
1501 static PyObject *__pyx_n_s_UnicodeDecodeError;
1502 static PyObject *__pyx_n_s__2;
1503 static PyObject *__pyx_kp_b__2;
1504 static PyObject *__pyx_kp_u__2;
1505 static PyObject *__pyx_n_s_base;
1506 static PyObject *__pyx_n_s_buf;
1507 static PyObject *__pyx_n_s_buf_pos;
1508 static PyObject *__pyx_n_s_c_string;
1509 static PyObject *__pyx_n_s_c_value;
1510 static PyObject *__pyx_n_s_ch_type;
1511 static PyObject *__pyx_n_s_clickhouse_driver_columns_string;
1512 static PyObject *__pyx_kp_s_clickhouse_driver_columns_string_2;
1513 static PyObject *__pyx_n_s_client_settings;
1514 static PyObject *__pyx_n_s_cline_in_traceback;
1515 static PyObject *__pyx_n_s_cls;
1516 static PyObject *__pyx_n_s_codecs;
1517 static PyObject *__pyx_n_s_column_options;
1518 static PyObject *__pyx_n_s_compat;
1519 static PyObject *__pyx_n_u_context;
1520 static PyObject *__pyx_n_s_create_string_column;
1521 static PyObject *__pyx_n_s_data;
1522 static PyObject *__pyx_n_s_data_ptr;
1523 static PyObject *__pyx_n_s_decode;
1524 static PyObject *__pyx_n_s_doc;
1525 static PyObject *__pyx_n_s_encode;
1526 static PyObject *__pyx_n_s_errors;
1527 static PyObject *__pyx_n_s_i;
1528 static PyObject *__pyx_n_s_import;
1529 static PyObject *__pyx_n_s_init;
1530 static PyObject *__pyx_n_s_item;
1531 static PyObject *__pyx_n_s_items;
1532 static PyObject *__pyx_n_s_items_buf;
1533 static PyObject *__pyx_n_s_items_buf_size;
1534 static PyObject *__pyx_n_s_j;
1535 static PyObject *__pyx_n_s_kwargs;
1536 static PyObject *__pyx_n_s_length;
1537 static PyObject *__pyx_n_s_main;
1538 static PyObject *__pyx_n_s_metaclass;
1539 static PyObject *__pyx_n_s_module;
1540 static PyObject *__pyx_n_s_n_items;
1541 static PyObject *__pyx_n_s_name;
1542 static PyObject *__pyx_n_s_null_value;
1543 static PyObject *__pyx_n_s_prepare;
1544 static PyObject *__pyx_n_s_py_types;
1545 static PyObject *__pyx_n_s_qualname;
1546 static PyObject *__pyx_n_s_range;
1547 static PyObject *__pyx_n_s_read;
1548 static PyObject *__pyx_n_s_read_items;
1549 static PyObject *__pyx_n_s_read_strings;
1550 static PyObject *__pyx_n_s_self;
1551 static PyObject *__pyx_n_s_spec;
1552 static PyObject *__pyx_n_s_string_types;
1553 static PyObject *__pyx_n_s_strings_as_bytes;
1554 static PyObject *__pyx_n_u_strings_as_bytes;
1555 static PyObject *__pyx_n_s_super;
1556 static PyObject *__pyx_n_s_test;
1557 static PyObject *__pyx_n_s_utf_8_encode;
1558 static PyObject *__pyx_n_s_util;
1559 static PyObject *__pyx_n_s_value;
1560 static PyObject *__pyx_n_s_value_len;
1561 static PyObject *__pyx_n_s_write;
1562 static PyObject *__pyx_n_s_write_items;
1563 static PyObject *__pyx_n_s_write_strings;
1564 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_write_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf); /* proto */
1565 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_2read_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_n_items, PyObject *__pyx_v_buf); /* proto */
1566 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_write_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf); /* proto */
1567 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_2read_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_n_items, PyObject *__pyx_v_buf); /* proto */
1568 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_length, PyObject *__pyx_v_kwargs); /* proto */
1569 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_2read_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, PyObject *__pyx_v_buf); /* proto */
1570 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_4write_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf); /* proto */
1571 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_read_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, PyObject *__pyx_v_buf); /* proto */
1572 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_2write_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf); /* proto */
1573 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_create_string_column(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spec, PyObject *__pyx_v_column_options); /* proto */
1574 static PyObject *__pyx_int_12;
1575 static PyObject *__pyx_int_neg_1;
1576 static PyObject *__pyx_slice_;
1577 static PyObject *__pyx_tuple__3;
1578 static PyObject *__pyx_tuple__5;
1579 static PyObject *__pyx_tuple__7;
1580 static PyObject *__pyx_tuple__9;
1581 static PyObject *__pyx_tuple__11;
1582 static PyObject *__pyx_tuple__13;
1583 static PyObject *__pyx_tuple__15;
1584 static PyObject *__pyx_tuple__17;
1585 static PyObject *__pyx_tuple__19;
1586 static PyObject *__pyx_tuple__21;
1587 static PyObject *__pyx_codeobj__4;
1588 static PyObject *__pyx_codeobj__6;
1589 static PyObject *__pyx_codeobj__8;
1590 static PyObject *__pyx_codeobj__10;
1591 static PyObject *__pyx_codeobj__12;
1592 static PyObject *__pyx_codeobj__14;
1593 static PyObject *__pyx_codeobj__16;
1594 static PyObject *__pyx_codeobj__18;
1595 static PyObject *__pyx_codeobj__20;
1596 static PyObject *__pyx_codeobj__22;
1597 /* Late includes */
1598
1599 /* "clickhouse_driver/columns/stringcolumn.pyx":25
1600 * # TODO: pass user encoding here
1601 *
1602 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
1603 * buf.write_strings(items, encode=True)
1604 *
1605 */
1606
1607 /* Python wrapper */
1608 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_1write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1609 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_6String_1write_items = {"write_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_1write_items, METH_VARARGS|METH_KEYWORDS, 0};
1610 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_1write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1611 CYTHON_UNUSED PyObject *__pyx_v_self = 0;
1612 PyObject *__pyx_v_items = 0;
1613 PyObject *__pyx_v_buf = 0;
1614 PyObject *__pyx_r = 0;
1615 __Pyx_RefNannyDeclarations
1616 __Pyx_RefNannySetupContext("write_items (wrapper)", 0);
1617 {
1618 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_items,&__pyx_n_s_buf,0};
1619 PyObject* values[3] = {0,0,0};
1620 if (unlikely(__pyx_kwds)) {
1621 Py_ssize_t kw_args;
1622 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1623 switch (pos_args) {
1624 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1625 CYTHON_FALLTHROUGH;
1626 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1627 CYTHON_FALLTHROUGH;
1628 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1629 CYTHON_FALLTHROUGH;
1630 case 0: break;
1631 default: goto __pyx_L5_argtuple_error;
1632 }
1633 kw_args = PyDict_Size(__pyx_kwds);
1634 switch (pos_args) {
1635 case 0:
1636 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
1637 else goto __pyx_L5_argtuple_error;
1638 CYTHON_FALLTHROUGH;
1639 case 1:
1640 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
1641 else {
1642 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 1); __PYX_ERR(0, 25, __pyx_L3_error)
1643 }
1644 CYTHON_FALLTHROUGH;
1645 case 2:
1646 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
1647 else {
1648 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 2); __PYX_ERR(0, 25, __pyx_L3_error)
1649 }
1650 }
1651 if (unlikely(kw_args > 0)) {
1652 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_items") < 0)) __PYX_ERR(0, 25, __pyx_L3_error)
1653 }
1654 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1655 goto __pyx_L5_argtuple_error;
1656 } else {
1657 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1658 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1659 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1660 }
1661 __pyx_v_self = values[0];
1662 __pyx_v_items = values[1];
1663 __pyx_v_buf = values[2];
1664 }
1665 goto __pyx_L4_argument_unpacking_done;
1666 __pyx_L5_argtuple_error:;
1667 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 25, __pyx_L3_error)
1668 __pyx_L3_error:;
1669 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.String.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
1670 __Pyx_RefNannyFinishContext();
1671 return NULL;
1672 __pyx_L4_argument_unpacking_done:;
1673 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_write_items(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_buf);
1674
1675 /* function exit code */
1676 __Pyx_RefNannyFinishContext();
1677 return __pyx_r;
1678 }
1679
1680 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_write_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf) {
1681 PyObject *__pyx_r = NULL;
1682 __Pyx_RefNannyDeclarations
1683 PyObject *__pyx_t_1 = NULL;
1684 PyObject *__pyx_t_2 = NULL;
1685 PyObject *__pyx_t_3 = NULL;
1686 PyObject *__pyx_t_4 = NULL;
1687 __Pyx_RefNannySetupContext("write_items", 0);
1688
1689 /* "clickhouse_driver/columns/stringcolumn.pyx":26
1690 *
1691 * def write_items(self, items, buf):
1692 * buf.write_strings(items, encode=True) # <<<<<<<<<<<<<<
1693 *
1694 * def read_items(self, n_items, buf):
1695 */
1696 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write_strings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
1697 __Pyx_GOTREF(__pyx_t_1);
1698 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
1699 __Pyx_GOTREF(__pyx_t_2);
1700 __Pyx_INCREF(__pyx_v_items);
1701 __Pyx_GIVEREF(__pyx_v_items);
1702 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_items);
1703 __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1704 __Pyx_GOTREF(__pyx_t_3);
1705 if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_encode, Py_True) < 0) __PYX_ERR(0, 26, __pyx_L1_error)
1706 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L1_error)
1707 __Pyx_GOTREF(__pyx_t_4);
1708 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1709 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1710 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1711 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1712
1713 /* "clickhouse_driver/columns/stringcolumn.pyx":25
1714 * # TODO: pass user encoding here
1715 *
1716 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
1717 * buf.write_strings(items, encode=True)
1718 *
1719 */
1720
1721 /* function exit code */
1722 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1723 goto __pyx_L0;
1724 __pyx_L1_error:;
1725 __Pyx_XDECREF(__pyx_t_1);
1726 __Pyx_XDECREF(__pyx_t_2);
1727 __Pyx_XDECREF(__pyx_t_3);
1728 __Pyx_XDECREF(__pyx_t_4);
1729 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.String.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
1730 __pyx_r = NULL;
1731 __pyx_L0:;
1732 __Pyx_XGIVEREF(__pyx_r);
1733 __Pyx_RefNannyFinishContext();
1734 return __pyx_r;
1735 }
1736
1737 /* "clickhouse_driver/columns/stringcolumn.pyx":28
1738 * buf.write_strings(items, encode=True)
1739 *
1740 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
1741 * return buf.read_strings(n_items, decode=True)
1742 *
1743 */
1744
1745 /* Python wrapper */
1746 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1747 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_6String_3read_items = {"read_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_3read_items, METH_VARARGS|METH_KEYWORDS, 0};
1748 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_6String_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1749 CYTHON_UNUSED PyObject *__pyx_v_self = 0;
1750 PyObject *__pyx_v_n_items = 0;
1751 PyObject *__pyx_v_buf = 0;
1752 PyObject *__pyx_r = 0;
1753 __Pyx_RefNannyDeclarations
1754 __Pyx_RefNannySetupContext("read_items (wrapper)", 0);
1755 {
1756 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_buf,0};
1757 PyObject* values[3] = {0,0,0};
1758 if (unlikely(__pyx_kwds)) {
1759 Py_ssize_t kw_args;
1760 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1761 switch (pos_args) {
1762 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1763 CYTHON_FALLTHROUGH;
1764 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1765 CYTHON_FALLTHROUGH;
1766 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1767 CYTHON_FALLTHROUGH;
1768 case 0: break;
1769 default: goto __pyx_L5_argtuple_error;
1770 }
1771 kw_args = PyDict_Size(__pyx_kwds);
1772 switch (pos_args) {
1773 case 0:
1774 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
1775 else goto __pyx_L5_argtuple_error;
1776 CYTHON_FALLTHROUGH;
1777 case 1:
1778 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
1779 else {
1780 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 1); __PYX_ERR(0, 28, __pyx_L3_error)
1781 }
1782 CYTHON_FALLTHROUGH;
1783 case 2:
1784 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
1785 else {
1786 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 2); __PYX_ERR(0, 28, __pyx_L3_error)
1787 }
1788 }
1789 if (unlikely(kw_args > 0)) {
1790 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_items") < 0)) __PYX_ERR(0, 28, __pyx_L3_error)
1791 }
1792 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1793 goto __pyx_L5_argtuple_error;
1794 } else {
1795 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1796 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1797 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1798 }
1799 __pyx_v_self = values[0];
1800 __pyx_v_n_items = values[1];
1801 __pyx_v_buf = values[2];
1802 }
1803 goto __pyx_L4_argument_unpacking_done;
1804 __pyx_L5_argtuple_error:;
1805 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 28, __pyx_L3_error)
1806 __pyx_L3_error:;
1807 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.String.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
1808 __Pyx_RefNannyFinishContext();
1809 return NULL;
1810 __pyx_L4_argument_unpacking_done:;
1811 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_2read_items(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_buf);
1812
1813 /* function exit code */
1814 __Pyx_RefNannyFinishContext();
1815 return __pyx_r;
1816 }
1817
1818 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_6String_2read_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_n_items, PyObject *__pyx_v_buf) {
1819 PyObject *__pyx_r = NULL;
1820 __Pyx_RefNannyDeclarations
1821 PyObject *__pyx_t_1 = NULL;
1822 PyObject *__pyx_t_2 = NULL;
1823 PyObject *__pyx_t_3 = NULL;
1824 PyObject *__pyx_t_4 = NULL;
1825 __Pyx_RefNannySetupContext("read_items", 0);
1826
1827 /* "clickhouse_driver/columns/stringcolumn.pyx":29
1828 *
1829 * def read_items(self, n_items, buf):
1830 * return buf.read_strings(n_items, decode=True) # <<<<<<<<<<<<<<
1831 *
1832 *
1833 */
1834 __Pyx_XDECREF(__pyx_r);
1835 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read_strings); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
1836 __Pyx_GOTREF(__pyx_t_1);
1837 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 29, __pyx_L1_error)
1838 __Pyx_GOTREF(__pyx_t_2);
1839 __Pyx_INCREF(__pyx_v_n_items);
1840 __Pyx_GIVEREF(__pyx_v_n_items);
1841 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_n_items);
1842 __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 29, __pyx_L1_error)
1843 __Pyx_GOTREF(__pyx_t_3);
1844 if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_decode, Py_True) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
1845 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 29, __pyx_L1_error)
1846 __Pyx_GOTREF(__pyx_t_4);
1847 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1848 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1849 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1850 __pyx_r = __pyx_t_4;
1851 __pyx_t_4 = 0;
1852 goto __pyx_L0;
1853
1854 /* "clickhouse_driver/columns/stringcolumn.pyx":28
1855 * buf.write_strings(items, encode=True)
1856 *
1857 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
1858 * return buf.read_strings(n_items, decode=True)
1859 *
1860 */
1861
1862 /* function exit code */
1863 __pyx_L1_error:;
1864 __Pyx_XDECREF(__pyx_t_1);
1865 __Pyx_XDECREF(__pyx_t_2);
1866 __Pyx_XDECREF(__pyx_t_3);
1867 __Pyx_XDECREF(__pyx_t_4);
1868 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.String.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
1869 __pyx_r = NULL;
1870 __pyx_L0:;
1871 __Pyx_XGIVEREF(__pyx_r);
1872 __Pyx_RefNannyFinishContext();
1873 return __pyx_r;
1874 }
1875
1876 /* "clickhouse_driver/columns/stringcolumn.pyx":36
1877 * null_value = b''
1878 *
1879 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
1880 * buf.write_strings(items)
1881 *
1882 */
1883
1884 /* Python wrapper */
1885 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_1write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1886 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_10ByteString_1write_items = {"write_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_1write_items, METH_VARARGS|METH_KEYWORDS, 0};
1887 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_1write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1888 CYTHON_UNUSED PyObject *__pyx_v_self = 0;
1889 PyObject *__pyx_v_items = 0;
1890 PyObject *__pyx_v_buf = 0;
1891 PyObject *__pyx_r = 0;
1892 __Pyx_RefNannyDeclarations
1893 __Pyx_RefNannySetupContext("write_items (wrapper)", 0);
1894 {
1895 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_items,&__pyx_n_s_buf,0};
1896 PyObject* values[3] = {0,0,0};
1897 if (unlikely(__pyx_kwds)) {
1898 Py_ssize_t kw_args;
1899 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1900 switch (pos_args) {
1901 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1902 CYTHON_FALLTHROUGH;
1903 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1904 CYTHON_FALLTHROUGH;
1905 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1906 CYTHON_FALLTHROUGH;
1907 case 0: break;
1908 default: goto __pyx_L5_argtuple_error;
1909 }
1910 kw_args = PyDict_Size(__pyx_kwds);
1911 switch (pos_args) {
1912 case 0:
1913 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
1914 else goto __pyx_L5_argtuple_error;
1915 CYTHON_FALLTHROUGH;
1916 case 1:
1917 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
1918 else {
1919 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 1); __PYX_ERR(0, 36, __pyx_L3_error)
1920 }
1921 CYTHON_FALLTHROUGH;
1922 case 2:
1923 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
1924 else {
1925 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 2); __PYX_ERR(0, 36, __pyx_L3_error)
1926 }
1927 }
1928 if (unlikely(kw_args > 0)) {
1929 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_items") < 0)) __PYX_ERR(0, 36, __pyx_L3_error)
1930 }
1931 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
1932 goto __pyx_L5_argtuple_error;
1933 } else {
1934 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1935 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1936 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1937 }
1938 __pyx_v_self = values[0];
1939 __pyx_v_items = values[1];
1940 __pyx_v_buf = values[2];
1941 }
1942 goto __pyx_L4_argument_unpacking_done;
1943 __pyx_L5_argtuple_error:;
1944 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 36, __pyx_L3_error)
1945 __pyx_L3_error:;
1946 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
1947 __Pyx_RefNannyFinishContext();
1948 return NULL;
1949 __pyx_L4_argument_unpacking_done:;
1950 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_write_items(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_buf);
1951
1952 /* function exit code */
1953 __Pyx_RefNannyFinishContext();
1954 return __pyx_r;
1955 }
1956
1957 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_write_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf) {
1958 PyObject *__pyx_r = NULL;
1959 __Pyx_RefNannyDeclarations
1960 PyObject *__pyx_t_1 = NULL;
1961 PyObject *__pyx_t_2 = NULL;
1962 PyObject *__pyx_t_3 = NULL;
1963 __Pyx_RefNannySetupContext("write_items", 0);
1964
1965 /* "clickhouse_driver/columns/stringcolumn.pyx":37
1966 *
1967 * def write_items(self, items, buf):
1968 * buf.write_strings(items) # <<<<<<<<<<<<<<
1969 *
1970 * def read_items(self, n_items, buf):
1971 */
1972 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write_strings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error)
1973 __Pyx_GOTREF(__pyx_t_2);
1974 __pyx_t_3 = NULL;
1975 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
1976 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
1977 if (likely(__pyx_t_3)) {
1978 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
1979 __Pyx_INCREF(__pyx_t_3);
1980 __Pyx_INCREF(function);
1981 __Pyx_DECREF_SET(__pyx_t_2, function);
1982 }
1983 }
1984 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_items) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_items);
1985 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1986 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
1987 __Pyx_GOTREF(__pyx_t_1);
1988 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1989 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1990
1991 /* "clickhouse_driver/columns/stringcolumn.pyx":36
1992 * null_value = b''
1993 *
1994 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
1995 * buf.write_strings(items)
1996 *
1997 */
1998
1999 /* function exit code */
2000 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2001 goto __pyx_L0;
2002 __pyx_L1_error:;
2003 __Pyx_XDECREF(__pyx_t_1);
2004 __Pyx_XDECREF(__pyx_t_2);
2005 __Pyx_XDECREF(__pyx_t_3);
2006 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2007 __pyx_r = NULL;
2008 __pyx_L0:;
2009 __Pyx_XGIVEREF(__pyx_r);
2010 __Pyx_RefNannyFinishContext();
2011 return __pyx_r;
2012 }
2013
2014 /* "clickhouse_driver/columns/stringcolumn.pyx":39
2015 * buf.write_strings(items)
2016 *
2017 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
2018 * return buf.read_strings(n_items)
2019 *
2020 */
2021
2022 /* Python wrapper */
2023 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2024 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_10ByteString_3read_items = {"read_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_3read_items, METH_VARARGS|METH_KEYWORDS, 0};
2025 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_10ByteString_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2026 CYTHON_UNUSED PyObject *__pyx_v_self = 0;
2027 PyObject *__pyx_v_n_items = 0;
2028 PyObject *__pyx_v_buf = 0;
2029 PyObject *__pyx_r = 0;
2030 __Pyx_RefNannyDeclarations
2031 __Pyx_RefNannySetupContext("read_items (wrapper)", 0);
2032 {
2033 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_buf,0};
2034 PyObject* values[3] = {0,0,0};
2035 if (unlikely(__pyx_kwds)) {
2036 Py_ssize_t kw_args;
2037 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2038 switch (pos_args) {
2039 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2040 CYTHON_FALLTHROUGH;
2041 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2042 CYTHON_FALLTHROUGH;
2043 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2044 CYTHON_FALLTHROUGH;
2045 case 0: break;
2046 default: goto __pyx_L5_argtuple_error;
2047 }
2048 kw_args = PyDict_Size(__pyx_kwds);
2049 switch (pos_args) {
2050 case 0:
2051 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
2052 else goto __pyx_L5_argtuple_error;
2053 CYTHON_FALLTHROUGH;
2054 case 1:
2055 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
2056 else {
2057 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 1); __PYX_ERR(0, 39, __pyx_L3_error)
2058 }
2059 CYTHON_FALLTHROUGH;
2060 case 2:
2061 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
2062 else {
2063 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 2); __PYX_ERR(0, 39, __pyx_L3_error)
2064 }
2065 }
2066 if (unlikely(kw_args > 0)) {
2067 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_items") < 0)) __PYX_ERR(0, 39, __pyx_L3_error)
2068 }
2069 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
2070 goto __pyx_L5_argtuple_error;
2071 } else {
2072 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2073 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2074 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2075 }
2076 __pyx_v_self = values[0];
2077 __pyx_v_n_items = values[1];
2078 __pyx_v_buf = values[2];
2079 }
2080 goto __pyx_L4_argument_unpacking_done;
2081 __pyx_L5_argtuple_error:;
2082 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 39, __pyx_L3_error)
2083 __pyx_L3_error:;
2084 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2085 __Pyx_RefNannyFinishContext();
2086 return NULL;
2087 __pyx_L4_argument_unpacking_done:;
2088 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_2read_items(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_buf);
2089
2090 /* function exit code */
2091 __Pyx_RefNannyFinishContext();
2092 return __pyx_r;
2093 }
2094
2095 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_10ByteString_2read_items(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_n_items, PyObject *__pyx_v_buf) {
2096 PyObject *__pyx_r = NULL;
2097 __Pyx_RefNannyDeclarations
2098 PyObject *__pyx_t_1 = NULL;
2099 PyObject *__pyx_t_2 = NULL;
2100 PyObject *__pyx_t_3 = NULL;
2101 __Pyx_RefNannySetupContext("read_items", 0);
2102
2103 /* "clickhouse_driver/columns/stringcolumn.pyx":40
2104 *
2105 * def read_items(self, n_items, buf):
2106 * return buf.read_strings(n_items) # <<<<<<<<<<<<<<
2107 *
2108 *
2109 */
2110 __Pyx_XDECREF(__pyx_r);
2111 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read_strings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error)
2112 __Pyx_GOTREF(__pyx_t_2);
2113 __pyx_t_3 = NULL;
2114 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
2115 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2116 if (likely(__pyx_t_3)) {
2117 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2118 __Pyx_INCREF(__pyx_t_3);
2119 __Pyx_INCREF(function);
2120 __Pyx_DECREF_SET(__pyx_t_2, function);
2121 }
2122 }
2123 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_n_items) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_n_items);
2124 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2125 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error)
2126 __Pyx_GOTREF(__pyx_t_1);
2127 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2128 __pyx_r = __pyx_t_1;
2129 __pyx_t_1 = 0;
2130 goto __pyx_L0;
2131
2132 /* "clickhouse_driver/columns/stringcolumn.pyx":39
2133 * buf.write_strings(items)
2134 *
2135 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
2136 * return buf.read_strings(n_items)
2137 *
2138 */
2139
2140 /* function exit code */
2141 __pyx_L1_error:;
2142 __Pyx_XDECREF(__pyx_t_1);
2143 __Pyx_XDECREF(__pyx_t_2);
2144 __Pyx_XDECREF(__pyx_t_3);
2145 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2146 __pyx_r = NULL;
2147 __pyx_L0:;
2148 __Pyx_XGIVEREF(__pyx_r);
2149 __Pyx_RefNannyFinishContext();
2150 return __pyx_r;
2151 }
2152
2153 /* "clickhouse_driver/columns/stringcolumn.pyx":46
2154 * ch_type = 'FixedString'
2155 *
2156 * def __init__(self, length, **kwargs): # <<<<<<<<<<<<<<
2157 * self.length = length
2158 * super(FixedString, self).__init__(**kwargs)
2159 */
2160
2161 /* Python wrapper */
2162 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2163 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
2164 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2165 PyObject *__pyx_v_self = 0;
2166 PyObject *__pyx_v_length = 0;
2167 PyObject *__pyx_v_kwargs = 0;
2168 PyObject *__pyx_r = 0;
2169 __Pyx_RefNannyDeclarations
2170 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
2171 __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
2172 __Pyx_GOTREF(__pyx_v_kwargs);
2173 {
2174 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_length,0};
2175 PyObject* values[2] = {0,0};
2176 if (unlikely(__pyx_kwds)) {
2177 Py_ssize_t kw_args;
2178 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2179 switch (pos_args) {
2180 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2181 CYTHON_FALLTHROUGH;
2182 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2183 CYTHON_FALLTHROUGH;
2184 case 0: break;
2185 default: goto __pyx_L5_argtuple_error;
2186 }
2187 kw_args = PyDict_Size(__pyx_kwds);
2188 switch (pos_args) {
2189 case 0:
2190 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
2191 else goto __pyx_L5_argtuple_error;
2192 CYTHON_FALLTHROUGH;
2193 case 1:
2194 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_length)) != 0)) kw_args--;
2195 else {
2196 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, 1); __PYX_ERR(0, 46, __pyx_L3_error)
2197 }
2198 }
2199 if (unlikely(kw_args > 0)) {
2200 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 46, __pyx_L3_error)
2201 }
2202 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2203 goto __pyx_L5_argtuple_error;
2204 } else {
2205 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2206 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2207 }
2208 __pyx_v_self = values[0];
2209 __pyx_v_length = values[1];
2210 }
2211 goto __pyx_L4_argument_unpacking_done;
2212 __pyx_L5_argtuple_error:;
2213 __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 46, __pyx_L3_error)
2214 __pyx_L3_error:;
2215 __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
2216 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2217 __Pyx_RefNannyFinishContext();
2218 return NULL;
2219 __pyx_L4_argument_unpacking_done:;
2220 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString___init__(__pyx_self, __pyx_v_self, __pyx_v_length, __pyx_v_kwargs);
2221
2222 /* function exit code */
2223 __Pyx_XDECREF(__pyx_v_kwargs);
2224 __Pyx_RefNannyFinishContext();
2225 return __pyx_r;
2226 }
2227
2228 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_length, PyObject *__pyx_v_kwargs) {
2229 PyObject *__pyx_r = NULL;
2230 __Pyx_RefNannyDeclarations
2231 PyObject *__pyx_t_1 = NULL;
2232 PyObject *__pyx_t_2 = NULL;
2233 __Pyx_RefNannySetupContext("__init__", 0);
2234
2235 /* "clickhouse_driver/columns/stringcolumn.pyx":47
2236 *
2237 * def __init__(self, length, **kwargs):
2238 * self.length = length # <<<<<<<<<<<<<<
2239 * super(FixedString, self).__init__(**kwargs)
2240 *
2241 */
2242 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_length, __pyx_v_length) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
2243
2244 /* "clickhouse_driver/columns/stringcolumn.pyx":48
2245 * def __init__(self, length, **kwargs):
2246 * self.length = length
2247 * super(FixedString, self).__init__(**kwargs) # <<<<<<<<<<<<<<
2248 *
2249 * def read_items(self, Py_ssize_t n_items, buf):
2250 */
2251 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_FixedString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
2252 __Pyx_GOTREF(__pyx_t_1);
2253 __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
2254 __Pyx_GOTREF(__pyx_t_2);
2255 __Pyx_GIVEREF(__pyx_t_1);
2256 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
2257 __Pyx_INCREF(__pyx_v_self);
2258 __Pyx_GIVEREF(__pyx_v_self);
2259 PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self);
2260 __pyx_t_1 = 0;
2261 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
2262 __Pyx_GOTREF(__pyx_t_1);
2263 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2264 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_init); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 48, __pyx_L1_error)
2265 __Pyx_GOTREF(__pyx_t_2);
2266 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2267 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_empty_tuple, __pyx_v_kwargs); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
2268 __Pyx_GOTREF(__pyx_t_1);
2269 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2270 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2271
2272 /* "clickhouse_driver/columns/stringcolumn.pyx":46
2273 * ch_type = 'FixedString'
2274 *
2275 * def __init__(self, length, **kwargs): # <<<<<<<<<<<<<<
2276 * self.length = length
2277 * super(FixedString, self).__init__(**kwargs)
2278 */
2279
2280 /* function exit code */
2281 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2282 goto __pyx_L0;
2283 __pyx_L1_error:;
2284 __Pyx_XDECREF(__pyx_t_1);
2285 __Pyx_XDECREF(__pyx_t_2);
2286 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
2287 __pyx_r = NULL;
2288 __pyx_L0:;
2289 __Pyx_XGIVEREF(__pyx_r);
2290 __Pyx_RefNannyFinishContext();
2291 return __pyx_r;
2292 }
2293
2294 /* "clickhouse_driver/columns/stringcolumn.pyx":50
2295 * super(FixedString, self).__init__(**kwargs)
2296 *
2297 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
2298 * cdef Py_ssize_t i, j, length = self.length
2299 * data = buf.read(length * n_items)
2300 */
2301
2302 /* Python wrapper */
2303 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2304 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_3read_items = {"read_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_3read_items, METH_VARARGS|METH_KEYWORDS, 0};
2305 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_3read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2306 PyObject *__pyx_v_self = 0;
2307 Py_ssize_t __pyx_v_n_items;
2308 PyObject *__pyx_v_buf = 0;
2309 PyObject *__pyx_r = 0;
2310 __Pyx_RefNannyDeclarations
2311 __Pyx_RefNannySetupContext("read_items (wrapper)", 0);
2312 {
2313 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_buf,0};
2314 PyObject* values[3] = {0,0,0};
2315 if (unlikely(__pyx_kwds)) {
2316 Py_ssize_t kw_args;
2317 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2318 switch (pos_args) {
2319 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2320 CYTHON_FALLTHROUGH;
2321 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2322 CYTHON_FALLTHROUGH;
2323 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2324 CYTHON_FALLTHROUGH;
2325 case 0: break;
2326 default: goto __pyx_L5_argtuple_error;
2327 }
2328 kw_args = PyDict_Size(__pyx_kwds);
2329 switch (pos_args) {
2330 case 0:
2331 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
2332 else goto __pyx_L5_argtuple_error;
2333 CYTHON_FALLTHROUGH;
2334 case 1:
2335 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
2336 else {
2337 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 1); __PYX_ERR(0, 50, __pyx_L3_error)
2338 }
2339 CYTHON_FALLTHROUGH;
2340 case 2:
2341 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
2342 else {
2343 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 2); __PYX_ERR(0, 50, __pyx_L3_error)
2344 }
2345 }
2346 if (unlikely(kw_args > 0)) {
2347 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_items") < 0)) __PYX_ERR(0, 50, __pyx_L3_error)
2348 }
2349 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
2350 goto __pyx_L5_argtuple_error;
2351 } else {
2352 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2353 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2354 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2355 }
2356 __pyx_v_self = values[0];
2357 __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 50, __pyx_L3_error)
2358 __pyx_v_buf = values[2];
2359 }
2360 goto __pyx_L4_argument_unpacking_done;
2361 __pyx_L5_argtuple_error:;
2362 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 50, __pyx_L3_error)
2363 __pyx_L3_error:;
2364 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2365 __Pyx_RefNannyFinishContext();
2366 return NULL;
2367 __pyx_L4_argument_unpacking_done:;
2368 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_2read_items(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_buf);
2369
2370 /* function exit code */
2371 __Pyx_RefNannyFinishContext();
2372 return __pyx_r;
2373 }
2374
2375 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_2read_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, PyObject *__pyx_v_buf) {
2376 Py_ssize_t __pyx_v_i;
2377 Py_ssize_t __pyx_v_j;
2378 Py_ssize_t __pyx_v_length;
2379 PyObject *__pyx_v_data = NULL;
2380 char *__pyx_v_data_ptr;
2381 char *__pyx_v_c_string;
2382 PyObject *__pyx_v_items = NULL;
2383 PyObject *__pyx_v_item = NULL;
2384 PyObject *__pyx_r = NULL;
2385 __Pyx_RefNannyDeclarations
2386 PyObject *__pyx_t_1 = NULL;
2387 Py_ssize_t __pyx_t_2;
2388 PyObject *__pyx_t_3 = NULL;
2389 PyObject *__pyx_t_4 = NULL;
2390 PyObject *__pyx_t_5 = NULL;
2391 int __pyx_t_6;
2392 Py_ssize_t __pyx_t_7;
2393 Py_ssize_t __pyx_t_8;
2394 int __pyx_t_9;
2395 PyObject *__pyx_t_10 = NULL;
2396 PyObject *__pyx_t_11 = NULL;
2397 PyObject *__pyx_t_12 = NULL;
2398 int __pyx_t_13;
2399 __Pyx_RefNannySetupContext("read_items", 0);
2400
2401 /* "clickhouse_driver/columns/stringcolumn.pyx":51
2402 *
2403 * def read_items(self, Py_ssize_t n_items, buf):
2404 * cdef Py_ssize_t i, j, length = self.length # <<<<<<<<<<<<<<
2405 * data = buf.read(length * n_items)
2406 * cdef char* data_ptr = PyByteArray_AsString(data)
2407 */
2408 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
2409 __Pyx_GOTREF(__pyx_t_1);
2410 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 51, __pyx_L1_error)
2411 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2412 __pyx_v_length = __pyx_t_2;
2413
2414 /* "clickhouse_driver/columns/stringcolumn.pyx":52
2415 * def read_items(self, Py_ssize_t n_items, buf):
2416 * cdef Py_ssize_t i, j, length = self.length
2417 * data = buf.read(length * n_items) # <<<<<<<<<<<<<<
2418 * cdef char* data_ptr = PyByteArray_AsString(data)
2419 *
2420 */
2421 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error)
2422 __Pyx_GOTREF(__pyx_t_3);
2423 __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
2424 __Pyx_GOTREF(__pyx_t_4);
2425 __pyx_t_5 = NULL;
2426 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
2427 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
2428 if (likely(__pyx_t_5)) {
2429 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2430 __Pyx_INCREF(__pyx_t_5);
2431 __Pyx_INCREF(function);
2432 __Pyx_DECREF_SET(__pyx_t_3, function);
2433 }
2434 }
2435 __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
2436 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2437 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2438 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
2439 __Pyx_GOTREF(__pyx_t_1);
2440 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2441 __pyx_v_data = __pyx_t_1;
2442 __pyx_t_1 = 0;
2443
2444 /* "clickhouse_driver/columns/stringcolumn.pyx":53
2445 * cdef Py_ssize_t i, j, length = self.length
2446 * data = buf.read(length * n_items)
2447 * cdef char* data_ptr = PyByteArray_AsString(data) # <<<<<<<<<<<<<<
2448 *
2449 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
2450 */
2451 __pyx_v_data_ptr = PyByteArray_AsString(__pyx_v_data);
2452
2453 /* "clickhouse_driver/columns/stringcolumn.pyx":55
2454 * cdef char* data_ptr = PyByteArray_AsString(data)
2455 *
2456 * cdef char* c_string = <char *>PyMem_Malloc(length + 1) # <<<<<<<<<<<<<<
2457 * if not c_string:
2458 * raise MemoryError()
2459 */
2460 __pyx_v_c_string = ((char *)PyMem_Malloc((__pyx_v_length + 1)));
2461
2462 /* "clickhouse_driver/columns/stringcolumn.pyx":56
2463 *
2464 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
2465 * if not c_string: # <<<<<<<<<<<<<<
2466 * raise MemoryError()
2467 * c_string[length] = 0
2468 */
2469 __pyx_t_6 = ((!(__pyx_v_c_string != 0)) != 0);
2470 if (unlikely(__pyx_t_6)) {
2471
2472 /* "clickhouse_driver/columns/stringcolumn.pyx":57
2473 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
2474 * if not c_string:
2475 * raise MemoryError() # <<<<<<<<<<<<<<
2476 * c_string[length] = 0
2477 *
2478 */
2479 PyErr_NoMemory(); __PYX_ERR(0, 57, __pyx_L1_error)
2480
2481 /* "clickhouse_driver/columns/stringcolumn.pyx":56
2482 *
2483 * cdef char* c_string = <char *>PyMem_Malloc(length + 1)
2484 * if not c_string: # <<<<<<<<<<<<<<
2485 * raise MemoryError()
2486 * c_string[length] = 0
2487 */
2488 }
2489
2490 /* "clickhouse_driver/columns/stringcolumn.pyx":58
2491 * if not c_string:
2492 * raise MemoryError()
2493 * c_string[length] = 0 # <<<<<<<<<<<<<<
2494 *
2495 * items = PyTuple_New(n_items)
2496 */
2497 (__pyx_v_c_string[__pyx_v_length]) = 0;
2498
2499 /* "clickhouse_driver/columns/stringcolumn.pyx":60
2500 * c_string[length] = 0
2501 *
2502 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
2503 * for i in range(n_items):
2504 * memcpy(c_string, &data_ptr[i * length], length)
2505 */
2506 __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
2507 __Pyx_GOTREF(__pyx_t_1);
2508 __pyx_v_items = ((PyObject*)__pyx_t_1);
2509 __pyx_t_1 = 0;
2510
2511 /* "clickhouse_driver/columns/stringcolumn.pyx":61
2512 *
2513 * items = PyTuple_New(n_items)
2514 * for i in range(n_items): # <<<<<<<<<<<<<<
2515 * memcpy(c_string, &data_ptr[i * length], length)
2516 *
2517 */
2518 __pyx_t_2 = __pyx_v_n_items;
2519 __pyx_t_7 = __pyx_t_2;
2520 for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_7; __pyx_t_8+=1) {
2521 __pyx_v_i = __pyx_t_8;
2522
2523 /* "clickhouse_driver/columns/stringcolumn.pyx":62
2524 * items = PyTuple_New(n_items)
2525 * for i in range(n_items):
2526 * memcpy(c_string, &data_ptr[i * length], length) # <<<<<<<<<<<<<<
2527 *
2528 * # Get last non zero byte of string from the end.
2529 */
2530 (void)(memcpy(__pyx_v_c_string, (&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length));
2531
2532 /* "clickhouse_driver/columns/stringcolumn.pyx":65
2533 *
2534 * # Get last non zero byte of string from the end.
2535 * j = length - 1 # <<<<<<<<<<<<<<
2536 * while j >= 0 and not c_string[j]:
2537 * j -= 1
2538 */
2539 __pyx_v_j = (__pyx_v_length - 1);
2540
2541 /* "clickhouse_driver/columns/stringcolumn.pyx":66
2542 * # Get last non zero byte of string from the end.
2543 * j = length - 1
2544 * while j >= 0 and not c_string[j]: # <<<<<<<<<<<<<<
2545 * j -= 1
2546 *
2547 */
2548 while (1) {
2549 __pyx_t_9 = ((__pyx_v_j >= 0) != 0);
2550 if (__pyx_t_9) {
2551 } else {
2552 __pyx_t_6 = __pyx_t_9;
2553 goto __pyx_L8_bool_binop_done;
2554 }
2555 __pyx_t_9 = ((!((__pyx_v_c_string[__pyx_v_j]) != 0)) != 0);
2556 __pyx_t_6 = __pyx_t_9;
2557 __pyx_L8_bool_binop_done:;
2558 if (!__pyx_t_6) break;
2559
2560 /* "clickhouse_driver/columns/stringcolumn.pyx":67
2561 * j = length - 1
2562 * while j >= 0 and not c_string[j]:
2563 * j -= 1 # <<<<<<<<<<<<<<
2564 *
2565 * try:
2566 */
2567 __pyx_v_j = (__pyx_v_j - 1);
2568 }
2569
2570 /* "clickhouse_driver/columns/stringcolumn.pyx":69
2571 * j -= 1
2572 *
2573 * try: # <<<<<<<<<<<<<<
2574 * item = c_string[:j + 1].decode('utf-8')
2575 * except UnicodeDecodeError:
2576 */
2577 {
2578 __Pyx_PyThreadState_declare
2579 __Pyx_PyThreadState_assign
2580 __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
2581 __Pyx_XGOTREF(__pyx_t_10);
2582 __Pyx_XGOTREF(__pyx_t_11);
2583 __Pyx_XGOTREF(__pyx_t_12);
2584 /*try:*/ {
2585
2586 /* "clickhouse_driver/columns/stringcolumn.pyx":70
2587 *
2588 * try:
2589 * item = c_string[:j + 1].decode('utf-8') # <<<<<<<<<<<<<<
2590 * except UnicodeDecodeError:
2591 * item = PyBytes_FromStringAndSize(c_string, length)
2592 */
2593 __pyx_t_1 = __Pyx_decode_c_string(__pyx_v_c_string, 0, (__pyx_v_j + 1), NULL, NULL, PyUnicode_DecodeUTF8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L10_error)
2594 __Pyx_GOTREF(__pyx_t_1);
2595 __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1);
2596 __pyx_t_1 = 0;
2597
2598 /* "clickhouse_driver/columns/stringcolumn.pyx":69
2599 * j -= 1
2600 *
2601 * try: # <<<<<<<<<<<<<<
2602 * item = c_string[:j + 1].decode('utf-8')
2603 * except UnicodeDecodeError:
2604 */
2605 }
2606 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2607 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
2608 __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
2609 goto __pyx_L17_try_end;
2610 __pyx_L10_error:;
2611 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2612 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2613 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2614 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2615
2616 /* "clickhouse_driver/columns/stringcolumn.pyx":71
2617 * try:
2618 * item = c_string[:j + 1].decode('utf-8')
2619 * except UnicodeDecodeError: # <<<<<<<<<<<<<<
2620 * item = PyBytes_FromStringAndSize(c_string, length)
2621 * Py_INCREF(item)
2622 */
2623 __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
2624 if (__pyx_t_13) {
2625 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2626 if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 71, __pyx_L12_except_error)
2627 __Pyx_GOTREF(__pyx_t_1);
2628 __Pyx_GOTREF(__pyx_t_3);
2629 __Pyx_GOTREF(__pyx_t_4);
2630
2631 /* "clickhouse_driver/columns/stringcolumn.pyx":72
2632 * item = c_string[:j + 1].decode('utf-8')
2633 * except UnicodeDecodeError:
2634 * item = PyBytes_FromStringAndSize(c_string, length) # <<<<<<<<<<<<<<
2635 * Py_INCREF(item)
2636 * PyTuple_SET_ITEM(items, i, item)
2637 */
2638 __pyx_t_5 = PyBytes_FromStringAndSize(__pyx_v_c_string, __pyx_v_length); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 72, __pyx_L12_except_error)
2639 __Pyx_GOTREF(__pyx_t_5);
2640 __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_5);
2641 __pyx_t_5 = 0;
2642 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
2643 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2644 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2645 goto __pyx_L11_exception_handled;
2646 }
2647 goto __pyx_L12_except_error;
2648 __pyx_L12_except_error:;
2649
2650 /* "clickhouse_driver/columns/stringcolumn.pyx":69
2651 * j -= 1
2652 *
2653 * try: # <<<<<<<<<<<<<<
2654 * item = c_string[:j + 1].decode('utf-8')
2655 * except UnicodeDecodeError:
2656 */
2657 __Pyx_XGIVEREF(__pyx_t_10);
2658 __Pyx_XGIVEREF(__pyx_t_11);
2659 __Pyx_XGIVEREF(__pyx_t_12);
2660 __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
2661 goto __pyx_L1_error;
2662 __pyx_L11_exception_handled:;
2663 __Pyx_XGIVEREF(__pyx_t_10);
2664 __Pyx_XGIVEREF(__pyx_t_11);
2665 __Pyx_XGIVEREF(__pyx_t_12);
2666 __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
2667 __pyx_L17_try_end:;
2668 }
2669
2670 /* "clickhouse_driver/columns/stringcolumn.pyx":73
2671 * except UnicodeDecodeError:
2672 * item = PyBytes_FromStringAndSize(c_string, length)
2673 * Py_INCREF(item) # <<<<<<<<<<<<<<
2674 * PyTuple_SET_ITEM(items, i, item)
2675 *
2676 */
2677 Py_INCREF(__pyx_v_item);
2678
2679 /* "clickhouse_driver/columns/stringcolumn.pyx":74
2680 * item = PyBytes_FromStringAndSize(c_string, length)
2681 * Py_INCREF(item)
2682 * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<<
2683 *
2684 * PyMem_Free(c_string)
2685 */
2686 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item);
2687 }
2688
2689 /* "clickhouse_driver/columns/stringcolumn.pyx":76
2690 * PyTuple_SET_ITEM(items, i, item)
2691 *
2692 * PyMem_Free(c_string) # <<<<<<<<<<<<<<
2693 *
2694 * return items
2695 */
2696 PyMem_Free(__pyx_v_c_string);
2697
2698 /* "clickhouse_driver/columns/stringcolumn.pyx":78
2699 * PyMem_Free(c_string)
2700 *
2701 * return items # <<<<<<<<<<<<<<
2702 *
2703 * def write_items(self, items, buf):
2704 */
2705 __Pyx_XDECREF(__pyx_r);
2706 __Pyx_INCREF(__pyx_v_items);
2707 __pyx_r = __pyx_v_items;
2708 goto __pyx_L0;
2709
2710 /* "clickhouse_driver/columns/stringcolumn.pyx":50
2711 * super(FixedString, self).__init__(**kwargs)
2712 *
2713 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
2714 * cdef Py_ssize_t i, j, length = self.length
2715 * data = buf.read(length * n_items)
2716 */
2717
2718 /* function exit code */
2719 __pyx_L1_error:;
2720 __Pyx_XDECREF(__pyx_t_1);
2721 __Pyx_XDECREF(__pyx_t_3);
2722 __Pyx_XDECREF(__pyx_t_4);
2723 __Pyx_XDECREF(__pyx_t_5);
2724 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2725 __pyx_r = NULL;
2726 __pyx_L0:;
2727 __Pyx_XDECREF(__pyx_v_data);
2728 __Pyx_XDECREF(__pyx_v_items);
2729 __Pyx_XDECREF(__pyx_v_item);
2730 __Pyx_XGIVEREF(__pyx_r);
2731 __Pyx_RefNannyFinishContext();
2732 return __pyx_r;
2733 }
2734
2735 /* "clickhouse_driver/columns/stringcolumn.pyx":80
2736 * return items
2737 *
2738 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
2739 * cdef Py_ssize_t buf_pos = 0
2740 * cdef Py_ssize_t length = self.length
2741 */
2742
2743 /* Python wrapper */
2744 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_5write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2745 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_5write_items = {"write_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_5write_items, METH_VARARGS|METH_KEYWORDS, 0};
2746 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_11FixedString_5write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2747 PyObject *__pyx_v_self = 0;
2748 PyObject *__pyx_v_items = 0;
2749 PyObject *__pyx_v_buf = 0;
2750 PyObject *__pyx_r = 0;
2751 __Pyx_RefNannyDeclarations
2752 __Pyx_RefNannySetupContext("write_items (wrapper)", 0);
2753 {
2754 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_items,&__pyx_n_s_buf,0};
2755 PyObject* values[3] = {0,0,0};
2756 if (unlikely(__pyx_kwds)) {
2757 Py_ssize_t kw_args;
2758 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2759 switch (pos_args) {
2760 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2761 CYTHON_FALLTHROUGH;
2762 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2763 CYTHON_FALLTHROUGH;
2764 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2765 CYTHON_FALLTHROUGH;
2766 case 0: break;
2767 default: goto __pyx_L5_argtuple_error;
2768 }
2769 kw_args = PyDict_Size(__pyx_kwds);
2770 switch (pos_args) {
2771 case 0:
2772 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
2773 else goto __pyx_L5_argtuple_error;
2774 CYTHON_FALLTHROUGH;
2775 case 1:
2776 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
2777 else {
2778 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 1); __PYX_ERR(0, 80, __pyx_L3_error)
2779 }
2780 CYTHON_FALLTHROUGH;
2781 case 2:
2782 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
2783 else {
2784 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 2); __PYX_ERR(0, 80, __pyx_L3_error)
2785 }
2786 }
2787 if (unlikely(kw_args > 0)) {
2788 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_items") < 0)) __PYX_ERR(0, 80, __pyx_L3_error)
2789 }
2790 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
2791 goto __pyx_L5_argtuple_error;
2792 } else {
2793 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2794 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2795 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2796 }
2797 __pyx_v_self = values[0];
2798 __pyx_v_items = values[1];
2799 __pyx_v_buf = values[2];
2800 }
2801 goto __pyx_L4_argument_unpacking_done;
2802 __pyx_L5_argtuple_error:;
2803 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 80, __pyx_L3_error)
2804 __pyx_L3_error:;
2805 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
2806 __Pyx_RefNannyFinishContext();
2807 return NULL;
2808 __pyx_L4_argument_unpacking_done:;
2809 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_4write_items(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_buf);
2810
2811 /* function exit code */
2812 __Pyx_RefNannyFinishContext();
2813 return __pyx_r;
2814 }
2815
2816 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_11FixedString_4write_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf) {
2817 Py_ssize_t __pyx_v_buf_pos;
2818 Py_ssize_t __pyx_v_length;
2819 Py_ssize_t __pyx_v_items_buf_size;
2820 char *__pyx_v_c_value;
2821 char *__pyx_v_items_buf;
2822 PyObject *__pyx_v_value = NULL;
2823 Py_ssize_t __pyx_v_value_len;
2824 PyObject *__pyx_r = NULL;
2825 __Pyx_RefNannyDeclarations
2826 PyObject *__pyx_t_1 = NULL;
2827 Py_ssize_t __pyx_t_2;
2828 int __pyx_t_3;
2829 PyObject *(*__pyx_t_4)(PyObject *);
2830 PyObject *__pyx_t_5 = NULL;
2831 int __pyx_t_6;
2832 PyObject *__pyx_t_7 = NULL;
2833 PyObject *__pyx_t_8 = NULL;
2834 Py_ssize_t __pyx_t_9;
2835 char *__pyx_t_10;
2836 __Pyx_RefNannySetupContext("write_items", 0);
2837
2838 /* "clickhouse_driver/columns/stringcolumn.pyx":81
2839 *
2840 * def write_items(self, items, buf):
2841 * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<<
2842 * cdef Py_ssize_t length = self.length
2843 * cdef Py_ssize_t items_buf_size = length * len(items)
2844 */
2845 __pyx_v_buf_pos = 0;
2846
2847 /* "clickhouse_driver/columns/stringcolumn.pyx":82
2848 * def write_items(self, items, buf):
2849 * cdef Py_ssize_t buf_pos = 0
2850 * cdef Py_ssize_t length = self.length # <<<<<<<<<<<<<<
2851 * cdef Py_ssize_t items_buf_size = length * len(items)
2852 *
2853 */
2854 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error)
2855 __Pyx_GOTREF(__pyx_t_1);
2856 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 82, __pyx_L1_error)
2857 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2858 __pyx_v_length = __pyx_t_2;
2859
2860 /* "clickhouse_driver/columns/stringcolumn.pyx":83
2861 * cdef Py_ssize_t buf_pos = 0
2862 * cdef Py_ssize_t length = self.length
2863 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<<
2864 *
2865 * cdef char* c_value
2866 */
2867 __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 83, __pyx_L1_error)
2868 __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_2);
2869
2870 /* "clickhouse_driver/columns/stringcolumn.pyx":86
2871 *
2872 * cdef char* c_value
2873 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<<
2874 * if not items_buf:
2875 * raise MemoryError()
2876 */
2877 __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size));
2878
2879 /* "clickhouse_driver/columns/stringcolumn.pyx":87
2880 * cdef char* c_value
2881 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2882 * if not items_buf: # <<<<<<<<<<<<<<
2883 * raise MemoryError()
2884 *
2885 */
2886 __pyx_t_3 = ((!(__pyx_v_items_buf != 0)) != 0);
2887 if (unlikely(__pyx_t_3)) {
2888
2889 /* "clickhouse_driver/columns/stringcolumn.pyx":88
2890 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2891 * if not items_buf:
2892 * raise MemoryError() # <<<<<<<<<<<<<<
2893 *
2894 * memset(items_buf, 0, items_buf_size)
2895 */
2896 PyErr_NoMemory(); __PYX_ERR(0, 88, __pyx_L1_error)
2897
2898 /* "clickhouse_driver/columns/stringcolumn.pyx":87
2899 * cdef char* c_value
2900 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
2901 * if not items_buf: # <<<<<<<<<<<<<<
2902 * raise MemoryError()
2903 *
2904 */
2905 }
2906
2907 /* "clickhouse_driver/columns/stringcolumn.pyx":90
2908 * raise MemoryError()
2909 *
2910 * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<<
2911 *
2912 * for value in items:
2913 */
2914 (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size));
2915
2916 /* "clickhouse_driver/columns/stringcolumn.pyx":92
2917 * memset(items_buf, 0, items_buf_size)
2918 *
2919 * for value in items: # <<<<<<<<<<<<<<
2920 * if not isinstance(value, bytes):
2921 * value = utf_8_encode(value)[0]
2922 */
2923 if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
2924 __pyx_t_1 = __pyx_v_items; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
2925 __pyx_t_4 = NULL;
2926 } else {
2927 __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 92, __pyx_L1_error)
2928 __Pyx_GOTREF(__pyx_t_1);
2929 __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error)
2930 }
2931 for (;;) {
2932 if (likely(!__pyx_t_4)) {
2933 if (likely(PyList_CheckExact(__pyx_t_1))) {
2934 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
2935 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2936 __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 92, __pyx_L1_error)
2937 #else
2938 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error)
2939 __Pyx_GOTREF(__pyx_t_5);
2940 #endif
2941 } else {
2942 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
2943 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
2944 __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 92, __pyx_L1_error)
2945 #else
2946 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 92, __pyx_L1_error)
2947 __Pyx_GOTREF(__pyx_t_5);
2948 #endif
2949 }
2950 } else {
2951 __pyx_t_5 = __pyx_t_4(__pyx_t_1);
2952 if (unlikely(!__pyx_t_5)) {
2953 PyObject* exc_type = PyErr_Occurred();
2954 if (exc_type) {
2955 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
2956 else __PYX_ERR(0, 92, __pyx_L1_error)
2957 }
2958 break;
2959 }
2960 __Pyx_GOTREF(__pyx_t_5);
2961 }
2962 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5);
2963 __pyx_t_5 = 0;
2964
2965 /* "clickhouse_driver/columns/stringcolumn.pyx":93
2966 *
2967 * for value in items:
2968 * if not isinstance(value, bytes): # <<<<<<<<<<<<<<
2969 * value = utf_8_encode(value)[0]
2970 *
2971 */
2972 __pyx_t_3 = PyBytes_Check(__pyx_v_value);
2973 __pyx_t_6 = ((!(__pyx_t_3 != 0)) != 0);
2974 if (__pyx_t_6) {
2975
2976 /* "clickhouse_driver/columns/stringcolumn.pyx":94
2977 * for value in items:
2978 * if not isinstance(value, bytes):
2979 * value = utf_8_encode(value)[0] # <<<<<<<<<<<<<<
2980 *
2981 * value_len = len(value)
2982 */
2983 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_utf_8_encode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error)
2984 __Pyx_GOTREF(__pyx_t_7);
2985 __pyx_t_8 = NULL;
2986 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) {
2987 __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
2988 if (likely(__pyx_t_8)) {
2989 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
2990 __Pyx_INCREF(__pyx_t_8);
2991 __Pyx_INCREF(function);
2992 __Pyx_DECREF_SET(__pyx_t_7, function);
2993 }
2994 }
2995 __pyx_t_5 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_8, __pyx_v_value) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_value);
2996 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2997 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 94, __pyx_L1_error)
2998 __Pyx_GOTREF(__pyx_t_5);
2999 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3000 __pyx_t_7 = __Pyx_GetItemInt(__pyx_t_5, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 94, __pyx_L1_error)
3001 __Pyx_GOTREF(__pyx_t_7);
3002 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3003 __Pyx_DECREF_SET(__pyx_v_value, __pyx_t_7);
3004 __pyx_t_7 = 0;
3005
3006 /* "clickhouse_driver/columns/stringcolumn.pyx":93
3007 *
3008 * for value in items:
3009 * if not isinstance(value, bytes): # <<<<<<<<<<<<<<
3010 * value = utf_8_encode(value)[0]
3011 *
3012 */
3013 }
3014
3015 /* "clickhouse_driver/columns/stringcolumn.pyx":96
3016 * value = utf_8_encode(value)[0]
3017 *
3018 * value_len = len(value) # <<<<<<<<<<<<<<
3019 * if length < value_len:
3020 * raise errors.TooLargeStringSize()
3021 */
3022 __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 96, __pyx_L1_error)
3023 __pyx_v_value_len = __pyx_t_9;
3024
3025 /* "clickhouse_driver/columns/stringcolumn.pyx":97
3026 *
3027 * value_len = len(value)
3028 * if length < value_len: # <<<<<<<<<<<<<<
3029 * raise errors.TooLargeStringSize()
3030 *
3031 */
3032 __pyx_t_6 = ((__pyx_v_length < __pyx_v_value_len) != 0);
3033 if (unlikely(__pyx_t_6)) {
3034
3035 /* "clickhouse_driver/columns/stringcolumn.pyx":98
3036 * value_len = len(value)
3037 * if length < value_len:
3038 * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<<
3039 *
3040 * if PyBytes_Check(value):
3041 */
3042 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_errors); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 98, __pyx_L1_error)
3043 __Pyx_GOTREF(__pyx_t_5);
3044 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_TooLargeStringSize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 98, __pyx_L1_error)
3045 __Pyx_GOTREF(__pyx_t_8);
3046 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3047 __pyx_t_5 = NULL;
3048 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
3049 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
3050 if (likely(__pyx_t_5)) {
3051 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
3052 __Pyx_INCREF(__pyx_t_5);
3053 __Pyx_INCREF(function);
3054 __Pyx_DECREF_SET(__pyx_t_8, function);
3055 }
3056 }
3057 __pyx_t_7 = (__pyx_t_5) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_5) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
3058 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3059 if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 98, __pyx_L1_error)
3060 __Pyx_GOTREF(__pyx_t_7);
3061 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3062 __Pyx_Raise(__pyx_t_7, 0, 0, 0);
3063 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3064 __PYX_ERR(0, 98, __pyx_L1_error)
3065
3066 /* "clickhouse_driver/columns/stringcolumn.pyx":97
3067 *
3068 * value_len = len(value)
3069 * if length < value_len: # <<<<<<<<<<<<<<
3070 * raise errors.TooLargeStringSize()
3071 *
3072 */
3073 }
3074
3075 /* "clickhouse_driver/columns/stringcolumn.pyx":100
3076 * raise errors.TooLargeStringSize()
3077 *
3078 * if PyBytes_Check(value): # <<<<<<<<<<<<<<
3079 * c_value = PyBytes_AsString(value)
3080 * else:
3081 */
3082 __pyx_t_6 = (PyBytes_Check(__pyx_v_value) != 0);
3083 if (__pyx_t_6) {
3084
3085 /* "clickhouse_driver/columns/stringcolumn.pyx":101
3086 *
3087 * if PyBytes_Check(value):
3088 * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<<
3089 * else:
3090 * c_value = PyByteArray_AsString(value)
3091 */
3092 __pyx_t_10 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_10 == ((char *)NULL))) __PYX_ERR(0, 101, __pyx_L1_error)
3093 __pyx_v_c_value = __pyx_t_10;
3094
3095 /* "clickhouse_driver/columns/stringcolumn.pyx":100
3096 * raise errors.TooLargeStringSize()
3097 *
3098 * if PyBytes_Check(value): # <<<<<<<<<<<<<<
3099 * c_value = PyBytes_AsString(value)
3100 * else:
3101 */
3102 goto __pyx_L8;
3103 }
3104
3105 /* "clickhouse_driver/columns/stringcolumn.pyx":103
3106 * c_value = PyBytes_AsString(value)
3107 * else:
3108 * c_value = PyByteArray_AsString(value) # <<<<<<<<<<<<<<
3109 *
3110 * memcpy(&items_buf[buf_pos], c_value, value_len)
3111 */
3112 /*else*/ {
3113 __pyx_v_c_value = PyByteArray_AsString(__pyx_v_value);
3114 }
3115 __pyx_L8:;
3116
3117 /* "clickhouse_driver/columns/stringcolumn.pyx":105
3118 * c_value = PyByteArray_AsString(value)
3119 *
3120 * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<<
3121 * buf_pos += length
3122 *
3123 */
3124 (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len));
3125
3126 /* "clickhouse_driver/columns/stringcolumn.pyx":106
3127 *
3128 * memcpy(&items_buf[buf_pos], c_value, value_len)
3129 * buf_pos += length # <<<<<<<<<<<<<<
3130 *
3131 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3132 */
3133 __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length);
3134
3135 /* "clickhouse_driver/columns/stringcolumn.pyx":92
3136 * memset(items_buf, 0, items_buf_size)
3137 *
3138 * for value in items: # <<<<<<<<<<<<<<
3139 * if not isinstance(value, bytes):
3140 * value = utf_8_encode(value)[0]
3141 */
3142 }
3143 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3144
3145 /* "clickhouse_driver/columns/stringcolumn.pyx":108
3146 * buf_pos += length
3147 *
3148 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<<
3149 *
3150 * PyMem_Free(items_buf)
3151 */
3152 __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 108, __pyx_L1_error)
3153 __Pyx_GOTREF(__pyx_t_7);
3154 __pyx_t_8 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 108, __pyx_L1_error)
3155 __Pyx_GOTREF(__pyx_t_8);
3156 __pyx_t_5 = NULL;
3157 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) {
3158 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
3159 if (likely(__pyx_t_5)) {
3160 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
3161 __Pyx_INCREF(__pyx_t_5);
3162 __Pyx_INCREF(function);
3163 __Pyx_DECREF_SET(__pyx_t_7, function);
3164 }
3165 }
3166 __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_5, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_8);
3167 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3168 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3169 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 108, __pyx_L1_error)
3170 __Pyx_GOTREF(__pyx_t_1);
3171 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3172 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3173
3174 /* "clickhouse_driver/columns/stringcolumn.pyx":110
3175 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3176 *
3177 * PyMem_Free(items_buf) # <<<<<<<<<<<<<<
3178 *
3179 *
3180 */
3181 PyMem_Free(__pyx_v_items_buf);
3182
3183 /* "clickhouse_driver/columns/stringcolumn.pyx":80
3184 * return items
3185 *
3186 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
3187 * cdef Py_ssize_t buf_pos = 0
3188 * cdef Py_ssize_t length = self.length
3189 */
3190
3191 /* function exit code */
3192 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3193 goto __pyx_L0;
3194 __pyx_L1_error:;
3195 __Pyx_XDECREF(__pyx_t_1);
3196 __Pyx_XDECREF(__pyx_t_5);
3197 __Pyx_XDECREF(__pyx_t_7);
3198 __Pyx_XDECREF(__pyx_t_8);
3199 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.FixedString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
3200 __pyx_r = NULL;
3201 __pyx_L0:;
3202 __Pyx_XDECREF(__pyx_v_value);
3203 __Pyx_XGIVEREF(__pyx_r);
3204 __Pyx_RefNannyFinishContext();
3205 return __pyx_r;
3206 }
3207
3208 /* "clickhouse_driver/columns/stringcolumn.pyx":117
3209 * null_value = b''
3210 *
3211 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
3212 * cdef Py_ssize_t i
3213 * cdef Py_ssize_t length = self.length
3214 */
3215
3216 /* Python wrapper */
3217 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3218 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items = {"read_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items, METH_VARARGS|METH_KEYWORDS, 0};
3219 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3220 PyObject *__pyx_v_self = 0;
3221 Py_ssize_t __pyx_v_n_items;
3222 PyObject *__pyx_v_buf = 0;
3223 PyObject *__pyx_r = 0;
3224 __Pyx_RefNannyDeclarations
3225 __Pyx_RefNannySetupContext("read_items (wrapper)", 0);
3226 {
3227 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_n_items,&__pyx_n_s_buf,0};
3228 PyObject* values[3] = {0,0,0};
3229 if (unlikely(__pyx_kwds)) {
3230 Py_ssize_t kw_args;
3231 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3232 switch (pos_args) {
3233 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3234 CYTHON_FALLTHROUGH;
3235 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3236 CYTHON_FALLTHROUGH;
3237 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3238 CYTHON_FALLTHROUGH;
3239 case 0: break;
3240 default: goto __pyx_L5_argtuple_error;
3241 }
3242 kw_args = PyDict_Size(__pyx_kwds);
3243 switch (pos_args) {
3244 case 0:
3245 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
3246 else goto __pyx_L5_argtuple_error;
3247 CYTHON_FALLTHROUGH;
3248 case 1:
3249 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_n_items)) != 0)) kw_args--;
3250 else {
3251 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 1); __PYX_ERR(0, 117, __pyx_L3_error)
3252 }
3253 CYTHON_FALLTHROUGH;
3254 case 2:
3255 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
3256 else {
3257 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, 2); __PYX_ERR(0, 117, __pyx_L3_error)
3258 }
3259 }
3260 if (unlikely(kw_args > 0)) {
3261 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "read_items") < 0)) __PYX_ERR(0, 117, __pyx_L3_error)
3262 }
3263 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3264 goto __pyx_L5_argtuple_error;
3265 } else {
3266 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3267 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3268 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3269 }
3270 __pyx_v_self = values[0];
3271 __pyx_v_n_items = __Pyx_PyIndex_AsSsize_t(values[1]); if (unlikely((__pyx_v_n_items == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L3_error)
3272 __pyx_v_buf = values[2];
3273 }
3274 goto __pyx_L4_argument_unpacking_done;
3275 __pyx_L5_argtuple_error:;
3276 __Pyx_RaiseArgtupleInvalid("read_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 117, __pyx_L3_error)
3277 __pyx_L3_error:;
3278 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteFixedString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
3279 __Pyx_RefNannyFinishContext();
3280 return NULL;
3281 __pyx_L4_argument_unpacking_done:;
3282 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_read_items(__pyx_self, __pyx_v_self, __pyx_v_n_items, __pyx_v_buf);
3283
3284 /* function exit code */
3285 __Pyx_RefNannyFinishContext();
3286 return __pyx_r;
3287 }
3288
3289 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_read_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, Py_ssize_t __pyx_v_n_items, PyObject *__pyx_v_buf) {
3290 Py_ssize_t __pyx_v_i;
3291 Py_ssize_t __pyx_v_length;
3292 PyObject *__pyx_v_data = NULL;
3293 char *__pyx_v_data_ptr;
3294 PyObject *__pyx_v_items = NULL;
3295 PyObject *__pyx_v_item = NULL;
3296 PyObject *__pyx_r = NULL;
3297 __Pyx_RefNannyDeclarations
3298 PyObject *__pyx_t_1 = NULL;
3299 Py_ssize_t __pyx_t_2;
3300 PyObject *__pyx_t_3 = NULL;
3301 PyObject *__pyx_t_4 = NULL;
3302 PyObject *__pyx_t_5 = NULL;
3303 Py_ssize_t __pyx_t_6;
3304 Py_ssize_t __pyx_t_7;
3305 __Pyx_RefNannySetupContext("read_items", 0);
3306
3307 /* "clickhouse_driver/columns/stringcolumn.pyx":119
3308 * def read_items(self, Py_ssize_t n_items, buf):
3309 * cdef Py_ssize_t i
3310 * cdef Py_ssize_t length = self.length # <<<<<<<<<<<<<<
3311 * data = buf.read(length * n_items)
3312 * cdef char* data_ptr = PyByteArray_AsString(data)
3313 */
3314 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error)
3315 __Pyx_GOTREF(__pyx_t_1);
3316 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 119, __pyx_L1_error)
3317 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3318 __pyx_v_length = __pyx_t_2;
3319
3320 /* "clickhouse_driver/columns/stringcolumn.pyx":120
3321 * cdef Py_ssize_t i
3322 * cdef Py_ssize_t length = self.length
3323 * data = buf.read(length * n_items) # <<<<<<<<<<<<<<
3324 * cdef char* data_ptr = PyByteArray_AsString(data)
3325 *
3326 */
3327 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_read); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 120, __pyx_L1_error)
3328 __Pyx_GOTREF(__pyx_t_3);
3329 __pyx_t_4 = PyInt_FromSsize_t((__pyx_v_length * __pyx_v_n_items)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error)
3330 __Pyx_GOTREF(__pyx_t_4);
3331 __pyx_t_5 = NULL;
3332 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3333 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
3334 if (likely(__pyx_t_5)) {
3335 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3336 __Pyx_INCREF(__pyx_t_5);
3337 __Pyx_INCREF(function);
3338 __Pyx_DECREF_SET(__pyx_t_3, function);
3339 }
3340 }
3341 __pyx_t_1 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
3342 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3343 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3344 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 120, __pyx_L1_error)
3345 __Pyx_GOTREF(__pyx_t_1);
3346 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3347 __pyx_v_data = __pyx_t_1;
3348 __pyx_t_1 = 0;
3349
3350 /* "clickhouse_driver/columns/stringcolumn.pyx":121
3351 * cdef Py_ssize_t length = self.length
3352 * data = buf.read(length * n_items)
3353 * cdef char* data_ptr = PyByteArray_AsString(data) # <<<<<<<<<<<<<<
3354 *
3355 * items = PyTuple_New(n_items)
3356 */
3357 __pyx_v_data_ptr = PyByteArray_AsString(__pyx_v_data);
3358
3359 /* "clickhouse_driver/columns/stringcolumn.pyx":123
3360 * cdef char* data_ptr = PyByteArray_AsString(data)
3361 *
3362 * items = PyTuple_New(n_items) # <<<<<<<<<<<<<<
3363 * for i in range(n_items):
3364 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3365 */
3366 __pyx_t_1 = PyTuple_New(__pyx_v_n_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error)
3367 __Pyx_GOTREF(__pyx_t_1);
3368 __pyx_v_items = ((PyObject*)__pyx_t_1);
3369 __pyx_t_1 = 0;
3370
3371 /* "clickhouse_driver/columns/stringcolumn.pyx":124
3372 *
3373 * items = PyTuple_New(n_items)
3374 * for i in range(n_items): # <<<<<<<<<<<<<<
3375 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3376 * Py_INCREF(item)
3377 */
3378 __pyx_t_2 = __pyx_v_n_items;
3379 __pyx_t_6 = __pyx_t_2;
3380 for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_6; __pyx_t_7+=1) {
3381 __pyx_v_i = __pyx_t_7;
3382
3383 /* "clickhouse_driver/columns/stringcolumn.pyx":125
3384 * items = PyTuple_New(n_items)
3385 * for i in range(n_items):
3386 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length) # <<<<<<<<<<<<<<
3387 * Py_INCREF(item)
3388 * PyTuple_SET_ITEM(items, i, item)
3389 */
3390 __pyx_t_1 = PyBytes_FromStringAndSize((&(__pyx_v_data_ptr[(__pyx_v_i * __pyx_v_length)])), __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
3391 __Pyx_GOTREF(__pyx_t_1);
3392 __Pyx_XDECREF_SET(__pyx_v_item, ((PyObject*)__pyx_t_1));
3393 __pyx_t_1 = 0;
3394
3395 /* "clickhouse_driver/columns/stringcolumn.pyx":126
3396 * for i in range(n_items):
3397 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3398 * Py_INCREF(item) # <<<<<<<<<<<<<<
3399 * PyTuple_SET_ITEM(items, i, item)
3400 *
3401 */
3402 Py_INCREF(__pyx_v_item);
3403
3404 /* "clickhouse_driver/columns/stringcolumn.pyx":127
3405 * item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
3406 * Py_INCREF(item)
3407 * PyTuple_SET_ITEM(items, i, item) # <<<<<<<<<<<<<<
3408 *
3409 * return items
3410 */
3411 PyTuple_SET_ITEM(__pyx_v_items, __pyx_v_i, __pyx_v_item);
3412 }
3413
3414 /* "clickhouse_driver/columns/stringcolumn.pyx":129
3415 * PyTuple_SET_ITEM(items, i, item)
3416 *
3417 * return items # <<<<<<<<<<<<<<
3418 *
3419 * def write_items(self, items, buf):
3420 */
3421 __Pyx_XDECREF(__pyx_r);
3422 __Pyx_INCREF(__pyx_v_items);
3423 __pyx_r = __pyx_v_items;
3424 goto __pyx_L0;
3425
3426 /* "clickhouse_driver/columns/stringcolumn.pyx":117
3427 * null_value = b''
3428 *
3429 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
3430 * cdef Py_ssize_t i
3431 * cdef Py_ssize_t length = self.length
3432 */
3433
3434 /* function exit code */
3435 __pyx_L1_error:;
3436 __Pyx_XDECREF(__pyx_t_1);
3437 __Pyx_XDECREF(__pyx_t_3);
3438 __Pyx_XDECREF(__pyx_t_4);
3439 __Pyx_XDECREF(__pyx_t_5);
3440 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteFixedString.read_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
3441 __pyx_r = NULL;
3442 __pyx_L0:;
3443 __Pyx_XDECREF(__pyx_v_data);
3444 __Pyx_XDECREF(__pyx_v_items);
3445 __Pyx_XDECREF(__pyx_v_item);
3446 __Pyx_XGIVEREF(__pyx_r);
3447 __Pyx_RefNannyFinishContext();
3448 return __pyx_r;
3449 }
3450
3451 /* "clickhouse_driver/columns/stringcolumn.pyx":131
3452 * return items
3453 *
3454 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
3455 * cdef Py_ssize_t buf_pos = 0
3456 * cdef Py_ssize_t length = self.length
3457 */
3458
3459 /* Python wrapper */
3460 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_3write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3461 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_3write_items = {"write_items", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_3write_items, METH_VARARGS|METH_KEYWORDS, 0};
3462 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_3write_items(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3463 PyObject *__pyx_v_self = 0;
3464 PyObject *__pyx_v_items = 0;
3465 PyObject *__pyx_v_buf = 0;
3466 PyObject *__pyx_r = 0;
3467 __Pyx_RefNannyDeclarations
3468 __Pyx_RefNannySetupContext("write_items (wrapper)", 0);
3469 {
3470 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_items,&__pyx_n_s_buf,0};
3471 PyObject* values[3] = {0,0,0};
3472 if (unlikely(__pyx_kwds)) {
3473 Py_ssize_t kw_args;
3474 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3475 switch (pos_args) {
3476 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3477 CYTHON_FALLTHROUGH;
3478 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3479 CYTHON_FALLTHROUGH;
3480 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3481 CYTHON_FALLTHROUGH;
3482 case 0: break;
3483 default: goto __pyx_L5_argtuple_error;
3484 }
3485 kw_args = PyDict_Size(__pyx_kwds);
3486 switch (pos_args) {
3487 case 0:
3488 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
3489 else goto __pyx_L5_argtuple_error;
3490 CYTHON_FALLTHROUGH;
3491 case 1:
3492 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_items)) != 0)) kw_args--;
3493 else {
3494 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 1); __PYX_ERR(0, 131, __pyx_L3_error)
3495 }
3496 CYTHON_FALLTHROUGH;
3497 case 2:
3498 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
3499 else {
3500 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, 2); __PYX_ERR(0, 131, __pyx_L3_error)
3501 }
3502 }
3503 if (unlikely(kw_args > 0)) {
3504 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_items") < 0)) __PYX_ERR(0, 131, __pyx_L3_error)
3505 }
3506 } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
3507 goto __pyx_L5_argtuple_error;
3508 } else {
3509 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3510 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3511 values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3512 }
3513 __pyx_v_self = values[0];
3514 __pyx_v_items = values[1];
3515 __pyx_v_buf = values[2];
3516 }
3517 goto __pyx_L4_argument_unpacking_done;
3518 __pyx_L5_argtuple_error:;
3519 __Pyx_RaiseArgtupleInvalid("write_items", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 131, __pyx_L3_error)
3520 __pyx_L3_error:;
3521 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteFixedString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
3522 __Pyx_RefNannyFinishContext();
3523 return NULL;
3524 __pyx_L4_argument_unpacking_done:;
3525 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_2write_items(__pyx_self, __pyx_v_self, __pyx_v_items, __pyx_v_buf);
3526
3527 /* function exit code */
3528 __Pyx_RefNannyFinishContext();
3529 return __pyx_r;
3530 }
3531
3532 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_2write_items(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_items, PyObject *__pyx_v_buf) {
3533 Py_ssize_t __pyx_v_buf_pos;
3534 Py_ssize_t __pyx_v_length;
3535 Py_ssize_t __pyx_v_items_buf_size;
3536 char *__pyx_v_c_value;
3537 char *__pyx_v_items_buf;
3538 PyObject *__pyx_v_value = NULL;
3539 Py_ssize_t __pyx_v_value_len;
3540 PyObject *__pyx_r = NULL;
3541 __Pyx_RefNannyDeclarations
3542 PyObject *__pyx_t_1 = NULL;
3543 Py_ssize_t __pyx_t_2;
3544 int __pyx_t_3;
3545 PyObject *(*__pyx_t_4)(PyObject *);
3546 PyObject *__pyx_t_5 = NULL;
3547 Py_ssize_t __pyx_t_6;
3548 PyObject *__pyx_t_7 = NULL;
3549 PyObject *__pyx_t_8 = NULL;
3550 char *__pyx_t_9;
3551 __Pyx_RefNannySetupContext("write_items", 0);
3552
3553 /* "clickhouse_driver/columns/stringcolumn.pyx":132
3554 *
3555 * def write_items(self, items, buf):
3556 * cdef Py_ssize_t buf_pos = 0 # <<<<<<<<<<<<<<
3557 * cdef Py_ssize_t length = self.length
3558 * cdef Py_ssize_t items_buf_size = length * len(items)
3559 */
3560 __pyx_v_buf_pos = 0;
3561
3562 /* "clickhouse_driver/columns/stringcolumn.pyx":133
3563 * def write_items(self, items, buf):
3564 * cdef Py_ssize_t buf_pos = 0
3565 * cdef Py_ssize_t length = self.length # <<<<<<<<<<<<<<
3566 * cdef Py_ssize_t items_buf_size = length * len(items)
3567 *
3568 */
3569 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
3570 __Pyx_GOTREF(__pyx_t_1);
3571 __pyx_t_2 = __Pyx_PyIndex_AsSsize_t(__pyx_t_1); if (unlikely((__pyx_t_2 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 133, __pyx_L1_error)
3572 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3573 __pyx_v_length = __pyx_t_2;
3574
3575 /* "clickhouse_driver/columns/stringcolumn.pyx":134
3576 * cdef Py_ssize_t buf_pos = 0
3577 * cdef Py_ssize_t length = self.length
3578 * cdef Py_ssize_t items_buf_size = length * len(items) # <<<<<<<<<<<<<<
3579 *
3580 * cdef char* c_value
3581 */
3582 __pyx_t_2 = PyObject_Length(__pyx_v_items); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 134, __pyx_L1_error)
3583 __pyx_v_items_buf_size = (__pyx_v_length * __pyx_t_2);
3584
3585 /* "clickhouse_driver/columns/stringcolumn.pyx":137
3586 *
3587 * cdef char* c_value
3588 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size) # <<<<<<<<<<<<<<
3589 * if not items_buf:
3590 * raise MemoryError()
3591 */
3592 __pyx_v_items_buf = ((char *)PyMem_Malloc(__pyx_v_items_buf_size));
3593
3594 /* "clickhouse_driver/columns/stringcolumn.pyx":138
3595 * cdef char* c_value
3596 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3597 * if not items_buf: # <<<<<<<<<<<<<<
3598 * raise MemoryError()
3599 *
3600 */
3601 __pyx_t_3 = ((!(__pyx_v_items_buf != 0)) != 0);
3602 if (unlikely(__pyx_t_3)) {
3603
3604 /* "clickhouse_driver/columns/stringcolumn.pyx":139
3605 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3606 * if not items_buf:
3607 * raise MemoryError() # <<<<<<<<<<<<<<
3608 *
3609 * memset(items_buf, 0, items_buf_size)
3610 */
3611 PyErr_NoMemory(); __PYX_ERR(0, 139, __pyx_L1_error)
3612
3613 /* "clickhouse_driver/columns/stringcolumn.pyx":138
3614 * cdef char* c_value
3615 * cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
3616 * if not items_buf: # <<<<<<<<<<<<<<
3617 * raise MemoryError()
3618 *
3619 */
3620 }
3621
3622 /* "clickhouse_driver/columns/stringcolumn.pyx":141
3623 * raise MemoryError()
3624 *
3625 * memset(items_buf, 0, items_buf_size) # <<<<<<<<<<<<<<
3626 *
3627 * for value in items:
3628 */
3629 (void)(memset(__pyx_v_items_buf, 0, __pyx_v_items_buf_size));
3630
3631 /* "clickhouse_driver/columns/stringcolumn.pyx":143
3632 * memset(items_buf, 0, items_buf_size)
3633 *
3634 * for value in items: # <<<<<<<<<<<<<<
3635 * value_len = len(value)
3636 * if length < value_len:
3637 */
3638 if (likely(PyList_CheckExact(__pyx_v_items)) || PyTuple_CheckExact(__pyx_v_items)) {
3639 __pyx_t_1 = __pyx_v_items; __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = 0;
3640 __pyx_t_4 = NULL;
3641 } else {
3642 __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error)
3643 __Pyx_GOTREF(__pyx_t_1);
3644 __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 143, __pyx_L1_error)
3645 }
3646 for (;;) {
3647 if (likely(!__pyx_t_4)) {
3648 if (likely(PyList_CheckExact(__pyx_t_1))) {
3649 if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
3650 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3651 __pyx_t_5 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
3652 #else
3653 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
3654 __Pyx_GOTREF(__pyx_t_5);
3655 #endif
3656 } else {
3657 if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
3658 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3659 __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++; if (unlikely(0 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
3660 #else
3661 __pyx_t_5 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 143, __pyx_L1_error)
3662 __Pyx_GOTREF(__pyx_t_5);
3663 #endif
3664 }
3665 } else {
3666 __pyx_t_5 = __pyx_t_4(__pyx_t_1);
3667 if (unlikely(!__pyx_t_5)) {
3668 PyObject* exc_type = PyErr_Occurred();
3669 if (exc_type) {
3670 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3671 else __PYX_ERR(0, 143, __pyx_L1_error)
3672 }
3673 break;
3674 }
3675 __Pyx_GOTREF(__pyx_t_5);
3676 }
3677 __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_5);
3678 __pyx_t_5 = 0;
3679
3680 /* "clickhouse_driver/columns/stringcolumn.pyx":144
3681 *
3682 * for value in items:
3683 * value_len = len(value) # <<<<<<<<<<<<<<
3684 * if length < value_len:
3685 * raise errors.TooLargeStringSize()
3686 */
3687 __pyx_t_6 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 144, __pyx_L1_error)
3688 __pyx_v_value_len = __pyx_t_6;
3689
3690 /* "clickhouse_driver/columns/stringcolumn.pyx":145
3691 * for value in items:
3692 * value_len = len(value)
3693 * if length < value_len: # <<<<<<<<<<<<<<
3694 * raise errors.TooLargeStringSize()
3695 *
3696 */
3697 __pyx_t_3 = ((__pyx_v_length < __pyx_v_value_len) != 0);
3698 if (unlikely(__pyx_t_3)) {
3699
3700 /* "clickhouse_driver/columns/stringcolumn.pyx":146
3701 * value_len = len(value)
3702 * if length < value_len:
3703 * raise errors.TooLargeStringSize() # <<<<<<<<<<<<<<
3704 *
3705 * if PyBytes_Check(value):
3706 */
3707 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_errors); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 146, __pyx_L1_error)
3708 __Pyx_GOTREF(__pyx_t_7);
3709 __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_TooLargeStringSize); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 146, __pyx_L1_error)
3710 __Pyx_GOTREF(__pyx_t_8);
3711 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
3712 __pyx_t_7 = NULL;
3713 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_8))) {
3714 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
3715 if (likely(__pyx_t_7)) {
3716 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
3717 __Pyx_INCREF(__pyx_t_7);
3718 __Pyx_INCREF(function);
3719 __Pyx_DECREF_SET(__pyx_t_8, function);
3720 }
3721 }
3722 __pyx_t_5 = (__pyx_t_7) ? __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_7) : __Pyx_PyObject_CallNoArg(__pyx_t_8);
3723 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3724 if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 146, __pyx_L1_error)
3725 __Pyx_GOTREF(__pyx_t_5);
3726 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3727 __Pyx_Raise(__pyx_t_5, 0, 0, 0);
3728 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3729 __PYX_ERR(0, 146, __pyx_L1_error)
3730
3731 /* "clickhouse_driver/columns/stringcolumn.pyx":145
3732 * for value in items:
3733 * value_len = len(value)
3734 * if length < value_len: # <<<<<<<<<<<<<<
3735 * raise errors.TooLargeStringSize()
3736 *
3737 */
3738 }
3739
3740 /* "clickhouse_driver/columns/stringcolumn.pyx":148
3741 * raise errors.TooLargeStringSize()
3742 *
3743 * if PyBytes_Check(value): # <<<<<<<<<<<<<<
3744 * c_value = PyBytes_AsString(value)
3745 * else:
3746 */
3747 __pyx_t_3 = (PyBytes_Check(__pyx_v_value) != 0);
3748 if (__pyx_t_3) {
3749
3750 /* "clickhouse_driver/columns/stringcolumn.pyx":149
3751 *
3752 * if PyBytes_Check(value):
3753 * c_value = PyBytes_AsString(value) # <<<<<<<<<<<<<<
3754 * else:
3755 * c_value = PyByteArray_AsString(value)
3756 */
3757 __pyx_t_9 = PyBytes_AsString(__pyx_v_value); if (unlikely(__pyx_t_9 == ((char *)NULL))) __PYX_ERR(0, 149, __pyx_L1_error)
3758 __pyx_v_c_value = __pyx_t_9;
3759
3760 /* "clickhouse_driver/columns/stringcolumn.pyx":148
3761 * raise errors.TooLargeStringSize()
3762 *
3763 * if PyBytes_Check(value): # <<<<<<<<<<<<<<
3764 * c_value = PyBytes_AsString(value)
3765 * else:
3766 */
3767 goto __pyx_L7;
3768 }
3769
3770 /* "clickhouse_driver/columns/stringcolumn.pyx":151
3771 * c_value = PyBytes_AsString(value)
3772 * else:
3773 * c_value = PyByteArray_AsString(value) # <<<<<<<<<<<<<<
3774 *
3775 * memcpy(&items_buf[buf_pos], c_value, value_len)
3776 */
3777 /*else*/ {
3778 __pyx_v_c_value = PyByteArray_AsString(__pyx_v_value);
3779 }
3780 __pyx_L7:;
3781
3782 /* "clickhouse_driver/columns/stringcolumn.pyx":153
3783 * c_value = PyByteArray_AsString(value)
3784 *
3785 * memcpy(&items_buf[buf_pos], c_value, value_len) # <<<<<<<<<<<<<<
3786 * buf_pos += length
3787 *
3788 */
3789 (void)(memcpy((&(__pyx_v_items_buf[__pyx_v_buf_pos])), __pyx_v_c_value, __pyx_v_value_len));
3790
3791 /* "clickhouse_driver/columns/stringcolumn.pyx":154
3792 *
3793 * memcpy(&items_buf[buf_pos], c_value, value_len)
3794 * buf_pos += length # <<<<<<<<<<<<<<
3795 *
3796 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3797 */
3798 __pyx_v_buf_pos = (__pyx_v_buf_pos + __pyx_v_length);
3799
3800 /* "clickhouse_driver/columns/stringcolumn.pyx":143
3801 * memset(items_buf, 0, items_buf_size)
3802 *
3803 * for value in items: # <<<<<<<<<<<<<<
3804 * value_len = len(value)
3805 * if length < value_len:
3806 */
3807 }
3808 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3809
3810 /* "clickhouse_driver/columns/stringcolumn.pyx":156
3811 * buf_pos += length
3812 *
3813 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size)) # <<<<<<<<<<<<<<
3814 *
3815 * PyMem_Free(items_buf)
3816 */
3817 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 156, __pyx_L1_error)
3818 __Pyx_GOTREF(__pyx_t_5);
3819 __pyx_t_8 = PyBytes_FromStringAndSize(__pyx_v_items_buf, __pyx_v_items_buf_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 156, __pyx_L1_error)
3820 __Pyx_GOTREF(__pyx_t_8);
3821 __pyx_t_7 = NULL;
3822 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) {
3823 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
3824 if (likely(__pyx_t_7)) {
3825 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
3826 __Pyx_INCREF(__pyx_t_7);
3827 __Pyx_INCREF(function);
3828 __Pyx_DECREF_SET(__pyx_t_5, function);
3829 }
3830 }
3831 __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_7, __pyx_t_8) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_8);
3832 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
3833 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
3834 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
3835 __Pyx_GOTREF(__pyx_t_1);
3836 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3837 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3838
3839 /* "clickhouse_driver/columns/stringcolumn.pyx":158
3840 * buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
3841 *
3842 * PyMem_Free(items_buf) # <<<<<<<<<<<<<<
3843 *
3844 *
3845 */
3846 PyMem_Free(__pyx_v_items_buf);
3847
3848 /* "clickhouse_driver/columns/stringcolumn.pyx":131
3849 * return items
3850 *
3851 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
3852 * cdef Py_ssize_t buf_pos = 0
3853 * cdef Py_ssize_t length = self.length
3854 */
3855
3856 /* function exit code */
3857 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3858 goto __pyx_L0;
3859 __pyx_L1_error:;
3860 __Pyx_XDECREF(__pyx_t_1);
3861 __Pyx_XDECREF(__pyx_t_5);
3862 __Pyx_XDECREF(__pyx_t_7);
3863 __Pyx_XDECREF(__pyx_t_8);
3864 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.ByteFixedString.write_items", __pyx_clineno, __pyx_lineno, __pyx_filename);
3865 __pyx_r = NULL;
3866 __pyx_L0:;
3867 __Pyx_XDECREF(__pyx_v_value);
3868 __Pyx_XGIVEREF(__pyx_r);
3869 __Pyx_RefNannyFinishContext();
3870 return __pyx_r;
3871 }
3872
3873 /* "clickhouse_driver/columns/stringcolumn.pyx":161
3874 *
3875 *
3876 * def create_string_column(spec, column_options): # <<<<<<<<<<<<<<
3877 * client_settings = column_options['context'].client_settings
3878 * strings_as_bytes = client_settings['strings_as_bytes']
3879 */
3880
3881 /* Python wrapper */
3882 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_1create_string_column(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3883 static PyMethodDef __pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_1create_string_column = {"create_string_column", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_1create_string_column, METH_VARARGS|METH_KEYWORDS, 0};
3884 static PyObject *__pyx_pw_17clickhouse_driver_7columns_12stringcolumn_1create_string_column(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3885 PyObject *__pyx_v_spec = 0;
3886 PyObject *__pyx_v_column_options = 0;
3887 PyObject *__pyx_r = 0;
3888 __Pyx_RefNannyDeclarations
3889 __Pyx_RefNannySetupContext("create_string_column (wrapper)", 0);
3890 {
3891 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_spec,&__pyx_n_s_column_options,0};
3892 PyObject* values[2] = {0,0};
3893 if (unlikely(__pyx_kwds)) {
3894 Py_ssize_t kw_args;
3895 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
3896 switch (pos_args) {
3897 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3898 CYTHON_FALLTHROUGH;
3899 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3900 CYTHON_FALLTHROUGH;
3901 case 0: break;
3902 default: goto __pyx_L5_argtuple_error;
3903 }
3904 kw_args = PyDict_Size(__pyx_kwds);
3905 switch (pos_args) {
3906 case 0:
3907 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_spec)) != 0)) kw_args--;
3908 else goto __pyx_L5_argtuple_error;
3909 CYTHON_FALLTHROUGH;
3910 case 1:
3911 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_column_options)) != 0)) kw_args--;
3912 else {
3913 __Pyx_RaiseArgtupleInvalid("create_string_column", 1, 2, 2, 1); __PYX_ERR(0, 161, __pyx_L3_error)
3914 }
3915 }
3916 if (unlikely(kw_args > 0)) {
3917 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "create_string_column") < 0)) __PYX_ERR(0, 161, __pyx_L3_error)
3918 }
3919 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3920 goto __pyx_L5_argtuple_error;
3921 } else {
3922 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3923 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3924 }
3925 __pyx_v_spec = values[0];
3926 __pyx_v_column_options = values[1];
3927 }
3928 goto __pyx_L4_argument_unpacking_done;
3929 __pyx_L5_argtuple_error:;
3930 __Pyx_RaiseArgtupleInvalid("create_string_column", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 161, __pyx_L3_error)
3931 __pyx_L3_error:;
3932 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.create_string_column", __pyx_clineno, __pyx_lineno, __pyx_filename);
3933 __Pyx_RefNannyFinishContext();
3934 return NULL;
3935 __pyx_L4_argument_unpacking_done:;
3936 __pyx_r = __pyx_pf_17clickhouse_driver_7columns_12stringcolumn_create_string_column(__pyx_self, __pyx_v_spec, __pyx_v_column_options);
3937
3938 /* function exit code */
3939 __Pyx_RefNannyFinishContext();
3940 return __pyx_r;
3941 }
3942
3943 static PyObject *__pyx_pf_17clickhouse_driver_7columns_12stringcolumn_create_string_column(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_spec, PyObject *__pyx_v_column_options) {
3944 PyObject *__pyx_v_client_settings = NULL;
3945 PyObject *__pyx_v_strings_as_bytes = NULL;
3946 PyObject *__pyx_v_cls = NULL;
3947 PyObject *__pyx_v_length = NULL;
3948 PyObject *__pyx_r = NULL;
3949 __Pyx_RefNannyDeclarations
3950 PyObject *__pyx_t_1 = NULL;
3951 PyObject *__pyx_t_2 = NULL;
3952 int __pyx_t_3;
3953 PyObject *__pyx_t_4 = NULL;
3954 __Pyx_RefNannySetupContext("create_string_column", 0);
3955
3956 /* "clickhouse_driver/columns/stringcolumn.pyx":162
3957 *
3958 * def create_string_column(spec, column_options):
3959 * client_settings = column_options['context'].client_settings # <<<<<<<<<<<<<<
3960 * strings_as_bytes = client_settings['strings_as_bytes']
3961 *
3962 */
3963 __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_v_column_options, __pyx_n_u_context); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 162, __pyx_L1_error)
3964 __Pyx_GOTREF(__pyx_t_1);
3965 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_client_settings); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 162, __pyx_L1_error)
3966 __Pyx_GOTREF(__pyx_t_2);
3967 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3968 __pyx_v_client_settings = __pyx_t_2;
3969 __pyx_t_2 = 0;
3970
3971 /* "clickhouse_driver/columns/stringcolumn.pyx":163
3972 * def create_string_column(spec, column_options):
3973 * client_settings = column_options['context'].client_settings
3974 * strings_as_bytes = client_settings['strings_as_bytes'] # <<<<<<<<<<<<<<
3975 *
3976 * if spec == 'String':
3977 */
3978 __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_v_client_settings, __pyx_n_u_strings_as_bytes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error)
3979 __Pyx_GOTREF(__pyx_t_2);
3980 __pyx_v_strings_as_bytes = __pyx_t_2;
3981 __pyx_t_2 = 0;
3982
3983 /* "clickhouse_driver/columns/stringcolumn.pyx":165
3984 * strings_as_bytes = client_settings['strings_as_bytes']
3985 *
3986 * if spec == 'String': # <<<<<<<<<<<<<<
3987 * cls = ByteString if strings_as_bytes else String
3988 * return cls(**column_options)
3989 */
3990 __pyx_t_3 = (__Pyx_PyUnicode_Equals(__pyx_v_spec, __pyx_n_u_String, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 165, __pyx_L1_error)
3991 if (__pyx_t_3) {
3992
3993 /* "clickhouse_driver/columns/stringcolumn.pyx":166
3994 *
3995 * if spec == 'String':
3996 * cls = ByteString if strings_as_bytes else String # <<<<<<<<<<<<<<
3997 * return cls(**column_options)
3998 * else:
3999 */
4000 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_strings_as_bytes); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 166, __pyx_L1_error)
4001 if (__pyx_t_3) {
4002 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ByteString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
4003 __Pyx_GOTREF(__pyx_t_1);
4004 __pyx_t_2 = __pyx_t_1;
4005 __pyx_t_1 = 0;
4006 } else {
4007 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_String); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error)
4008 __Pyx_GOTREF(__pyx_t_1);
4009 __pyx_t_2 = __pyx_t_1;
4010 __pyx_t_1 = 0;
4011 }
4012 __pyx_v_cls = __pyx_t_2;
4013 __pyx_t_2 = 0;
4014
4015 /* "clickhouse_driver/columns/stringcolumn.pyx":167
4016 * if spec == 'String':
4017 * cls = ByteString if strings_as_bytes else String
4018 * return cls(**column_options) # <<<<<<<<<<<<<<
4019 * else:
4020 * length = int(spec[12:-1])
4021 */
4022 __Pyx_XDECREF(__pyx_r);
4023 if (unlikely(__pyx_v_column_options == Py_None)) {
4024 PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
4025 __PYX_ERR(0, 167, __pyx_L1_error)
4026 }
4027 if (likely(PyDict_CheckExact(__pyx_v_column_options))) {
4028 __pyx_t_2 = PyDict_Copy(__pyx_v_column_options); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
4029 __Pyx_GOTREF(__pyx_t_2);
4030 } else {
4031 __pyx_t_2 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_column_options, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error)
4032 __Pyx_GOTREF(__pyx_t_2);
4033 }
4034 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
4035 __Pyx_GOTREF(__pyx_t_1);
4036 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4037 __pyx_r = __pyx_t_1;
4038 __pyx_t_1 = 0;
4039 goto __pyx_L0;
4040
4041 /* "clickhouse_driver/columns/stringcolumn.pyx":165
4042 * strings_as_bytes = client_settings['strings_as_bytes']
4043 *
4044 * if spec == 'String': # <<<<<<<<<<<<<<
4045 * cls = ByteString if strings_as_bytes else String
4046 * return cls(**column_options)
4047 */
4048 }
4049
4050 /* "clickhouse_driver/columns/stringcolumn.pyx":169
4051 * return cls(**column_options)
4052 * else:
4053 * length = int(spec[12:-1]) # <<<<<<<<<<<<<<
4054 * cls = ByteFixedString if strings_as_bytes else FixedString
4055 * return cls(length, **column_options)
4056 */
4057 /*else*/ {
4058 __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_spec, 12, -1L, NULL, NULL, &__pyx_slice_, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error)
4059 __Pyx_GOTREF(__pyx_t_1);
4060 __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error)
4061 __Pyx_GOTREF(__pyx_t_2);
4062 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4063 __pyx_v_length = __pyx_t_2;
4064 __pyx_t_2 = 0;
4065
4066 /* "clickhouse_driver/columns/stringcolumn.pyx":170
4067 * else:
4068 * length = int(spec[12:-1])
4069 * cls = ByteFixedString if strings_as_bytes else FixedString # <<<<<<<<<<<<<<
4070 * return cls(length, **column_options)
4071 */
4072 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_strings_as_bytes); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 170, __pyx_L1_error)
4073 if (__pyx_t_3) {
4074 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_ByteFixedString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
4075 __Pyx_GOTREF(__pyx_t_1);
4076 __pyx_t_2 = __pyx_t_1;
4077 __pyx_t_1 = 0;
4078 } else {
4079 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_FixedString); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
4080 __Pyx_GOTREF(__pyx_t_1);
4081 __pyx_t_2 = __pyx_t_1;
4082 __pyx_t_1 = 0;
4083 }
4084 __pyx_v_cls = __pyx_t_2;
4085 __pyx_t_2 = 0;
4086
4087 /* "clickhouse_driver/columns/stringcolumn.pyx":171
4088 * length = int(spec[12:-1])
4089 * cls = ByteFixedString if strings_as_bytes else FixedString
4090 * return cls(length, **column_options) # <<<<<<<<<<<<<<
4091 */
4092 __Pyx_XDECREF(__pyx_r);
4093 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error)
4094 __Pyx_GOTREF(__pyx_t_2);
4095 __Pyx_INCREF(__pyx_v_length);
4096 __Pyx_GIVEREF(__pyx_v_length);
4097 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_length);
4098 if (unlikely(__pyx_v_column_options == Py_None)) {
4099 PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
4100 __PYX_ERR(0, 171, __pyx_L1_error)
4101 }
4102 if (likely(PyDict_CheckExact(__pyx_v_column_options))) {
4103 __pyx_t_1 = PyDict_Copy(__pyx_v_column_options); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
4104 __Pyx_GOTREF(__pyx_t_1);
4105 } else {
4106 __pyx_t_1 = PyObject_CallFunctionObjArgs((PyObject*)&PyDict_Type, __pyx_v_column_options, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error)
4107 __Pyx_GOTREF(__pyx_t_1);
4108 }
4109 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_v_cls, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 171, __pyx_L1_error)
4110 __Pyx_GOTREF(__pyx_t_4);
4111 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4112 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4113 __pyx_r = __pyx_t_4;
4114 __pyx_t_4 = 0;
4115 goto __pyx_L0;
4116 }
4117
4118 /* "clickhouse_driver/columns/stringcolumn.pyx":161
4119 *
4120 *
4121 * def create_string_column(spec, column_options): # <<<<<<<<<<<<<<
4122 * client_settings = column_options['context'].client_settings
4123 * strings_as_bytes = client_settings['strings_as_bytes']
4124 */
4125
4126 /* function exit code */
4127 __pyx_L1_error:;
4128 __Pyx_XDECREF(__pyx_t_1);
4129 __Pyx_XDECREF(__pyx_t_2);
4130 __Pyx_XDECREF(__pyx_t_4);
4131 __Pyx_AddTraceback("clickhouse_driver.columns.stringcolumn.create_string_column", __pyx_clineno, __pyx_lineno, __pyx_filename);
4132 __pyx_r = NULL;
4133 __pyx_L0:;
4134 __Pyx_XDECREF(__pyx_v_client_settings);
4135 __Pyx_XDECREF(__pyx_v_strings_as_bytes);
4136 __Pyx_XDECREF(__pyx_v_cls);
4137 __Pyx_XDECREF(__pyx_v_length);
4138 __Pyx_XGIVEREF(__pyx_r);
4139 __Pyx_RefNannyFinishContext();
4140 return __pyx_r;
4141 }
4142
4143 static PyMethodDef __pyx_methods[] = {
4144 {0, 0, 0, 0}
4145 };
4146
4147 #if PY_MAJOR_VERSION >= 3
4148 #if CYTHON_PEP489_MULTI_PHASE_INIT
4149 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
4150 static int __pyx_pymod_exec_stringcolumn(PyObject* module); /*proto*/
4151 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
4152 {Py_mod_create, (void*)__pyx_pymod_create},
4153 {Py_mod_exec, (void*)__pyx_pymod_exec_stringcolumn},
4154 {0, NULL}
4155 };
4156 #endif
4157
4158 static struct PyModuleDef __pyx_moduledef = {
4159 PyModuleDef_HEAD_INIT,
4160 "stringcolumn",
4161 0, /* m_doc */
4162 #if CYTHON_PEP489_MULTI_PHASE_INIT
4163 0, /* m_size */
4164 #else
4165 -1, /* m_size */
4166 #endif
4167 __pyx_methods /* m_methods */,
4168 #if CYTHON_PEP489_MULTI_PHASE_INIT
4169 __pyx_moduledef_slots, /* m_slots */
4170 #else
4171 NULL, /* m_reload */
4172 #endif
4173 NULL, /* m_traverse */
4174 NULL, /* m_clear */
4175 NULL /* m_free */
4176 };
4177 #endif
4178 #ifndef CYTHON_SMALL_CODE
4179 #if defined(__clang__)
4180 #define CYTHON_SMALL_CODE
4181 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
4182 #define CYTHON_SMALL_CODE __attribute__((cold))
4183 #else
4184 #define CYTHON_SMALL_CODE
4185 #endif
4186 #endif
4187
4188 static __Pyx_StringTabEntry __pyx_string_tab[] = {
4189 {&__pyx_n_s_ByteFixedString, __pyx_k_ByteFixedString, sizeof(__pyx_k_ByteFixedString), 0, 0, 1, 1},
4190 {&__pyx_n_s_ByteFixedString_read_items, __pyx_k_ByteFixedString_read_items, sizeof(__pyx_k_ByteFixedString_read_items), 0, 0, 1, 1},
4191 {&__pyx_n_s_ByteFixedString_write_items, __pyx_k_ByteFixedString_write_items, sizeof(__pyx_k_ByteFixedString_write_items), 0, 0, 1, 1},
4192 {&__pyx_n_s_ByteString, __pyx_k_ByteString, sizeof(__pyx_k_ByteString), 0, 0, 1, 1},
4193 {&__pyx_n_s_ByteString_read_items, __pyx_k_ByteString_read_items, sizeof(__pyx_k_ByteString_read_items), 0, 0, 1, 1},
4194 {&__pyx_n_s_ByteString_write_items, __pyx_k_ByteString_write_items, sizeof(__pyx_k_ByteString_write_items), 0, 0, 1, 1},
4195 {&__pyx_n_s_Column, __pyx_k_Column, sizeof(__pyx_k_Column), 0, 0, 1, 1},
4196 {&__pyx_n_s_FixedString, __pyx_k_FixedString, sizeof(__pyx_k_FixedString), 0, 0, 1, 1},
4197 {&__pyx_n_u_FixedString, __pyx_k_FixedString, sizeof(__pyx_k_FixedString), 0, 1, 0, 1},
4198 {&__pyx_n_s_FixedString___init, __pyx_k_FixedString___init, sizeof(__pyx_k_FixedString___init), 0, 0, 1, 1},
4199 {&__pyx_n_s_FixedString_read_items, __pyx_k_FixedString_read_items, sizeof(__pyx_k_FixedString_read_items), 0, 0, 1, 1},
4200 {&__pyx_n_s_FixedString_write_items, __pyx_k_FixedString_write_items, sizeof(__pyx_k_FixedString_write_items), 0, 0, 1, 1},
4201 {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
4202 {&__pyx_n_s_String, __pyx_k_String, sizeof(__pyx_k_String), 0, 0, 1, 1},
4203 {&__pyx_n_u_String, __pyx_k_String, sizeof(__pyx_k_String), 0, 1, 0, 1},
4204 {&__pyx_n_s_String_read_items, __pyx_k_String_read_items, sizeof(__pyx_k_String_read_items), 0, 0, 1, 1},
4205 {&__pyx_n_s_String_write_items, __pyx_k_String_write_items, sizeof(__pyx_k_String_write_items), 0, 0, 1, 1},
4206 {&__pyx_n_s_TooLargeStringSize, __pyx_k_TooLargeStringSize, sizeof(__pyx_k_TooLargeStringSize), 0, 0, 1, 1},
4207 {&__pyx_n_s_UnicodeDecodeError, __pyx_k_UnicodeDecodeError, sizeof(__pyx_k_UnicodeDecodeError), 0, 0, 1, 1},
4208 {&__pyx_n_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 1},
4209 {&__pyx_kp_b__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 0, 0},
4210 {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
4211 {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
4212 {&__pyx_n_s_buf, __pyx_k_buf, sizeof(__pyx_k_buf), 0, 0, 1, 1},
4213 {&__pyx_n_s_buf_pos, __pyx_k_buf_pos, sizeof(__pyx_k_buf_pos), 0, 0, 1, 1},
4214 {&__pyx_n_s_c_string, __pyx_k_c_string, sizeof(__pyx_k_c_string), 0, 0, 1, 1},
4215 {&__pyx_n_s_c_value, __pyx_k_c_value, sizeof(__pyx_k_c_value), 0, 0, 1, 1},
4216 {&__pyx_n_s_ch_type, __pyx_k_ch_type, sizeof(__pyx_k_ch_type), 0, 0, 1, 1},
4217 {&__pyx_n_s_clickhouse_driver_columns_string, __pyx_k_clickhouse_driver_columns_string, sizeof(__pyx_k_clickhouse_driver_columns_string), 0, 0, 1, 1},
4218 {&__pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_k_clickhouse_driver_columns_string_2, sizeof(__pyx_k_clickhouse_driver_columns_string_2), 0, 0, 1, 0},
4219 {&__pyx_n_s_client_settings, __pyx_k_client_settings, sizeof(__pyx_k_client_settings), 0, 0, 1, 1},
4220 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
4221 {&__pyx_n_s_cls, __pyx_k_cls, sizeof(__pyx_k_cls), 0, 0, 1, 1},
4222 {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1},
4223 {&__pyx_n_s_column_options, __pyx_k_column_options, sizeof(__pyx_k_column_options), 0, 0, 1, 1},
4224 {&__pyx_n_s_compat, __pyx_k_compat, sizeof(__pyx_k_compat), 0, 0, 1, 1},
4225 {&__pyx_n_u_context, __pyx_k_context, sizeof(__pyx_k_context), 0, 1, 0, 1},
4226 {&__pyx_n_s_create_string_column, __pyx_k_create_string_column, sizeof(__pyx_k_create_string_column), 0, 0, 1, 1},
4227 {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
4228 {&__pyx_n_s_data_ptr, __pyx_k_data_ptr, sizeof(__pyx_k_data_ptr), 0, 0, 1, 1},
4229 {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1},
4230 {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
4231 {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
4232 {&__pyx_n_s_errors, __pyx_k_errors, sizeof(__pyx_k_errors), 0, 0, 1, 1},
4233 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
4234 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
4235 {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
4236 {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
4237 {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
4238 {&__pyx_n_s_items_buf, __pyx_k_items_buf, sizeof(__pyx_k_items_buf), 0, 0, 1, 1},
4239 {&__pyx_n_s_items_buf_size, __pyx_k_items_buf_size, sizeof(__pyx_k_items_buf_size), 0, 0, 1, 1},
4240 {&__pyx_n_s_j, __pyx_k_j, sizeof(__pyx_k_j), 0, 0, 1, 1},
4241 {&__pyx_n_s_kwargs, __pyx_k_kwargs, sizeof(__pyx_k_kwargs), 0, 0, 1, 1},
4242 {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
4243 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
4244 {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
4245 {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
4246 {&__pyx_n_s_n_items, __pyx_k_n_items, sizeof(__pyx_k_n_items), 0, 0, 1, 1},
4247 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
4248 {&__pyx_n_s_null_value, __pyx_k_null_value, sizeof(__pyx_k_null_value), 0, 0, 1, 1},
4249 {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
4250 {&__pyx_n_s_py_types, __pyx_k_py_types, sizeof(__pyx_k_py_types), 0, 0, 1, 1},
4251 {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
4252 {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
4253 {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1},
4254 {&__pyx_n_s_read_items, __pyx_k_read_items, sizeof(__pyx_k_read_items), 0, 0, 1, 1},
4255 {&__pyx_n_s_read_strings, __pyx_k_read_strings, sizeof(__pyx_k_read_strings), 0, 0, 1, 1},
4256 {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
4257 {&__pyx_n_s_spec, __pyx_k_spec, sizeof(__pyx_k_spec), 0, 0, 1, 1},
4258 {&__pyx_n_s_string_types, __pyx_k_string_types, sizeof(__pyx_k_string_types), 0, 0, 1, 1},
4259 {&__pyx_n_s_strings_as_bytes, __pyx_k_strings_as_bytes, sizeof(__pyx_k_strings_as_bytes), 0, 0, 1, 1},
4260 {&__pyx_n_u_strings_as_bytes, __pyx_k_strings_as_bytes, sizeof(__pyx_k_strings_as_bytes), 0, 1, 0, 1},
4261 {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
4262 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
4263 {&__pyx_n_s_utf_8_encode, __pyx_k_utf_8_encode, sizeof(__pyx_k_utf_8_encode), 0, 0, 1, 1},
4264 {&__pyx_n_s_util, __pyx_k_util, sizeof(__pyx_k_util), 0, 0, 1, 1},
4265 {&__pyx_n_s_value, __pyx_k_value, sizeof(__pyx_k_value), 0, 0, 1, 1},
4266 {&__pyx_n_s_value_len, __pyx_k_value_len, sizeof(__pyx_k_value_len), 0, 0, 1, 1},
4267 {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
4268 {&__pyx_n_s_write_items, __pyx_k_write_items, sizeof(__pyx_k_write_items), 0, 0, 1, 1},
4269 {&__pyx_n_s_write_strings, __pyx_k_write_strings, sizeof(__pyx_k_write_strings), 0, 0, 1, 1},
4270 {0, 0, 0, 0, 0, 0, 0}
4271 };
4272 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
4273 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 48, __pyx_L1_error)
4274 __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) __PYX_ERR(0, 57, __pyx_L1_error)
4275 __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 61, __pyx_L1_error)
4276 __pyx_builtin_UnicodeDecodeError = __Pyx_GetBuiltinName(__pyx_n_s_UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) __PYX_ERR(0, 71, __pyx_L1_error)
4277 return 0;
4278 __pyx_L1_error:;
4279 return -1;
4280 }
4281
4282 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
4283 __Pyx_RefNannyDeclarations
4284 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
4285
4286 /* "clickhouse_driver/columns/stringcolumn.pyx":169
4287 * return cls(**column_options)
4288 * else:
4289 * length = int(spec[12:-1]) # <<<<<<<<<<<<<<
4290 * cls = ByteFixedString if strings_as_bytes else FixedString
4291 * return cls(length, **column_options)
4292 */
4293 __pyx_slice_ = PySlice_New(__pyx_int_12, __pyx_int_neg_1, Py_None); if (unlikely(!__pyx_slice_)) __PYX_ERR(0, 169, __pyx_L1_error)
4294 __Pyx_GOTREF(__pyx_slice_);
4295 __Pyx_GIVEREF(__pyx_slice_);
4296
4297 /* "clickhouse_driver/columns/stringcolumn.pyx":25
4298 * # TODO: pass user encoding here
4299 *
4300 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4301 * buf.write_strings(items, encode=True)
4302 *
4303 */
4304 __pyx_tuple__3 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 25, __pyx_L1_error)
4305 __Pyx_GOTREF(__pyx_tuple__3);
4306 __Pyx_GIVEREF(__pyx_tuple__3);
4307 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_write_items, 25, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 25, __pyx_L1_error)
4308
4309 /* "clickhouse_driver/columns/stringcolumn.pyx":28
4310 * buf.write_strings(items, encode=True)
4311 *
4312 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
4313 * return buf.read_strings(n_items, decode=True)
4314 *
4315 */
4316 __pyx_tuple__5 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_n_items, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 28, __pyx_L1_error)
4317 __Pyx_GOTREF(__pyx_tuple__5);
4318 __Pyx_GIVEREF(__pyx_tuple__5);
4319 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_read_items, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 28, __pyx_L1_error)
4320
4321 /* "clickhouse_driver/columns/stringcolumn.pyx":36
4322 * null_value = b''
4323 *
4324 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4325 * buf.write_strings(items)
4326 *
4327 */
4328 __pyx_tuple__7 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 36, __pyx_L1_error)
4329 __Pyx_GOTREF(__pyx_tuple__7);
4330 __Pyx_GIVEREF(__pyx_tuple__7);
4331 __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_write_items, 36, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 36, __pyx_L1_error)
4332
4333 /* "clickhouse_driver/columns/stringcolumn.pyx":39
4334 * buf.write_strings(items)
4335 *
4336 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
4337 * return buf.read_strings(n_items)
4338 *
4339 */
4340 __pyx_tuple__9 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_n_items, __pyx_n_s_buf); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 39, __pyx_L1_error)
4341 __Pyx_GOTREF(__pyx_tuple__9);
4342 __Pyx_GIVEREF(__pyx_tuple__9);
4343 __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_read_items, 39, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 39, __pyx_L1_error)
4344
4345 /* "clickhouse_driver/columns/stringcolumn.pyx":46
4346 * ch_type = 'FixedString'
4347 *
4348 * def __init__(self, length, **kwargs): # <<<<<<<<<<<<<<
4349 * self.length = length
4350 * super(FixedString, self).__init__(**kwargs)
4351 */
4352 __pyx_tuple__11 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_length, __pyx_n_s_kwargs); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 46, __pyx_L1_error)
4353 __Pyx_GOTREF(__pyx_tuple__11);
4354 __Pyx_GIVEREF(__pyx_tuple__11);
4355 __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS|CO_VARKEYWORDS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_init, 46, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 46, __pyx_L1_error)
4356
4357 /* "clickhouse_driver/columns/stringcolumn.pyx":50
4358 * super(FixedString, self).__init__(**kwargs)
4359 *
4360 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
4361 * cdef Py_ssize_t i, j, length = self.length
4362 * data = buf.read(length * n_items)
4363 */
4364 __pyx_tuple__13 = PyTuple_Pack(11, __pyx_n_s_self, __pyx_n_s_n_items, __pyx_n_s_buf, __pyx_n_s_i, __pyx_n_s_j, __pyx_n_s_length, __pyx_n_s_data, __pyx_n_s_data_ptr, __pyx_n_s_c_string, __pyx_n_s_items, __pyx_n_s_item); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 50, __pyx_L1_error)
4365 __Pyx_GOTREF(__pyx_tuple__13);
4366 __Pyx_GIVEREF(__pyx_tuple__13);
4367 __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(3, 0, 11, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_read_items, 50, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 50, __pyx_L1_error)
4368
4369 /* "clickhouse_driver/columns/stringcolumn.pyx":80
4370 * return items
4371 *
4372 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4373 * cdef Py_ssize_t buf_pos = 0
4374 * cdef Py_ssize_t length = self.length
4375 */
4376 __pyx_tuple__15 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_buf, __pyx_n_s_buf_pos, __pyx_n_s_length, __pyx_n_s_items_buf_size, __pyx_n_s_c_value, __pyx_n_s_items_buf, __pyx_n_s_value, __pyx_n_s_value_len); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 80, __pyx_L1_error)
4377 __Pyx_GOTREF(__pyx_tuple__15);
4378 __Pyx_GIVEREF(__pyx_tuple__15);
4379 __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_write_items, 80, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 80, __pyx_L1_error)
4380
4381 /* "clickhouse_driver/columns/stringcolumn.pyx":117
4382 * null_value = b''
4383 *
4384 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
4385 * cdef Py_ssize_t i
4386 * cdef Py_ssize_t length = self.length
4387 */
4388 __pyx_tuple__17 = PyTuple_Pack(9, __pyx_n_s_self, __pyx_n_s_n_items, __pyx_n_s_buf, __pyx_n_s_i, __pyx_n_s_length, __pyx_n_s_data, __pyx_n_s_data_ptr, __pyx_n_s_items, __pyx_n_s_item); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 117, __pyx_L1_error)
4389 __Pyx_GOTREF(__pyx_tuple__17);
4390 __Pyx_GIVEREF(__pyx_tuple__17);
4391 __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_read_items, 117, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 117, __pyx_L1_error)
4392
4393 /* "clickhouse_driver/columns/stringcolumn.pyx":131
4394 * return items
4395 *
4396 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4397 * cdef Py_ssize_t buf_pos = 0
4398 * cdef Py_ssize_t length = self.length
4399 */
4400 __pyx_tuple__19 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_items, __pyx_n_s_buf, __pyx_n_s_buf_pos, __pyx_n_s_length, __pyx_n_s_items_buf_size, __pyx_n_s_c_value, __pyx_n_s_items_buf, __pyx_n_s_value, __pyx_n_s_value_len); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 131, __pyx_L1_error)
4401 __Pyx_GOTREF(__pyx_tuple__19);
4402 __Pyx_GIVEREF(__pyx_tuple__19);
4403 __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(3, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_write_items, 131, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) __PYX_ERR(0, 131, __pyx_L1_error)
4404
4405 /* "clickhouse_driver/columns/stringcolumn.pyx":161
4406 *
4407 *
4408 * def create_string_column(spec, column_options): # <<<<<<<<<<<<<<
4409 * client_settings = column_options['context'].client_settings
4410 * strings_as_bytes = client_settings['strings_as_bytes']
4411 */
4412 __pyx_tuple__21 = PyTuple_Pack(6, __pyx_n_s_spec, __pyx_n_s_column_options, __pyx_n_s_client_settings, __pyx_n_s_strings_as_bytes, __pyx_n_s_cls, __pyx_n_s_length); if (unlikely(!__pyx_tuple__21)) __PYX_ERR(0, 161, __pyx_L1_error)
4413 __Pyx_GOTREF(__pyx_tuple__21);
4414 __Pyx_GIVEREF(__pyx_tuple__21);
4415 __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(2, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_columns_string_2, __pyx_n_s_create_string_column, 161, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) __PYX_ERR(0, 161, __pyx_L1_error)
4416 __Pyx_RefNannyFinishContext();
4417 return 0;
4418 __pyx_L1_error:;
4419 __Pyx_RefNannyFinishContext();
4420 return -1;
4421 }
4422
4423 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
4424 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4425 __pyx_int_12 = PyInt_FromLong(12); if (unlikely(!__pyx_int_12)) __PYX_ERR(0, 1, __pyx_L1_error)
4426 __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error)
4427 return 0;
4428 __pyx_L1_error:;
4429 return -1;
4430 }
4431
4432 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
4433 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
4434 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
4435 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
4436 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
4437 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
4438 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
4439
4440 static int __Pyx_modinit_global_init_code(void) {
4441 __Pyx_RefNannyDeclarations
4442 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
4443 /*--- Global init code ---*/
4444 __Pyx_RefNannyFinishContext();
4445 return 0;
4446 }
4447
4448 static int __Pyx_modinit_variable_export_code(void) {
4449 __Pyx_RefNannyDeclarations
4450 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
4451 /*--- Variable export code ---*/
4452 __Pyx_RefNannyFinishContext();
4453 return 0;
4454 }
4455
4456 static int __Pyx_modinit_function_export_code(void) {
4457 __Pyx_RefNannyDeclarations
4458 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
4459 /*--- Function export code ---*/
4460 __Pyx_RefNannyFinishContext();
4461 return 0;
4462 }
4463
4464 static int __Pyx_modinit_type_init_code(void) {
4465 __Pyx_RefNannyDeclarations
4466 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
4467 /*--- Type init code ---*/
4468 __Pyx_RefNannyFinishContext();
4469 return 0;
4470 }
4471
4472 static int __Pyx_modinit_type_import_code(void) {
4473 __Pyx_RefNannyDeclarations
4474 PyObject *__pyx_t_1 = NULL;
4475 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
4476 /*--- Type import code ---*/
4477 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
4478 __Pyx_GOTREF(__pyx_t_1);
4479 __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "type",
4480 #if defined(PYPY_VERSION_NUM) && PYPY_VERSION_NUM < 0x050B0000
4481 sizeof(PyTypeObject),
4482 #else
4483 sizeof(PyHeapTypeObject),
4484 #endif
4485 __Pyx_ImportType_CheckSize_Warn);
4486 if (!__pyx_ptype_7cpython_4type_type) __PYX_ERR(1, 9, __pyx_L1_error)
4487 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4488 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(2, 8, __pyx_L1_error)
4489 __Pyx_GOTREF(__pyx_t_1);
4490 __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), __Pyx_ImportType_CheckSize_Warn);
4491 if (!__pyx_ptype_7cpython_4bool_bool) __PYX_ERR(2, 8, __pyx_L1_error)
4492 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4493 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(3, 15, __pyx_L1_error)
4494 __Pyx_GOTREF(__pyx_t_1);
4495 __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__pyx_t_1, __Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), __Pyx_ImportType_CheckSize_Warn);
4496 if (!__pyx_ptype_7cpython_7complex_complex) __PYX_ERR(3, 15, __pyx_L1_error)
4497 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4498 __Pyx_RefNannyFinishContext();
4499 return 0;
4500 __pyx_L1_error:;
4501 __Pyx_XDECREF(__pyx_t_1);
4502 __Pyx_RefNannyFinishContext();
4503 return -1;
4504 }
4505
4506 static int __Pyx_modinit_variable_import_code(void) {
4507 __Pyx_RefNannyDeclarations
4508 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
4509 /*--- Variable import code ---*/
4510 __Pyx_RefNannyFinishContext();
4511 return 0;
4512 }
4513
4514 static int __Pyx_modinit_function_import_code(void) {
4515 __Pyx_RefNannyDeclarations
4516 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
4517 /*--- Function import code ---*/
4518 __Pyx_RefNannyFinishContext();
4519 return 0;
4520 }
4521
4522
4523 #if PY_MAJOR_VERSION < 3
4524 #ifdef CYTHON_NO_PYINIT_EXPORT
4525 #define __Pyx_PyMODINIT_FUNC void
4526 #else
4527 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
4528 #endif
4529 #else
4530 #ifdef CYTHON_NO_PYINIT_EXPORT
4531 #define __Pyx_PyMODINIT_FUNC PyObject *
4532 #else
4533 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
4534 #endif
4535 #endif
4536
4537
4538 #if PY_MAJOR_VERSION < 3
4539 __Pyx_PyMODINIT_FUNC initstringcolumn(void) CYTHON_SMALL_CODE; /*proto*/
4540 __Pyx_PyMODINIT_FUNC initstringcolumn(void)
4541 #else
4542 __Pyx_PyMODINIT_FUNC PyInit_stringcolumn(void) CYTHON_SMALL_CODE; /*proto*/
4543 __Pyx_PyMODINIT_FUNC PyInit_stringcolumn(void)
4544 #if CYTHON_PEP489_MULTI_PHASE_INIT
4545 {
4546 return PyModuleDef_Init(&__pyx_moduledef);
4547 }
4548 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
4549 #if PY_VERSION_HEX >= 0x030700A1
4550 static PY_INT64_T main_interpreter_id = -1;
4551 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
4552 if (main_interpreter_id == -1) {
4553 main_interpreter_id = current_id;
4554 return (unlikely(current_id == -1)) ? -1 : 0;
4555 } else if (unlikely(main_interpreter_id != current_id))
4556 #else
4557 static PyInterpreterState *main_interpreter = NULL;
4558 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
4559 if (!main_interpreter) {
4560 main_interpreter = current_interpreter;
4561 } else if (unlikely(main_interpreter != current_interpreter))
4562 #endif
4563 {
4564 PyErr_SetString(
4565 PyExc_ImportError,
4566 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
4567 return -1;
4568 }
4569 return 0;
4570 }
4571 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
4572 PyObject *value = PyObject_GetAttrString(spec, from_name);
4573 int result = 0;
4574 if (likely(value)) {
4575 if (allow_none || value != Py_None) {
4576 result = PyDict_SetItemString(moddict, to_name, value);
4577 }
4578 Py_DECREF(value);
4579 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
4580 PyErr_Clear();
4581 } else {
4582 result = -1;
4583 }
4584 return result;
4585 }
4586 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
4587 PyObject *module = NULL, *moddict, *modname;
4588 if (__Pyx_check_single_interpreter())
4589 return NULL;
4590 if (__pyx_m)
4591 return __Pyx_NewRef(__pyx_m);
4592 modname = PyObject_GetAttrString(spec, "name");
4593 if (unlikely(!modname)) goto bad;
4594 module = PyModule_NewObject(modname);
4595 Py_DECREF(modname);
4596 if (unlikely(!module)) goto bad;
4597 moddict = PyModule_GetDict(module);
4598 if (unlikely(!moddict)) goto bad;
4599 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
4600 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
4601 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
4602 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
4603 return module;
4604 bad:
4605 Py_XDECREF(module);
4606 return NULL;
4607 }
4608
4609
4610 static CYTHON_SMALL_CODE int __pyx_pymod_exec_stringcolumn(PyObject *__pyx_pyinit_module)
4611 #endif
4612 #endif
4613 {
4614 PyObject *__pyx_t_1 = NULL;
4615 PyObject *__pyx_t_2 = NULL;
4616 PyObject *__pyx_t_3 = NULL;
4617 PyObject *__pyx_t_4 = NULL;
4618 PyObject *__pyx_t_5 = NULL;
4619 __Pyx_RefNannyDeclarations
4620 #if CYTHON_PEP489_MULTI_PHASE_INIT
4621 if (__pyx_m) {
4622 if (__pyx_m == __pyx_pyinit_module) return 0;
4623 PyErr_SetString(PyExc_RuntimeError, "Module 'stringcolumn' has already been imported. Re-initialisation is not supported.");
4624 return -1;
4625 }
4626 #elif PY_MAJOR_VERSION >= 3
4627 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
4628 #endif
4629 #if CYTHON_REFNANNY
4630 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
4631 if (!__Pyx_RefNanny) {
4632 PyErr_Clear();
4633 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
4634 if (!__Pyx_RefNanny)
4635 Py_FatalError("failed to import 'refnanny' module");
4636 }
4637 #endif
4638 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_stringcolumn(void)", 0);
4639 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4640 #ifdef __Pxy_PyFrame_Initialize_Offsets
4641 __Pxy_PyFrame_Initialize_Offsets();
4642 #endif
4643 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
4644 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
4645 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
4646 #ifdef __Pyx_CyFunction_USED
4647 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4648 #endif
4649 #ifdef __Pyx_FusedFunction_USED
4650 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4651 #endif
4652 #ifdef __Pyx_Coroutine_USED
4653 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4654 #endif
4655 #ifdef __Pyx_Generator_USED
4656 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4657 #endif
4658 #ifdef __Pyx_AsyncGen_USED
4659 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4660 #endif
4661 #ifdef __Pyx_StopAsyncIteration_USED
4662 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4663 #endif
4664 /*--- Library function declarations ---*/
4665 /*--- Threads initialization code ---*/
4666 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
4667 #ifdef WITH_THREAD /* Python build with threading support? */
4668 PyEval_InitThreads();
4669 #endif
4670 #endif
4671 /*--- Module creation code ---*/
4672 #if CYTHON_PEP489_MULTI_PHASE_INIT
4673 __pyx_m = __pyx_pyinit_module;
4674 Py_INCREF(__pyx_m);
4675 #else
4676 #if PY_MAJOR_VERSION < 3
4677 __pyx_m = Py_InitModule4("stringcolumn", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
4678 #else
4679 __pyx_m = PyModule_Create(&__pyx_moduledef);
4680 #endif
4681 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
4682 #endif
4683 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
4684 Py_INCREF(__pyx_d);
4685 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
4686 Py_INCREF(__pyx_b);
4687 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
4688 Py_INCREF(__pyx_cython_runtime);
4689 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
4690 /*--- Initialize various global constants etc. ---*/
4691 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4692 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
4693 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4694 #endif
4695 if (__pyx_module_is_main_clickhouse_driver__columns__stringcolumn) {
4696 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4697 }
4698 #if PY_MAJOR_VERSION >= 3
4699 {
4700 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
4701 if (!PyDict_GetItemString(modules, "clickhouse_driver.columns.stringcolumn")) {
4702 if (unlikely(PyDict_SetItemString(modules, "clickhouse_driver.columns.stringcolumn", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
4703 }
4704 }
4705 #endif
4706 /*--- Builtin init code ---*/
4707 if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
4708 /*--- Constants init code ---*/
4709 if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
4710 /*--- Global type/function init code ---*/
4711 (void)__Pyx_modinit_global_init_code();
4712 (void)__Pyx_modinit_variable_export_code();
4713 (void)__Pyx_modinit_function_export_code();
4714 (void)__Pyx_modinit_type_init_code();
4715 if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
4716 (void)__Pyx_modinit_variable_import_code();
4717 (void)__Pyx_modinit_function_import_code();
4718 /*--- Execution code ---*/
4719 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
4720 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
4721 #endif
4722
4723 /* "clickhouse_driver/columns/stringcolumn.pyx":11
4724 * from libc.string cimport memcpy, memset
4725 *
4726 * from .. import errors # <<<<<<<<<<<<<<
4727 * from ..util import compat
4728 * from .base import Column
4729 */
4730 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
4731 __Pyx_GOTREF(__pyx_t_1);
4732 __Pyx_INCREF(__pyx_n_s_errors);
4733 __Pyx_GIVEREF(__pyx_n_s_errors);
4734 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_errors);
4735 __pyx_t_2 = __Pyx_Import(__pyx_n_s__2, __pyx_t_1, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
4736 __Pyx_GOTREF(__pyx_t_2);
4737 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4738 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_errors); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
4739 __Pyx_GOTREF(__pyx_t_1);
4740 if (PyDict_SetItem(__pyx_d, __pyx_n_s_errors, __pyx_t_1) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
4741 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4742 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4743
4744 /* "clickhouse_driver/columns/stringcolumn.pyx":12
4745 *
4746 * from .. import errors
4747 * from ..util import compat # <<<<<<<<<<<<<<
4748 * from .base import Column
4749 *
4750 */
4751 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
4752 __Pyx_GOTREF(__pyx_t_2);
4753 __Pyx_INCREF(__pyx_n_s_compat);
4754 __Pyx_GIVEREF(__pyx_n_s_compat);
4755 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_compat);
4756 __pyx_t_1 = __Pyx_Import(__pyx_n_s_util, __pyx_t_2, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
4757 __Pyx_GOTREF(__pyx_t_1);
4758 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4759 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_compat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
4760 __Pyx_GOTREF(__pyx_t_2);
4761 if (PyDict_SetItem(__pyx_d, __pyx_n_s_compat, __pyx_t_2) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
4762 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4763 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4764
4765 /* "clickhouse_driver/columns/stringcolumn.pyx":13
4766 * from .. import errors
4767 * from ..util import compat
4768 * from .base import Column # <<<<<<<<<<<<<<
4769 *
4770 * from codecs import utf_8_encode
4771 */
4772 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
4773 __Pyx_GOTREF(__pyx_t_1);
4774 __Pyx_INCREF(__pyx_n_s_Column);
4775 __Pyx_GIVEREF(__pyx_n_s_Column);
4776 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_Column);
4777 __pyx_t_2 = __Pyx_Import(__pyx_n_s_base, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
4778 __Pyx_GOTREF(__pyx_t_2);
4779 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4780 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Column); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
4781 __Pyx_GOTREF(__pyx_t_1);
4782 if (PyDict_SetItem(__pyx_d, __pyx_n_s_Column, __pyx_t_1) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
4783 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4784 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4785
4786 /* "clickhouse_driver/columns/stringcolumn.pyx":15
4787 * from .base import Column
4788 *
4789 * from codecs import utf_8_encode # <<<<<<<<<<<<<<
4790 *
4791 *
4792 */
4793 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
4794 __Pyx_GOTREF(__pyx_t_2);
4795 __Pyx_INCREF(__pyx_n_s_utf_8_encode);
4796 __Pyx_GIVEREF(__pyx_n_s_utf_8_encode);
4797 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_utf_8_encode);
4798 __pyx_t_1 = __Pyx_Import(__pyx_n_s_codecs, __pyx_t_2, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
4799 __Pyx_GOTREF(__pyx_t_1);
4800 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4801 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_utf_8_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 15, __pyx_L1_error)
4802 __Pyx_GOTREF(__pyx_t_2);
4803 if (PyDict_SetItem(__pyx_d, __pyx_n_s_utf_8_encode, __pyx_t_2) < 0) __PYX_ERR(0, 15, __pyx_L1_error)
4804 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4805 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4806
4807 /* "clickhouse_driver/columns/stringcolumn.pyx":18
4808 *
4809 *
4810 * class String(Column): # <<<<<<<<<<<<<<
4811 * ch_type = 'String'
4812 * py_types = compat.string_types
4813 */
4814 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_Column); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
4815 __Pyx_GOTREF(__pyx_t_1);
4816 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 18, __pyx_L1_error)
4817 __Pyx_GOTREF(__pyx_t_2);
4818 __Pyx_GIVEREF(__pyx_t_1);
4819 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4820 __pyx_t_1 = 0;
4821 __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
4822 __Pyx_GOTREF(__pyx_t_1);
4823 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_String, __pyx_n_s_String, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_columns_string, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 18, __pyx_L1_error)
4824 __Pyx_GOTREF(__pyx_t_3);
4825
4826 /* "clickhouse_driver/columns/stringcolumn.pyx":19
4827 *
4828 * class String(Column):
4829 * ch_type = 'String' # <<<<<<<<<<<<<<
4830 * py_types = compat.string_types
4831 * null_value = ''
4832 */
4833 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_ch_type, __pyx_n_u_String) < 0) __PYX_ERR(0, 19, __pyx_L1_error)
4834
4835 /* "clickhouse_driver/columns/stringcolumn.pyx":20
4836 * class String(Column):
4837 * ch_type = 'String'
4838 * py_types = compat.string_types # <<<<<<<<<<<<<<
4839 * null_value = ''
4840 *
4841 */
4842 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_compat); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error)
4843 __Pyx_GOTREF(__pyx_t_4);
4844 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_string_types); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 20, __pyx_L1_error)
4845 __Pyx_GOTREF(__pyx_t_5);
4846 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4847 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_py_types, __pyx_t_5) < 0) __PYX_ERR(0, 20, __pyx_L1_error)
4848 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4849
4850 /* "clickhouse_driver/columns/stringcolumn.pyx":21
4851 * ch_type = 'String'
4852 * py_types = compat.string_types
4853 * null_value = '' # <<<<<<<<<<<<<<
4854 *
4855 * # TODO: pass user encoding here
4856 */
4857 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_null_value, __pyx_kp_u__2) < 0) __PYX_ERR(0, 21, __pyx_L1_error)
4858
4859 /* "clickhouse_driver/columns/stringcolumn.pyx":25
4860 * # TODO: pass user encoding here
4861 *
4862 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4863 * buf.write_strings(items, encode=True)
4864 *
4865 */
4866 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_6String_1write_items, 0, __pyx_n_s_String_write_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__4)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 25, __pyx_L1_error)
4867 __Pyx_GOTREF(__pyx_t_5);
4868 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_write_items, __pyx_t_5) < 0) __PYX_ERR(0, 25, __pyx_L1_error)
4869 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4870
4871 /* "clickhouse_driver/columns/stringcolumn.pyx":28
4872 * buf.write_strings(items, encode=True)
4873 *
4874 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
4875 * return buf.read_strings(n_items, decode=True)
4876 *
4877 */
4878 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_6String_3read_items, 0, __pyx_n_s_String_read_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__6)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 28, __pyx_L1_error)
4879 __Pyx_GOTREF(__pyx_t_5);
4880 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_items, __pyx_t_5) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
4881 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4882
4883 /* "clickhouse_driver/columns/stringcolumn.pyx":18
4884 *
4885 *
4886 * class String(Column): # <<<<<<<<<<<<<<
4887 * ch_type = 'String'
4888 * py_types = compat.string_types
4889 */
4890 __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_String, __pyx_t_2, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 18, __pyx_L1_error)
4891 __Pyx_GOTREF(__pyx_t_5);
4892 if (PyDict_SetItem(__pyx_d, __pyx_n_s_String, __pyx_t_5) < 0) __PYX_ERR(0, 18, __pyx_L1_error)
4893 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4894 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4895 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4896 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4897
4898 /* "clickhouse_driver/columns/stringcolumn.pyx":32
4899 *
4900 *
4901 * class ByteString(String): # <<<<<<<<<<<<<<
4902 * py_types = (bytearray, bytes)
4903 * null_value = b''
4904 */
4905 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_String); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
4906 __Pyx_GOTREF(__pyx_t_2);
4907 __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
4908 __Pyx_GOTREF(__pyx_t_1);
4909 __Pyx_GIVEREF(__pyx_t_2);
4910 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
4911 __pyx_t_2 = 0;
4912 __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 32, __pyx_L1_error)
4913 __Pyx_GOTREF(__pyx_t_2);
4914 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_ByteString, __pyx_n_s_ByteString, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_columns_string, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 32, __pyx_L1_error)
4915 __Pyx_GOTREF(__pyx_t_3);
4916
4917 /* "clickhouse_driver/columns/stringcolumn.pyx":33
4918 *
4919 * class ByteString(String):
4920 * py_types = (bytearray, bytes) # <<<<<<<<<<<<<<
4921 * null_value = b''
4922 *
4923 */
4924 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 33, __pyx_L1_error)
4925 __Pyx_GOTREF(__pyx_t_5);
4926 __Pyx_INCREF(((PyObject *)(&PyByteArray_Type)));
4927 __Pyx_GIVEREF(((PyObject *)(&PyByteArray_Type)));
4928 PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)(&PyByteArray_Type)));
4929 __Pyx_INCREF(((PyObject *)(&PyBytes_Type)));
4930 __Pyx_GIVEREF(((PyObject *)(&PyBytes_Type)));
4931 PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)(&PyBytes_Type)));
4932 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_py_types, __pyx_t_5) < 0) __PYX_ERR(0, 33, __pyx_L1_error)
4933 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4934
4935 /* "clickhouse_driver/columns/stringcolumn.pyx":34
4936 * class ByteString(String):
4937 * py_types = (bytearray, bytes)
4938 * null_value = b'' # <<<<<<<<<<<<<<
4939 *
4940 * def write_items(self, items, buf):
4941 */
4942 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_null_value, __pyx_kp_b__2) < 0) __PYX_ERR(0, 34, __pyx_L1_error)
4943
4944 /* "clickhouse_driver/columns/stringcolumn.pyx":36
4945 * null_value = b''
4946 *
4947 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
4948 * buf.write_strings(items)
4949 *
4950 */
4951 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_10ByteString_1write_items, 0, __pyx_n_s_ByteString_write_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__8)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 36, __pyx_L1_error)
4952 __Pyx_GOTREF(__pyx_t_5);
4953 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_write_items, __pyx_t_5) < 0) __PYX_ERR(0, 36, __pyx_L1_error)
4954 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4955
4956 /* "clickhouse_driver/columns/stringcolumn.pyx":39
4957 * buf.write_strings(items)
4958 *
4959 * def read_items(self, n_items, buf): # <<<<<<<<<<<<<<
4960 * return buf.read_strings(n_items)
4961 *
4962 */
4963 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_10ByteString_3read_items, 0, __pyx_n_s_ByteString_read_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__10)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 39, __pyx_L1_error)
4964 __Pyx_GOTREF(__pyx_t_5);
4965 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_items, __pyx_t_5) < 0) __PYX_ERR(0, 39, __pyx_L1_error)
4966 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4967
4968 /* "clickhouse_driver/columns/stringcolumn.pyx":32
4969 *
4970 *
4971 * class ByteString(String): # <<<<<<<<<<<<<<
4972 * py_types = (bytearray, bytes)
4973 * null_value = b''
4974 */
4975 __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ByteString, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 32, __pyx_L1_error)
4976 __Pyx_GOTREF(__pyx_t_5);
4977 if (PyDict_SetItem(__pyx_d, __pyx_n_s_ByteString, __pyx_t_5) < 0) __PYX_ERR(0, 32, __pyx_L1_error)
4978 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4979 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4980 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4981 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4982
4983 /* "clickhouse_driver/columns/stringcolumn.pyx":43
4984 *
4985 *
4986 * class FixedString(String): # <<<<<<<<<<<<<<
4987 * ch_type = 'FixedString'
4988 *
4989 */
4990 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_String); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
4991 __Pyx_GOTREF(__pyx_t_1);
4992 __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 43, __pyx_L1_error)
4993 __Pyx_GOTREF(__pyx_t_2);
4994 __Pyx_GIVEREF(__pyx_t_1);
4995 PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
4996 __pyx_t_1 = 0;
4997 __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
4998 __Pyx_GOTREF(__pyx_t_1);
4999 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_FixedString, __pyx_n_s_FixedString, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_columns_string, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 43, __pyx_L1_error)
5000 __Pyx_GOTREF(__pyx_t_3);
5001
5002 /* "clickhouse_driver/columns/stringcolumn.pyx":44
5003 *
5004 * class FixedString(String):
5005 * ch_type = 'FixedString' # <<<<<<<<<<<<<<
5006 *
5007 * def __init__(self, length, **kwargs):
5008 */
5009 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_ch_type, __pyx_n_u_FixedString) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
5010
5011 /* "clickhouse_driver/columns/stringcolumn.pyx":46
5012 * ch_type = 'FixedString'
5013 *
5014 * def __init__(self, length, **kwargs): # <<<<<<<<<<<<<<
5015 * self.length = length
5016 * super(FixedString, self).__init__(**kwargs)
5017 */
5018 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_1__init__, 0, __pyx_n_s_FixedString___init, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__12)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 46, __pyx_L1_error)
5019 __Pyx_GOTREF(__pyx_t_5);
5020 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_init, __pyx_t_5) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
5021 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5022
5023 /* "clickhouse_driver/columns/stringcolumn.pyx":50
5024 * super(FixedString, self).__init__(**kwargs)
5025 *
5026 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
5027 * cdef Py_ssize_t i, j, length = self.length
5028 * data = buf.read(length * n_items)
5029 */
5030 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_3read_items, 0, __pyx_n_s_FixedString_read_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__14)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 50, __pyx_L1_error)
5031 __Pyx_GOTREF(__pyx_t_5);
5032 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_items, __pyx_t_5) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
5033 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5034
5035 /* "clickhouse_driver/columns/stringcolumn.pyx":80
5036 * return items
5037 *
5038 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
5039 * cdef Py_ssize_t buf_pos = 0
5040 * cdef Py_ssize_t length = self.length
5041 */
5042 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_11FixedString_5write_items, 0, __pyx_n_s_FixedString_write_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 80, __pyx_L1_error)
5043 __Pyx_GOTREF(__pyx_t_5);
5044 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_write_items, __pyx_t_5) < 0) __PYX_ERR(0, 80, __pyx_L1_error)
5045 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5046
5047 /* "clickhouse_driver/columns/stringcolumn.pyx":43
5048 *
5049 *
5050 * class FixedString(String): # <<<<<<<<<<<<<<
5051 * ch_type = 'FixedString'
5052 *
5053 */
5054 __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_FixedString, __pyx_t_2, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 43, __pyx_L1_error)
5055 __Pyx_GOTREF(__pyx_t_5);
5056 if (PyDict_SetItem(__pyx_d, __pyx_n_s_FixedString, __pyx_t_5) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
5057 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5058 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5059 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5060 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5061
5062 /* "clickhouse_driver/columns/stringcolumn.pyx":113
5063 *
5064 *
5065 * class ByteFixedString(FixedString): # <<<<<<<<<<<<<<
5066 * py_types = (bytearray, bytes)
5067 * null_value = b''
5068 */
5069 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_FixedString); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
5070 __Pyx_GOTREF(__pyx_t_2);
5071 __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 113, __pyx_L1_error)
5072 __Pyx_GOTREF(__pyx_t_1);
5073 __Pyx_GIVEREF(__pyx_t_2);
5074 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
5075 __pyx_t_2 = 0;
5076 __pyx_t_2 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
5077 __Pyx_GOTREF(__pyx_t_2);
5078 __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_2, __pyx_t_1, __pyx_n_s_ByteFixedString, __pyx_n_s_ByteFixedString, (PyObject *) NULL, __pyx_n_s_clickhouse_driver_columns_string, (PyObject *) NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
5079 __Pyx_GOTREF(__pyx_t_3);
5080
5081 /* "clickhouse_driver/columns/stringcolumn.pyx":114
5082 *
5083 * class ByteFixedString(FixedString):
5084 * py_types = (bytearray, bytes) # <<<<<<<<<<<<<<
5085 * null_value = b''
5086 *
5087 */
5088 __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 114, __pyx_L1_error)
5089 __Pyx_GOTREF(__pyx_t_5);
5090 __Pyx_INCREF(((PyObject *)(&PyByteArray_Type)));
5091 __Pyx_GIVEREF(((PyObject *)(&PyByteArray_Type)));
5092 PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)(&PyByteArray_Type)));
5093 __Pyx_INCREF(((PyObject *)(&PyBytes_Type)));
5094 __Pyx_GIVEREF(((PyObject *)(&PyBytes_Type)));
5095 PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)(&PyBytes_Type)));
5096 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_py_types, __pyx_t_5) < 0) __PYX_ERR(0, 114, __pyx_L1_error)
5097 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5098
5099 /* "clickhouse_driver/columns/stringcolumn.pyx":115
5100 * class ByteFixedString(FixedString):
5101 * py_types = (bytearray, bytes)
5102 * null_value = b'' # <<<<<<<<<<<<<<
5103 *
5104 * def read_items(self, Py_ssize_t n_items, buf):
5105 */
5106 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_null_value, __pyx_kp_b__2) < 0) __PYX_ERR(0, 115, __pyx_L1_error)
5107
5108 /* "clickhouse_driver/columns/stringcolumn.pyx":117
5109 * null_value = b''
5110 *
5111 * def read_items(self, Py_ssize_t n_items, buf): # <<<<<<<<<<<<<<
5112 * cdef Py_ssize_t i
5113 * cdef Py_ssize_t length = self.length
5114 */
5115 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_1read_items, 0, __pyx_n_s_ByteFixedString_read_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L1_error)
5116 __Pyx_GOTREF(__pyx_t_5);
5117 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_read_items, __pyx_t_5) < 0) __PYX_ERR(0, 117, __pyx_L1_error)
5118 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5119
5120 /* "clickhouse_driver/columns/stringcolumn.pyx":131
5121 * return items
5122 *
5123 * def write_items(self, items, buf): # <<<<<<<<<<<<<<
5124 * cdef Py_ssize_t buf_pos = 0
5125 * cdef Py_ssize_t length = self.length
5126 */
5127 __pyx_t_5 = __Pyx_CyFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_15ByteFixedString_3write_items, 0, __pyx_n_s_ByteFixedString_write_items, NULL, __pyx_n_s_clickhouse_driver_columns_string, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 131, __pyx_L1_error)
5128 __Pyx_GOTREF(__pyx_t_5);
5129 if (__Pyx_SetNameInClass(__pyx_t_3, __pyx_n_s_write_items, __pyx_t_5) < 0) __PYX_ERR(0, 131, __pyx_L1_error)
5130 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5131
5132 /* "clickhouse_driver/columns/stringcolumn.pyx":113
5133 *
5134 *
5135 * class ByteFixedString(FixedString): # <<<<<<<<<<<<<<
5136 * py_types = (bytearray, bytes)
5137 * null_value = b''
5138 */
5139 __pyx_t_5 = __Pyx_Py3ClassCreate(__pyx_t_2, __pyx_n_s_ByteFixedString, __pyx_t_1, __pyx_t_3, NULL, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 113, __pyx_L1_error)
5140 __Pyx_GOTREF(__pyx_t_5);
5141 if (PyDict_SetItem(__pyx_d, __pyx_n_s_ByteFixedString, __pyx_t_5) < 0) __PYX_ERR(0, 113, __pyx_L1_error)
5142 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5143 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5144 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5145 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5146
5147 /* "clickhouse_driver/columns/stringcolumn.pyx":161
5148 *
5149 *
5150 * def create_string_column(spec, column_options): # <<<<<<<<<<<<<<
5151 * client_settings = column_options['context'].client_settings
5152 * strings_as_bytes = client_settings['strings_as_bytes']
5153 */
5154 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_7columns_12stringcolumn_1create_string_column, NULL, __pyx_n_s_clickhouse_driver_columns_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
5155 __Pyx_GOTREF(__pyx_t_1);
5156 if (PyDict_SetItem(__pyx_d, __pyx_n_s_create_string_column, __pyx_t_1) < 0) __PYX_ERR(0, 161, __pyx_L1_error)
5157 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5158
5159 /* "clickhouse_driver/columns/stringcolumn.pyx":1
5160 * from cpython cimport Py_INCREF, PyBytes_AsString, PyBytes_FromStringAndSize, \ # <<<<<<<<<<<<<<
5161 * PyBytes_Check
5162 * from cpython.bytearray cimport PyByteArray_AsString, \
5163 */
5164 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
5165 __Pyx_GOTREF(__pyx_t_1);
5166 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
5167 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5168
5169 /*--- Wrapped vars code ---*/
5170
5171 goto __pyx_L0;
5172 __pyx_L1_error:;
5173 __Pyx_XDECREF(__pyx_t_1);
5174 __Pyx_XDECREF(__pyx_t_2);
5175 __Pyx_XDECREF(__pyx_t_3);
5176 __Pyx_XDECREF(__pyx_t_4);
5177 __Pyx_XDECREF(__pyx_t_5);
5178 if (__pyx_m) {
5179 if (__pyx_d) {
5180 __Pyx_AddTraceback("init clickhouse_driver.columns.stringcolumn", __pyx_clineno, __pyx_lineno, __pyx_filename);
5181 }
5182 Py_CLEAR(__pyx_m);
5183 } else if (!PyErr_Occurred()) {
5184 PyErr_SetString(PyExc_ImportError, "init clickhouse_driver.columns.stringcolumn");
5185 }
5186 __pyx_L0:;
5187 __Pyx_RefNannyFinishContext();
5188 #if CYTHON_PEP489_MULTI_PHASE_INIT
5189 return (__pyx_m != NULL) ? 0 : -1;
5190 #elif PY_MAJOR_VERSION >= 3
5191 return __pyx_m;
5192 #else
5193 return;
5194 #endif
5195 }
5196
5197 /* --- Runtime support code --- */
5198 /* Refnanny */
5199 #if CYTHON_REFNANNY
5200 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
5201 PyObject *m = NULL, *p = NULL;
5202 void *r = NULL;
5203 m = PyImport_ImportModule(modname);
5204 if (!m) goto end;
5205 p = PyObject_GetAttrString(m, "RefNannyAPI");
5206 if (!p) goto end;
5207 r = PyLong_AsVoidPtr(p);
5208 end:
5209 Py_XDECREF(p);
5210 Py_XDECREF(m);
5211 return (__Pyx_RefNannyAPIStruct *)r;
5212 }
5213 #endif
5214
5215 /* PyObjectGetAttrStr */
5216 #if CYTHON_USE_TYPE_SLOTS
5217 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
5218 PyTypeObject* tp = Py_TYPE(obj);
5219 if (likely(tp->tp_getattro))
5220 return tp->tp_getattro(obj, attr_name);
5221 #if PY_MAJOR_VERSION < 3
5222 if (likely(tp->tp_getattr))
5223 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
5224 #endif
5225 return PyObject_GetAttr(obj, attr_name);
5226 }
5227 #endif
5228
5229 /* GetBuiltinName */
5230 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
5231 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
5232 if (unlikely(!result)) {
5233 PyErr_Format(PyExc_NameError,
5234 #if PY_MAJOR_VERSION >= 3
5235 "name '%U' is not defined", name);
5236 #else
5237 "name '%.200s' is not defined", PyString_AS_STRING(name));
5238 #endif
5239 }
5240 return result;
5241 }
5242
5243 /* RaiseArgTupleInvalid */
5244 static void __Pyx_RaiseArgtupleInvalid(
5245 const char* func_name,
5246 int exact,
5247 Py_ssize_t num_min,
5248 Py_ssize_t num_max,
5249 Py_ssize_t num_found)
5250 {
5251 Py_ssize_t num_expected;
5252 const char *more_or_less;
5253 if (num_found < num_min) {
5254 num_expected = num_min;
5255 more_or_less = "at least";
5256 } else {
5257 num_expected = num_max;
5258 more_or_less = "at most";
5259 }
5260 if (exact) {
5261 more_or_less = "exactly";
5262 }
5263 PyErr_Format(PyExc_TypeError,
5264 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
5265 func_name, more_or_less, num_expected,
5266 (num_expected == 1) ? "" : "s", num_found);
5267 }
5268
5269 /* RaiseDoubleKeywords */
5270 static void __Pyx_RaiseDoubleKeywordsError(
5271 const char* func_name,
5272 PyObject* kw_name)
5273 {
5274 PyErr_Format(PyExc_TypeError,
5275 #if PY_MAJOR_VERSION >= 3
5276 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
5277 #else
5278 "%s() got multiple values for keyword argument '%s'", func_name,
5279 PyString_AsString(kw_name));
5280 #endif
5281 }
5282
5283 /* ParseKeywords */
5284 static int __Pyx_ParseOptionalKeywords(
5285 PyObject *kwds,
5286 PyObject **argnames[],
5287 PyObject *kwds2,
5288 PyObject *values[],
5289 Py_ssize_t num_pos_args,
5290 const char* function_name)
5291 {
5292 PyObject *key = 0, *value = 0;
5293 Py_ssize_t pos = 0;
5294 PyObject*** name;
5295 PyObject*** first_kw_arg = argnames + num_pos_args;
5296 while (PyDict_Next(kwds, &pos, &key, &value)) {
5297 name = first_kw_arg;
5298 while (*name && (**name != key)) name++;
5299 if (*name) {
5300 values[name-argnames] = value;
5301 continue;
5302 }
5303 name = first_kw_arg;
5304 #if PY_MAJOR_VERSION < 3
5305 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
5306 while (*name) {
5307 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
5308 && _PyString_Eq(**name, key)) {
5309 values[name-argnames] = value;
5310 break;
5311 }
5312 name++;
5313 }
5314 if (*name) continue;
5315 else {
5316 PyObject*** argname = argnames;
5317 while (argname != first_kw_arg) {
5318 if ((**argname == key) || (
5319 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
5320 && _PyString_Eq(**argname, key))) {
5321 goto arg_passed_twice;
5322 }
5323 argname++;
5324 }
5325 }
5326 } else
5327 #endif
5328 if (likely(PyUnicode_Check(key))) {
5329 while (*name) {
5330 int cmp = (**name == key) ? 0 :
5331 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5332 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
5333 #endif
5334 PyUnicode_Compare(**name, key);
5335 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5336 if (cmp == 0) {
5337 values[name-argnames] = value;
5338 break;
5339 }
5340 name++;
5341 }
5342 if (*name) continue;
5343 else {
5344 PyObject*** argname = argnames;
5345 while (argname != first_kw_arg) {
5346 int cmp = (**argname == key) ? 0 :
5347 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
5348 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
5349 #endif
5350 PyUnicode_Compare(**argname, key);
5351 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
5352 if (cmp == 0) goto arg_passed_twice;
5353 argname++;
5354 }
5355 }
5356 } else
5357 goto invalid_keyword_type;
5358 if (kwds2) {
5359 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
5360 } else {
5361 goto invalid_keyword;
5362 }
5363 }
5364 return 0;
5365 arg_passed_twice:
5366 __Pyx_RaiseDoubleKeywordsError(function_name, key);
5367 goto bad;
5368 invalid_keyword_type:
5369 PyErr_Format(PyExc_TypeError,
5370 "%.200s() keywords must be strings", function_name);
5371 goto bad;
5372 invalid_keyword:
5373 PyErr_Format(PyExc_TypeError,
5374 #if PY_MAJOR_VERSION < 3
5375 "%.200s() got an unexpected keyword argument '%.200s'",
5376 function_name, PyString_AsString(key));
5377 #else
5378 "%s() got an unexpected keyword argument '%U'",
5379 function_name, key);
5380 #endif
5381 bad:
5382 return -1;
5383 }
5384
5385 /* PyObjectCall */
5386 #if CYTHON_COMPILING_IN_CPYTHON
5387 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
5388 PyObject *result;
5389 ternaryfunc call = func->ob_type->tp_call;
5390 if (unlikely(!call))
5391 return PyObject_Call(func, arg, kw);
5392 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5393 return NULL;
5394 result = (*call)(func, arg, kw);
5395 Py_LeaveRecursiveCall();
5396 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5397 PyErr_SetString(
5398 PyExc_SystemError,
5399 "NULL result without error in PyObject_Call");
5400 }
5401 return result;
5402 }
5403 #endif
5404
5405 /* PyCFunctionFastCall */
5406 #if CYTHON_FAST_PYCCALL
5407 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
5408 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
5409 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
5410 PyObject *self = PyCFunction_GET_SELF(func);
5411 int flags = PyCFunction_GET_FLAGS(func);
5412 assert(PyCFunction_Check(func));
5413 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
5414 assert(nargs >= 0);
5415 assert(nargs == 0 || args != NULL);
5416 /* _PyCFunction_FastCallDict() must not be called with an exception set,
5417 because it may clear it (directly or indirectly) and so the
5418 caller loses its exception */
5419 assert(!PyErr_Occurred());
5420 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
5421 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
5422 } else {
5423 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
5424 }
5425 }
5426 #endif
5427
5428 /* PyFunctionFastCall */
5429 #if CYTHON_FAST_PYCALL
5430 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
5431 PyObject *globals) {
5432 PyFrameObject *f;
5433 PyThreadState *tstate = __Pyx_PyThreadState_Current;
5434 PyObject **fastlocals;
5435 Py_ssize_t i;
5436 PyObject *result;
5437 assert(globals != NULL);
5438 /* XXX Perhaps we should create a specialized
5439 PyFrame_New() that doesn't take locals, but does
5440 take builtins without sanity checking them.
5441 */
5442 assert(tstate != NULL);
5443 f = PyFrame_New(tstate, co, globals, NULL);
5444 if (f == NULL) {
5445 return NULL;
5446 }
5447 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
5448 for (i = 0; i < na; i++) {
5449 Py_INCREF(*args);
5450 fastlocals[i] = *args++;
5451 }
5452 result = PyEval_EvalFrameEx(f,0);
5453 ++tstate->recursion_depth;
5454 Py_DECREF(f);
5455 --tstate->recursion_depth;
5456 return result;
5457 }
5458 #if 1 || PY_VERSION_HEX < 0x030600B1
5459 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
5460 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
5461 PyObject *globals = PyFunction_GET_GLOBALS(func);
5462 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
5463 PyObject *closure;
5464 #if PY_MAJOR_VERSION >= 3
5465 PyObject *kwdefs;
5466 #endif
5467 PyObject *kwtuple, **k;
5468 PyObject **d;
5469 Py_ssize_t nd;
5470 Py_ssize_t nk;
5471 PyObject *result;
5472 assert(kwargs == NULL || PyDict_Check(kwargs));
5473 nk = kwargs ? PyDict_Size(kwargs) : 0;
5474 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
5475 return NULL;
5476 }
5477 if (
5478 #if PY_MAJOR_VERSION >= 3
5479 co->co_kwonlyargcount == 0 &&
5480 #endif
5481 likely(kwargs == NULL || nk == 0) &&
5482 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
5483 if (argdefs == NULL && co->co_argcount == nargs) {
5484 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
5485 goto done;
5486 }
5487 else if (nargs == 0 && argdefs != NULL
5488 && co->co_argcount == Py_SIZE(argdefs)) {
5489 /* function called with no arguments, but all parameters have
5490 a default value: use default values as arguments .*/
5491 args = &PyTuple_GET_ITEM(argdefs, 0);
5492 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
5493 goto done;
5494 }
5495 }
5496 if (kwargs != NULL) {
5497 Py_ssize_t pos, i;
5498 kwtuple = PyTuple_New(2 * nk);
5499 if (kwtuple == NULL) {
5500 result = NULL;
5501 goto done;
5502 }
5503 k = &PyTuple_GET_ITEM(kwtuple, 0);
5504 pos = i = 0;
5505 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
5506 Py_INCREF(k[i]);
5507 Py_INCREF(k[i+1]);
5508 i += 2;
5509 }
5510 nk = i / 2;
5511 }
5512 else {
5513 kwtuple = NULL;
5514 k = NULL;
5515 }
5516 closure = PyFunction_GET_CLOSURE(func);
5517 #if PY_MAJOR_VERSION >= 3
5518 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
5519 #endif
5520 if (argdefs != NULL) {
5521 d = &PyTuple_GET_ITEM(argdefs, 0);
5522 nd = Py_SIZE(argdefs);
5523 }
5524 else {
5525 d = NULL;
5526 nd = 0;
5527 }
5528 #if PY_MAJOR_VERSION >= 3
5529 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
5530 args, (int)nargs,
5531 k, (int)nk,
5532 d, (int)nd, kwdefs, closure);
5533 #else
5534 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
5535 args, (int)nargs,
5536 k, (int)nk,
5537 d, (int)nd, closure);
5538 #endif
5539 Py_XDECREF(kwtuple);
5540 done:
5541 Py_LeaveRecursiveCall();
5542 return result;
5543 }
5544 #endif
5545 #endif
5546
5547 /* PyObjectCall2Args */
5548 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
5549 PyObject *args, *result = NULL;
5550 #if CYTHON_FAST_PYCALL
5551 if (PyFunction_Check(function)) {
5552 PyObject *args[2] = {arg1, arg2};
5553 return __Pyx_PyFunction_FastCall(function, args, 2);
5554 }
5555 #endif
5556 #if CYTHON_FAST_PYCCALL
5557 if (__Pyx_PyFastCFunction_Check(function)) {
5558 PyObject *args[2] = {arg1, arg2};
5559 return __Pyx_PyCFunction_FastCall(function, args, 2);
5560 }
5561 #endif
5562 args = PyTuple_New(2);
5563 if (unlikely(!args)) goto done;
5564 Py_INCREF(arg1);
5565 PyTuple_SET_ITEM(args, 0, arg1);
5566 Py_INCREF(arg2);
5567 PyTuple_SET_ITEM(args, 1, arg2);
5568 Py_INCREF(function);
5569 result = __Pyx_PyObject_Call(function, args, NULL);
5570 Py_DECREF(args);
5571 Py_DECREF(function);
5572 done:
5573 return result;
5574 }
5575
5576 /* PyObjectCallMethO */
5577 #if CYTHON_COMPILING_IN_CPYTHON
5578 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
5579 PyObject *self, *result;
5580 PyCFunction cfunc;
5581 cfunc = PyCFunction_GET_FUNCTION(func);
5582 self = PyCFunction_GET_SELF(func);
5583 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
5584 return NULL;
5585 result = cfunc(self, arg);
5586 Py_LeaveRecursiveCall();
5587 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
5588 PyErr_SetString(
5589 PyExc_SystemError,
5590 "NULL result without error in PyObject_Call");
5591 }
5592 return result;
5593 }
5594 #endif
5595
5596 /* PyObjectCallOneArg */
5597 #if CYTHON_COMPILING_IN_CPYTHON
5598 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5599 PyObject *result;
5600 PyObject *args = PyTuple_New(1);
5601 if (unlikely(!args)) return NULL;
5602 Py_INCREF(arg);
5603 PyTuple_SET_ITEM(args, 0, arg);
5604 result = __Pyx_PyObject_Call(func, args, NULL);
5605 Py_DECREF(args);
5606 return result;
5607 }
5608 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5609 #if CYTHON_FAST_PYCALL
5610 if (PyFunction_Check(func)) {
5611 return __Pyx_PyFunction_FastCall(func, &arg, 1);
5612 }
5613 #endif
5614 if (likely(PyCFunction_Check(func))) {
5615 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
5616 return __Pyx_PyObject_CallMethO(func, arg);
5617 #if CYTHON_FAST_PYCCALL
5618 } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) {
5619 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
5620 #endif
5621 }
5622 }
5623 return __Pyx__PyObject_CallOneArg(func, arg);
5624 }
5625 #else
5626 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
5627 PyObject *result;
5628 PyObject *args = PyTuple_Pack(1, arg);
5629 if (unlikely(!args)) return NULL;
5630 result = __Pyx_PyObject_Call(func, args, NULL);
5631 Py_DECREF(args);
5632 return result;
5633 }
5634 #endif
5635
5636 /* PyObjectSetAttrStr */
5637 #if CYTHON_USE_TYPE_SLOTS
5638 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
5639 PyTypeObject* tp = Py_TYPE(obj);
5640 if (likely(tp->tp_setattro))
5641 return tp->tp_setattro(obj, attr_name, value);
5642 #if PY_MAJOR_VERSION < 3
5643 if (likely(tp->tp_setattr))
5644 return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
5645 #endif
5646 return PyObject_SetAttr(obj, attr_name, value);
5647 }
5648 #endif
5649
5650 /* PyDictVersioning */
5651 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
5652 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
5653 PyObject *dict = Py_TYPE(obj)->tp_dict;
5654 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
5655 }
5656 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
5657 PyObject **dictptr = NULL;
5658 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
5659 if (offset) {
5660 #if CYTHON_COMPILING_IN_CPYTHON
5661 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
5662 #else
5663 dictptr = _PyObject_GetDictPtr(obj);
5664 #endif
5665 }
5666 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
5667 }
5668 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
5669 PyObject *dict = Py_TYPE(obj)->tp_dict;
5670 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
5671 return 0;
5672 return obj_dict_version == __Pyx_get_object_dict_version(obj);
5673 }
5674 #endif
5675
5676 /* GetModuleGlobalName */
5677 #if CYTHON_USE_DICT_VERSIONS
5678 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
5679 #else
5680 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
5681 #endif
5682 {
5683 PyObject *result;
5684 #if !CYTHON_AVOID_BORROWED_REFS
5685 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
5686 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
5687 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5688 if (likely(result)) {
5689 return __Pyx_NewRef(result);
5690 } else if (unlikely(PyErr_Occurred())) {
5691 return NULL;
5692 }
5693 #else
5694 result = PyDict_GetItem(__pyx_d, name);
5695 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5696 if (likely(result)) {
5697 return __Pyx_NewRef(result);
5698 }
5699 #endif
5700 #else
5701 result = PyObject_GetItem(__pyx_d, name);
5702 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
5703 if (likely(result)) {
5704 return __Pyx_NewRef(result);
5705 }
5706 PyErr_Clear();
5707 #endif
5708 return __Pyx_GetBuiltinName(name);
5709 }
5710
5711 /* decode_c_string */
5712 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
5713 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
5714 const char* encoding, const char* errors,
5715 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
5716 Py_ssize_t length;
5717 if (unlikely((start < 0) | (stop < 0))) {
5718 size_t slen = strlen(cstring);
5719 if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
5720 PyErr_SetString(PyExc_OverflowError,
5721 "c-string too long to convert to Python");
5722 return NULL;
5723 }
5724 length = (Py_ssize_t) slen;
5725 if (start < 0) {
5726 start += length;
5727 if (start < 0)
5728 start = 0;
5729 }
5730 if (stop < 0)
5731 stop += length;
5732 }
5733 length = stop - start;
5734 if (unlikely(length <= 0))
5735 return PyUnicode_FromUnicode(NULL, 0);
5736 cstring += start;
5737 if (decode_func) {
5738 return decode_func(cstring, length, errors);
5739 } else {
5740 return PyUnicode_Decode(cstring, length, encoding, errors);
5741 }
5742 }
5743
5744 /* GetTopmostException */
5745 #if CYTHON_USE_EXC_INFO_STACK
5746 static _PyErr_StackItem *
5747 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
5748 {
5749 _PyErr_StackItem *exc_info = tstate->exc_info;
5750 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
5751 exc_info->previous_item != NULL)
5752 {
5753 exc_info = exc_info->previous_item;
5754 }
5755 return exc_info;
5756 }
5757 #endif
5758
5759 /* SaveResetException */
5760 #if CYTHON_FAST_THREAD_STATE
5761 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
5762 #if CYTHON_USE_EXC_INFO_STACK
5763 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
5764 *type = exc_info->exc_type;
5765 *value = exc_info->exc_value;
5766 *tb = exc_info->exc_traceback;
5767 #else
5768 *type = tstate->exc_type;
5769 *value = tstate->exc_value;
5770 *tb = tstate->exc_traceback;
5771 #endif
5772 Py_XINCREF(*type);
5773 Py_XINCREF(*value);
5774 Py_XINCREF(*tb);
5775 }
5776 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
5777 PyObject *tmp_type, *tmp_value, *tmp_tb;
5778 #if CYTHON_USE_EXC_INFO_STACK
5779 _PyErr_StackItem *exc_info = tstate->exc_info;
5780 tmp_type = exc_info->exc_type;
5781 tmp_value = exc_info->exc_value;
5782 tmp_tb = exc_info->exc_traceback;
5783 exc_info->exc_type = type;
5784 exc_info->exc_value = value;
5785 exc_info->exc_traceback = tb;
5786 #else
5787 tmp_type = tstate->exc_type;
5788 tmp_value = tstate->exc_value;
5789 tmp_tb = tstate->exc_traceback;
5790 tstate->exc_type = type;
5791 tstate->exc_value = value;
5792 tstate->exc_traceback = tb;
5793 #endif
5794 Py_XDECREF(tmp_type);
5795 Py_XDECREF(tmp_value);
5796 Py_XDECREF(tmp_tb);
5797 }
5798 #endif
5799
5800 /* PyErrExceptionMatches */
5801 #if CYTHON_FAST_THREAD_STATE
5802 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
5803 Py_ssize_t i, n;
5804 n = PyTuple_GET_SIZE(tuple);
5805 #if PY_MAJOR_VERSION >= 3
5806 for (i=0; i<n; i++) {
5807 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
5808 }
5809 #endif
5810 for (i=0; i<n; i++) {
5811 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
5812 }
5813 return 0;
5814 }
5815 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
5816 PyObject *exc_type = tstate->curexc_type;
5817 if (exc_type == err) return 1;
5818 if (unlikely(!exc_type)) return 0;
5819 if (unlikely(PyTuple_Check(err)))
5820 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
5821 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
5822 }
5823 #endif
5824
5825 /* GetException */
5826 #if CYTHON_FAST_THREAD_STATE
5827 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
5828 #else
5829 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
5830 #endif
5831 {
5832 PyObject *local_type, *local_value, *local_tb;
5833 #if CYTHON_FAST_THREAD_STATE
5834 PyObject *tmp_type, *tmp_value, *tmp_tb;
5835 local_type = tstate->curexc_type;
5836 local_value = tstate->curexc_value;
5837 local_tb = tstate->curexc_traceback;
5838 tstate->curexc_type = 0;
5839 tstate->curexc_value = 0;
5840 tstate->curexc_traceback = 0;
5841 #else
5842 PyErr_Fetch(&local_type, &local_value, &local_tb);
5843 #endif
5844 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
5845 #if CYTHON_FAST_THREAD_STATE
5846 if (unlikely(tstate->curexc_type))
5847 #else
5848 if (unlikely(PyErr_Occurred()))
5849 #endif
5850 goto bad;
5851 #if PY_MAJOR_VERSION >= 3
5852 if (local_tb) {
5853 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
5854 goto bad;
5855 }
5856 #endif
5857 Py_XINCREF(local_tb);
5858 Py_XINCREF(local_type);
5859 Py_XINCREF(local_value);
5860 *type = local_type;
5861 *value = local_value;
5862 *tb = local_tb;
5863 #if CYTHON_FAST_THREAD_STATE
5864 #if CYTHON_USE_EXC_INFO_STACK
5865 {
5866 _PyErr_StackItem *exc_info = tstate->exc_info;
5867 tmp_type = exc_info->exc_type;
5868 tmp_value = exc_info->exc_value;
5869 tmp_tb = exc_info->exc_traceback;
5870 exc_info->exc_type = local_type;
5871 exc_info->exc_value = local_value;
5872 exc_info->exc_traceback = local_tb;
5873 }
5874 #else
5875 tmp_type = tstate->exc_type;
5876 tmp_value = tstate->exc_value;
5877 tmp_tb = tstate->exc_traceback;
5878 tstate->exc_type = local_type;
5879 tstate->exc_value = local_value;
5880 tstate->exc_traceback = local_tb;
5881 #endif
5882 Py_XDECREF(tmp_type);
5883 Py_XDECREF(tmp_value);
5884 Py_XDECREF(tmp_tb);
5885 #else
5886 PyErr_SetExcInfo(local_type, local_value, local_tb);
5887 #endif
5888 return 0;
5889 bad:
5890 *type = 0;
5891 *value = 0;
5892 *tb = 0;
5893 Py_XDECREF(local_type);
5894 Py_XDECREF(local_value);
5895 Py_XDECREF(local_tb);
5896 return -1;
5897 }
5898
5899 /* GetItemInt */
5900 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
5901 PyObject *r;
5902 if (!j) return NULL;
5903 r = PyObject_GetItem(o, j);
5904 Py_DECREF(j);
5905 return r;
5906 }
5907 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
5908 CYTHON_NCP_UNUSED int wraparound,
5909 CYTHON_NCP_UNUSED int boundscheck) {
5910 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5911 Py_ssize_t wrapped_i = i;
5912 if (wraparound & unlikely(i < 0)) {
5913 wrapped_i += PyList_GET_SIZE(o);
5914 }
5915 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
5916 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
5917 Py_INCREF(r);
5918 return r;
5919 }
5920 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5921 #else
5922 return PySequence_GetItem(o, i);
5923 #endif
5924 }
5925 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
5926 CYTHON_NCP_UNUSED int wraparound,
5927 CYTHON_NCP_UNUSED int boundscheck) {
5928 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
5929 Py_ssize_t wrapped_i = i;
5930 if (wraparound & unlikely(i < 0)) {
5931 wrapped_i += PyTuple_GET_SIZE(o);
5932 }
5933 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
5934 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
5935 Py_INCREF(r);
5936 return r;
5937 }
5938 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5939 #else
5940 return PySequence_GetItem(o, i);
5941 #endif
5942 }
5943 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
5944 CYTHON_NCP_UNUSED int wraparound,
5945 CYTHON_NCP_UNUSED int boundscheck) {
5946 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
5947 if (is_list || PyList_CheckExact(o)) {
5948 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
5949 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
5950 PyObject *r = PyList_GET_ITEM(o, n);
5951 Py_INCREF(r);
5952 return r;
5953 }
5954 }
5955 else if (PyTuple_CheckExact(o)) {
5956 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
5957 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
5958 PyObject *r = PyTuple_GET_ITEM(o, n);
5959 Py_INCREF(r);
5960 return r;
5961 }
5962 } else {
5963 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
5964 if (likely(m && m->sq_item)) {
5965 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
5966 Py_ssize_t l = m->sq_length(o);
5967 if (likely(l >= 0)) {
5968 i += l;
5969 } else {
5970 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
5971 return NULL;
5972 PyErr_Clear();
5973 }
5974 }
5975 return m->sq_item(o, i);
5976 }
5977 }
5978 #else
5979 if (is_list || PySequence_Check(o)) {
5980 return PySequence_GetItem(o, i);
5981 }
5982 #endif
5983 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
5984 }
5985
5986 /* PyObjectCallNoArg */
5987 #if CYTHON_COMPILING_IN_CPYTHON
5988 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
5989 #if CYTHON_FAST_PYCALL
5990 if (PyFunction_Check(func)) {
5991 return __Pyx_PyFunction_FastCall(func, NULL, 0);
5992 }
5993 #endif
5994 #ifdef __Pyx_CyFunction_USED
5995 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
5996 #else
5997 if (likely(PyCFunction_Check(func)))
5998 #endif
5999 {
6000 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
6001 return __Pyx_PyObject_CallMethO(func, NULL);
6002 }
6003 }
6004 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
6005 }
6006 #endif
6007
6008 /* PyErrFetchRestore */
6009 #if CYTHON_FAST_THREAD_STATE
6010 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
6011 PyObject *tmp_type, *tmp_value, *tmp_tb;
6012 tmp_type = tstate->curexc_type;
6013 tmp_value = tstate->curexc_value;
6014 tmp_tb = tstate->curexc_traceback;
6015 tstate->curexc_type = type;
6016 tstate->curexc_value = value;
6017 tstate->curexc_traceback = tb;
6018 Py_XDECREF(tmp_type);
6019 Py_XDECREF(tmp_value);
6020 Py_XDECREF(tmp_tb);
6021 }
6022 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
6023 *type = tstate->curexc_type;
6024 *value = tstate->curexc_value;
6025 *tb = tstate->curexc_traceback;
6026 tstate->curexc_type = 0;
6027 tstate->curexc_value = 0;
6028 tstate->curexc_traceback = 0;
6029 }
6030 #endif
6031
6032 /* RaiseException */
6033 #if PY_MAJOR_VERSION < 3
6034 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
6035 CYTHON_UNUSED PyObject *cause) {
6036 __Pyx_PyThreadState_declare
6037 Py_XINCREF(type);
6038 if (!value || value == Py_None)
6039 value = NULL;
6040 else
6041 Py_INCREF(value);
6042 if (!tb || tb == Py_None)
6043 tb = NULL;
6044 else {
6045 Py_INCREF(tb);
6046 if (!PyTraceBack_Check(tb)) {
6047 PyErr_SetString(PyExc_TypeError,
6048 "raise: arg 3 must be a traceback or None");
6049 goto raise_error;
6050 }
6051 }
6052 if (PyType_Check(type)) {
6053 #if CYTHON_COMPILING_IN_PYPY
6054 if (!value) {
6055 Py_INCREF(Py_None);
6056 value = Py_None;
6057 }
6058 #endif
6059 PyErr_NormalizeException(&type, &value, &tb);
6060 } else {
6061 if (value) {
6062 PyErr_SetString(PyExc_TypeError,
6063 "instance exception may not have a separate value");
6064 goto raise_error;
6065 }
6066 value = type;
6067 type = (PyObject*) Py_TYPE(type);
6068 Py_INCREF(type);
6069 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
6070 PyErr_SetString(PyExc_TypeError,
6071 "raise: exception class must be a subclass of BaseException");
6072 goto raise_error;
6073 }
6074 }
6075 __Pyx_PyThreadState_assign
6076 __Pyx_ErrRestore(type, value, tb);
6077 return;
6078 raise_error:
6079 Py_XDECREF(value);
6080 Py_XDECREF(type);
6081 Py_XDECREF(tb);
6082 return;
6083 }
6084 #else
6085 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
6086 PyObject* owned_instance = NULL;
6087 if (tb == Py_None) {
6088 tb = 0;
6089 } else if (tb && !PyTraceBack_Check(tb)) {
6090 PyErr_SetString(PyExc_TypeError,
6091 "raise: arg 3 must be a traceback or None");
6092 goto bad;
6093 }
6094 if (value == Py_None)
6095 value = 0;
6096 if (PyExceptionInstance_Check(type)) {
6097 if (value) {
6098 PyErr_SetString(PyExc_TypeError,
6099 "instance exception may not have a separate value");
6100 goto bad;
6101 }
6102 value = type;
6103 type = (PyObject*) Py_TYPE(value);
6104 } else if (PyExceptionClass_Check(type)) {
6105 PyObject *instance_class = NULL;
6106 if (value && PyExceptionInstance_Check(value)) {
6107 instance_class = (PyObject*) Py_TYPE(value);
6108 if (instance_class != type) {
6109 int is_subclass = PyObject_IsSubclass(instance_class, type);
6110 if (!is_subclass) {
6111 instance_class = NULL;
6112 } else if (unlikely(is_subclass == -1)) {
6113 goto bad;
6114 } else {
6115 type = instance_class;
6116 }
6117 }
6118 }
6119 if (!instance_class) {
6120 PyObject *args;
6121 if (!value)
6122 args = PyTuple_New(0);
6123 else if (PyTuple_Check(value)) {
6124 Py_INCREF(value);
6125 args = value;
6126 } else
6127 args = PyTuple_Pack(1, value);
6128 if (!args)
6129 goto bad;
6130 owned_instance = PyObject_Call(type, args, NULL);
6131 Py_DECREF(args);
6132 if (!owned_instance)
6133 goto bad;
6134 value = owned_instance;
6135 if (!PyExceptionInstance_Check(value)) {
6136 PyErr_Format(PyExc_TypeError,
6137 "calling %R should have returned an instance of "
6138 "BaseException, not %R",
6139 type, Py_TYPE(value));
6140 goto bad;
6141 }
6142 }
6143 } else {
6144 PyErr_SetString(PyExc_TypeError,
6145 "raise: exception class must be a subclass of BaseException");
6146 goto bad;
6147 }
6148 if (cause) {
6149 PyObject *fixed_cause;
6150 if (cause == Py_None) {
6151 fixed_cause = NULL;
6152 } else if (PyExceptionClass_Check(cause)) {
6153 fixed_cause = PyObject_CallObject(cause, NULL);
6154 if (fixed_cause == NULL)
6155 goto bad;
6156 } else if (PyExceptionInstance_Check(cause)) {
6157 fixed_cause = cause;
6158 Py_INCREF(fixed_cause);
6159 } else {
6160 PyErr_SetString(PyExc_TypeError,
6161 "exception causes must derive from "
6162 "BaseException");
6163 goto bad;
6164 }
6165 PyException_SetCause(value, fixed_cause);
6166 }
6167 PyErr_SetObject(type, value);
6168 if (tb) {
6169 #if CYTHON_COMPILING_IN_PYPY
6170 PyObject *tmp_type, *tmp_value, *tmp_tb;
6171 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
6172 Py_INCREF(tb);
6173 PyErr_Restore(tmp_type, tmp_value, tb);
6174 Py_XDECREF(tmp_tb);
6175 #else
6176 PyThreadState *tstate = __Pyx_PyThreadState_Current;
6177 PyObject* tmp_tb = tstate->curexc_traceback;
6178 if (tb != tmp_tb) {
6179 Py_INCREF(tb);
6180 tstate->curexc_traceback = tb;
6181 Py_XDECREF(tmp_tb);
6182 }
6183 #endif
6184 }
6185 bad:
6186 Py_XDECREF(owned_instance);
6187 return;
6188 }
6189 #endif
6190
6191 /* DictGetItem */
6192 #if PY_MAJOR_VERSION >= 3 && !CYTHON_COMPILING_IN_PYPY
6193 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
6194 PyObject *value;
6195 value = PyDict_GetItemWithError(d, key);
6196 if (unlikely(!value)) {
6197 if (!PyErr_Occurred()) {
6198 if (unlikely(PyTuple_Check(key))) {
6199 PyObject* args = PyTuple_Pack(1, key);
6200 if (likely(args)) {
6201 PyErr_SetObject(PyExc_KeyError, args);
6202 Py_DECREF(args);
6203 }
6204 } else {
6205 PyErr_SetObject(PyExc_KeyError, key);
6206 }
6207 }
6208 return NULL;
6209 }
6210 Py_INCREF(value);
6211 return value;
6212 }
6213 #endif
6214
6215 /* BytesEquals */
6216 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
6217 #if CYTHON_COMPILING_IN_PYPY
6218 return PyObject_RichCompareBool(s1, s2, equals);
6219 #else
6220 if (s1 == s2) {
6221 return (equals == Py_EQ);
6222 } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
6223 const char *ps1, *ps2;
6224 Py_ssize_t length = PyBytes_GET_SIZE(s1);
6225 if (length != PyBytes_GET_SIZE(s2))
6226 return (equals == Py_NE);
6227 ps1 = PyBytes_AS_STRING(s1);
6228 ps2 = PyBytes_AS_STRING(s2);
6229 if (ps1[0] != ps2[0]) {
6230 return (equals == Py_NE);
6231 } else if (length == 1) {
6232 return (equals == Py_EQ);
6233 } else {
6234 int result;
6235 #if CYTHON_USE_UNICODE_INTERNALS
6236 Py_hash_t hash1, hash2;
6237 hash1 = ((PyBytesObject*)s1)->ob_shash;
6238 hash2 = ((PyBytesObject*)s2)->ob_shash;
6239 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
6240 return (equals == Py_NE);
6241 }
6242 #endif
6243 result = memcmp(ps1, ps2, (size_t)length);
6244 return (equals == Py_EQ) ? (result == 0) : (result != 0);
6245 }
6246 } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
6247 return (equals == Py_NE);
6248 } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
6249 return (equals == Py_NE);
6250 } else {
6251 int result;
6252 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
6253 if (!py_result)
6254 return -1;
6255 result = __Pyx_PyObject_IsTrue(py_result);
6256 Py_DECREF(py_result);
6257 return result;
6258 }
6259 #endif
6260 }
6261
6262 /* UnicodeEquals */
6263 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
6264 #if CYTHON_COMPILING_IN_PYPY
6265 return PyObject_RichCompareBool(s1, s2, equals);
6266 #else
6267 #if PY_MAJOR_VERSION < 3
6268 PyObject* owned_ref = NULL;
6269 #endif
6270 int s1_is_unicode, s2_is_unicode;
6271 if (s1 == s2) {
6272 goto return_eq;
6273 }
6274 s1_is_unicode = PyUnicode_CheckExact(s1);
6275 s2_is_unicode = PyUnicode_CheckExact(s2);
6276 #if PY_MAJOR_VERSION < 3
6277 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
6278 owned_ref = PyUnicode_FromObject(s2);
6279 if (unlikely(!owned_ref))
6280 return -1;
6281 s2 = owned_ref;
6282 s2_is_unicode = 1;
6283 } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
6284 owned_ref = PyUnicode_FromObject(s1);
6285 if (unlikely(!owned_ref))
6286 return -1;
6287 s1 = owned_ref;
6288 s1_is_unicode = 1;
6289 } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
6290 return __Pyx_PyBytes_Equals(s1, s2, equals);
6291 }
6292 #endif
6293 if (s1_is_unicode & s2_is_unicode) {
6294 Py_ssize_t length;
6295 int kind;
6296 void *data1, *data2;
6297 if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
6298 return -1;
6299 length = __Pyx_PyUnicode_GET_LENGTH(s1);
6300 if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
6301 goto return_ne;
6302 }
6303 #if CYTHON_USE_UNICODE_INTERNALS
6304 {
6305 Py_hash_t hash1, hash2;
6306 #if CYTHON_PEP393_ENABLED
6307 hash1 = ((PyASCIIObject*)s1)->hash;
6308 hash2 = ((PyASCIIObject*)s2)->hash;
6309 #else
6310 hash1 = ((PyUnicodeObject*)s1)->hash;
6311 hash2 = ((PyUnicodeObject*)s2)->hash;
6312 #endif
6313 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
6314 goto return_ne;
6315 }
6316 }
6317 #endif
6318 kind = __Pyx_PyUnicode_KIND(s1);
6319 if (kind != __Pyx_PyUnicode_KIND(s2)) {
6320 goto return_ne;
6321 }
6322 data1 = __Pyx_PyUnicode_DATA(s1);
6323 data2 = __Pyx_PyUnicode_DATA(s2);
6324 if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
6325 goto return_ne;
6326 } else if (length == 1) {
6327 goto return_eq;
6328 } else {
6329 int result = memcmp(data1, data2, (size_t)(length * kind));
6330 #if PY_MAJOR_VERSION < 3
6331 Py_XDECREF(owned_ref);
6332 #endif
6333 return (equals == Py_EQ) ? (result == 0) : (result != 0);
6334 }
6335 } else if ((s1 == Py_None) & s2_is_unicode) {
6336 goto return_ne;
6337 } else if ((s2 == Py_None) & s1_is_unicode) {
6338 goto return_ne;
6339 } else {
6340 int result;
6341 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
6342 #if PY_MAJOR_VERSION < 3
6343 Py_XDECREF(owned_ref);
6344 #endif
6345 if (!py_result)
6346 return -1;
6347 result = __Pyx_PyObject_IsTrue(py_result);
6348 Py_DECREF(py_result);
6349 return result;
6350 }
6351 return_eq:
6352 #if PY_MAJOR_VERSION < 3
6353 Py_XDECREF(owned_ref);
6354 #endif
6355 return (equals == Py_EQ);
6356 return_ne:
6357 #if PY_MAJOR_VERSION < 3
6358 Py_XDECREF(owned_ref);
6359 #endif
6360 return (equals == Py_NE);
6361 #endif
6362 }
6363
6364 /* SliceObject */
6365 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
6366 Py_ssize_t cstart, Py_ssize_t cstop,
6367 PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
6368 int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
6369 #if CYTHON_USE_TYPE_SLOTS
6370 PyMappingMethods* mp;
6371 #if PY_MAJOR_VERSION < 3
6372 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
6373 if (likely(ms && ms->sq_slice)) {
6374 if (!has_cstart) {
6375 if (_py_start && (*_py_start != Py_None)) {
6376 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
6377 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
6378 } else
6379 cstart = 0;
6380 }
6381 if (!has_cstop) {
6382 if (_py_stop && (*_py_stop != Py_None)) {
6383 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
6384 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
6385 } else
6386 cstop = PY_SSIZE_T_MAX;
6387 }
6388 if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
6389 Py_ssize_t l = ms->sq_length(obj);
6390 if (likely(l >= 0)) {
6391 if (cstop < 0) {
6392 cstop += l;
6393 if (cstop < 0) cstop = 0;
6394 }
6395 if (cstart < 0) {
6396 cstart += l;
6397 if (cstart < 0) cstart = 0;
6398 }
6399 } else {
6400 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
6401 goto bad;
6402 PyErr_Clear();
6403 }
6404 }
6405 return ms->sq_slice(obj, cstart, cstop);
6406 }
6407 #endif
6408 mp = Py_TYPE(obj)->tp_as_mapping;
6409 if (likely(mp && mp->mp_subscript))
6410 #endif
6411 {
6412 PyObject* result;
6413 PyObject *py_slice, *py_start, *py_stop;
6414 if (_py_slice) {
6415 py_slice = *_py_slice;
6416 } else {
6417 PyObject* owned_start = NULL;
6418 PyObject* owned_stop = NULL;
6419 if (_py_start) {
6420 py_start = *_py_start;
6421 } else {
6422 if (has_cstart) {
6423 owned_start = py_start = PyInt_FromSsize_t(cstart);
6424 if (unlikely(!py_start)) goto bad;
6425 } else
6426 py_start = Py_None;
6427 }
6428 if (_py_stop) {
6429 py_stop = *_py_stop;
6430 } else {
6431 if (has_cstop) {
6432 owned_stop = py_stop = PyInt_FromSsize_t(cstop);
6433 if (unlikely(!py_stop)) {
6434 Py_XDECREF(owned_start);
6435 goto bad;
6436 }
6437 } else
6438 py_stop = Py_None;
6439 }
6440 py_slice = PySlice_New(py_start, py_stop, Py_None);
6441 Py_XDECREF(owned_start);
6442 Py_XDECREF(owned_stop);
6443 if (unlikely(!py_slice)) goto bad;
6444 }
6445 #if CYTHON_USE_TYPE_SLOTS
6446 result = mp->mp_subscript(obj, py_slice);
6447 #else
6448 result = PyObject_GetItem(obj, py_slice);
6449 #endif
6450 if (!_py_slice) {
6451 Py_DECREF(py_slice);
6452 }
6453 return result;
6454 }
6455 PyErr_Format(PyExc_TypeError,
6456 "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
6457 bad:
6458 return NULL;
6459 }
6460
6461 /* TypeImport */
6462 #ifndef __PYX_HAVE_RT_ImportType
6463 #define __PYX_HAVE_RT_ImportType
6464 static PyTypeObject *__Pyx_ImportType(PyObject *module, const char *module_name, const char *class_name,
6465 size_t size, enum __Pyx_ImportType_CheckSize check_size)
6466 {
6467 PyObject *result = 0;
6468 char warning[200];
6469 Py_ssize_t basicsize;
6470 #ifdef Py_LIMITED_API
6471 PyObject *py_basicsize;
6472 #endif
6473 result = PyObject_GetAttrString(module, class_name);
6474 if (!result)
6475 goto bad;
6476 if (!PyType_Check(result)) {
6477 PyErr_Format(PyExc_TypeError,
6478 "%.200s.%.200s is not a type object",
6479 module_name, class_name);
6480 goto bad;
6481 }
6482 #ifndef Py_LIMITED_API
6483 basicsize = ((PyTypeObject *)result)->tp_basicsize;
6484 #else
6485 py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
6486 if (!py_basicsize)
6487 goto bad;
6488 basicsize = PyLong_AsSsize_t(py_basicsize);
6489 Py_DECREF(py_basicsize);
6490 py_basicsize = 0;
6491 if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
6492 goto bad;
6493 #endif
6494 if ((size_t)basicsize < size) {
6495 PyErr_Format(PyExc_ValueError,
6496 "%.200s.%.200s size changed, may indicate binary incompatibility. "
6497 "Expected %zd from C header, got %zd from PyObject",
6498 module_name, class_name, size, basicsize);
6499 goto bad;
6500 }
6501 if (check_size == __Pyx_ImportType_CheckSize_Error && (size_t)basicsize != size) {
6502 PyErr_Format(PyExc_ValueError,
6503 "%.200s.%.200s size changed, may indicate binary incompatibility. "
6504 "Expected %zd from C header, got %zd from PyObject",
6505 module_name, class_name, size, basicsize);
6506 goto bad;
6507 }
6508 else if (check_size == __Pyx_ImportType_CheckSize_Warn && (size_t)basicsize > size) {
6509 PyOS_snprintf(warning, sizeof(warning),
6510 "%s.%s size changed, may indicate binary incompatibility. "
6511 "Expected %zd from C header, got %zd from PyObject",
6512 module_name, class_name, size, basicsize);
6513 if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
6514 }
6515 return (PyTypeObject *)result;
6516 bad:
6517 Py_XDECREF(result);
6518 return NULL;
6519 }
6520 #endif
6521
6522 /* Import */
6523 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
6524 PyObject *empty_list = 0;
6525 PyObject *module = 0;
6526 PyObject *global_dict = 0;
6527 PyObject *empty_dict = 0;
6528 PyObject *list;
6529 #if PY_MAJOR_VERSION < 3
6530 PyObject *py_import;
6531 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
6532 if (!py_import)
6533 goto bad;
6534 #endif
6535 if (from_list)
6536 list = from_list;
6537 else {
6538 empty_list = PyList_New(0);
6539 if (!empty_list)
6540 goto bad;
6541 list = empty_list;
6542 }
6543 global_dict = PyModule_GetDict(__pyx_m);
6544 if (!global_dict)
6545 goto bad;
6546 empty_dict = PyDict_New();
6547 if (!empty_dict)
6548 goto bad;
6549 {
6550 #if PY_MAJOR_VERSION >= 3
6551 if (level == -1) {
6552 if (strchr(__Pyx_MODULE_NAME, '.')) {
6553 module = PyImport_ImportModuleLevelObject(
6554 name, global_dict, empty_dict, list, 1);
6555 if (!module) {
6556 if (!PyErr_ExceptionMatches(PyExc_ImportError))
6557 goto bad;
6558 PyErr_Clear();
6559 }
6560 }
6561 level = 0;
6562 }
6563 #endif
6564 if (!module) {
6565 #if PY_MAJOR_VERSION < 3
6566 PyObject *py_level = PyInt_FromLong(level);
6567 if (!py_level)
6568 goto bad;
6569 module = PyObject_CallFunctionObjArgs(py_import,
6570 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
6571 Py_DECREF(py_level);
6572 #else
6573 module = PyImport_ImportModuleLevelObject(
6574 name, global_dict, empty_dict, list, level);
6575 #endif
6576 }
6577 }
6578 bad:
6579 #if PY_MAJOR_VERSION < 3
6580 Py_XDECREF(py_import);
6581 #endif
6582 Py_XDECREF(empty_list);
6583 Py_XDECREF(empty_dict);
6584 return module;
6585 }
6586
6587 /* ImportFrom */
6588 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
6589 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
6590 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
6591 PyErr_Format(PyExc_ImportError,
6592 #if PY_MAJOR_VERSION < 3
6593 "cannot import name %.230s", PyString_AS_STRING(name));
6594 #else
6595 "cannot import name %S", name);
6596 #endif
6597 }
6598 return value;
6599 }
6600
6601 /* CalculateMetaclass */
6602 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
6603 Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
6604 for (i=0; i < nbases; i++) {
6605 PyTypeObject *tmptype;
6606 PyObject *tmp = PyTuple_GET_ITEM(bases, i);
6607 tmptype = Py_TYPE(tmp);
6608 #if PY_MAJOR_VERSION < 3
6609 if (tmptype == &PyClass_Type)
6610 continue;
6611 #endif
6612 if (!metaclass) {
6613 metaclass = tmptype;
6614 continue;
6615 }
6616 if (PyType_IsSubtype(metaclass, tmptype))
6617 continue;
6618 if (PyType_IsSubtype(tmptype, metaclass)) {
6619 metaclass = tmptype;
6620 continue;
6621 }
6622 PyErr_SetString(PyExc_TypeError,
6623 "metaclass conflict: "
6624 "the metaclass of a derived class "
6625 "must be a (non-strict) subclass "
6626 "of the metaclasses of all its bases");
6627 return NULL;
6628 }
6629 if (!metaclass) {
6630 #if PY_MAJOR_VERSION < 3
6631 metaclass = &PyClass_Type;
6632 #else
6633 metaclass = &PyType_Type;
6634 #endif
6635 }
6636 Py_INCREF((PyObject*) metaclass);
6637 return (PyObject*) metaclass;
6638 }
6639
6640 /* FetchCommonType */
6641 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
6642 PyObject* fake_module;
6643 PyTypeObject* cached_type = NULL;
6644 fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
6645 if (!fake_module) return NULL;
6646 Py_INCREF(fake_module);
6647 cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
6648 if (cached_type) {
6649 if (!PyType_Check((PyObject*)cached_type)) {
6650 PyErr_Format(PyExc_TypeError,
6651 "Shared Cython type %.200s is not a type object",
6652 type->tp_name);
6653 goto bad;
6654 }
6655 if (cached_type->tp_basicsize != type->tp_basicsize) {
6656 PyErr_Format(PyExc_TypeError,
6657 "Shared Cython type %.200s has the wrong size, try recompiling",
6658 type->tp_name);
6659 goto bad;
6660 }
6661 } else {
6662 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
6663 PyErr_Clear();
6664 if (PyType_Ready(type) < 0) goto bad;
6665 if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
6666 goto bad;
6667 Py_INCREF(type);
6668 cached_type = type;
6669 }
6670 done:
6671 Py_DECREF(fake_module);
6672 return cached_type;
6673 bad:
6674 Py_XDECREF(cached_type);
6675 cached_type = NULL;
6676 goto done;
6677 }
6678
6679 /* CythonFunction */
6680 #include <structmember.h>
6681 static PyObject *
6682 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
6683 {
6684 if (unlikely(op->func_doc == NULL)) {
6685 if (op->func.m_ml->ml_doc) {
6686 #if PY_MAJOR_VERSION >= 3
6687 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
6688 #else
6689 op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
6690 #endif
6691 if (unlikely(op->func_doc == NULL))
6692 return NULL;
6693 } else {
6694 Py_INCREF(Py_None);
6695 return Py_None;
6696 }
6697 }
6698 Py_INCREF(op->func_doc);
6699 return op->func_doc;
6700 }
6701 static int
6702 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6703 {
6704 PyObject *tmp = op->func_doc;
6705 if (value == NULL) {
6706 value = Py_None;
6707 }
6708 Py_INCREF(value);
6709 op->func_doc = value;
6710 Py_XDECREF(tmp);
6711 return 0;
6712 }
6713 static PyObject *
6714 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6715 {
6716 if (unlikely(op->func_name == NULL)) {
6717 #if PY_MAJOR_VERSION >= 3
6718 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
6719 #else
6720 op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
6721 #endif
6722 if (unlikely(op->func_name == NULL))
6723 return NULL;
6724 }
6725 Py_INCREF(op->func_name);
6726 return op->func_name;
6727 }
6728 static int
6729 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6730 {
6731 PyObject *tmp;
6732 #if PY_MAJOR_VERSION >= 3
6733 if (unlikely(value == NULL || !PyUnicode_Check(value)))
6734 #else
6735 if (unlikely(value == NULL || !PyString_Check(value)))
6736 #endif
6737 {
6738 PyErr_SetString(PyExc_TypeError,
6739 "__name__ must be set to a string object");
6740 return -1;
6741 }
6742 tmp = op->func_name;
6743 Py_INCREF(value);
6744 op->func_name = value;
6745 Py_XDECREF(tmp);
6746 return 0;
6747 }
6748 static PyObject *
6749 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6750 {
6751 Py_INCREF(op->func_qualname);
6752 return op->func_qualname;
6753 }
6754 static int
6755 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6756 {
6757 PyObject *tmp;
6758 #if PY_MAJOR_VERSION >= 3
6759 if (unlikely(value == NULL || !PyUnicode_Check(value)))
6760 #else
6761 if (unlikely(value == NULL || !PyString_Check(value)))
6762 #endif
6763 {
6764 PyErr_SetString(PyExc_TypeError,
6765 "__qualname__ must be set to a string object");
6766 return -1;
6767 }
6768 tmp = op->func_qualname;
6769 Py_INCREF(value);
6770 op->func_qualname = value;
6771 Py_XDECREF(tmp);
6772 return 0;
6773 }
6774 static PyObject *
6775 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
6776 {
6777 PyObject *self;
6778 self = m->func_closure;
6779 if (self == NULL)
6780 self = Py_None;
6781 Py_INCREF(self);
6782 return self;
6783 }
6784 static PyObject *
6785 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6786 {
6787 if (unlikely(op->func_dict == NULL)) {
6788 op->func_dict = PyDict_New();
6789 if (unlikely(op->func_dict == NULL))
6790 return NULL;
6791 }
6792 Py_INCREF(op->func_dict);
6793 return op->func_dict;
6794 }
6795 static int
6796 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
6797 {
6798 PyObject *tmp;
6799 if (unlikely(value == NULL)) {
6800 PyErr_SetString(PyExc_TypeError,
6801 "function's dictionary may not be deleted");
6802 return -1;
6803 }
6804 if (unlikely(!PyDict_Check(value))) {
6805 PyErr_SetString(PyExc_TypeError,
6806 "setting function's dictionary to a non-dict");
6807 return -1;
6808 }
6809 tmp = op->func_dict;
6810 Py_INCREF(value);
6811 op->func_dict = value;
6812 Py_XDECREF(tmp);
6813 return 0;
6814 }
6815 static PyObject *
6816 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6817 {
6818 Py_INCREF(op->func_globals);
6819 return op->func_globals;
6820 }
6821 static PyObject *
6822 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6823 {
6824 Py_INCREF(Py_None);
6825 return Py_None;
6826 }
6827 static PyObject *
6828 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
6829 {
6830 PyObject* result = (op->func_code) ? op->func_code : Py_None;
6831 Py_INCREF(result);
6832 return result;
6833 }
6834 static int
6835 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
6836 int result = 0;
6837 PyObject *res = op->defaults_getter((PyObject *) op);
6838 if (unlikely(!res))
6839 return -1;
6840 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
6841 op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
6842 Py_INCREF(op->defaults_tuple);
6843 op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
6844 Py_INCREF(op->defaults_kwdict);
6845 #else
6846 op->defaults_tuple = PySequence_ITEM(res, 0);
6847 if (unlikely(!op->defaults_tuple)) result = -1;
6848 else {
6849 op->defaults_kwdict = PySequence_ITEM(res, 1);
6850 if (unlikely(!op->defaults_kwdict)) result = -1;
6851 }
6852 #endif
6853 Py_DECREF(res);
6854 return result;
6855 }
6856 static int
6857 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6858 PyObject* tmp;
6859 if (!value) {
6860 value = Py_None;
6861 } else if (value != Py_None && !PyTuple_Check(value)) {
6862 PyErr_SetString(PyExc_TypeError,
6863 "__defaults__ must be set to a tuple object");
6864 return -1;
6865 }
6866 Py_INCREF(value);
6867 tmp = op->defaults_tuple;
6868 op->defaults_tuple = value;
6869 Py_XDECREF(tmp);
6870 return 0;
6871 }
6872 static PyObject *
6873 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6874 PyObject* result = op->defaults_tuple;
6875 if (unlikely(!result)) {
6876 if (op->defaults_getter) {
6877 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
6878 result = op->defaults_tuple;
6879 } else {
6880 result = Py_None;
6881 }
6882 }
6883 Py_INCREF(result);
6884 return result;
6885 }
6886 static int
6887 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6888 PyObject* tmp;
6889 if (!value) {
6890 value = Py_None;
6891 } else if (value != Py_None && !PyDict_Check(value)) {
6892 PyErr_SetString(PyExc_TypeError,
6893 "__kwdefaults__ must be set to a dict object");
6894 return -1;
6895 }
6896 Py_INCREF(value);
6897 tmp = op->defaults_kwdict;
6898 op->defaults_kwdict = value;
6899 Py_XDECREF(tmp);
6900 return 0;
6901 }
6902 static PyObject *
6903 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6904 PyObject* result = op->defaults_kwdict;
6905 if (unlikely(!result)) {
6906 if (op->defaults_getter) {
6907 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
6908 result = op->defaults_kwdict;
6909 } else {
6910 result = Py_None;
6911 }
6912 }
6913 Py_INCREF(result);
6914 return result;
6915 }
6916 static int
6917 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
6918 PyObject* tmp;
6919 if (!value || value == Py_None) {
6920 value = NULL;
6921 } else if (!PyDict_Check(value)) {
6922 PyErr_SetString(PyExc_TypeError,
6923 "__annotations__ must be set to a dict object");
6924 return -1;
6925 }
6926 Py_XINCREF(value);
6927 tmp = op->func_annotations;
6928 op->func_annotations = value;
6929 Py_XDECREF(tmp);
6930 return 0;
6931 }
6932 static PyObject *
6933 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
6934 PyObject* result = op->func_annotations;
6935 if (unlikely(!result)) {
6936 result = PyDict_New();
6937 if (unlikely(!result)) return NULL;
6938 op->func_annotations = result;
6939 }
6940 Py_INCREF(result);
6941 return result;
6942 }
6943 static PyGetSetDef __pyx_CyFunction_getsets[] = {
6944 {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6945 {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
6946 {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6947 {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
6948 {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
6949 {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
6950 {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6951 {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
6952 {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6953 {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
6954 {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6955 {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
6956 {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6957 {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
6958 {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6959 {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
6960 {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
6961 {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
6962 {0, 0, 0, 0, 0}
6963 };
6964 static PyMemberDef __pyx_CyFunction_members[] = {
6965 {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
6966 {0, 0, 0, 0, 0}
6967 };
6968 static PyObject *
6969 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
6970 {
6971 #if PY_MAJOR_VERSION >= 3
6972 return PyUnicode_FromString(m->func.m_ml->ml_name);
6973 #else
6974 return PyString_FromString(m->func.m_ml->ml_name);
6975 #endif
6976 }
6977 static PyMethodDef __pyx_CyFunction_methods[] = {
6978 {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
6979 {0, 0, 0, 0}
6980 };
6981 #if PY_VERSION_HEX < 0x030500A0
6982 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
6983 #else
6984 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
6985 #endif
6986 static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
6987 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
6988 __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
6989 if (op == NULL)
6990 return NULL;
6991 op->flags = flags;
6992 __Pyx_CyFunction_weakreflist(op) = NULL;
6993 op->func.m_ml = ml;
6994 op->func.m_self = (PyObject *) op;
6995 Py_XINCREF(closure);
6996 op->func_closure = closure;
6997 Py_XINCREF(module);
6998 op->func.m_module = module;
6999 op->func_dict = NULL;
7000 op->func_name = NULL;
7001 Py_INCREF(qualname);
7002 op->func_qualname = qualname;
7003 op->func_doc = NULL;
7004 op->func_classobj = NULL;
7005 op->func_globals = globals;
7006 Py_INCREF(op->func_globals);
7007 Py_XINCREF(code);
7008 op->func_code = code;
7009 op->defaults_pyobjects = 0;
7010 op->defaults = NULL;
7011 op->defaults_tuple = NULL;
7012 op->defaults_kwdict = NULL;
7013 op->defaults_getter = NULL;
7014 op->func_annotations = NULL;
7015 PyObject_GC_Track(op);
7016 return (PyObject *) op;
7017 }
7018 static int
7019 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
7020 {
7021 Py_CLEAR(m->func_closure);
7022 Py_CLEAR(m->func.m_module);
7023 Py_CLEAR(m->func_dict);
7024 Py_CLEAR(m->func_name);
7025 Py_CLEAR(m->func_qualname);
7026 Py_CLEAR(m->func_doc);
7027 Py_CLEAR(m->func_globals);
7028 Py_CLEAR(m->func_code);
7029 Py_CLEAR(m->func_classobj);
7030 Py_CLEAR(m->defaults_tuple);
7031 Py_CLEAR(m->defaults_kwdict);
7032 Py_CLEAR(m->func_annotations);
7033 if (m->defaults) {
7034 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
7035 int i;
7036 for (i = 0; i < m->defaults_pyobjects; i++)
7037 Py_XDECREF(pydefaults[i]);
7038 PyObject_Free(m->defaults);
7039 m->defaults = NULL;
7040 }
7041 return 0;
7042 }
7043 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
7044 {
7045 if (__Pyx_CyFunction_weakreflist(m) != NULL)
7046 PyObject_ClearWeakRefs((PyObject *) m);
7047 __Pyx_CyFunction_clear(m);
7048 PyObject_GC_Del(m);
7049 }
7050 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
7051 {
7052 PyObject_GC_UnTrack(m);
7053 __Pyx__CyFunction_dealloc(m);
7054 }
7055 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
7056 {
7057 Py_VISIT(m->func_closure);
7058 Py_VISIT(m->func.m_module);
7059 Py_VISIT(m->func_dict);
7060 Py_VISIT(m->func_name);
7061 Py_VISIT(m->func_qualname);
7062 Py_VISIT(m->func_doc);
7063 Py_VISIT(m->func_globals);
7064 Py_VISIT(m->func_code);
7065 Py_VISIT(m->func_classobj);
7066 Py_VISIT(m->defaults_tuple);
7067 Py_VISIT(m->defaults_kwdict);
7068 if (m->defaults) {
7069 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
7070 int i;
7071 for (i = 0; i < m->defaults_pyobjects; i++)
7072 Py_VISIT(pydefaults[i]);
7073 }
7074 return 0;
7075 }
7076 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
7077 {
7078 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
7079 if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
7080 Py_INCREF(func);
7081 return func;
7082 }
7083 if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
7084 if (type == NULL)
7085 type = (PyObject *)(Py_TYPE(obj));
7086 return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
7087 }
7088 if (obj == Py_None)
7089 obj = NULL;
7090 return __Pyx_PyMethod_New(func, obj, type);
7091 }
7092 static PyObject*
7093 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
7094 {
7095 #if PY_MAJOR_VERSION >= 3
7096 return PyUnicode_FromFormat("<cyfunction %U at %p>",
7097 op->func_qualname, (void *)op);
7098 #else
7099 return PyString_FromFormat("<cyfunction %s at %p>",
7100 PyString_AsString(op->func_qualname), (void *)op);
7101 #endif
7102 }
7103 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
7104 PyCFunctionObject* f = (PyCFunctionObject*)func;
7105 PyCFunction meth = f->m_ml->ml_meth;
7106 Py_ssize_t size;
7107 switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
7108 case METH_VARARGS:
7109 if (likely(kw == NULL || PyDict_Size(kw) == 0))
7110 return (*meth)(self, arg);
7111 break;
7112 case METH_VARARGS | METH_KEYWORDS:
7113 return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
7114 case METH_NOARGS:
7115 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
7116 size = PyTuple_GET_SIZE(arg);
7117 if (likely(size == 0))
7118 return (*meth)(self, NULL);
7119 PyErr_Format(PyExc_TypeError,
7120 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
7121 f->m_ml->ml_name, size);
7122 return NULL;
7123 }
7124 break;
7125 case METH_O:
7126 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
7127 size = PyTuple_GET_SIZE(arg);
7128 if (likely(size == 1)) {
7129 PyObject *result, *arg0;
7130 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
7131 arg0 = PyTuple_GET_ITEM(arg, 0);
7132 #else
7133 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
7134 #endif
7135 result = (*meth)(self, arg0);
7136 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
7137 Py_DECREF(arg0);
7138 #endif
7139 return result;
7140 }
7141 PyErr_Format(PyExc_TypeError,
7142 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
7143 f->m_ml->ml_name, size);
7144 return NULL;
7145 }
7146 break;
7147 default:
7148 PyErr_SetString(PyExc_SystemError, "Bad call flags in "
7149 "__Pyx_CyFunction_Call. METH_OLDARGS is no "
7150 "longer supported!");
7151 return NULL;
7152 }
7153 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
7154 f->m_ml->ml_name);
7155 return NULL;
7156 }
7157 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
7158 return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
7159 }
7160 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
7161 PyObject *result;
7162 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
7163 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
7164 Py_ssize_t argc;
7165 PyObject *new_args;
7166 PyObject *self;
7167 argc = PyTuple_GET_SIZE(args);
7168 new_args = PyTuple_GetSlice(args, 1, argc);
7169 if (unlikely(!new_args))
7170 return NULL;
7171 self = PyTuple_GetItem(args, 0);
7172 if (unlikely(!self)) {
7173 Py_DECREF(new_args);
7174 return NULL;
7175 }
7176 result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
7177 Py_DECREF(new_args);
7178 } else {
7179 result = __Pyx_CyFunction_Call(func, args, kw);
7180 }
7181 return result;
7182 }
7183 static PyTypeObject __pyx_CyFunctionType_type = {
7184 PyVarObject_HEAD_INIT(0, 0)
7185 "cython_function_or_method",
7186 sizeof(__pyx_CyFunctionObject),
7187 0,
7188 (destructor) __Pyx_CyFunction_dealloc,
7189 0,
7190 0,
7191 0,
7192 #if PY_MAJOR_VERSION < 3
7193 0,
7194 #else
7195 0,
7196 #endif
7197 (reprfunc) __Pyx_CyFunction_repr,
7198 0,
7199 0,
7200 0,
7201 0,
7202 __Pyx_CyFunction_CallAsMethod,
7203 0,
7204 0,
7205 0,
7206 0,
7207 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
7208 0,
7209 (traverseproc) __Pyx_CyFunction_traverse,
7210 (inquiry) __Pyx_CyFunction_clear,
7211 0,
7212 #if PY_VERSION_HEX < 0x030500A0
7213 offsetof(__pyx_CyFunctionObject, func_weakreflist),
7214 #else
7215 offsetof(PyCFunctionObject, m_weakreflist),
7216 #endif
7217 0,
7218 0,
7219 __pyx_CyFunction_methods,
7220 __pyx_CyFunction_members,
7221 __pyx_CyFunction_getsets,
7222 0,
7223 0,
7224 __Pyx_CyFunction_descr_get,
7225 0,
7226 offsetof(__pyx_CyFunctionObject, func_dict),
7227 0,
7228 0,
7229 0,
7230 0,
7231 0,
7232 0,
7233 0,
7234 0,
7235 0,
7236 0,
7237 0,
7238 0,
7239 #if PY_VERSION_HEX >= 0x030400a1
7240 0,
7241 #endif
7242 #if PY_VERSION_HEX >= 0x030800b1
7243 0,
7244 #endif
7245 };
7246 static int __pyx_CyFunction_init(void) {
7247 __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
7248 if (unlikely(__pyx_CyFunctionType == NULL)) {
7249 return -1;
7250 }
7251 return 0;
7252 }
7253 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
7254 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
7255 m->defaults = PyObject_Malloc(size);
7256 if (unlikely(!m->defaults))
7257 return PyErr_NoMemory();
7258 memset(m->defaults, 0, size);
7259 m->defaults_pyobjects = pyobjects;
7260 return m->defaults;
7261 }
7262 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
7263 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
7264 m->defaults_tuple = tuple;
7265 Py_INCREF(tuple);
7266 }
7267 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
7268 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
7269 m->defaults_kwdict = dict;
7270 Py_INCREF(dict);
7271 }
7272 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
7273 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
7274 m->func_annotations = dict;
7275 Py_INCREF(dict);
7276 }
7277
7278 /* Py3ClassCreate */
7279 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
7280 PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
7281 PyObject *ns;
7282 if (metaclass) {
7283 PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
7284 if (prep) {
7285 PyObject *pargs = PyTuple_Pack(2, name, bases);
7286 if (unlikely(!pargs)) {
7287 Py_DECREF(prep);
7288 return NULL;
7289 }
7290 ns = PyObject_Call(prep, pargs, mkw);
7291 Py_DECREF(prep);
7292 Py_DECREF(pargs);
7293 } else {
7294 if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
7295 return NULL;
7296 PyErr_Clear();
7297 ns = PyDict_New();
7298 }
7299 } else {
7300 ns = PyDict_New();
7301 }
7302 if (unlikely(!ns))
7303 return NULL;
7304 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
7305 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
7306 if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
7307 return ns;
7308 bad:
7309 Py_DECREF(ns);
7310 return NULL;
7311 }
7312 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
7313 PyObject *dict, PyObject *mkw,
7314 int calculate_metaclass, int allow_py2_metaclass) {
7315 PyObject *result, *margs;
7316 PyObject *owned_metaclass = NULL;
7317 if (allow_py2_metaclass) {
7318 owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
7319 if (owned_metaclass) {
7320 metaclass = owned_metaclass;
7321 } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
7322 PyErr_Clear();
7323 } else {
7324 return NULL;
7325 }
7326 }
7327 if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
7328 metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
7329 Py_XDECREF(owned_metaclass);
7330 if (unlikely(!metaclass))
7331 return NULL;
7332 owned_metaclass = metaclass;
7333 }
7334 margs = PyTuple_Pack(3, name, bases, dict);
7335 if (unlikely(!margs)) {
7336 result = NULL;
7337 } else {
7338 result = PyObject_Call(metaclass, margs, mkw);
7339 Py_DECREF(margs);
7340 }
7341 Py_XDECREF(owned_metaclass);
7342 return result;
7343 }
7344
7345 /* CLineInTraceback */
7346 #ifndef CYTHON_CLINE_IN_TRACEBACK
7347 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
7348 PyObject *use_cline;
7349 PyObject *ptype, *pvalue, *ptraceback;
7350 #if CYTHON_COMPILING_IN_CPYTHON
7351 PyObject **cython_runtime_dict;
7352 #endif
7353 if (unlikely(!__pyx_cython_runtime)) {
7354 return c_line;
7355 }
7356 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
7357 #if CYTHON_COMPILING_IN_CPYTHON
7358 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
7359 if (likely(cython_runtime_dict)) {
7360 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
7361 use_cline, *cython_runtime_dict,
7362 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
7363 } else
7364 #endif
7365 {
7366 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
7367 if (use_cline_obj) {
7368 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
7369 Py_DECREF(use_cline_obj);
7370 } else {
7371 PyErr_Clear();
7372 use_cline = NULL;
7373 }
7374 }
7375 if (!use_cline) {
7376 c_line = 0;
7377 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
7378 }
7379 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
7380 c_line = 0;
7381 }
7382 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
7383 return c_line;
7384 }
7385 #endif
7386
7387 /* CodeObjectCache */
7388 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
7389 int start = 0, mid = 0, end = count - 1;
7390 if (end >= 0 && code_line > entries[end].code_line) {
7391 return count;
7392 }
7393 while (start < end) {
7394 mid = start + (end - start) / 2;
7395 if (code_line < entries[mid].code_line) {
7396 end = mid;
7397 } else if (code_line > entries[mid].code_line) {
7398 start = mid + 1;
7399 } else {
7400 return mid;
7401 }
7402 }
7403 if (code_line <= entries[mid].code_line) {
7404 return mid;
7405 } else {
7406 return mid + 1;
7407 }
7408 }
7409 static PyCodeObject *__pyx_find_code_object(int code_line) {
7410 PyCodeObject* code_object;
7411 int pos;
7412 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
7413 return NULL;
7414 }
7415 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
7416 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
7417 return NULL;
7418 }
7419 code_object = __pyx_code_cache.entries[pos].code_object;
7420 Py_INCREF(code_object);
7421 return code_object;
7422 }
7423 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
7424 int pos, i;
7425 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
7426 if (unlikely(!code_line)) {
7427 return;
7428 }
7429 if (unlikely(!entries)) {
7430 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
7431 if (likely(entries)) {
7432 __pyx_code_cache.entries = entries;
7433 __pyx_code_cache.max_count = 64;
7434 __pyx_code_cache.count = 1;
7435 entries[0].code_line = code_line;
7436 entries[0].code_object = code_object;
7437 Py_INCREF(code_object);
7438 }
7439 return;
7440 }
7441 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
7442 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
7443 PyCodeObject* tmp = entries[pos].code_object;
7444 entries[pos].code_object = code_object;
7445 Py_DECREF(tmp);
7446 return;
7447 }
7448 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
7449 int new_max = __pyx_code_cache.max_count + 64;
7450 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
7451 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
7452 if (unlikely(!entries)) {
7453 return;
7454 }
7455 __pyx_code_cache.entries = entries;
7456 __pyx_code_cache.max_count = new_max;
7457 }
7458 for (i=__pyx_code_cache.count; i>pos; i--) {
7459 entries[i] = entries[i-1];
7460 }
7461 entries[pos].code_line = code_line;
7462 entries[pos].code_object = code_object;
7463 __pyx_code_cache.count++;
7464 Py_INCREF(code_object);
7465 }
7466
7467 /* AddTraceback */
7468 #include "compile.h"
7469 #include "frameobject.h"
7470 #include "traceback.h"
7471 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
7472 const char *funcname, int c_line,
7473 int py_line, const char *filename) {
7474 PyCodeObject *py_code = 0;
7475 PyObject *py_srcfile = 0;
7476 PyObject *py_funcname = 0;
7477 #if PY_MAJOR_VERSION < 3
7478 py_srcfile = PyString_FromString(filename);
7479 #else
7480 py_srcfile = PyUnicode_FromString(filename);
7481 #endif
7482 if (!py_srcfile) goto bad;
7483 if (c_line) {
7484 #if PY_MAJOR_VERSION < 3
7485 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
7486 #else
7487 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
7488 #endif
7489 }
7490 else {
7491 #if PY_MAJOR_VERSION < 3
7492 py_funcname = PyString_FromString(funcname);
7493 #else
7494 py_funcname = PyUnicode_FromString(funcname);
7495 #endif
7496 }
7497 if (!py_funcname) goto bad;
7498 py_code = __Pyx_PyCode_New(
7499 0,
7500 0,
7501 0,
7502 0,
7503 0,
7504 __pyx_empty_bytes, /*PyObject *code,*/
7505 __pyx_empty_tuple, /*PyObject *consts,*/
7506 __pyx_empty_tuple, /*PyObject *names,*/
7507 __pyx_empty_tuple, /*PyObject *varnames,*/
7508 __pyx_empty_tuple, /*PyObject *freevars,*/
7509 __pyx_empty_tuple, /*PyObject *cellvars,*/
7510 py_srcfile, /*PyObject *filename,*/
7511 py_funcname, /*PyObject *name,*/
7512 py_line,
7513 __pyx_empty_bytes /*PyObject *lnotab*/
7514 );
7515 Py_DECREF(py_srcfile);
7516 Py_DECREF(py_funcname);
7517 return py_code;
7518 bad:
7519 Py_XDECREF(py_srcfile);
7520 Py_XDECREF(py_funcname);
7521 return NULL;
7522 }
7523 static void __Pyx_AddTraceback(const char *funcname, int c_line,
7524 int py_line, const char *filename) {
7525 PyCodeObject *py_code = 0;
7526 PyFrameObject *py_frame = 0;
7527 PyThreadState *tstate = __Pyx_PyThreadState_Current;
7528 if (c_line) {
7529 c_line = __Pyx_CLineForTraceback(tstate, c_line);
7530 }
7531 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
7532 if (!py_code) {
7533 py_code = __Pyx_CreateCodeObjectForTraceback(
7534 funcname, c_line, py_line, filename);
7535 if (!py_code) goto bad;
7536 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
7537 }
7538 py_frame = PyFrame_New(
7539 tstate, /*PyThreadState *tstate,*/
7540 py_code, /*PyCodeObject *code,*/
7541 __pyx_d, /*PyObject *globals,*/
7542 0 /*PyObject *locals*/
7543 );
7544 if (!py_frame) goto bad;
7545 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
7546 PyTraceBack_Here(py_frame);
7547 bad:
7548 Py_XDECREF(py_code);
7549 Py_XDECREF(py_frame);
7550 }
7551
7552 /* CIntToPy */
7553 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
7554 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
7555 const int is_unsigned = neg_one > const_zero;
7556 if (is_unsigned) {
7557 if (sizeof(long) < sizeof(long)) {
7558 return PyInt_FromLong((long) value);
7559 } else if (sizeof(long) <= sizeof(unsigned long)) {
7560 return PyLong_FromUnsignedLong((unsigned long) value);
7561 #ifdef HAVE_LONG_LONG
7562 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7563 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
7564 #endif
7565 }
7566 } else {
7567 if (sizeof(long) <= sizeof(long)) {
7568 return PyInt_FromLong((long) value);
7569 #ifdef HAVE_LONG_LONG
7570 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7571 return PyLong_FromLongLong((PY_LONG_LONG) value);
7572 #endif
7573 }
7574 }
7575 {
7576 int one = 1; int little = (int)*(unsigned char *)&one;
7577 unsigned char *bytes = (unsigned char *)&value;
7578 return _PyLong_FromByteArray(bytes, sizeof(long),
7579 little, !is_unsigned);
7580 }
7581 }
7582
7583 /* CIntFromPyVerify */
7584 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
7585 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
7586 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
7587 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
7588 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
7589 {\
7590 func_type value = func_value;\
7591 if (sizeof(target_type) < sizeof(func_type)) {\
7592 if (unlikely(value != (func_type) (target_type) value)) {\
7593 func_type zero = 0;\
7594 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
7595 return (target_type) -1;\
7596 if (is_unsigned && unlikely(value < zero))\
7597 goto raise_neg_overflow;\
7598 else\
7599 goto raise_overflow;\
7600 }\
7601 }\
7602 return (target_type) value;\
7603 }
7604
7605 /* CIntFromPy */
7606 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
7607 const long neg_one = (long) ((long) 0 - (long) 1), const_zero = (long) 0;
7608 const int is_unsigned = neg_one > const_zero;
7609 #if PY_MAJOR_VERSION < 3
7610 if (likely(PyInt_Check(x))) {
7611 if (sizeof(long) < sizeof(long)) {
7612 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
7613 } else {
7614 long val = PyInt_AS_LONG(x);
7615 if (is_unsigned && unlikely(val < 0)) {
7616 goto raise_neg_overflow;
7617 }
7618 return (long) val;
7619 }
7620 } else
7621 #endif
7622 if (likely(PyLong_Check(x))) {
7623 if (is_unsigned) {
7624 #if CYTHON_USE_PYLONG_INTERNALS
7625 const digit* digits = ((PyLongObject*)x)->ob_digit;
7626 switch (Py_SIZE(x)) {
7627 case 0: return (long) 0;
7628 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
7629 case 2:
7630 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7631 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7632 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7633 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
7634 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7635 }
7636 }
7637 break;
7638 case 3:
7639 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7640 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7641 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7642 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
7643 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7644 }
7645 }
7646 break;
7647 case 4:
7648 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7649 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7650 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7651 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
7652 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
7653 }
7654 }
7655 break;
7656 }
7657 #endif
7658 #if CYTHON_COMPILING_IN_CPYTHON
7659 if (unlikely(Py_SIZE(x) < 0)) {
7660 goto raise_neg_overflow;
7661 }
7662 #else
7663 {
7664 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7665 if (unlikely(result < 0))
7666 return (long) -1;
7667 if (unlikely(result == 1))
7668 goto raise_neg_overflow;
7669 }
7670 #endif
7671 if (sizeof(long) <= sizeof(unsigned long)) {
7672 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
7673 #ifdef HAVE_LONG_LONG
7674 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
7675 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7676 #endif
7677 }
7678 } else {
7679 #if CYTHON_USE_PYLONG_INTERNALS
7680 const digit* digits = ((PyLongObject*)x)->ob_digit;
7681 switch (Py_SIZE(x)) {
7682 case 0: return (long) 0;
7683 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
7684 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
7685 case -2:
7686 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
7687 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7688 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7689 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7690 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7691 }
7692 }
7693 break;
7694 case 2:
7695 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
7696 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7697 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7698 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7699 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7700 }
7701 }
7702 break;
7703 case -3:
7704 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
7705 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7706 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7707 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7708 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7709 }
7710 }
7711 break;
7712 case 3:
7713 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
7714 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7715 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7716 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7717 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7718 }
7719 }
7720 break;
7721 case -4:
7722 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
7723 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7724 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7725 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7726 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7727 }
7728 }
7729 break;
7730 case 4:
7731 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
7732 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7733 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7734 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
7735 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
7736 }
7737 }
7738 break;
7739 }
7740 #endif
7741 if (sizeof(long) <= sizeof(long)) {
7742 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
7743 #ifdef HAVE_LONG_LONG
7744 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
7745 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
7746 #endif
7747 }
7748 }
7749 {
7750 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7751 PyErr_SetString(PyExc_RuntimeError,
7752 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7753 #else
7754 long val;
7755 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7756 #if PY_MAJOR_VERSION < 3
7757 if (likely(v) && !PyLong_Check(v)) {
7758 PyObject *tmp = v;
7759 v = PyNumber_Long(tmp);
7760 Py_DECREF(tmp);
7761 }
7762 #endif
7763 if (likely(v)) {
7764 int one = 1; int is_little = (int)*(unsigned char *)&one;
7765 unsigned char *bytes = (unsigned char *)&val;
7766 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7767 bytes, sizeof(val),
7768 is_little, !is_unsigned);
7769 Py_DECREF(v);
7770 if (likely(!ret))
7771 return val;
7772 }
7773 #endif
7774 return (long) -1;
7775 }
7776 } else {
7777 long val;
7778 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7779 if (!tmp) return (long) -1;
7780 val = __Pyx_PyInt_As_long(tmp);
7781 Py_DECREF(tmp);
7782 return val;
7783 }
7784 raise_overflow:
7785 PyErr_SetString(PyExc_OverflowError,
7786 "value too large to convert to long");
7787 return (long) -1;
7788 raise_neg_overflow:
7789 PyErr_SetString(PyExc_OverflowError,
7790 "can't convert negative value to long");
7791 return (long) -1;
7792 }
7793
7794 /* CIntFromPy */
7795 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
7796 const int neg_one = (int) ((int) 0 - (int) 1), const_zero = (int) 0;
7797 const int is_unsigned = neg_one > const_zero;
7798 #if PY_MAJOR_VERSION < 3
7799 if (likely(PyInt_Check(x))) {
7800 if (sizeof(int) < sizeof(long)) {
7801 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
7802 } else {
7803 long val = PyInt_AS_LONG(x);
7804 if (is_unsigned && unlikely(val < 0)) {
7805 goto raise_neg_overflow;
7806 }
7807 return (int) val;
7808 }
7809 } else
7810 #endif
7811 if (likely(PyLong_Check(x))) {
7812 if (is_unsigned) {
7813 #if CYTHON_USE_PYLONG_INTERNALS
7814 const digit* digits = ((PyLongObject*)x)->ob_digit;
7815 switch (Py_SIZE(x)) {
7816 case 0: return (int) 0;
7817 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
7818 case 2:
7819 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7820 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7821 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7822 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
7823 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7824 }
7825 }
7826 break;
7827 case 3:
7828 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7829 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7830 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7831 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
7832 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7833 }
7834 }
7835 break;
7836 case 4:
7837 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7838 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7839 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7840 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
7841 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
7842 }
7843 }
7844 break;
7845 }
7846 #endif
7847 #if CYTHON_COMPILING_IN_CPYTHON
7848 if (unlikely(Py_SIZE(x) < 0)) {
7849 goto raise_neg_overflow;
7850 }
7851 #else
7852 {
7853 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
7854 if (unlikely(result < 0))
7855 return (int) -1;
7856 if (unlikely(result == 1))
7857 goto raise_neg_overflow;
7858 }
7859 #endif
7860 if (sizeof(int) <= sizeof(unsigned long)) {
7861 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
7862 #ifdef HAVE_LONG_LONG
7863 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
7864 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
7865 #endif
7866 }
7867 } else {
7868 #if CYTHON_USE_PYLONG_INTERNALS
7869 const digit* digits = ((PyLongObject*)x)->ob_digit;
7870 switch (Py_SIZE(x)) {
7871 case 0: return (int) 0;
7872 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
7873 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
7874 case -2:
7875 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
7876 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7877 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7878 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7879 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7880 }
7881 }
7882 break;
7883 case 2:
7884 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
7885 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
7886 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7887 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7888 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7889 }
7890 }
7891 break;
7892 case -3:
7893 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
7894 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7895 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7896 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7897 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7898 }
7899 }
7900 break;
7901 case 3:
7902 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
7903 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
7904 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7905 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7906 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7907 }
7908 }
7909 break;
7910 case -4:
7911 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
7912 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7913 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7914 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7915 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7916 }
7917 }
7918 break;
7919 case 4:
7920 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
7921 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
7922 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
7923 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
7924 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
7925 }
7926 }
7927 break;
7928 }
7929 #endif
7930 if (sizeof(int) <= sizeof(long)) {
7931 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
7932 #ifdef HAVE_LONG_LONG
7933 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
7934 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
7935 #endif
7936 }
7937 }
7938 {
7939 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
7940 PyErr_SetString(PyExc_RuntimeError,
7941 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
7942 #else
7943 int val;
7944 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
7945 #if PY_MAJOR_VERSION < 3
7946 if (likely(v) && !PyLong_Check(v)) {
7947 PyObject *tmp = v;
7948 v = PyNumber_Long(tmp);
7949 Py_DECREF(tmp);
7950 }
7951 #endif
7952 if (likely(v)) {
7953 int one = 1; int is_little = (int)*(unsigned char *)&one;
7954 unsigned char *bytes = (unsigned char *)&val;
7955 int ret = _PyLong_AsByteArray((PyLongObject *)v,
7956 bytes, sizeof(val),
7957 is_little, !is_unsigned);
7958 Py_DECREF(v);
7959 if (likely(!ret))
7960 return val;
7961 }
7962 #endif
7963 return (int) -1;
7964 }
7965 } else {
7966 int val;
7967 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
7968 if (!tmp) return (int) -1;
7969 val = __Pyx_PyInt_As_int(tmp);
7970 Py_DECREF(tmp);
7971 return val;
7972 }
7973 raise_overflow:
7974 PyErr_SetString(PyExc_OverflowError,
7975 "value too large to convert to int");
7976 return (int) -1;
7977 raise_neg_overflow:
7978 PyErr_SetString(PyExc_OverflowError,
7979 "can't convert negative value to int");
7980 return (int) -1;
7981 }
7982
7983 /* FastTypeChecks */
7984 #if CYTHON_COMPILING_IN_CPYTHON
7985 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
7986 while (a) {
7987 a = a->tp_base;
7988 if (a == b)
7989 return 1;
7990 }
7991 return b == &PyBaseObject_Type;
7992 }
7993 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
7994 PyObject *mro;
7995 if (a == b) return 1;
7996 mro = a->tp_mro;
7997 if (likely(mro)) {
7998 Py_ssize_t i, n;
7999 n = PyTuple_GET_SIZE(mro);
8000 for (i = 0; i < n; i++) {
8001 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
8002 return 1;
8003 }
8004 return 0;
8005 }
8006 return __Pyx_InBases(a, b);
8007 }
8008 #if PY_MAJOR_VERSION == 2
8009 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
8010 PyObject *exception, *value, *tb;
8011 int res;
8012 __Pyx_PyThreadState_declare
8013 __Pyx_PyThreadState_assign
8014 __Pyx_ErrFetch(&exception, &value, &tb);
8015 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
8016 if (unlikely(res == -1)) {
8017 PyErr_WriteUnraisable(err);
8018 res = 0;
8019 }
8020 if (!res) {
8021 res = PyObject_IsSubclass(err, exc_type2);
8022 if (unlikely(res == -1)) {
8023 PyErr_WriteUnraisable(err);
8024 res = 0;
8025 }
8026 }
8027 __Pyx_ErrRestore(exception, value, tb);
8028 return res;
8029 }
8030 #else
8031 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
8032 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
8033 if (!res) {
8034 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
8035 }
8036 return res;
8037 }
8038 #endif
8039 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
8040 Py_ssize_t i, n;
8041 assert(PyExceptionClass_Check(exc_type));
8042 n = PyTuple_GET_SIZE(tuple);
8043 #if PY_MAJOR_VERSION >= 3
8044 for (i=0; i<n; i++) {
8045 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
8046 }
8047 #endif
8048 for (i=0; i<n; i++) {
8049 PyObject *t = PyTuple_GET_ITEM(tuple, i);
8050 #if PY_MAJOR_VERSION < 3
8051 if (likely(exc_type == t)) return 1;
8052 #endif
8053 if (likely(PyExceptionClass_Check(t))) {
8054 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
8055 } else {
8056 }
8057 }
8058 return 0;
8059 }
8060 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
8061 if (likely(err == exc_type)) return 1;
8062 if (likely(PyExceptionClass_Check(err))) {
8063 if (likely(PyExceptionClass_Check(exc_type))) {
8064 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
8065 } else if (likely(PyTuple_Check(exc_type))) {
8066 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
8067 } else {
8068 }
8069 }
8070 return PyErr_GivenExceptionMatches(err, exc_type);
8071 }
8072 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
8073 assert(PyExceptionClass_Check(exc_type1));
8074 assert(PyExceptionClass_Check(exc_type2));
8075 if (likely(err == exc_type1 || err == exc_type2)) return 1;
8076 if (likely(PyExceptionClass_Check(err))) {
8077 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
8078 }
8079 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
8080 }
8081 #endif
8082
8083 /* CheckBinaryVersion */
8084 static int __Pyx_check_binary_version(void) {
8085 char ctversion[4], rtversion[4];
8086 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
8087 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
8088 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
8089 char message[200];
8090 PyOS_snprintf(message, sizeof(message),
8091 "compiletime version %s of module '%.100s' "
8092 "does not match runtime version %s",
8093 ctversion, __Pyx_MODULE_NAME, rtversion);
8094 return PyErr_WarnEx(NULL, message, 1);
8095 }
8096 return 0;
8097 }
8098
8099 /* InitStrings */
8100 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
8101 while (t->p) {
8102 #if PY_MAJOR_VERSION < 3
8103 if (t->is_unicode) {
8104 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
8105 } else if (t->intern) {
8106 *t->p = PyString_InternFromString(t->s);
8107 } else {
8108 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
8109 }
8110 #else
8111 if (t->is_unicode | t->is_str) {
8112 if (t->intern) {
8113 *t->p = PyUnicode_InternFromString(t->s);
8114 } else if (t->encoding) {
8115 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
8116 } else {
8117 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
8118 }
8119 } else {
8120 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
8121 }
8122 #endif
8123 if (!*t->p)
8124 return -1;
8125 if (PyObject_Hash(*t->p) == -1)
8126 return -1;
8127 ++t;
8128 }
8129 return 0;
8130 }
8131
8132 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
8133 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
8134 }
8135 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
8136 Py_ssize_t ignore;
8137 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
8138 }
8139 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
8140 #if !CYTHON_PEP393_ENABLED
8141 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8142 char* defenc_c;
8143 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
8144 if (!defenc) return NULL;
8145 defenc_c = PyBytes_AS_STRING(defenc);
8146 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8147 {
8148 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
8149 char* c;
8150 for (c = defenc_c; c < end; c++) {
8151 if ((unsigned char) (*c) >= 128) {
8152 PyUnicode_AsASCIIString(o);
8153 return NULL;
8154 }
8155 }
8156 }
8157 #endif
8158 *length = PyBytes_GET_SIZE(defenc);
8159 return defenc_c;
8160 }
8161 #else
8162 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8163 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
8164 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8165 if (likely(PyUnicode_IS_ASCII(o))) {
8166 *length = PyUnicode_GET_LENGTH(o);
8167 return PyUnicode_AsUTF8(o);
8168 } else {
8169 PyUnicode_AsASCIIString(o);
8170 return NULL;
8171 }
8172 #else
8173 return PyUnicode_AsUTF8AndSize(o, length);
8174 #endif
8175 }
8176 #endif
8177 #endif
8178 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
8179 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
8180 if (
8181 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
8182 __Pyx_sys_getdefaultencoding_not_ascii &&
8183 #endif
8184 PyUnicode_Check(o)) {
8185 return __Pyx_PyUnicode_AsStringAndSize(o, length);
8186 } else
8187 #endif
8188 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
8189 if (PyByteArray_Check(o)) {
8190 *length = PyByteArray_GET_SIZE(o);
8191 return PyByteArray_AS_STRING(o);
8192 } else
8193 #endif
8194 {
8195 char* result;
8196 int r = PyBytes_AsStringAndSize(o, &result, length);
8197 if (unlikely(r < 0)) {
8198 return NULL;
8199 } else {
8200 return result;
8201 }
8202 }
8203 }
8204 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
8205 int is_true = x == Py_True;
8206 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
8207 else return PyObject_IsTrue(x);
8208 }
8209 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
8210 int retval;
8211 if (unlikely(!x)) return -1;
8212 retval = __Pyx_PyObject_IsTrue(x);
8213 Py_DECREF(x);
8214 return retval;
8215 }
8216 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
8217 #if PY_MAJOR_VERSION >= 3
8218 if (PyLong_Check(result)) {
8219 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
8220 "__int__ returned non-int (type %.200s). "
8221 "The ability to return an instance of a strict subclass of int "
8222 "is deprecated, and may be removed in a future version of Python.",
8223 Py_TYPE(result)->tp_name)) {
8224 Py_DECREF(result);
8225 return NULL;
8226 }
8227 return result;
8228 }
8229 #endif
8230 PyErr_Format(PyExc_TypeError,
8231 "__%.4s__ returned non-%.4s (type %.200s)",
8232 type_name, type_name, Py_TYPE(result)->tp_name);
8233 Py_DECREF(result);
8234 return NULL;
8235 }
8236 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
8237 #if CYTHON_USE_TYPE_SLOTS
8238 PyNumberMethods *m;
8239 #endif
8240 const char *name = NULL;
8241 PyObject *res = NULL;
8242 #if PY_MAJOR_VERSION < 3
8243 if (likely(PyInt_Check(x) || PyLong_Check(x)))
8244 #else
8245 if (likely(PyLong_Check(x)))
8246 #endif
8247 return __Pyx_NewRef(x);
8248 #if CYTHON_USE_TYPE_SLOTS
8249 m = Py_TYPE(x)->tp_as_number;
8250 #if PY_MAJOR_VERSION < 3
8251 if (m && m->nb_int) {
8252 name = "int";
8253 res = m->nb_int(x);
8254 }
8255 else if (m && m->nb_long) {
8256 name = "long";
8257 res = m->nb_long(x);
8258 }
8259 #else
8260 if (likely(m && m->nb_int)) {
8261 name = "int";
8262 res = m->nb_int(x);
8263 }
8264 #endif
8265 #else
8266 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
8267 res = PyNumber_Int(x);
8268 }
8269 #endif
8270 if (likely(res)) {
8271 #if PY_MAJOR_VERSION < 3
8272 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
8273 #else
8274 if (unlikely(!PyLong_CheckExact(res))) {
8275 #endif
8276 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
8277 }
8278 }
8279 else if (!PyErr_Occurred()) {
8280 PyErr_SetString(PyExc_TypeError,
8281 "an integer is required");
8282 }
8283 return res;
8284 }
8285 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
8286 Py_ssize_t ival;
8287 PyObject *x;
8288 #if PY_MAJOR_VERSION < 3
8289 if (likely(PyInt_CheckExact(b))) {
8290 if (sizeof(Py_ssize_t) >= sizeof(long))
8291 return PyInt_AS_LONG(b);
8292 else
8293 return PyInt_AsSsize_t(b);
8294 }
8295 #endif
8296 if (likely(PyLong_CheckExact(b))) {
8297 #if CYTHON_USE_PYLONG_INTERNALS
8298 const digit* digits = ((PyLongObject*)b)->ob_digit;
8299 const Py_ssize_t size = Py_SIZE(b);
8300 if (likely(__Pyx_sst_abs(size) <= 1)) {
8301 ival = likely(size) ? digits[0] : 0;
8302 if (size == -1) ival = -ival;
8303 return ival;
8304 } else {
8305 switch (size) {
8306 case 2:
8307 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8308 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8309 }
8310 break;
8311 case -2:
8312 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
8313 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8314 }
8315 break;
8316 case 3:
8317 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8318 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8319 }
8320 break;
8321 case -3:
8322 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
8323 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8324 }
8325 break;
8326 case 4:
8327 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8328 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8329 }
8330 break;
8331 case -4:
8332 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
8333 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
8334 }
8335 break;
8336 }
8337 }
8338 #endif
8339 return PyLong_AsSsize_t(b);
8340 }
8341 x = PyNumber_Index(b);
8342 if (!x) return -1;
8343 ival = PyInt_AsSsize_t(x);
8344 Py_DECREF(x);
8345 return ival;
8346 }
8347 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
8348 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
8349 }
8350 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
8351 return PyInt_FromSize_t(ival);
8352 }
8353
8354
8355 #endif /* Py_PYTHON_H */
0
1 from .. import defines
2 from ..util import compat
3 from .base import Column
4
5
6 class String(Column):
7 ch_type = 'String'
8 py_types = compat.string_types
9 null_value = ''
10
11 default_encoding = defines.STRINGS_ENCODING
12
13 def __init__(self, encoding=default_encoding, **kwargs):
14 self.encoding = encoding
15 super(String, self).__init__(**kwargs)
16
17 def write_items(self, items, buf):
18 buf.write_strings(items, encoding=self.encoding)
19
20 def read_items(self, n_items, buf):
21 return buf.read_strings(n_items, encoding=self.encoding)
22
23
24 class ByteString(String):
25 py_types = (bytes, )
26 null_value = b''
27
28 def write_items(self, items, buf):
29 buf.write_strings(items)
30
31 def read_items(self, n_items, buf):
32 return buf.read_strings(n_items)
33
34
35 class FixedString(String):
36 ch_type = 'FixedString'
37
38 def __init__(self, length, **kwargs):
39 self.length = length
40 super(FixedString, self).__init__(**kwargs)
41
42 def read_items(self, n_items, buf):
43 return buf.read_fixed_strings(
44 n_items, self.length, encoding=self.encoding
45 )
46
47 def write_items(self, items, buf):
48 buf.write_fixed_strings(items, self.length, encoding=self.encoding)
49
50
51 class ByteFixedString(FixedString):
52 py_types = (bytearray, bytes)
53 null_value = b''
54
55 def read_items(self, n_items, buf):
56 return buf.read_fixed_strings(n_items, self.length)
57
58 def write_items(self, items, buf):
59 buf.write_fixed_strings(items, self.length)
60
61
62 def create_string_column(spec, column_options):
63 client_settings = column_options['context'].client_settings
64 strings_as_bytes = client_settings['strings_as_bytes']
65 encoding = client_settings.get('strings_encoding', String.default_encoding)
66
67 if spec == 'String':
68 cls = ByteString if strings_as_bytes else String
69 return cls(encoding=encoding, **column_options)
70 else:
71 length = int(spec[12:-1])
72 cls = ByteFixedString if strings_as_bytes else FixedString
73 return cls(length, encoding=encoding, **column_options)
+0
-171
clickhouse_driver/columns/stringcolumn.pyx less more
0 from cpython cimport Py_INCREF, PyBytes_AsString, PyBytes_FromStringAndSize, \
1 PyBytes_Check
2 from cpython.bytearray cimport PyByteArray_AsString, \
3 PyByteArray_FromStringAndSize
4 # Using python's versions of pure c memory management functions for
5 # proper memory statistics count.
6 from cpython.mem cimport PyMem_Malloc, PyMem_Realloc, PyMem_Free
7 from cpython.tuple cimport PyTuple_New, PyTuple_SET_ITEM
8 from libc.string cimport memcpy, memset
9
10 from .. import errors
11 from ..util import compat
12 from .base import Column
13
14 from codecs import utf_8_encode
15
16
17 class String(Column):
18 ch_type = 'String'
19 py_types = compat.string_types
20 null_value = ''
21
22 # TODO: pass user encoding here
23
24 def write_items(self, items, buf):
25 buf.write_strings(items, encode=True)
26
27 def read_items(self, n_items, buf):
28 return buf.read_strings(n_items, decode=True)
29
30
31 class ByteString(String):
32 py_types = (bytearray, bytes)
33 null_value = b''
34
35 def write_items(self, items, buf):
36 buf.write_strings(items)
37
38 def read_items(self, n_items, buf):
39 return buf.read_strings(n_items)
40
41
42 class FixedString(String):
43 ch_type = 'FixedString'
44
45 def __init__(self, length, **kwargs):
46 self.length = length
47 super(FixedString, self).__init__(**kwargs)
48
49 def read_items(self, Py_ssize_t n_items, buf):
50 cdef Py_ssize_t i, j, length = self.length
51 data = buf.read(length * n_items)
52 cdef char* data_ptr = PyByteArray_AsString(data)
53
54 cdef char* c_string = <char *>PyMem_Malloc(length + 1)
55 if not c_string:
56 raise MemoryError()
57 c_string[length] = 0
58
59 items = PyTuple_New(n_items)
60 for i in range(n_items):
61 memcpy(c_string, &data_ptr[i * length], length)
62
63 # Get last non zero byte of string from the end.
64 j = length - 1
65 while j >= 0 and not c_string[j]:
66 j -= 1
67
68 try:
69 item = c_string[:j + 1].decode('utf-8')
70 except UnicodeDecodeError:
71 item = PyBytes_FromStringAndSize(c_string, length)
72 Py_INCREF(item)
73 PyTuple_SET_ITEM(items, i, item)
74
75 PyMem_Free(c_string)
76
77 return items
78
79 def write_items(self, items, buf):
80 cdef Py_ssize_t buf_pos = 0
81 cdef Py_ssize_t length = self.length
82 cdef Py_ssize_t items_buf_size = length * len(items)
83
84 cdef char* c_value
85 cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
86 if not items_buf:
87 raise MemoryError()
88
89 memset(items_buf, 0, items_buf_size)
90
91 for value in items:
92 if not isinstance(value, bytes):
93 value = utf_8_encode(value)[0]
94
95 value_len = len(value)
96 if length < value_len:
97 raise errors.TooLargeStringSize()
98
99 if PyBytes_Check(value):
100 c_value = PyBytes_AsString(value)
101 else:
102 c_value = PyByteArray_AsString(value)
103
104 memcpy(&items_buf[buf_pos], c_value, value_len)
105 buf_pos += length
106
107 buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
108
109 PyMem_Free(items_buf)
110
111
112 class ByteFixedString(FixedString):
113 py_types = (bytearray, bytes)
114 null_value = b''
115
116 def read_items(self, Py_ssize_t n_items, buf):
117 cdef Py_ssize_t i
118 cdef Py_ssize_t length = self.length
119 data = buf.read(length * n_items)
120 cdef char* data_ptr = PyByteArray_AsString(data)
121
122 items = PyTuple_New(n_items)
123 for i in range(n_items):
124 item = PyBytes_FromStringAndSize(&data_ptr[i * length], length)
125 Py_INCREF(item)
126 PyTuple_SET_ITEM(items, i, item)
127
128 return items
129
130 def write_items(self, items, buf):
131 cdef Py_ssize_t buf_pos = 0
132 cdef Py_ssize_t length = self.length
133 cdef Py_ssize_t items_buf_size = length * len(items)
134
135 cdef char* c_value
136 cdef char* items_buf = <char *>PyMem_Malloc(items_buf_size)
137 if not items_buf:
138 raise MemoryError()
139
140 memset(items_buf, 0, items_buf_size)
141
142 for value in items:
143 value_len = len(value)
144 if length < value_len:
145 raise errors.TooLargeStringSize()
146
147 if PyBytes_Check(value):
148 c_value = PyBytes_AsString(value)
149 else:
150 c_value = PyByteArray_AsString(value)
151
152 memcpy(&items_buf[buf_pos], c_value, value_len)
153 buf_pos += length
154
155 buf.write(PyBytes_FromStringAndSize(items_buf, items_buf_size))
156
157 PyMem_Free(items_buf)
158
159
160 def create_string_column(spec, column_options):
161 client_settings = column_options['context'].client_settings
162 strings_as_bytes = client_settings['strings_as_bytes']
163
164 if spec == 'String':
165 cls = ByteString if strings_as_bytes else String
166 return cls(**column_options)
167 else:
168 length = int(spec[12:-1])
169 cls = ByteFixedString if strings_as_bytes else FixedString
170 return cls(length, **column_options)
0
1 from .base import Column
2
3
4 class TupleColumn(Column):
5 py_types = (list, tuple)
6
7 def __init__(self, nested_columns, **kwargs):
8 self.nested_columns = nested_columns
9 super(TupleColumn, self).__init__(**kwargs)
10
11 def write_data(self, items, buf):
12 items = list(zip(*items))
13
14 for i, x in enumerate(self.nested_columns):
15 x.write_data(list(items[i]), buf)
16
17 def write_items(self, items, buf):
18 return self.write_data(items, buf)
19
20 def read_data(self, n_items, buf):
21 rv = [x.read_data(n_items, buf) for x in self.nested_columns]
22 return list(zip(*rv))
23
24 def read_items(self, n_items, buf):
25 return self.read_data(n_items, buf)
26
27
28 def create_tuple_column(spec, column_by_spec_getter):
29 brackets = 0
30 column_begin = 0
31
32 inner_spec = get_inner_spec(spec)
33 nested_columns = []
34 for i, x in enumerate(inner_spec + ','):
35 if x == ',':
36 if brackets == 0:
37 nested_columns.append(inner_spec[column_begin:i])
38 column_begin = i + 1
39 elif x == '(':
40 brackets += 1
41 elif x == ')':
42 brackets -= 1
43 elif x == ' ':
44 if brackets == 0:
45 column_begin = i + 1
46
47 return TupleColumn([column_by_spec_getter(x) for x in nested_columns])
48
49
50 def get_inner_spec(spec):
51 brackets = 1
52 offset = len('Tuple(')
53 i = offset
54 for i, ch in enumerate(spec[offset:], offset):
55 if brackets == 0:
56 break
57
58 if ch == '(':
59 brackets += 1
60
61 elif ch == ')':
62 brackets -= 1
63
64 return spec[offset:i]
00 import logging
11 import socket
22 import ssl
3 from collections import deque
34 from contextlib import contextmanager
45 from time import time
56
5455 def version_tuple(self):
5556 return self.version_major, self.version_minor, self.version_patch
5657
58 def __repr__(self):
59 version = '%s.%s.%s' % (
60 self.version_major, self.version_minor, self.version_patch
61 )
62 items = [
63 ('name', self.name),
64 ('version', version),
65 ('revision', self.revision),
66 ('timezone', self.timezone),
67 ('display_name', self.display_name)
68 ]
69
70 params = ', '.join('{}={}'.format(key, value) for key, value in items)
71 return '<ServerInfo(%s)>' % (params)
72
5773
5874 class Connection(object):
5975 """
94110 :param ciphers: see :func:`ssl.wrap_socket` docs.
95111 :param alt_hosts: list of alternative hosts for connection.
96112 Example: alt_hosts=host1:port1,host2:port2.
113 :param settings_is_important: ``False`` means unknown settings will be
114 ignored, ``True`` means that the query will
115 fail with UNKNOWN_SETTING error.
116 Defaults to ``False``.
97117 """
98118
99119 def __init__(
108128 secure=False,
109129 # Secure socket parameters.
110130 verify=True, ssl_version=None, ca_certs=None, ciphers=None,
111 alt_hosts=None
131 alt_hosts=None,
132 settings_is_important=False,
112133 ):
113134 if secure:
114135 default_port = defines.DEFAULT_SECURE_PORT
115136 else:
116137 default_port = defines.DEFAULT_PORT
117138
118 self.hosts = [(host, port or default_port)]
139 self.hosts = deque([(host, port or default_port)])
119140
120141 if alt_hosts:
121142 for host in alt_hosts.split(','):
129150 self.connect_timeout = connect_timeout
130151 self.send_receive_timeout = send_receive_timeout
131152 self.sync_request_timeout = sync_request_timeout
153 self.settings_is_important = settings_is_important
132154
133155 self.secure_socket = secure
134156 self.verify_cert = verify
206228 sock.settimeout(self.connect_timeout)
207229
208230 if self.secure_socket:
209 sock = ssl.wrap_socket(sock, **ssl_options)
231 ssl_context = self._create_ssl_context(ssl_options)
232 sock = ssl_context.wrap_socket(sock, server_hostname=host)
210233
211234 sock.connect(sa)
212235 return sock
220243 raise err
221244 else:
222245 raise socket.error("getaddrinfo returns an empty list")
246
247 def _create_ssl_context(self, ssl_options):
248 purpose = ssl.Purpose.SERVER_AUTH
249
250 version = ssl_options.get('ssl_version', ssl.PROTOCOL_TLS)
251 context = ssl.SSLContext(version)
252
253 if 'ca_certs' in ssl_options:
254 context.load_verify_locations(ssl_options['ca_certs'])
255 elif ssl_options.get('cert_reqs') != ssl.CERT_NONE:
256 context.load_default_certs(purpose
257 )
258 if 'ciphers' in ssl_options:
259 context.set_ciphers(ssl_options['ciphers'])
260
261 if 'cert_reqs' in ssl_options:
262 context.options = ssl_options['cert_reqs']
263
264 return context
223265
224266 def _init_connection(self, host, port):
225267 self.socket = self._create_socket(host, port)
239281 self.block_in = self.get_block_in_stream()
240282 self.block_out = self.get_block_out_stream()
241283
284 def _format_connection_error(self, e, host, port):
285 err = (e.strerror + ' ') if e.strerror else ''
286 return err + '({}:{})'.format(host, port)
287
242288 def connect(self):
243289 if self.connected:
244290 self.disconnect()
248294 )
249295
250296 err = None
251 for host, port in self.hosts:
297 for i in range(len(self.hosts)):
298 host, port = self.hosts[0]
252299 logger.debug('Connecting to %s:%s', host, port)
253300
254301 try:
259306 logger.warning(
260307 'Failed to connect to %s:%s', host, port, exc_info=True
261308 )
262 err = errors.SocketTimeoutError(
263 '{} ({})'.format(e.strerror, self.get_description())
264 )
309 err_str = self._format_connection_error(e, host, port)
310 err = errors.SocketTimeoutError(err_str)
265311
266312 except socket.error as e:
267313 self.disconnect()
268314 logger.warning(
269315 'Failed to connect to %s:%s', host, port, exc_info=True
270316 )
271 err = errors.NetworkError(
272 '{} ({})'.format(e.strerror, self.get_description())
273 )
317 err_str = self._format_connection_error(e, host, port)
318 err = errors.NetworkError(err_str)
319
320 self.hosts.rotate(-1)
274321
275322 if err is not None:
276323 raise err
504551 write_binary_str(table_name, self.fout)
505552
506553 self.block_out.write(block)
507 logger.debug('Block send time: %f', time() - start)
554 logger.debug('Block "%s" send time: %f', table_name, time() - start)
508555
509556 def send_query(self, query, query_id=None):
510557 if not self.connected:
521568
522569 client_info.write(revision, self.fout)
523570
524 write_settings(self.context.settings, self.fout)
571 settings_as_strings = (
572 revision >= defines
573 .DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS
574 )
575 write_settings(self.context.settings, self.fout, settings_as_strings,
576 self.settings_is_important)
577
578 if revision >= defines.DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET:
579 write_binary_str('', self.fout)
525580
526581 write_varint(QueryProcessingStage.COMPLETE, self.fout)
527582 write_varint(self.compression, self.fout)
2828 @client_settings.setter
2929 def client_settings(self, value):
3030 self._client_settings = value.copy()
31
32 def __repr__(self):
33 return '<Context(server_info=%s, client_settings=%s, settings=%s)>' % (
34 self._server_info, self._client_settings, self._settings
35 )
1515 """
1616 Create a new database connection.
1717
18 The connection parameters can be specified via DSN:
18 The connection can be specified via DSN:
1919
20 ``conn = clickhouse_driver.connect("clickhouse://localhost/test")``
20 ``conn = connect("clickhouse://localhost/test?param1=value1&...")``
2121
2222 or using database and credentials arguments:
2323
24 ``conn = clickhouse_driver.connect(database="test", user="default",
25 password="default", host="localhost")``
24 ``conn = connect(database="test", user="default", password="default",
25 host="localhost", **kwargs)``
2626
2727 The basic connection parameters are:
2828
2424 self.database = database
2525 self.connection_kwargs = kwargs
2626 self.is_closed = False
27 self._hosts = None
2728 super(Connection, self).__init__()
2829
2930 def __repr__(self):
8283 raise InterfaceError('connection already closed')
8384
8485 client = self._make_client()
86 if self._hosts is None:
87 self._hosts = client.connection.hosts
88 else:
89 client.connection.hosts = self._hosts
8590 cursor = Cursor(client)
8691 self.cursors.append(cursor)
8792 return cursor
2828
2929 self.arraysize = 1
3030
31 # Begin non-PEP attributes
32 self._columns_with_types = None
33 # End non-PEP attributes
34
3135 super(Cursor, self).__init__()
3236
3337 def __repr__(self):
205209 pass
206210
207211 # Begin non-PEP methods
212 @property
213 def columns_with_types(self):
214 """
215 :return: list of column names with corresponding types of the last
216 .execute*(). E.g. [('x', 'UInt64')].
217 """
218 return self._columns_with_types
219
208220 def set_stream_results(self, stream_results, max_row_buffer):
209221 """
210222 Toggles results streaming from server. Driver will consume
251263 :return: None
252264 """
253265 self._external_tables[name] = (structure, data)
266
267 def set_query_id(self, query_id):
268 """
269 Specifies the query identifier for cursor.
270
271 :param query_id: the query identifier.
272 :return: None
273 """
274 self._query_id = query_id
254275 # End non-PEP methods
255276
256277 # Private methods.
270291 execute_kwargs = {
271292 'settings': self._settings,
272293 'external_tables': external_tables,
273 'types_check': self._types_check
294 'types_check': self._types_check,
295 'query_id': self._query_id
274296 }
275297
276298 return execute, execute_kwargs
290312
291313 else:
292314 rows, columns_with_types = response
315
316 self._columns_with_types = columns_with_types
293317
294318 # Only SELECT queries have columns_with_types.
295319 # DDL and INSERT INTO ... SELECT queries have empty columns header.
317341 self._stream_results = False
318342 self._max_row_buffer = 0
319343 self._settings = None
344 self._query_id = None
320345 self._external_tables = {}
321346 self._types_check = False
322347
1313 DBMS_MIN_REVISION_WITH_SERVER_LOGS = 54406
1414 DBMS_MIN_REVISION_WITH_COLUMN_DEFAULTS_METADATA = 54410
1515 DBMS_MIN_REVISION_WITH_CLIENT_WRITE_INFO = 54420
16 DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS = 54429
17 DBMS_MIN_REVISION_WITH_INTERSERVER_SECRET = 54441
1618
1719 # Timeouts
1820 DBMS_DEFAULT_CONNECT_TIMEOUT_SEC = 10
2527
2628 DBMS_NAME = 'ClickHouse'
2729 CLIENT_NAME = 'python-driver'
28 CLIENT_VERSION_MAJOR = 18
30 CLIENT_VERSION_MAJOR = 20
2931 CLIENT_VERSION_MINOR = 10
30 CLIENT_VERSION_PATCH = 3
31 CLIENT_REVISION = 54421
32 CLIENT_VERSION_PATCH = 2
33 CLIENT_REVISION = 54441
3234
3335 BUFFER_SIZE = 1048576
36
37 STRINGS_ENCODING = 'utf-8'
381381
382382 def __init__(self, message=None):
383383 self.message = message
384 super().__init__(message)
384385
385386 def __str__(self):
386387 message = ' ' + self.message if self.message is not None else ''
387388 return 'Code: {}.{}'.format(self.code, message)
388389
389390 class ServerException(Error):
390 def __init__(self, message, code, nested=None):
391 def __init__(self, message, code=None, nested=None):
391392 self.message = message
392393 self.code = code
393394 self.nested = nested
395 super().__init__(message)
394396
395397 def __str__(self):
396398 nested = '\nNested: {}'.format(self.nested) if self.nested else ''
402404
403405 def __init__(self, message=None):
404406 self.message = message
407 super(Error, self).__init__(message)
405408
406409 def __unicode__(self):
407410 message = ' ' + self.message if self.message is not None else ''
411414 return compat.text_type(self).encode('utf-8')
412415
413416 class ServerException(Error):
414 def __init__(self, message, code, nested=None):
417 def __init__(self, message, code=None, nested=None):
415418 self.message = message
416419 self.code = code
417420 self.nested = nested
421 super(ServerException, self).__init__(message)
418422
419423 def __unicode__(self):
420424 nested = '\nNested: {}'.format(self.nested) if self.nested else ''
1616
1717
1818 def log_block(block):
19 if block is None:
20 return
21
1922 column_names = [x[0] for x in block.columns_with_types]
2023
2124 for row in block.get_rows():
2629 else:
2730 priority = row[0]
2831
32 # thread_number in servers prior 20.x
33 thread_id = row.get('thread_id') or row['thread_number']
34
2935 logger.info(
30 '{%s} [ %s ] <%s> %s: %s',
36 '[ %s ] [ %s ] {%s} <%s> %s: %s',
37 row['host_name'],
38 thread_id,
3139 row['query_id'],
32 row['thread_number'],
3340 priority,
3441 row['source'],
3542 row['text']
0 import numpy as np
1
2 from ..block import ColumnOrientedBlock
3
4
5 class NumpyColumnOrientedBlock(ColumnOrientedBlock):
6 def transposed(self):
7 return np.transpose(self.data)
0 import numpy as np
1 import pandas as pd
2
3
4 def column_chunks(columns, n):
5 for column in columns:
6 if not isinstance(column, (np.ndarray, pd.DatetimeIndex)):
7 raise TypeError(
8 'Unsupported column type: {}. '
9 'ndarray/DatetimeIndex is expected.'
10 .format(type(column))
11 )
12
13 # create chunk generator for every column
14 chunked = [
15 iter(np.array_split(c, range(0, len(c), n)) if len(c) > n else [c])
16 for c in columns
17 ]
18
19 while True:
20 # get next chunk for every column
21 item = [next(column, []) for column in chunked]
22 if not any(len(x) for x in item):
23 break
24 yield item
0 from itertools import chain
1
2 import numpy as np
3 import pandas as pd
4 from pandas.api.types import union_categoricals
5
6 from ..progress import Progress
7 from ..result import QueryResult
8
9
10 class NumpyQueryResult(QueryResult):
11 """
12 Stores query result from multiple blocks as numpy arrays.
13 """
14
15 def store(self, packet):
16 block = getattr(packet, 'block', None)
17 if block is None:
18 return
19
20 # Header block contains no rows. Pick columns from it.
21 if block.num_rows:
22 if self.columnar:
23 self.data.append(block.get_columns())
24 else:
25 self.data.extend(block.get_rows())
26
27 elif not self.columns_with_types:
28 self.columns_with_types = block.columns_with_types
29
30 def get_result(self):
31 """
32 :return: stored query result.
33 """
34
35 for packet in self.packet_generator:
36 self.store(packet)
37
38 if self.columnar:
39 data = []
40 # Transpose to a list of columns, each column is list of chunks
41 for column_chunks in zip(*self.data):
42 # Concatenate chunks for each column
43 if isinstance(column_chunks[0], np.ndarray):
44 column = np.concatenate(column_chunks)
45 elif isinstance(column_chunks[0], pd.Categorical):
46 column = union_categoricals(column_chunks)
47 else:
48 column = tuple(chain.from_iterable(column_chunks))
49 data.append(column)
50 else:
51 data = self.data
52
53 if self.with_column_types:
54 return data, self.columns_with_types
55 else:
56 return data
57
58
59 class NumpyProgressQueryResult(NumpyQueryResult):
60 """
61 Stores query result and progress information from multiple blocks.
62 Provides iteration over query progress.
63 """
64
65 def __init__(self, *args, **kwargs):
66 self.progress_totals = Progress()
67
68 super(NumpyProgressQueryResult, self).__init__(*args, **kwargs)
69
70 def __iter__(self):
71 return self
72
73 def next(self):
74 while True:
75 packet = next(self.packet_generator)
76 progress_packet = getattr(packet, 'progress', None)
77 if progress_packet:
78 self.progress_totals.increment(progress_packet)
79 return (
80 self.progress_totals.rows, self.progress_totals.total_rows
81 )
82 else:
83 self.store(packet)
84
85 # For Python 3.
86 __next__ = next
87
88 def get_result(self):
89 # Read all progress packets.
90 for _ in self:
91 pass
92
93 return super(NumpyProgressQueryResult, self).get_result()
94
95
96 class NumpyIterQueryResult(object):
97 """
98 Provides iteration over returned data by chunks (streaming by chunks).
99 """
100
101 def __init__(
102 self, packet_generator,
103 with_column_types=False):
104 self.packet_generator = packet_generator
105 self.with_column_types = with_column_types
106
107 self.first_block = True
108 super(NumpyIterQueryResult, self).__init__()
109
110 def __iter__(self):
111 return self
112
113 def next(self):
114 packet = next(self.packet_generator)
115 block = getattr(packet, 'block', None)
116 if block is None:
117 return []
118
119 if self.first_block and self.with_column_types:
120 self.first_block = False
121 rv = [block.columns_with_types]
122 rv.extend(block.get_rows())
123 return rv
124 else:
125 return block.get_rows()
126
127 # For Python 3.
128 __next__ = next
3030 if self.data:
3131 # Extend corresponding column.
3232 for i, column in enumerate(columns):
33 self.data[i] += column
33 self.data[i].extend(column)
3434 else:
35 self.data.extend(columns)
35 # Cast tuples to lists for further extending.
36 # Concatenating tuples produce new tuple. It's slow.
37 self.data = [list(c) for c in columns]
3638 else:
3739 self.data.extend(block.get_rows())
3840
4749 for packet in self.packet_generator:
4850 self.store(packet)
4951
52 data = self.data
53 if self.columnar:
54 data = [tuple(c) for c in self.data]
55
5056 if self.with_column_types:
51 return self.data, self.columns_with_types
57 return data, self.columns_with_types
5258 else:
53 return self.data
59 return data
5460
5561
5662 class ProgressQueryResult(QueryResult):
5965 Provides iteration over query progress.
6066 """
6167
62 def __init__(
63 self, packet_generator,
64 with_column_types=False, columnar=False):
68 def __init__(self, *args, **kwargs):
6569 self.progress_totals = Progress()
66
67 super(ProgressQueryResult, self).__init__(
68 packet_generator, with_column_types, columnar
69 )
70 super(ProgressQueryResult, self).__init__(*args, **kwargs)
7071
7172 def __iter__(self):
7273 return self
1313 SettingLoadBalancing = SettingTotalsMode = SettingCompressionMethod = \
1414 SettingDistributedProductMode = SettingGlobalSubqueriesMethod = \
1515 SettingDateTimeInputFormat = \
16 SettingURI = \
17 SettingJoinAlgorithm = \
18 SettingSpecialSort = \
19 SettingLogQueriesType = \
20 SettingDefaultDatabaseEngine = \
1621 SettingString
1722
1823 settings = {
349354 'mutations_sync': SettingUInt64,
350355 'optimize_if_chain_to_miltiif': SettingBool,
351356 'max_parser_depth': SettingUInt64,
357
358 'max_joined_block_size_rows': SettingUInt64,
359 'connect_timeout_with_failover_secure_ms': SettingMilliseconds,
360 'parallel_distributed_insert_select': SettingBool,
361 'force_optimize_skip_unused_shards_no_nested': SettingBool,
362 'format_avro_schema_registry_url': SettingURI,
363 'output_format_tsv_crlf_end_of_line': SettingBool,
364 'join_algorithm': SettingJoinAlgorithm,
365 'memory_profiler_step': SettingUInt64,
366 'output_format_csv_crlf_end_of_line': SettingBool,
367 'allow_experimental_alter_materialized_view_structure': SettingBool,
368 'enable_early_constant_folding': SettingBool,
369 'deduplicate_blocks_in_dependent_materialized_views': SettingBool,
370 'use_compact_format_in_distributed_parts_names': SettingBool,
371 'multiple_joins_rewriter_version': SettingUInt64,
372
373 'min_insert_block_size_rows_for_materialized_views': SettingUInt64,
374 'min_insert_block_size_bytes_for_materialized_views': SettingUInt64,
375 'max_final_threads': SettingUInt64,
376 'background_buffer_flush_schedule_pool_size': SettingUInt64,
377 'background_distributed_schedule_pool_size': SettingUInt64,
378 'special_sort': SettingSpecialSort,
379 'optimize_distributed_group_by_sharding_key': SettingBool,
380 'log_queries_min_type': SettingLogQueriesType,
381 'allow_suspicious_codecs': SettingBool,
382 'metrics_perf_events_enabled': SettingBool,
383 'metrics_perf_events_list': SettingString,
384 'join_on_disk_max_files_to_merge': SettingUInt64,
385 'temporary_files_codec': SettingString,
386 'max_untracked_memory': SettingUInt64,
387 'memory_profiler_sample_probability': SettingFloat,
388 'optimize_aggregation_in_order': SettingBool,
389 'default_database_engine': SettingDefaultDatabaseEngine,
390 'allow_experimental_database_atomic': SettingBool,
391 'show_table_uuid_in_table_create_query_if_not_nil': SettingBool,
392 'optimize_arithmetic_operations_in_aggregate_functions': SettingBool,
393 'validate_polygons': SettingBool,
394 'transform_null_in': SettingBool,
395 'allow_nondeterministic_mutations': SettingBool,
396 'lock_acquire_timeout': SettingSeconds,
397 'materialize_ttl_after_modify': SettingBool,
398 'allow_experimental_geo_types': SettingBool,
399 'output_format_pretty_max_value_width': SettingUInt64,
400 'format_regexp': SettingString,
401 'format_regexp_escaping_rule': SettingString,
402 'format_regexp_skip_unmatched': SettingBool,
403 'output_format_enable_streaming': SettingBool,
352404 }
0
0 from ..util.compat import asbool
11 from ..varint import write_varint
22 from ..writer import write_binary_str
33
1717 class SettingBool(SettingType):
1818 @classmethod
1919 def write(cls, value, buf):
20 write_varint(bool(value), buf)
20 write_varint(asbool(value), buf)
2121
2222
2323 class SettingString(SettingType):
00 import logging
11
2 from ..writer import write_binary_str
2 from ..writer import write_binary_str, write_binary_uint8
33 from .available import settings as available_settings
44
55
66 logger = logging.getLogger(__name__)
77
88
9 def write_settings(settings, buf):
9 def write_settings(settings, buf, settings_as_strings, is_important=False):
1010 for setting, value in (settings or {}).items():
11 setting_writer = available_settings.get(setting)
11 # If the server support settings as string we do not need to know
12 # anything about them, so we can write any setting.
13 if settings_as_strings:
14 write_binary_str(setting, buf)
15 write_binary_uint8(int(is_important), buf)
16 write_binary_str(str(value), buf)
1217
13 if not setting_writer:
14 logger.warning('Unknown setting %s. Skipping', setting)
15 continue
16
17 write_binary_str(setting, buf)
18 setting_writer.write(value, buf)
18 else:
19 # If the server requires string in binary,
20 # then they cannot be written without type.
21 setting_writer = available_settings.get(setting)
22 if not setting_writer:
23 logger.warning('Unknown setting %s. Skipping', setting)
24 continue
25 write_binary_str(setting, buf)
26 setting_writer.write(value, buf)
1927
2028 write_binary_str('', buf) # end of settings
7474 self.fin)
7575 data.append(column)
7676
77 block = ColumnOrientedBlock(
77 if self.context.client_settings['use_numpy']:
78 from ..numpy.block import NumpyColumnOrientedBlock
79 block_cls = NumpyColumnOrientedBlock
80 else:
81 block_cls = ColumnOrientedBlock
82
83 block = block_cls(
7884 columns_with_types=list(zip(names, types)),
7985 data=data,
8086 info=info,
66
77
88 if PY3:
9 from urllib.parse import parse_qs, urlparse # noqa: F401
9 from urllib.parse import parse_qs, urlparse, unquote # noqa: F401
1010
1111 string_types = str,
1212 integer_types = int,
1717 StandardError = Exception
1818
1919 else:
20 from urlparse import parse_qs, urlparse # noqa: F401
20 from urlparse import parse_qs, urlparse, unquote # noqa: F401
2121
2222 string_types = basestring, # noqa: F821
2323 integer_types = (int, long) # noqa: F821
0 from itertools import islice
0 from itertools import islice, tee
11
22
33 def chunks(seq, n):
4 it = iter(seq)
5 item = list(islice(it, n))
6 while item:
7 yield item
4 # islice is MUCH slower than slice for lists and tuples.
5 if isinstance(seq, (list, tuple)):
6 i = 0
7 item = seq[i:i+n]
8 while item:
9 yield list(item)
10 i += n
11 item = seq[i:i+n]
12
13 else:
14 it = iter(seq)
815 item = list(islice(it, n))
16 while item:
17 yield item
18 item = list(islice(it, n))
19
20
21 def pairwise(iterable):
22 a, b = tee(iterable)
23 next(b, None)
24 return zip(a, b)
925
1026
1127 def column_chunks(columns, n):
0 /* Generated by Cython 0.29.13 */
0 /* Generated by Cython 0.29.21 */
11
22 /* BEGIN: Cython Metadata
33 {
44 "distutils": {
5 "depends": [],
6 "name": "clickhouse_driver.varint",
5 "depends": [],
6 "name": "clickhouse_driver.varint",
77 "sources": [
88 "clickhouse_driver/varint.pyx"
99 ]
10 },
10 },
1111 "module_name": "clickhouse_driver.varint"
1212 }
1313 END: Cython Metadata */
1919 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
2020 #error Cython requires Python 2.6+ or Python 3.3+.
2121 #else
22 #define CYTHON_ABI "0_29_13"
23 #define CYTHON_HEX_VERSION 0x001D0DF0
22 #define CYTHON_ABI "0_29_21"
23 #define CYTHON_HEX_VERSION 0x001D15F0
2424 #define CYTHON_FUTURE_DIVISION 1
2525 #include <stddef.h>
2626 #ifndef offsetof
447447 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
448448 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
449449 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
450 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
450451 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
452 #else
453 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
454 #endif
451455 #else
452456 #define CYTHON_PEP393_ENABLED 0
453457 #define PyUnicode_1BYTE_KIND 1
496500 #define PyString_Type PyUnicode_Type
497501 #define PyString_Check PyUnicode_Check
498502 #define PyString_CheckExact PyUnicode_CheckExact
503 #ifndef PyObject_Unicode
499504 #define PyObject_Unicode PyObject_Str
505 #endif
500506 #endif
501507 #if PY_MAJOR_VERSION >= 3
502508 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
507513 #endif
508514 #ifndef PySet_CheckExact
509515 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
516 #endif
517 #if PY_VERSION_HEX >= 0x030900A4
518 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
519 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
520 #else
521 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
522 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
510523 #endif
511524 #if CYTHON_ASSUME_SAFE_MACROS
512525 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
547560 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
548561 #endif
549562 #if PY_MAJOR_VERSION >= 3
550 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : (Py_INCREF(func), func))
563 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
551564 #else
552565 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
553566 #endif
588601 #define __Pyx_truncl truncl
589602 #endif
590603
591
604 #define __PYX_MARK_ERR_POS(f_index, lineno) \
605 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
592606 #define __PYX_ERR(f_index, lineno, Ln_error) \
593 { \
594 __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \
595 }
607 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
596608
597609 #ifndef __PYX_EXTERN_C
598610 #ifdef __cplusplus
10611073 static void __Pyx_AddTraceback(const char *funcname, int c_line,
10621074 int py_line, const char *filename);
10631075
1076 /* CIntToPy.proto */
1077 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value);
1078
10641079 /* CIntFromPy.proto */
1065 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *);
1080 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *);
10661081
10671082 /* CIntToPy.proto */
10681083 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
11931208 static const char __pyx_k_number[] = "number";
11941209 static const char __pyx_k_result[] = "result";
11951210 static const char __pyx_k_num_buf[] = "num_buf";
1196 static const char __pyx_k_towrite[] = "towrite";
11971211 static const char __pyx_k_read_one[] = "read_one";
1212 static const char __pyx_k_to_write[] = "to_write";
1213 static const char __pyx_k_make_varint[] = "make_varint";
11981214 static const char __pyx_k_read_varint[] = "read_varint";
11991215 static const char __pyx_k_write_varint[] = "write_varint";
12001216 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
12071223 static PyObject *__pyx_n_s_f;
12081224 static PyObject *__pyx_n_s_i;
12091225 static PyObject *__pyx_n_s_main;
1226 static PyObject *__pyx_n_s_make_varint;
12101227 static PyObject *__pyx_n_s_name;
12111228 static PyObject *__pyx_n_s_num_buf;
12121229 static PyObject *__pyx_n_s_number;
12151232 static PyObject *__pyx_n_s_result;
12161233 static PyObject *__pyx_n_s_shift;
12171234 static PyObject *__pyx_n_s_test;
1218 static PyObject *__pyx_n_s_towrite;
1235 static PyObject *__pyx_n_s_to_write;
12191236 static PyObject *__pyx_n_s_write;
12201237 static PyObject *__pyx_n_s_write_varint;
1221 static PyObject *__pyx_pf_17clickhouse_driver_6varint_write_varint(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_number, PyObject *__pyx_v_buf); /* proto */
1222 static PyObject *__pyx_pf_17clickhouse_driver_6varint_2read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
1238 static PyObject *__pyx_pf_17clickhouse_driver_6varint_make_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number); /* proto */
1239 static PyObject *__pyx_pf_17clickhouse_driver_6varint_2write_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number, PyObject *__pyx_v_buf); /* proto */
1240 static PyObject *__pyx_pf_17clickhouse_driver_6varint_4read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f); /* proto */
12231241 static PyObject *__pyx_tuple_;
12241242 static PyObject *__pyx_tuple__3;
1243 static PyObject *__pyx_tuple__5;
12251244 static PyObject *__pyx_codeobj__2;
12261245 static PyObject *__pyx_codeobj__4;
1246 static PyObject *__pyx_codeobj__6;
12271247 /* Late includes */
12281248
12291249 /* "clickhouse_driver/varint.pyx":4
12301250 *
12311251 *
1232 * def write_varint(Py_ssize_t number, buf): # <<<<<<<<<<<<<<
1252 * def make_varint(unsigned long long number): # <<<<<<<<<<<<<<
12331253 * """
12341254 * Writes integer of variable length using LEB128.
12351255 */
12361256
12371257 /* Python wrapper */
1238 static PyObject *__pyx_pw_17clickhouse_driver_6varint_1write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1239 static char __pyx_doc_17clickhouse_driver_6varint_write_varint[] = "\n Writes integer of variable length using LEB128.\n ";
1240 static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_1write_varint = {"write_varint", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_6varint_1write_varint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_6varint_write_varint};
1241 static PyObject *__pyx_pw_17clickhouse_driver_6varint_1write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1242 Py_ssize_t __pyx_v_number;
1258 static PyObject *__pyx_pw_17clickhouse_driver_6varint_1make_varint(PyObject *__pyx_self, PyObject *__pyx_arg_number); /*proto*/
1259 static char __pyx_doc_17clickhouse_driver_6varint_make_varint[] = "\n Writes integer of variable length using LEB128.\n ";
1260 static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_1make_varint = {"make_varint", (PyCFunction)__pyx_pw_17clickhouse_driver_6varint_1make_varint, METH_O, __pyx_doc_17clickhouse_driver_6varint_make_varint};
1261 static PyObject *__pyx_pw_17clickhouse_driver_6varint_1make_varint(PyObject *__pyx_self, PyObject *__pyx_arg_number) {
1262 unsigned PY_LONG_LONG __pyx_v_number;
1263 int __pyx_lineno = 0;
1264 const char *__pyx_filename = NULL;
1265 int __pyx_clineno = 0;
1266 PyObject *__pyx_r = 0;
1267 __Pyx_RefNannyDeclarations
1268 __Pyx_RefNannySetupContext("make_varint (wrapper)", 0);
1269 assert(__pyx_arg_number); {
1270 __pyx_v_number = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_arg_number); if (unlikely((__pyx_v_number == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error)
1271 }
1272 goto __pyx_L4_argument_unpacking_done;
1273 __pyx_L3_error:;
1274 __Pyx_AddTraceback("clickhouse_driver.varint.make_varint", __pyx_clineno, __pyx_lineno, __pyx_filename);
1275 __Pyx_RefNannyFinishContext();
1276 return NULL;
1277 __pyx_L4_argument_unpacking_done:;
1278 __pyx_r = __pyx_pf_17clickhouse_driver_6varint_make_varint(__pyx_self, ((unsigned PY_LONG_LONG)__pyx_v_number));
1279
1280 /* function exit code */
1281 __Pyx_RefNannyFinishContext();
1282 return __pyx_r;
1283 }
1284
1285 static PyObject *__pyx_pf_17clickhouse_driver_6varint_make_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number) {
1286 unsigned char __pyx_v_to_write;
1287 unsigned char __pyx_v_i;
1288 unsigned char __pyx_v_num_buf[32];
1289 PyObject *__pyx_r = NULL;
1290 __Pyx_RefNannyDeclarations
1291 int __pyx_t_1;
1292 PyObject *__pyx_t_2 = NULL;
1293 int __pyx_lineno = 0;
1294 const char *__pyx_filename = NULL;
1295 int __pyx_clineno = 0;
1296 __Pyx_RefNannySetupContext("make_varint", 0);
1297
1298 /* "clickhouse_driver/varint.pyx":8
1299 * Writes integer of variable length using LEB128.
1300 * """
1301 * cdef unsigned char to_write, i = 0 # <<<<<<<<<<<<<<
1302 * # unsigned PY_LONG_LONG checks integer on function call and
1303 * # raises OverflowError if integer overflows unsigned PY_LONG_LONG.
1304 */
1305 __pyx_v_i = 0;
1306
1307 /* "clickhouse_driver/varint.pyx":14
1308 * cdef unsigned char num_buf[32]
1309 *
1310 * while True: # <<<<<<<<<<<<<<
1311 * to_write = number & 0x7f
1312 * number >>= 7
1313 */
1314 while (1) {
1315
1316 /* "clickhouse_driver/varint.pyx":15
1317 *
1318 * while True:
1319 * to_write = number & 0x7f # <<<<<<<<<<<<<<
1320 * number >>= 7
1321 * if number:
1322 */
1323 __pyx_v_to_write = (__pyx_v_number & 0x7f);
1324
1325 /* "clickhouse_driver/varint.pyx":16
1326 * while True:
1327 * to_write = number & 0x7f
1328 * number >>= 7 # <<<<<<<<<<<<<<
1329 * if number:
1330 * num_buf[i] = to_write | 0x80
1331 */
1332 __pyx_v_number = (__pyx_v_number >> 7);
1333
1334 /* "clickhouse_driver/varint.pyx":17
1335 * to_write = number & 0x7f
1336 * number >>= 7
1337 * if number: # <<<<<<<<<<<<<<
1338 * num_buf[i] = to_write | 0x80
1339 * i += 1
1340 */
1341 __pyx_t_1 = (__pyx_v_number != 0);
1342 if (__pyx_t_1) {
1343
1344 /* "clickhouse_driver/varint.pyx":18
1345 * number >>= 7
1346 * if number:
1347 * num_buf[i] = to_write | 0x80 # <<<<<<<<<<<<<<
1348 * i += 1
1349 * else:
1350 */
1351 (__pyx_v_num_buf[__pyx_v_i]) = (__pyx_v_to_write | 0x80);
1352
1353 /* "clickhouse_driver/varint.pyx":19
1354 * if number:
1355 * num_buf[i] = to_write | 0x80
1356 * i += 1 # <<<<<<<<<<<<<<
1357 * else:
1358 * num_buf[i] = to_write
1359 */
1360 __pyx_v_i = (__pyx_v_i + 1);
1361
1362 /* "clickhouse_driver/varint.pyx":17
1363 * to_write = number & 0x7f
1364 * number >>= 7
1365 * if number: # <<<<<<<<<<<<<<
1366 * num_buf[i] = to_write | 0x80
1367 * i += 1
1368 */
1369 goto __pyx_L5;
1370 }
1371
1372 /* "clickhouse_driver/varint.pyx":21
1373 * i += 1
1374 * else:
1375 * num_buf[i] = to_write # <<<<<<<<<<<<<<
1376 * i += 1
1377 * break
1378 */
1379 /*else*/ {
1380 (__pyx_v_num_buf[__pyx_v_i]) = __pyx_v_to_write;
1381
1382 /* "clickhouse_driver/varint.pyx":22
1383 * else:
1384 * num_buf[i] = to_write
1385 * i += 1 # <<<<<<<<<<<<<<
1386 * break
1387 *
1388 */
1389 __pyx_v_i = (__pyx_v_i + 1);
1390
1391 /* "clickhouse_driver/varint.pyx":23
1392 * num_buf[i] = to_write
1393 * i += 1
1394 * break # <<<<<<<<<<<<<<
1395 *
1396 * return PyBytes_FromStringAndSize(<char *>num_buf, i)
1397 */
1398 goto __pyx_L4_break;
1399 }
1400 __pyx_L5:;
1401 }
1402 __pyx_L4_break:;
1403
1404 /* "clickhouse_driver/varint.pyx":25
1405 * break
1406 *
1407 * return PyBytes_FromStringAndSize(<char *>num_buf, i) # <<<<<<<<<<<<<<
1408 *
1409 *
1410 */
1411 __Pyx_XDECREF(__pyx_r);
1412 __pyx_t_2 = PyBytes_FromStringAndSize(((char *)__pyx_v_num_buf), __pyx_v_i); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error)
1413 __Pyx_GOTREF(__pyx_t_2);
1414 __pyx_r = __pyx_t_2;
1415 __pyx_t_2 = 0;
1416 goto __pyx_L0;
1417
1418 /* "clickhouse_driver/varint.pyx":4
1419 *
1420 *
1421 * def make_varint(unsigned long long number): # <<<<<<<<<<<<<<
1422 * """
1423 * Writes integer of variable length using LEB128.
1424 */
1425
1426 /* function exit code */
1427 __pyx_L1_error:;
1428 __Pyx_XDECREF(__pyx_t_2);
1429 __Pyx_AddTraceback("clickhouse_driver.varint.make_varint", __pyx_clineno, __pyx_lineno, __pyx_filename);
1430 __pyx_r = NULL;
1431 __pyx_L0:;
1432 __Pyx_XGIVEREF(__pyx_r);
1433 __Pyx_RefNannyFinishContext();
1434 return __pyx_r;
1435 }
1436
1437 /* "clickhouse_driver/varint.pyx":28
1438 *
1439 *
1440 * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<<
1441 * """
1442 * Writes integer of variable length using LEB128.
1443 */
1444
1445 /* Python wrapper */
1446 static PyObject *__pyx_pw_17clickhouse_driver_6varint_3write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1447 static char __pyx_doc_17clickhouse_driver_6varint_2write_varint[] = "\n Writes integer of variable length using LEB128.\n ";
1448 static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_3write_varint = {"write_varint", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_17clickhouse_driver_6varint_3write_varint, METH_VARARGS|METH_KEYWORDS, __pyx_doc_17clickhouse_driver_6varint_2write_varint};
1449 static PyObject *__pyx_pw_17clickhouse_driver_6varint_3write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1450 unsigned PY_LONG_LONG __pyx_v_number;
12431451 PyObject *__pyx_v_buf = 0;
1452 int __pyx_lineno = 0;
1453 const char *__pyx_filename = NULL;
1454 int __pyx_clineno = 0;
12441455 PyObject *__pyx_r = 0;
12451456 __Pyx_RefNannyDeclarations
12461457 __Pyx_RefNannySetupContext("write_varint (wrapper)", 0);
12671478 case 1:
12681479 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
12691480 else {
1270 __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, 1); __PYX_ERR(0, 4, __pyx_L3_error)
1481 __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, 1); __PYX_ERR(0, 28, __pyx_L3_error)
12711482 }
12721483 }
12731484 if (unlikely(kw_args > 0)) {
1274 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_varint") < 0)) __PYX_ERR(0, 4, __pyx_L3_error)
1485 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_varint") < 0)) __PYX_ERR(0, 28, __pyx_L3_error)
12751486 }
12761487 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
12771488 goto __pyx_L5_argtuple_error;
12791490 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
12801491 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
12811492 }
1282 __pyx_v_number = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_number == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error)
1493 __pyx_v_number = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(values[0]); if (unlikely((__pyx_v_number == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 28, __pyx_L3_error)
12831494 __pyx_v_buf = values[1];
12841495 }
12851496 goto __pyx_L4_argument_unpacking_done;
12861497 __pyx_L5_argtuple_error:;
1287 __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4, __pyx_L3_error)
1498 __Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 28, __pyx_L3_error)
12881499 __pyx_L3_error:;
12891500 __Pyx_AddTraceback("clickhouse_driver.varint.write_varint", __pyx_clineno, __pyx_lineno, __pyx_filename);
12901501 __Pyx_RefNannyFinishContext();
12911502 return NULL;
12921503 __pyx_L4_argument_unpacking_done:;
1293 __pyx_r = __pyx_pf_17clickhouse_driver_6varint_write_varint(__pyx_self, __pyx_v_number, __pyx_v_buf);
1504 __pyx_r = __pyx_pf_17clickhouse_driver_6varint_2write_varint(__pyx_self, __pyx_v_number, __pyx_v_buf);
12941505
12951506 /* function exit code */
12961507 __Pyx_RefNannyFinishContext();
12971508 return __pyx_r;
12981509 }
12991510
1300 static PyObject *__pyx_pf_17clickhouse_driver_6varint_write_varint(CYTHON_UNUSED PyObject *__pyx_self, Py_ssize_t __pyx_v_number, PyObject *__pyx_v_buf) {
1301 Py_ssize_t __pyx_v_i;
1302 unsigned char __pyx_v_towrite;
1511 static PyObject *__pyx_pf_17clickhouse_driver_6varint_2write_varint(CYTHON_UNUSED PyObject *__pyx_self, unsigned PY_LONG_LONG __pyx_v_number, PyObject *__pyx_v_buf) {
1512 unsigned char __pyx_v_to_write;
1513 unsigned char __pyx_v_i;
13031514 unsigned char __pyx_v_num_buf[32];
13041515 PyObject *__pyx_r = NULL;
13051516 __Pyx_RefNannyDeclarations
13081519 PyObject *__pyx_t_3 = NULL;
13091520 PyObject *__pyx_t_4 = NULL;
13101521 PyObject *__pyx_t_5 = NULL;
1522 int __pyx_lineno = 0;
1523 const char *__pyx_filename = NULL;
1524 int __pyx_clineno = 0;
13111525 __Pyx_RefNannySetupContext("write_varint", 0);
13121526
1313 /* "clickhouse_driver/varint.pyx":8
1527 /* "clickhouse_driver/varint.pyx":32
13141528 * Writes integer of variable length using LEB128.
13151529 * """
1316 * cdef Py_ssize_t i = 0 # <<<<<<<<<<<<<<
1317 * cdef unsigned char towrite
1318 * # Py_ssize_t checks integer on function call and
1530 * cdef unsigned char to_write, i = 0 # <<<<<<<<<<<<<<
1531 * # unsigned PY_LONG_LONG checks integer on function call and
1532 * # raises OverflowError if integer overflows unsigned PY_LONG_LONG.
13191533 */
13201534 __pyx_v_i = 0;
13211535
1322 /* "clickhouse_driver/varint.pyx":15
1536 /* "clickhouse_driver/varint.pyx":38
13231537 * cdef unsigned char num_buf[32]
13241538 *
13251539 * while True: # <<<<<<<<<<<<<<
1326 * towrite = number & 0x7f
1540 * to_write = number & 0x7f
13271541 * number >>= 7
13281542 */
13291543 while (1) {
13301544
1331 /* "clickhouse_driver/varint.pyx":16
1545 /* "clickhouse_driver/varint.pyx":39
13321546 *
13331547 * while True:
1334 * towrite = number & 0x7f # <<<<<<<<<<<<<<
1548 * to_write = number & 0x7f # <<<<<<<<<<<<<<
13351549 * number >>= 7
13361550 * if number:
13371551 */
1338 __pyx_v_towrite = (__pyx_v_number & 0x7f);
1339
1340 /* "clickhouse_driver/varint.pyx":17
1552 __pyx_v_to_write = (__pyx_v_number & 0x7f);
1553
1554 /* "clickhouse_driver/varint.pyx":40
13411555 * while True:
1342 * towrite = number & 0x7f
1556 * to_write = number & 0x7f
13431557 * number >>= 7 # <<<<<<<<<<<<<<
13441558 * if number:
1345 * num_buf[i] = towrite | 0x80
1559 * num_buf[i] = to_write | 0x80
13461560 */
13471561 __pyx_v_number = (__pyx_v_number >> 7);
13481562
1349 /* "clickhouse_driver/varint.pyx":18
1350 * towrite = number & 0x7f
1563 /* "clickhouse_driver/varint.pyx":41
1564 * to_write = number & 0x7f
13511565 * number >>= 7
13521566 * if number: # <<<<<<<<<<<<<<
1353 * num_buf[i] = towrite | 0x80
1567 * num_buf[i] = to_write | 0x80
13541568 * i += 1
13551569 */
13561570 __pyx_t_1 = (__pyx_v_number != 0);
13571571 if (__pyx_t_1) {
13581572
1359 /* "clickhouse_driver/varint.pyx":19
1573 /* "clickhouse_driver/varint.pyx":42
13601574 * number >>= 7
13611575 * if number:
1362 * num_buf[i] = towrite | 0x80 # <<<<<<<<<<<<<<
1576 * num_buf[i] = to_write | 0x80 # <<<<<<<<<<<<<<
13631577 * i += 1
13641578 * else:
13651579 */
1366 (__pyx_v_num_buf[__pyx_v_i]) = (__pyx_v_towrite | 0x80);
1367
1368 /* "clickhouse_driver/varint.pyx":20
1580 (__pyx_v_num_buf[__pyx_v_i]) = (__pyx_v_to_write | 0x80);
1581
1582 /* "clickhouse_driver/varint.pyx":43
13691583 * if number:
1370 * num_buf[i] = towrite | 0x80
1584 * num_buf[i] = to_write | 0x80
13711585 * i += 1 # <<<<<<<<<<<<<<
13721586 * else:
1373 * num_buf[i] = towrite
1587 * num_buf[i] = to_write
13741588 */
13751589 __pyx_v_i = (__pyx_v_i + 1);
13761590
1377 /* "clickhouse_driver/varint.pyx":18
1378 * towrite = number & 0x7f
1591 /* "clickhouse_driver/varint.pyx":41
1592 * to_write = number & 0x7f
13791593 * number >>= 7
13801594 * if number: # <<<<<<<<<<<<<<
1381 * num_buf[i] = towrite | 0x80
1595 * num_buf[i] = to_write | 0x80
13821596 * i += 1
13831597 */
13841598 goto __pyx_L5;
13851599 }
13861600
1387 /* "clickhouse_driver/varint.pyx":22
1601 /* "clickhouse_driver/varint.pyx":45
13881602 * i += 1
13891603 * else:
1390 * num_buf[i] = towrite # <<<<<<<<<<<<<<
1604 * num_buf[i] = to_write # <<<<<<<<<<<<<<
13911605 * i += 1
13921606 * break
13931607 */
13941608 /*else*/ {
1395 (__pyx_v_num_buf[__pyx_v_i]) = __pyx_v_towrite;
1396
1397 /* "clickhouse_driver/varint.pyx":23
1609 (__pyx_v_num_buf[__pyx_v_i]) = __pyx_v_to_write;
1610
1611 /* "clickhouse_driver/varint.pyx":46
13981612 * else:
1399 * num_buf[i] = towrite
1613 * num_buf[i] = to_write
14001614 * i += 1 # <<<<<<<<<<<<<<
14011615 * break
14021616 *
14031617 */
14041618 __pyx_v_i = (__pyx_v_i + 1);
14051619
1406 /* "clickhouse_driver/varint.pyx":24
1407 * num_buf[i] = towrite
1620 /* "clickhouse_driver/varint.pyx":47
1621 * num_buf[i] = to_write
14081622 * i += 1
14091623 * break # <<<<<<<<<<<<<<
14101624 *
14161630 }
14171631 __pyx_L4_break:;
14181632
1419 /* "clickhouse_driver/varint.pyx":26
1633 /* "clickhouse_driver/varint.pyx":49
14201634 * break
14211635 *
14221636 * buf.write(PyBytes_FromStringAndSize(<char *>num_buf, i)) # <<<<<<<<<<<<<<
14231637 *
14241638 *
14251639 */
1426 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 26, __pyx_L1_error)
1640 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_buf, __pyx_n_s_write); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 49, __pyx_L1_error)
14271641 __Pyx_GOTREF(__pyx_t_3);
1428 __pyx_t_4 = PyBytes_FromStringAndSize(((char *)__pyx_v_num_buf), __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L1_error)
1642 __pyx_t_4 = PyBytes_FromStringAndSize(((char *)__pyx_v_num_buf), __pyx_v_i); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)
14291643 __Pyx_GOTREF(__pyx_t_4);
14301644 __pyx_t_5 = NULL;
14311645 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
14401654 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
14411655 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
14421656 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1443 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error)
1657 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error)
14441658 __Pyx_GOTREF(__pyx_t_2);
14451659 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14461660 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14471661
1448 /* "clickhouse_driver/varint.pyx":4
1449 *
1450 *
1451 * def write_varint(Py_ssize_t number, buf): # <<<<<<<<<<<<<<
1662 /* "clickhouse_driver/varint.pyx":28
1663 *
1664 *
1665 * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<<
14521666 * """
14531667 * Writes integer of variable length using LEB128.
14541668 */
14691683 return __pyx_r;
14701684 }
14711685
1472 /* "clickhouse_driver/varint.pyx":29
1686 /* "clickhouse_driver/varint.pyx":52
14731687 *
14741688 *
14751689 * def read_varint(f): # <<<<<<<<<<<<<<
14781692 */
14791693
14801694 /* Python wrapper */
1481 static PyObject *__pyx_pw_17clickhouse_driver_6varint_3read_varint(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
1482 static char __pyx_doc_17clickhouse_driver_6varint_2read_varint[] = "\n Reads integer of variable length using LEB128.\n ";
1483 static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_3read_varint = {"read_varint", (PyCFunction)__pyx_pw_17clickhouse_driver_6varint_3read_varint, METH_O, __pyx_doc_17clickhouse_driver_6varint_2read_varint};
1484 static PyObject *__pyx_pw_17clickhouse_driver_6varint_3read_varint(PyObject *__pyx_self, PyObject *__pyx_v_f) {
1695 static PyObject *__pyx_pw_17clickhouse_driver_6varint_5read_varint(PyObject *__pyx_self, PyObject *__pyx_v_f); /*proto*/
1696 static char __pyx_doc_17clickhouse_driver_6varint_4read_varint[] = "\n Reads integer of variable length using LEB128.\n ";
1697 static PyMethodDef __pyx_mdef_17clickhouse_driver_6varint_5read_varint = {"read_varint", (PyCFunction)__pyx_pw_17clickhouse_driver_6varint_5read_varint, METH_O, __pyx_doc_17clickhouse_driver_6varint_4read_varint};
1698 static PyObject *__pyx_pw_17clickhouse_driver_6varint_5read_varint(PyObject *__pyx_self, PyObject *__pyx_v_f) {
14851699 PyObject *__pyx_r = 0;
14861700 __Pyx_RefNannyDeclarations
14871701 __Pyx_RefNannySetupContext("read_varint (wrapper)", 0);
1488 __pyx_r = __pyx_pf_17clickhouse_driver_6varint_2read_varint(__pyx_self, ((PyObject *)__pyx_v_f));
1702 __pyx_r = __pyx_pf_17clickhouse_driver_6varint_4read_varint(__pyx_self, ((PyObject *)__pyx_v_f));
14891703
14901704 /* function exit code */
14911705 __Pyx_RefNannyFinishContext();
14921706 return __pyx_r;
14931707 }
14941708
1495 static PyObject *__pyx_pf_17clickhouse_driver_6varint_2read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
1496 Py_ssize_t __pyx_v_shift;
1497 Py_ssize_t __pyx_v_result;
1498 unsigned char __pyx_v_i;
1709 static PyObject *__pyx_pf_17clickhouse_driver_6varint_4read_varint(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_f) {
1710 unsigned char __pyx_v_shift;
1711 unsigned PY_LONG_LONG __pyx_v_i;
1712 unsigned PY_LONG_LONG __pyx_v_result;
1713 PyObject *__pyx_v_read_one = NULL;
14991714 PyObject *__pyx_r = NULL;
15001715 __Pyx_RefNannyDeclarations
15011716 PyObject *__pyx_t_1 = NULL;
15021717 PyObject *__pyx_t_2 = NULL;
15031718 PyObject *__pyx_t_3 = NULL;
1504 unsigned char __pyx_t_4;
1719 unsigned PY_LONG_LONG __pyx_t_4;
15051720 int __pyx_t_5;
1721 int __pyx_lineno = 0;
1722 const char *__pyx_filename = NULL;
1723 int __pyx_clineno = 0;
15061724 __Pyx_RefNannySetupContext("read_varint", 0);
15071725
1508 /* "clickhouse_driver/varint.pyx":33
1726 /* "clickhouse_driver/varint.pyx":56
15091727 * Reads integer of variable length using LEB128.
15101728 * """
1511 * cdef Py_ssize_t shift = 0 # <<<<<<<<<<<<<<
1512 * cdef Py_ssize_t result = 0
1513 * cdef unsigned char i
1729 * cdef unsigned char shift = 0 # <<<<<<<<<<<<<<
1730 * cdef unsigned long long i, result = 0
1731 *
15141732 */
15151733 __pyx_v_shift = 0;
15161734
1517 /* "clickhouse_driver/varint.pyx":34
1735 /* "clickhouse_driver/varint.pyx":57
15181736 * """
1519 * cdef Py_ssize_t shift = 0
1520 * cdef Py_ssize_t result = 0 # <<<<<<<<<<<<<<
1521 * cdef unsigned char i
1522 *
1737 * cdef unsigned char shift = 0
1738 * cdef unsigned long long i, result = 0 # <<<<<<<<<<<<<<
1739 *
1740 * read_one = f.read_one
15231741 */
15241742 __pyx_v_result = 0;
15251743
1526 /* "clickhouse_driver/varint.pyx":37
1527 * cdef unsigned char i
1744 /* "clickhouse_driver/varint.pyx":59
1745 * cdef unsigned long long i, result = 0
1746 *
1747 * read_one = f.read_one # <<<<<<<<<<<<<<
1748 *
1749 * while True:
1750 */
1751 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read_one); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
1752 __Pyx_GOTREF(__pyx_t_1);
1753 __pyx_v_read_one = __pyx_t_1;
1754 __pyx_t_1 = 0;
1755
1756 /* "clickhouse_driver/varint.pyx":61
1757 * read_one = f.read_one
15281758 *
15291759 * while True: # <<<<<<<<<<<<<<
1530 * i = f.read_one()
1760 * i = read_one()
15311761 * result |= (i & 0x7f) << shift
15321762 */
15331763 while (1) {
15341764
1535 /* "clickhouse_driver/varint.pyx":38
1765 /* "clickhouse_driver/varint.pyx":62
15361766 *
15371767 * while True:
1538 * i = f.read_one() # <<<<<<<<<<<<<<
1768 * i = read_one() # <<<<<<<<<<<<<<
15391769 * result |= (i & 0x7f) << shift
15401770 * shift += 7
15411771 */
1542 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_f, __pyx_n_s_read_one); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 38, __pyx_L1_error)
1543 __Pyx_GOTREF(__pyx_t_2);
1544 __pyx_t_3 = NULL;
1772 __Pyx_INCREF(__pyx_v_read_one);
1773 __pyx_t_2 = __pyx_v_read_one; __pyx_t_3 = NULL;
15451774 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
15461775 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
15471776 if (likely(__pyx_t_3)) {
15531782 }
15541783 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3) : __Pyx_PyObject_CallNoArg(__pyx_t_2);
15551784 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1556 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 38, __pyx_L1_error)
1785 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
15571786 __Pyx_GOTREF(__pyx_t_1);
15581787 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1559 __pyx_t_4 = __Pyx_PyInt_As_unsigned_char(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned char)-1) && PyErr_Occurred())) __PYX_ERR(0, 38, __pyx_L1_error)
1788 __pyx_t_4 = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(__pyx_t_1); if (unlikely((__pyx_t_4 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) __PYX_ERR(0, 62, __pyx_L1_error)
15601789 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15611790 __pyx_v_i = __pyx_t_4;
15621791
1563 /* "clickhouse_driver/varint.pyx":39
1792 /* "clickhouse_driver/varint.pyx":63
15641793 * while True:
1565 * i = f.read_one()
1794 * i = read_one()
15661795 * result |= (i & 0x7f) << shift # <<<<<<<<<<<<<<
15671796 * shift += 7
15681797 * if i < 0x80:
15691798 */
15701799 __pyx_v_result = (__pyx_v_result | ((__pyx_v_i & 0x7f) << __pyx_v_shift));
15711800
1572 /* "clickhouse_driver/varint.pyx":40
1573 * i = f.read_one()
1801 /* "clickhouse_driver/varint.pyx":64
1802 * i = read_one()
15741803 * result |= (i & 0x7f) << shift
15751804 * shift += 7 # <<<<<<<<<<<<<<
15761805 * if i < 0x80:
15781807 */
15791808 __pyx_v_shift = (__pyx_v_shift + 7);
15801809
1581 /* "clickhouse_driver/varint.pyx":41
1810 /* "clickhouse_driver/varint.pyx":65
15821811 * result |= (i & 0x7f) << shift
15831812 * shift += 7
15841813 * if i < 0x80: # <<<<<<<<<<<<<<
15881817 __pyx_t_5 = ((__pyx_v_i < 0x80) != 0);
15891818 if (__pyx_t_5) {
15901819
1591 /* "clickhouse_driver/varint.pyx":42
1820 /* "clickhouse_driver/varint.pyx":66
15921821 * shift += 7
15931822 * if i < 0x80:
15941823 * break # <<<<<<<<<<<<<<
15971826 */
15981827 goto __pyx_L4_break;
15991828
1600 /* "clickhouse_driver/varint.pyx":41
1829 /* "clickhouse_driver/varint.pyx":65
16011830 * result |= (i & 0x7f) << shift
16021831 * shift += 7
16031832 * if i < 0x80: # <<<<<<<<<<<<<<
16081837 }
16091838 __pyx_L4_break:;
16101839
1611 /* "clickhouse_driver/varint.pyx":44
1840 /* "clickhouse_driver/varint.pyx":68
16121841 * break
16131842 *
16141843 * return result # <<<<<<<<<<<<<<
16151844 */
16161845 __Pyx_XDECREF(__pyx_r);
1617 __pyx_t_1 = PyInt_FromSsize_t(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
1846 __pyx_t_1 = __Pyx_PyInt_From_unsigned_PY_LONG_LONG(__pyx_v_result); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
16181847 __Pyx_GOTREF(__pyx_t_1);
16191848 __pyx_r = __pyx_t_1;
16201849 __pyx_t_1 = 0;
16211850 goto __pyx_L0;
16221851
1623 /* "clickhouse_driver/varint.pyx":29
1852 /* "clickhouse_driver/varint.pyx":52
16241853 *
16251854 *
16261855 * def read_varint(f): # <<<<<<<<<<<<<<
16361865 __Pyx_AddTraceback("clickhouse_driver.varint.read_varint", __pyx_clineno, __pyx_lineno, __pyx_filename);
16371866 __pyx_r = NULL;
16381867 __pyx_L0:;
1868 __Pyx_XDECREF(__pyx_v_read_one);
16391869 __Pyx_XGIVEREF(__pyx_r);
16401870 __Pyx_RefNannyFinishContext();
16411871 return __pyx_r;
16941924 {&__pyx_n_s_f, __pyx_k_f, sizeof(__pyx_k_f), 0, 0, 1, 1},
16951925 {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
16961926 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1927 {&__pyx_n_s_make_varint, __pyx_k_make_varint, sizeof(__pyx_k_make_varint), 0, 0, 1, 1},
16971928 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
16981929 {&__pyx_n_s_num_buf, __pyx_k_num_buf, sizeof(__pyx_k_num_buf), 0, 0, 1, 1},
16991930 {&__pyx_n_s_number, __pyx_k_number, sizeof(__pyx_k_number), 0, 0, 1, 1},
17021933 {&__pyx_n_s_result, __pyx_k_result, sizeof(__pyx_k_result), 0, 0, 1, 1},
17031934 {&__pyx_n_s_shift, __pyx_k_shift, sizeof(__pyx_k_shift), 0, 0, 1, 1},
17041935 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1705 {&__pyx_n_s_towrite, __pyx_k_towrite, sizeof(__pyx_k_towrite), 0, 0, 1, 1},
1936 {&__pyx_n_s_to_write, __pyx_k_to_write, sizeof(__pyx_k_to_write), 0, 0, 1, 1},
17061937 {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
17071938 {&__pyx_n_s_write_varint, __pyx_k_write_varint, sizeof(__pyx_k_write_varint), 0, 0, 1, 1},
17081939 {0, 0, 0, 0, 0, 0, 0}
17181949 /* "clickhouse_driver/varint.pyx":4
17191950 *
17201951 *
1721 * def write_varint(Py_ssize_t number, buf): # <<<<<<<<<<<<<<
1952 * def make_varint(unsigned long long number): # <<<<<<<<<<<<<<
17221953 * """
17231954 * Writes integer of variable length using LEB128.
17241955 */
1725 __pyx_tuple_ = PyTuple_Pack(5, __pyx_n_s_number, __pyx_n_s_buf, __pyx_n_s_i, __pyx_n_s_towrite, __pyx_n_s_num_buf); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 4, __pyx_L1_error)
1956 __pyx_tuple_ = PyTuple_Pack(5, __pyx_n_s_number, __pyx_n_s_number, __pyx_n_s_to_write, __pyx_n_s_i, __pyx_n_s_num_buf); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 4, __pyx_L1_error)
17261957 __Pyx_GOTREF(__pyx_tuple_);
17271958 __Pyx_GIVEREF(__pyx_tuple_);
1728 __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_varint_pyx, __pyx_n_s_write_varint, 4, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 4, __pyx_L1_error)
1729
1730 /* "clickhouse_driver/varint.pyx":29
1959 __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_varint_pyx, __pyx_n_s_make_varint, 4, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) __PYX_ERR(0, 4, __pyx_L1_error)
1960
1961 /* "clickhouse_driver/varint.pyx":28
1962 *
1963 *
1964 * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<<
1965 * """
1966 * Writes integer of variable length using LEB128.
1967 */
1968 __pyx_tuple__3 = PyTuple_Pack(5, __pyx_n_s_number, __pyx_n_s_buf, __pyx_n_s_to_write, __pyx_n_s_i, __pyx_n_s_num_buf); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 28, __pyx_L1_error)
1969 __Pyx_GOTREF(__pyx_tuple__3);
1970 __Pyx_GIVEREF(__pyx_tuple__3);
1971 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_varint_pyx, __pyx_n_s_write_varint, 28, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 28, __pyx_L1_error)
1972
1973 /* "clickhouse_driver/varint.pyx":52
17311974 *
17321975 *
17331976 * def read_varint(f): # <<<<<<<<<<<<<<
17341977 * """
17351978 * Reads integer of variable length using LEB128.
17361979 */
1737 __pyx_tuple__3 = PyTuple_Pack(4, __pyx_n_s_f, __pyx_n_s_shift, __pyx_n_s_result, __pyx_n_s_i); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 29, __pyx_L1_error)
1738 __Pyx_GOTREF(__pyx_tuple__3);
1739 __Pyx_GIVEREF(__pyx_tuple__3);
1740 __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_varint_pyx, __pyx_n_s_read_varint, 29, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) __PYX_ERR(0, 29, __pyx_L1_error)
1980 __pyx_tuple__5 = PyTuple_Pack(5, __pyx_n_s_f, __pyx_n_s_shift, __pyx_n_s_i, __pyx_n_s_result, __pyx_n_s_read_one); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 52, __pyx_L1_error)
1981 __Pyx_GOTREF(__pyx_tuple__5);
1982 __Pyx_GIVEREF(__pyx_tuple__5);
1983 __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(1, 0, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_clickhouse_driver_varint_pyx, __pyx_n_s_read_varint, 52, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 52, __pyx_L1_error)
17411984 __Pyx_RefNannyFinishContext();
17421985 return 0;
17431986 __pyx_L1_error:;
17952038 static int __Pyx_modinit_type_import_code(void) {
17962039 __Pyx_RefNannyDeclarations
17972040 PyObject *__pyx_t_1 = NULL;
2041 int __pyx_lineno = 0;
2042 const char *__pyx_filename = NULL;
2043 int __pyx_clineno = 0;
17982044 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
17992045 /*--- Type import code ---*/
18002046 __pyx_t_1 = PyImport_ImportModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 9, __pyx_L1_error)
18432089 }
18442090
18452091
1846 #if PY_MAJOR_VERSION < 3
1847 #ifdef CYTHON_NO_PYINIT_EXPORT
2092 #ifndef CYTHON_NO_PYINIT_EXPORT
2093 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
2094 #elif PY_MAJOR_VERSION < 3
2095 #ifdef __cplusplus
2096 #define __Pyx_PyMODINIT_FUNC extern "C" void
2097 #else
18482098 #define __Pyx_PyMODINIT_FUNC void
1849 #else
1850 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1851 #endif
1852 #else
1853 #ifdef CYTHON_NO_PYINIT_EXPORT
2099 #endif
2100 #else
2101 #ifdef __cplusplus
2102 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
2103 #else
18542104 #define __Pyx_PyMODINIT_FUNC PyObject *
1855 #else
1856 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
18572105 #endif
18582106 #endif
18592107
19352183 #endif
19362184 {
19372185 PyObject *__pyx_t_1 = NULL;
2186 int __pyx_lineno = 0;
2187 const char *__pyx_filename = NULL;
2188 int __pyx_clineno = 0;
19382189 __Pyx_RefNannyDeclarations
19392190 #if CYTHON_PEP489_MULTI_PHASE_INIT
19402191 if (__pyx_m) {
20232274 }
20242275 #endif
20252276 /*--- Builtin init code ---*/
2026 if (__Pyx_InitCachedBuiltins() < 0) goto __pyx_L1_error;
2277 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
20272278 /*--- Constants init code ---*/
2028 if (__Pyx_InitCachedConstants() < 0) goto __pyx_L1_error;
2279 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
20292280 /*--- Global type/function init code ---*/
20302281 (void)__Pyx_modinit_global_init_code();
20312282 (void)__Pyx_modinit_variable_export_code();
20322283 (void)__Pyx_modinit_function_export_code();
20332284 (void)__Pyx_modinit_type_init_code();
2034 if (unlikely(__Pyx_modinit_type_import_code() != 0)) goto __pyx_L1_error;
2285 if (unlikely(__Pyx_modinit_type_import_code() < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
20352286 (void)__Pyx_modinit_variable_import_code();
20362287 (void)__Pyx_modinit_function_import_code();
20372288 /*--- Execution code ---*/
20422293 /* "clickhouse_driver/varint.pyx":4
20432294 *
20442295 *
2045 * def write_varint(Py_ssize_t number, buf): # <<<<<<<<<<<<<<
2296 * def make_varint(unsigned long long number): # <<<<<<<<<<<<<<
20462297 * """
20472298 * Writes integer of variable length using LEB128.
20482299 */
2049 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_6varint_1write_varint, NULL, __pyx_n_s_clickhouse_driver_varint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
2300 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_6varint_1make_varint, NULL, __pyx_n_s_clickhouse_driver_varint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
20502301 __Pyx_GOTREF(__pyx_t_1);
2051 if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_varint, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
2302 if (PyDict_SetItem(__pyx_d, __pyx_n_s_make_varint, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
20522303 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20532304
2054 /* "clickhouse_driver/varint.pyx":29
2305 /* "clickhouse_driver/varint.pyx":28
2306 *
2307 *
2308 * def write_varint(unsigned long long number, buf): # <<<<<<<<<<<<<<
2309 * """
2310 * Writes integer of variable length using LEB128.
2311 */
2312 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_6varint_3write_varint, NULL, __pyx_n_s_clickhouse_driver_varint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
2313 __Pyx_GOTREF(__pyx_t_1);
2314 if (PyDict_SetItem(__pyx_d, __pyx_n_s_write_varint, __pyx_t_1) < 0) __PYX_ERR(0, 28, __pyx_L1_error)
2315 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2316
2317 /* "clickhouse_driver/varint.pyx":52
20552318 *
20562319 *
20572320 * def read_varint(f): # <<<<<<<<<<<<<<
20582321 * """
20592322 * Reads integer of variable length using LEB128.
20602323 */
2061 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_6varint_3read_varint, NULL, __pyx_n_s_clickhouse_driver_varint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error)
2324 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_17clickhouse_driver_6varint_5read_varint, NULL, __pyx_n_s_clickhouse_driver_varint); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
20622325 __Pyx_GOTREF(__pyx_t_1);
2063 if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_varint, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error)
2326 if (PyDict_SetItem(__pyx_d, __pyx_n_s_read_varint, __pyx_t_1) < 0) __PYX_ERR(0, 52, __pyx_L1_error)
20642327 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20652328
20662329 /* "clickhouse_driver/varint.pyx":1
2067 * from cpython cimport Py_INCREF, PyBytes_FromStringAndSize # <<<<<<<<<<<<<<
2330 * from cpython cimport PyBytes_FromStringAndSize # <<<<<<<<<<<<<<
20682331 *
20692332 *
20702333 */
21772440 }
21782441 name = first_kw_arg;
21792442 #if PY_MAJOR_VERSION < 3
2180 if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
2443 if (likely(PyString_Check(key))) {
21812444 while (*name) {
21822445 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
21832446 && _PyString_Eq(**name, key)) {
22042467 while (*name) {
22052468 int cmp = (**name == key) ? 0 :
22062469 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2207 (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
2470 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
22082471 #endif
22092472 PyUnicode_Compare(**name, key);
22102473 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
22202483 while (argname != first_kw_arg) {
22212484 int cmp = (**argname == key) ? 0 :
22222485 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2223 (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
2486 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
22242487 #endif
22252488 PyUnicode_Compare(**argname, key);
22262489 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
26572920
26582921 /* CLineInTraceback */
26592922 #ifndef CYTHON_CLINE_IN_TRACEBACK
2660 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
2923 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
26612924 PyObject *use_cline;
26622925 PyObject *ptype, *pvalue, *ptraceback;
26632926 #if CYTHON_COMPILING_IN_CPYTHON
27613024 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
27623025 int new_max = __pyx_code_cache.max_count + 64;
27633026 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
2764 __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
3027 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
27653028 if (unlikely(!entries)) {
27663029 return;
27673030 }
28843147 return (target_type) value;\
28853148 }
28863149
3150 /* CIntToPy */
3151 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_PY_LONG_LONG(unsigned PY_LONG_LONG value) {
3152 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
3153 const int is_unsigned = neg_one > const_zero;
3154 if (is_unsigned) {
3155 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
3156 return PyInt_FromLong((long) value);
3157 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
3158 return PyLong_FromUnsignedLong((unsigned long) value);
3159 #ifdef HAVE_LONG_LONG
3160 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
3161 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
3162 #endif
3163 }
3164 } else {
3165 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
3166 return PyInt_FromLong((long) value);
3167 #ifdef HAVE_LONG_LONG
3168 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
3169 return PyLong_FromLongLong((PY_LONG_LONG) value);
3170 #endif
3171 }
3172 }
3173 {
3174 int one = 1; int little = (int)*(unsigned char *)&one;
3175 unsigned char *bytes = (unsigned char *)&value;
3176 return _PyLong_FromByteArray(bytes, sizeof(unsigned PY_LONG_LONG),
3177 little, !is_unsigned);
3178 }
3179 }
3180
28873181 /* CIntFromPy */
2888 static CYTHON_INLINE unsigned char __Pyx_PyInt_As_unsigned_char(PyObject *x) {
2889 const unsigned char neg_one = (unsigned char) ((unsigned char) 0 - (unsigned char) 1), const_zero = (unsigned char) 0;
3182 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_As_unsigned_PY_LONG_LONG(PyObject *x) {
3183 const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG) ((unsigned PY_LONG_LONG) 0 - (unsigned PY_LONG_LONG) 1), const_zero = (unsigned PY_LONG_LONG) 0;
28903184 const int is_unsigned = neg_one > const_zero;
28913185 #if PY_MAJOR_VERSION < 3
28923186 if (likely(PyInt_Check(x))) {
2893 if (sizeof(unsigned char) < sizeof(long)) {
2894 __PYX_VERIFY_RETURN_INT(unsigned char, long, PyInt_AS_LONG(x))
3187 if (sizeof(unsigned PY_LONG_LONG) < sizeof(long)) {
3188 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, PyInt_AS_LONG(x))
28953189 } else {
28963190 long val = PyInt_AS_LONG(x);
28973191 if (is_unsigned && unlikely(val < 0)) {
28983192 goto raise_neg_overflow;
28993193 }
2900 return (unsigned char) val;
3194 return (unsigned PY_LONG_LONG) val;
29013195 }
29023196 } else
29033197 #endif
29063200 #if CYTHON_USE_PYLONG_INTERNALS
29073201 const digit* digits = ((PyLongObject*)x)->ob_digit;
29083202 switch (Py_SIZE(x)) {
2909 case 0: return (unsigned char) 0;
2910 case 1: __PYX_VERIFY_RETURN_INT(unsigned char, digit, digits[0])
3203 case 0: return (unsigned PY_LONG_LONG) 0;
3204 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, digits[0])
29113205 case 2:
2912 if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
3206 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
29133207 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2914 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2915 } else if (8 * sizeof(unsigned char) >= 2 * PyLong_SHIFT) {
2916 return (unsigned char) (((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
3208 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3209 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 2 * PyLong_SHIFT) {
3210 return (unsigned PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
29173211 }
29183212 }
29193213 break;
29203214 case 3:
2921 if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
3215 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
29223216 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2923 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2924 } else if (8 * sizeof(unsigned char) >= 3 * PyLong_SHIFT) {
2925 return (unsigned char) (((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
3217 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3218 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 3 * PyLong_SHIFT) {
3219 return (unsigned PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
29263220 }
29273221 }
29283222 break;
29293223 case 4:
2930 if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
3224 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
29313225 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2932 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2933 } else if (8 * sizeof(unsigned char) >= 4 * PyLong_SHIFT) {
2934 return (unsigned char) (((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0]));
3226 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3227 } else if (8 * sizeof(unsigned PY_LONG_LONG) >= 4 * PyLong_SHIFT) {
3228 return (unsigned PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
29353229 }
29363230 }
29373231 break;
29453239 {
29463240 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
29473241 if (unlikely(result < 0))
2948 return (unsigned char) -1;
3242 return (unsigned PY_LONG_LONG) -1;
29493243 if (unlikely(result == 1))
29503244 goto raise_neg_overflow;
29513245 }
29523246 #endif
2953 if (sizeof(unsigned char) <= sizeof(unsigned long)) {
2954 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned long, PyLong_AsUnsignedLong(x))
3247 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned long)) {
3248 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned long, PyLong_AsUnsignedLong(x))
29553249 #ifdef HAVE_LONG_LONG
2956 } else if (sizeof(unsigned char) <= sizeof(unsigned PY_LONG_LONG)) {
2957 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
3250 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(unsigned PY_LONG_LONG)) {
3251 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
29583252 #endif
29593253 }
29603254 } else {
29613255 #if CYTHON_USE_PYLONG_INTERNALS
29623256 const digit* digits = ((PyLongObject*)x)->ob_digit;
29633257 switch (Py_SIZE(x)) {
2964 case 0: return (unsigned char) 0;
2965 case -1: __PYX_VERIFY_RETURN_INT(unsigned char, sdigit, (sdigit) (-(sdigit)digits[0]))
2966 case 1: __PYX_VERIFY_RETURN_INT(unsigned char, digit, +digits[0])
3258 case 0: return (unsigned PY_LONG_LONG) 0;
3259 case -1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, sdigit, (sdigit) (-(sdigit)digits[0]))
3260 case 1: __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, digit, +digits[0])
29673261 case -2:
2968 if (8 * sizeof(unsigned char) - 1 > 1 * PyLong_SHIFT) {
3262 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 1 * PyLong_SHIFT) {
29693263 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2970 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2971 } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
2972 return (unsigned char) (((unsigned char)-1)*(((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3264 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3265 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3266 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
29733267 }
29743268 }
29753269 break;
29763270 case 2:
2977 if (8 * sizeof(unsigned char) > 1 * PyLong_SHIFT) {
3271 if (8 * sizeof(unsigned PY_LONG_LONG) > 1 * PyLong_SHIFT) {
29783272 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2979 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2980 } else if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
2981 return (unsigned char) ((((((unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3273 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3274 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
3275 return (unsigned PY_LONG_LONG) ((((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
29823276 }
29833277 }
29843278 break;
29853279 case -3:
2986 if (8 * sizeof(unsigned char) - 1 > 2 * PyLong_SHIFT) {
3280 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
29873281 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2988 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2989 } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
2990 return (unsigned char) (((unsigned char)-1)*(((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3282 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3283 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3284 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
29913285 }
29923286 }
29933287 break;
29943288 case 3:
2995 if (8 * sizeof(unsigned char) > 2 * PyLong_SHIFT) {
3289 if (8 * sizeof(unsigned PY_LONG_LONG) > 2 * PyLong_SHIFT) {
29963290 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2997 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2998 } else if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
2999 return (unsigned char) ((((((((unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3291 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3292 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
3293 return (unsigned PY_LONG_LONG) ((((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
30003294 }
30013295 }
30023296 break;
30033297 case -4:
3004 if (8 * sizeof(unsigned char) - 1 > 3 * PyLong_SHIFT) {
3298 if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
30053299 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3006 __PYX_VERIFY_RETURN_INT(unsigned char, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3007 } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
3008 return (unsigned char) (((unsigned char)-1)*(((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3300 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3301 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3302 return (unsigned PY_LONG_LONG) (((unsigned PY_LONG_LONG)-1)*(((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
30093303 }
30103304 }
30113305 break;
30123306 case 4:
3013 if (8 * sizeof(unsigned char) > 3 * PyLong_SHIFT) {
3307 if (8 * sizeof(unsigned PY_LONG_LONG) > 3 * PyLong_SHIFT) {
30143308 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
3015 __PYX_VERIFY_RETURN_INT(unsigned char, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3016 } else if (8 * sizeof(unsigned char) - 1 > 4 * PyLong_SHIFT) {
3017 return (unsigned char) ((((((((((unsigned char)digits[3]) << PyLong_SHIFT) | (unsigned char)digits[2]) << PyLong_SHIFT) | (unsigned char)digits[1]) << PyLong_SHIFT) | (unsigned char)digits[0])));
3309 __PYX_VERIFY_RETURN_INT(unsigned PY_LONG_LONG, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
3310 } else if (8 * sizeof(unsigned PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
3311 return (unsigned PY_LONG_LONG) ((((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0])));
30183312 }
30193313 }
30203314 break;
30213315 }
30223316 #endif
3023 if (sizeof(unsigned char) <= sizeof(long)) {
3024 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, long, PyLong_AsLong(x))
3317 if (sizeof(unsigned PY_LONG_LONG) <= sizeof(long)) {
3318 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, long, PyLong_AsLong(x))
30253319 #ifdef HAVE_LONG_LONG
3026 } else if (sizeof(unsigned char) <= sizeof(PY_LONG_LONG)) {
3027 __PYX_VERIFY_RETURN_INT_EXC(unsigned char, PY_LONG_LONG, PyLong_AsLongLong(x))
3320 } else if (sizeof(unsigned PY_LONG_LONG) <= sizeof(PY_LONG_LONG)) {
3321 __PYX_VERIFY_RETURN_INT_EXC(unsigned PY_LONG_LONG, PY_LONG_LONG, PyLong_AsLongLong(x))
30283322 #endif
30293323 }
30303324 }
30333327 PyErr_SetString(PyExc_RuntimeError,
30343328 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
30353329 #else
3036 unsigned char val;
3330 unsigned PY_LONG_LONG val;
30373331 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
30383332 #if PY_MAJOR_VERSION < 3
30393333 if (likely(v) && !PyLong_Check(v)) {
30533347 return val;
30543348 }
30553349 #endif
3056 return (unsigned char) -1;
3350 return (unsigned PY_LONG_LONG) -1;
30573351 }
30583352 } else {
3059 unsigned char val;
3353 unsigned PY_LONG_LONG val;
30603354 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
3061 if (!tmp) return (unsigned char) -1;
3062 val = __Pyx_PyInt_As_unsigned_char(tmp);
3355 if (!tmp) return (unsigned PY_LONG_LONG) -1;
3356 val = __Pyx_PyInt_As_unsigned_PY_LONG_LONG(tmp);
30633357 Py_DECREF(tmp);
30643358 return val;
30653359 }
30663360 raise_overflow:
30673361 PyErr_SetString(PyExc_OverflowError,
3068 "value too large to convert to unsigned char");
3069 return (unsigned char) -1;
3362 "value too large to convert to unsigned PY_LONG_LONG");
3363 return (unsigned PY_LONG_LONG) -1;
30703364 raise_neg_overflow:
30713365 PyErr_SetString(PyExc_OverflowError,
3072 "can't convert negative value to unsigned char");
3073 return (unsigned char) -1;
3366 "can't convert negative value to unsigned PY_LONG_LONG");
3367 return (unsigned PY_LONG_LONG) -1;
30743368 }
30753369
30763370 /* CIntToPy */
0 from cpython cimport Py_INCREF, PyBytes_FromStringAndSize
0 from cpython cimport PyBytes_FromStringAndSize
11
22
3 def write_varint(Py_ssize_t number, buf):
3 def make_varint(unsigned long long number):
44 """
55 Writes integer of variable length using LEB128.
66 """
7 cdef Py_ssize_t i = 0
8 cdef unsigned char towrite
9 # Py_ssize_t checks integer on function call and
10 # raises OverflowError if integer overflows Py_ssize_t.
11 # Long enough for handling Py_ssize_t.
7 cdef unsigned char to_write, i = 0
8 # unsigned PY_LONG_LONG checks integer on function call and
9 # raises OverflowError if integer overflows unsigned PY_LONG_LONG.
10 # Long enough for handling unsigned PY_LONG_LONG.
1211 cdef unsigned char num_buf[32]
1312
1413 while True:
15 towrite = number & 0x7f
14 to_write = number & 0x7f
1615 number >>= 7
1716 if number:
18 num_buf[i] = towrite | 0x80
17 num_buf[i] = to_write | 0x80
1918 i += 1
2019 else:
21 num_buf[i] = towrite
20 num_buf[i] = to_write
21 i += 1
22 break
23
24 return PyBytes_FromStringAndSize(<char *>num_buf, i)
25
26
27 def write_varint(unsigned long long number, buf):
28 """
29 Writes integer of variable length using LEB128.
30 """
31 cdef unsigned char to_write, i = 0
32 # unsigned PY_LONG_LONG checks integer on function call and
33 # raises OverflowError if integer overflows unsigned PY_LONG_LONG.
34 # Long enough for handling unsigned PY_LONG_LONG.
35 cdef unsigned char num_buf[32]
36
37 while True:
38 to_write = number & 0x7f
39 number >>= 7
40 if number:
41 num_buf[i] = to_write | 0x80
42 i += 1
43 else:
44 num_buf[i] = to_write
2245 i += 1
2346 break
2447
2952 """
3053 Reads integer of variable length using LEB128.
3154 """
32 cdef Py_ssize_t shift = 0
33 cdef Py_ssize_t result = 0
34 cdef unsigned char i
55 cdef unsigned char shift = 0
56 cdef unsigned long long i, result = 0
57
58 read_one = f.read_one
3559
3660 while True:
37 i = f.read_one()
61 i = read_one()
3862 result |= (i & 0x7f) << shift
3963 shift += 7
4064 if i < 0x80:
0
1 table.table-small-text {
2 font-size: small;
3 }
4
5
6 table.table-center-header thead tr th {
7 text-align: center;
8 }
9
10
11 table.table-right-text-align-results tbody tr td {
12 text-align: right;
13 }
14
15 table.table-right-text-align-results tbody tr td:first-child {
16 text-align: inherit;
17 }
0 {% extends "!layout.html" %}
1 {% block extrahead %}
2 <link href="{{ pathto("_static/css/custom.css", True) }}" rel="stylesheet" type="text/css">
3 {% endblock %}
100100 "github_user": "mymarilyn",
101101 "github_repo": "clickhouse-driver",
102102 "fixed_sidebar": True,
103 "sidebar_width": '300px',
104 "page_width": '1000px'
103105 }
106
107 html_css_files = [
108 'css/custom.css',
109 ]
104110
105111 # Custom sidebar templates, must be a dictionary that maps document names
106112 # to template names.
2525 quickstart
2626 features
2727 types
28 performance
2829 misc
30 unsupportedserverversions
2931
3032 API Reference
3133 -------------
241241 >>>
242242 >>> settings = {'send_logs_level': 'debug'}
243243 >>> client.execute('SELECT 1', settings=settings)
244 2018-12-14 10:24:53,873 INFO clickhouse_driver.log: {b328ad33-60e8-4012-b4cc-97f44a7b28f2} [ 25 ] <Debug> executeQuery: (from 127.0.0.1:57762) SELECT 1
245 2018-12-14 10:24:53,874 INFO clickhouse_driver.log: {b328ad33-60e8-4012-b4cc-97f44a7b28f2} [ 25 ] <Debug> executeQuery: Query pipeline:
244 2018-12-14 10:24:53,873 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} <Debug> executeQuery: (from 127.0.0.1:57762) SELECT 1
245 2018-12-14 10:24:53,874 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} <Debug> executeQuery: Query pipeline:
246246 Expression
247247 Expression
248248 One
249249
250 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: {b328ad33-60e8-4012-b4cc-97f44a7b28f2} [ 25 ] <Information> executeQuery: Read 1 rows, 1.00 B in 0.004 sec., 262 rows/sec., 262.32 B/sec.
251 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: {b328ad33-60e8-4012-b4cc-97f44a7b28f2} [ 25 ] <Debug> MemoryTracker: Peak memory usage (for query): 40.23 KiB.
250 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} <Information> executeQuery: Read 1 rows, 1.00 B in 0.004 sec., 262 rows/sec., 262.32 B/sec.
251 2018-12-14 10:24:53,875 INFO clickhouse_driver.log: [ klebedev-ThinkPad-T460 ] [ 25 ] {b328ad33-60e8-4012-b4cc-97f44a7b28f2} <Debug> MemoryTracker: Peak memory usage (for query): 40.23 KiB.
252252 [(1,)]
253253
254254
348348 >>> with conn.cursor() as cursor:
349349 >>> cursor.execute('SHOW TABLES')
350350 >>> print(cursor.fetchall())
351
352
353 NumPy arrays support
354 --------------------
355
356 *New in version 0.1.6.*
357
358 Starting from version 0.1.6 package can SELECT and INSERT columns as NumPy
359 arrays. Additional packages are required for :ref:`installation-numpy-support`.
360
361 .. code-block:: python
362
363 >>> client = Client('localhost', settings={'use_numpy': True}):
364 >>> client.execute(
365 ... 'SELECT * FROM system.numbers LIMIT 10000',
366 ... columnar=True
367 ... )
368 [array([ 0, 1, 2, ..., 9997, 9998, 9999], dtype=uint64)]
369
370
371 Supported types:
372
373 * Float32/64
374 * [U]Int8/16/32/64
375 * Date/DateTime('timezone')/DateTime64('timezone')
376 * String/FixedString(N)
377 * LowCardinality(T)
378
379 NumPy arrays are not used when reading nullable columns and columns of
380 unsupported types.
381
382 Direct loading into NumPy arrays increases performance and lowers memory
383 requirements on large amounts of rows.
384
385 Direct loading into pandas DataFrame is also supported by using
386 `query_dataframe`:
387
388 .. code-block:: python
389
390 >>> client = Client('localhost', settings={'use_numpy': True})
391 >>> client.query_dataframe('
392 ... 'SELECT number AS x, (number + 100) AS y '
393 ... 'FROM system.numbers LIMIT 10000'
394 ... )
395 x y
396 0 0 100
397 1 1 101
398 2 2 102
399 3 3 103
400 4 4 104
401 ... ... ...
402 9995 9995 10095
403 9996 9996 10096
404 9997 9997 10097
405 9998 9998 10098
406 9999 9999 10099
407
408 [10000 rows x 2 columns]
409
410 Writing pandas DataFrame is also supported with `insert_dataframe`:
411
412 .. code-block:: python
413
414 >>> client = Client('localhost', settings={'use_numpy': True})
415 >>> client.execute(
416 ... 'CREATE TABLE test (x Int64, y Int64) Engine = Memory'
417 ... )
418 >>> []
419 >>> df = client.query_dataframe(
420 ... 'SELECT number AS x, (number + 100) AS y '
421 ... 'FROM system.numbers LIMIT 10000'
422 ... )
423 >>> client.insert_dataframe('INSERT INTO test VALUES', df)
424 >>> 10000
00 Welcome to clickhouse-driver
11 ============================
2
3 Release |release|.
24
35 Welcome to clickhouse-driver's documentation. Get started with :ref:`installation`
46 and then get an overview with the :ref:`quickstart` where common queries are described.
2020
2121 By default there are wheels for Linux, Mac OS X and Windows.
2222
23 Packages for Linux and Mac OS X are available for python: 2.7, 3.4, 3.5, 3.6, 3.7, 3.8.
23 Packages for Linux and Mac OS X are available for python: 2.7, 3.4 -- 3.9.
2424
25 Packages for Windows are available for python: 2.7, 3.5, 3.6, 3.7, 3.8.
25 Packages for Windows are available for python: 2.7, 3.5 -- 3.9.
2626
2727 Dependencies
2828 ------------
7676 pip install clickhouse-driver[lz4,zstd]
7777
7878
79 .. _installation-numpy-support:
80
81 NumPy support
82 -------------
83
84 You can install additional packages (NumPy and Pandas) if you need NumPy support:
85
86 .. code-block:: bash
87
88 pip install clickhouse-driver[numpy]
89
90 NumPy supported versions are limited by ``numpy`` package python support.
91
92
7993 Installation from github
8094 ------------------------
8195
3636
3737 If parameter doesn't match Connection's init signature will be treated as settings parameter.
3838
39 .. _insert-from-csv-file:
3940
4041 Inserting data from CSV file
4142 ----------------------------
110111 >>> client = Client('localhost', settings={'allow_suspicious_low_cardinality_types': True})
111112 >>> client.execute('CREATE TABLE test (x LowCardinality(Int32)) Engine = Null')
112113 []
114
115
116 *New in version 0.1.5.*
117
118 Modern ClickHouse servers (20.*+) use text serialization for settings instead of
119 binary serialization. You don't have to add missed settings manually into
120 available. Just specify new settings and it will work.
121
122 .. code-block:: python
123
124 >>> client = Client('localhost', settings={'brand_new_setting': 42})
125 >>> client.execute('SELECT 1')
0
1 Performance
2 ===========
3
4 This section compares clickhouse-driver performance over Native interface
5 with TSV and JSONEachRow formats available over HTTP interface.
6
7 clickhouse-driver returns already parsed row items in Python data types.
8 Driver performs all transformation for you.
9
10 When you read data over HTTP you may need to cast strings into Python types.
11
12
13 Test data
14 ---------
15
16 Sample data for testing is taken from `ClickHouse docs <https://clickhouse.tech/docs>`_.
17
18 Create database and table:
19
20 .. code-block:: sql
21
22 DROP DATABASE IF EXISTS perftest;
23
24 CREATE DATABASE perftest;
25
26 CREATE TABLE perftest.ontime (
27 Year UInt16,
28 Quarter UInt8,
29 Month UInt8,
30 DayofMonth UInt8,
31 DayOfWeek UInt8,
32 FlightDate Date,
33 UniqueCarrier FixedString(7),
34 AirlineID Int32,
35 Carrier FixedString(2),
36 TailNum String,
37 FlightNum String,
38 OriginAirportID Int32,
39 OriginAirportSeqID Int32,
40 OriginCityMarketID Int32,
41 Origin FixedString(5),
42 OriginCityName String,
43 OriginState FixedString(2),
44 OriginStateFips String,
45 OriginStateName String,
46 OriginWac Int32,
47 DestAirportID Int32,
48 DestAirportSeqID Int32,
49 DestCityMarketID Int32,
50 Dest FixedString(5),
51 DestCityName String,
52 DestState FixedString(2),
53 DestStateFips String,
54 DestStateName String,
55 DestWac Int32,
56 CRSDepTime Int32,
57 DepTime Int32,
58 DepDelay Int32,
59 DepDelayMinutes Int32,
60 DepDel15 Int32,
61 DepartureDelayGroups String,
62 DepTimeBlk String,
63 TaxiOut Int32,
64 WheelsOff Int32,
65 WheelsOn Int32,
66 TaxiIn Int32,
67 CRSArrTime Int32,
68 ArrTime Int32,
69 ArrDelay Int32,
70 ArrDelayMinutes Int32,
71 ArrDel15 Int32,
72 ArrivalDelayGroups Int32,
73 ArrTimeBlk String,
74 Cancelled UInt8,
75 CancellationCode FixedString(1),
76 Diverted UInt8,
77 CRSElapsedTime Int32,
78 ActualElapsedTime Int32,
79 AirTime Int32,
80 Flights Int32,
81 Distance Int32,
82 DistanceGroup UInt8,
83 CarrierDelay Int32,
84 WeatherDelay Int32,
85 NASDelay Int32,
86 SecurityDelay Int32,
87 LateAircraftDelay Int32,
88 FirstDepTime String,
89 TotalAddGTime String,
90 LongestAddGTime String,
91 DivAirportLandings String,
92 DivReachedDest String,
93 DivActualElapsedTime String,
94 DivArrDelay String,
95 DivDistance String,
96 Div1Airport String,
97 Div1AirportID Int32,
98 Div1AirportSeqID Int32,
99 Div1WheelsOn String,
100 Div1TotalGTime String,
101 Div1LongestGTime String,
102 Div1WheelsOff String,
103 Div1TailNum String,
104 Div2Airport String,
105 Div2AirportID Int32,
106 Div2AirportSeqID Int32,
107 Div2WheelsOn String,
108 Div2TotalGTime String,
109 Div2LongestGTime String,
110 Div2WheelsOff String,
111 Div2TailNum String,
112 Div3Airport String,
113 Div3AirportID Int32,
114 Div3AirportSeqID Int32,
115 Div3WheelsOn String,
116 Div3TotalGTime String,
117 Div3LongestGTime String,
118 Div3WheelsOff String,
119 Div3TailNum String,
120 Div4Airport String,
121 Div4AirportID Int32,
122 Div4AirportSeqID Int32,
123 Div4WheelsOn String,
124 Div4TotalGTime String,
125 Div4LongestGTime String,
126 Div4WheelsOff String,
127 Div4TailNum String,
128 Div5Airport String,
129 Div5AirportID Int32,
130 Div5AirportSeqID Int32,
131 Div5WheelsOn String,
132 Div5TotalGTime String,
133 Div5LongestGTime String,
134 Div5WheelsOff String,
135 Div5TailNum String
136 ) ENGINE = MergeTree
137 PARTITION BY Year
138 ORDER BY (Carrier, FlightDate)
139 SETTINGS index_granularity = 8192;
140
141
142 Download some data for 2017 year:
143
144 .. code-block:: bash
145
146 for s in `seq 2017 2017`
147 do
148 for m in `seq 1 12`
149 do
150 wget https://transtats.bts.gov/PREZIP/On_Time_Reporting_Carrier_On_Time_Performance_1987_present_${s}_${m}.zip
151 done
152 done
153
154 Insert data into ClickHouse:
155
156 .. code-block:: bash
157
158 for i in *.zip; do echo $i; unzip -cq $i '*.csv' | sed 's/\.00//g' | clickhouse-client --query="INSERT INTO perftest.ontime FORMAT CSVWithNames"; done
159
160
161 Required packages
162 -----------------
163
164 .. code-block:: bash
165
166 pip install clickhouse-driver requests
167
168 For fast json parsing we'll use ``ujson`` package:
169
170 .. code-block:: bash
171
172 pip install ujson
173
174 Installed packages: ::
175
176 $ pip freeze
177 certifi==2020.4.5.1
178 chardet==3.0.4
179 clickhouse-driver==0.1.3
180 idna==2.9
181 pytz==2019.3
182 requests==2.23.0
183 tzlocal==2.0.0
184 ujson==2.0.3
185 urllib3==1.25.9
186
187 Versions
188 --------
189
190 Machine: Linux ThinkPad-T460 4.4.0-177-generic #207-Ubuntu SMP Mon Mar 16 01:16:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
191
192 Python: CPython 3.6.5 (default, May 30 2019, 14:48:31) [GCC 5.4.0 20160609]
193
194
195 Benchmarking
196 ------------
197
198 Let's pick number of rows for testing with ``clickhouse-client``.
199
200 .. code-block:: sql
201
202 SELECT count() FROM ontime WHERE FlightDate < '2017-01-04'
203
204 45202
205
206 .. code-block:: sql
207
208 SELECT count() FROM ontime WHERE FlightDate < '2017-01-10'
209
210 131848
211
212 .. code-block:: sql
213
214 SELECT count() FROM ontime WHERE FlightDate < '2017-01-16'
215
216 217015
217
218 .. code-block:: sql
219
220 SELECT count() FROM ontime WHERE FlightDate < '2017-02-01'
221
222 450017
223
224 .. code-block:: sql
225
226 SELECT count() FROM ontime WHERE FlightDate < '2017-02-18'
227
228 697813
229
230 Scripts below can be benchmarked with following one-liner:
231
232 .. code-block:: bash
233
234 for d in 2017-01-04 2017-01-10 2017-01-16 2017-02-01 2017-02-18; do /usr/bin/time -f "%e s / %M kB" python script.py $d; done
235
236 Time will measure:
237
238 * elapsed real (wall clock) time used by the process, in seconds;
239 * maximum resident set size of the process during its lifetime, in kilobytes.
240
241 Plain text without parsing
242 ^^^^^^^^^^^^^^^^^^^^^^^^^^
243
244 Let's take get plain text response from ClickHouse server as baseline.
245
246
247 Fetching not parsed data with pure requests (1)
248
249 .. code-block:: python
250
251 import sys
252 import requests
253
254 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT {}".format(sys.argv[1], sys.argv[2])
255 data = requests.get('http://localhost:8123/', params={'query': query})
256
257
258 Parsed rows
259 ^^^^^^^^^^^
260
261 Line split into elements will be consider as "parsed" for TSV format (2)
262
263 .. code-block:: python
264
265 import sys
266 import requests
267
268 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1])
269 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
270
271 data = [line.decode('utf-8').split('\t') for line in resp.iter_lines(chunk_size=10000)]
272
273
274 Now we cast each element to it's data type (2.5)
275
276 .. code-block:: python
277
278 from datetime import date
279 import sys
280 import requests
281
282
283 def get_python_type(ch_type):
284 if ch_type.startswith('Int') or ch_type.startswith('UInt'):
285 return int
286
287 elif ch_type == 'String' or ch_type.startswith('FixedString'):
288 return None
289
290 elif ch_type == 'Date':
291 return lambda value: date(*[int(x) for x in value.split('-')])
292
293 raise ValueError(f'Unsupported type: "{ch_type}"')
294
295
296 resp = requests.get('http://localhost:8123', params={'query': 'describe table perftest.ontime FORMAT TSV'})
297 ch_types = [x.split('\t')[1] for x in resp.text.split('\n') if x]
298 python_types = [get_python_type(x) for x in ch_types]
299
300 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1])
301 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
302
303 data = []
304
305 for line in resp.iter_lines(chunk_size=10000):
306 data.append([cls(x) if cls else x for x, cls in zip(line.decode('utf-8').split('\t'), python_types)])
307
308
309 JSONEachRow format can be loaded with json loads (3)
310
311 .. code-block:: python
312
313 import sys
314 import requests
315 from ujson import loads
316
317 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(sys.argv[1])
318 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
319
320 data = [list(loads(line).values()) for line in resp.iter_lines(chunk_size=10000)]
321
322
323 Get fully parsed rows with ``clickhouse-driver`` in Native format (4)
324
325 .. code-block:: python
326
327 import sys
328 from clickhouse_driver import Client
329
330 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1])
331 client = Client.from_url('clickhouse://localhost')
332
333 data = client.execute(query)
334
335
336 Iteration over rows
337 ^^^^^^^^^^^^^^^^^^^
338
339 Iteration over TSV (5)
340
341 .. code-block:: python
342
343 import sys
344 import requests
345
346 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1])
347 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
348
349 for line in resp.iter_lines(chunk_size=10000):
350 line = line.decode('utf-8').split('\t')
351
352
353 Now we cast each element to it's data type (5.5)
354
355 .. code-block:: python
356
357 from datetime import date
358 import sys
359 import requests
360
361
362 def get_python_type(ch_type):
363 if ch_type.startswith('Int') or ch_type.startswith('UInt'):
364 return int
365
366 elif ch_type == 'String' or ch_type.startswith('FixedString'):
367 return None
368
369 elif ch_type == 'Date':
370 return lambda value: date(*[int(x) for x in value.split('-')])
371
372 raise ValueError(f'Unsupported type: "{ch_type}"')
373
374
375 resp = requests.get('http://localhost:8123', params={'query': 'describe table perftest.ontime FORMAT TSV'})
376 ch_types = [x.split('\t')[1] for x in resp.text.split('\n') if x]
377 python_types = [get_python_type(x) for x in ch_types]
378
379 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(sys.argv[1])
380 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
381
382 for line in resp.iter_lines(chunk_size=10000):
383 line = [cls(x) if cls else x for x, cls in zip(line.decode('utf-8').split('\t'), python_types)]
384
385
386 Iteration over JSONEachRow (6)
387
388 .. code-block:: python
389
390 import sys
391 import requests
392 from ujson import loads
393
394 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(sys.argv[1])
395 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
396
397 for line in resp.iter_lines(chunk_size=10000):
398 line = list(loads(line).values())
399
400
401 Iteration over rows with ``clickhouse-driver`` in Native format (7)
402
403 .. code-block:: python
404
405 import sys
406 from clickhouse_driver import Client
407
408 query = "SELECT * FROM perftest.ontime WHERE FlightDate < '{}'".format(sys.argv[1])
409 client = Client.from_url('clickhouse://localhost')
410
411 for row in client.execute_iter(query):
412 pass
413
414
415 Iteration over string rows
416 ^^^^^^^^^^^^^^^^^^^^^^^^^^
417
418 OK, but what if we need only string columns?
419
420 Iteration over TSV (8)
421
422 .. code-block:: python
423
424 import sys
425 import requests
426
427 cols = [
428 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState',
429 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips',
430 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode',
431 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest',
432 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime',
433 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime',
434 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime',
435 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime',
436 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime',
437 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum'
438 ]
439
440 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(', '.join(cols), sys.argv[1])
441 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
442
443 for line in resp.iter_lines(chunk_size=10000):
444 line = line.decode('utf-8').split('\t')
445
446
447 Iteration over JSONEachRow (9)
448
449 .. code-block:: python
450
451 import sys
452 import requests
453 from ujson import loads
454
455 cols = [
456 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState',
457 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips',
458 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode',
459 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest',
460 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime',
461 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime',
462 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime',
463 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime',
464 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime',
465 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum'
466 ]
467
468 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(', '.join(cols), sys.argv[1])
469 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
470
471 for line in resp.iter_lines(chunk_size=10000):
472 line = list(loads(line).values())
473
474
475 Iteration over string rows with ``clickhouse-driver`` in Native format (10)
476
477 .. code-block:: python
478
479 import sys
480 from clickhouse_driver import Client
481
482 cols = [
483 'UniqueCarrier', 'Carrier', 'TailNum', 'FlightNum', 'Origin', 'OriginCityName', 'OriginState',
484 'OriginStateFips', 'OriginStateName', 'Dest', 'DestCityName', 'DestState', 'DestStateFips',
485 'DestStateName', 'DepartureDelayGroups', 'DepTimeBlk', 'ArrTimeBlk', 'CancellationCode',
486 'FirstDepTime', 'TotalAddGTime', 'LongestAddGTime', 'DivAirportLandings', 'DivReachedDest',
487 'DivActualElapsedTime', 'DivArrDelay', 'DivDistance', 'Div1Airport', 'Div1WheelsOn', 'Div1TotalGTime',
488 'Div1LongestGTime', 'Div1WheelsOff', 'Div1TailNum', 'Div2Airport', 'Div2WheelsOn', 'Div2TotalGTime',
489 'Div2LongestGTime', 'Div2WheelsOff', 'Div2TailNum', 'Div3Airport', 'Div3WheelsOn', 'Div3TotalGTime',
490 'Div3LongestGTime', 'Div3WheelsOff', 'Div3TailNum', 'Div4Airport', 'Div4WheelsOn', 'Div4TotalGTime',
491 'Div4LongestGTime', 'Div4WheelsOff', 'Div4TailNum', 'Div5Airport', 'Div5WheelsOn', 'Div5TotalGTime',
492 'Div5LongestGTime', 'Div5WheelsOff', 'Div5TailNum'
493 ]
494
495 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1])
496 client = Client.from_url('clickhouse://localhost')
497
498 for row in client.execute_iter(query):
499 pass
500
501
502 Iteration over int rows
503 ^^^^^^^^^^^^^^^^^^^^^^^
504
505 Iteration over TSV (11)
506
507 .. code-block:: python
508
509 import sys
510 import requests
511
512 cols = [
513 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID',
514 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac',
515 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn',
516 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups',
517 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance',
518 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay',
519 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID',
520 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID'
521 ]
522
523 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT TSV".format(', '.join(cols), sys.argv[1])
524 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
525
526 for line in resp.iter_lines(chunk_size=10000):
527 line = [int(x) for x in line.split(b'\t')]
528
529
530 Iteration over JSONEachRow (12)
531
532 .. code-block:: python
533
534 import sys
535 import requests
536 from ujson import loads
537
538 cols = [
539 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID',
540 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac',
541 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn',
542 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups',
543 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance',
544 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay',
545 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID',
546 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID'
547 ]
548
549 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}' FORMAT JSONEachRow".format(', '.join(cols), sys.argv[1])
550 resp = requests.get('http://localhost:8123/', stream=True, params={'query': query})
551
552 for line in resp.iter_lines(chunk_size=10000):
553 line = list(loads(line).values())
554
555
556 Iteration over int rows with ``clickhouse-driver`` in Native format (13)
557
558 .. code-block:: python
559
560 import sys
561 from clickhouse_driver import Client
562
563 cols = [
564 'Year', 'Quarter', 'Month', 'DayofMonth', 'DayOfWeek', 'AirlineID', 'OriginAirportID', 'OriginAirportSeqID',
565 'OriginCityMarketID', 'OriginWac', 'DestAirportID', 'DestAirportSeqID', 'DestCityMarketID', 'DestWac',
566 'CRSDepTime', 'DepTime', 'DepDelay', 'DepDelayMinutes', 'DepDel15', 'TaxiOut', 'WheelsOff', 'WheelsOn',
567 'TaxiIn', 'CRSArrTime', 'ArrTime', 'ArrDelay', 'ArrDelayMinutes', 'ArrDel15', 'ArrivalDelayGroups',
568 'Cancelled', 'Diverted', 'CRSElapsedTime', 'ActualElapsedTime', 'AirTime', 'Flights', 'Distance',
569 'DistanceGroup', 'CarrierDelay', 'WeatherDelay', 'NASDelay', 'SecurityDelay', 'LateAircraftDelay',
570 'Div1AirportID', 'Div1AirportSeqID', 'Div2AirportID', 'Div2AirportSeqID', 'Div3AirportID',
571 'Div3AirportSeqID', 'Div4AirportID', 'Div4AirportSeqID', 'Div5AirportID', 'Div5AirportSeqID'
572 ]
573
574 query = "SELECT {} FROM perftest.ontime WHERE FlightDate < '{}'".format(', '.join(cols), sys.argv[1])
575 client = Client.from_url('clickhouse://localhost')
576
577 for row in client.execute_iter(query):
578 pass
579
580
581 Results
582 -------
583
584 This table contains memory and timing benchmark results of snippets above.
585
586 JSON in table is shorthand for JSONEachRow.
587
588 .. rst-class:: table-small-text table-center-header table-right-text-align-results
589
590 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
591 | | Rows |
592 | +-----------+-----------+-----------+-----------+-----------+
593 | | 50k | 131k | 217k | 450k | 697k |
594 +==================================+===========+===========+===========+===========+===========+
595 |**Plain text without parsing: timing** |
596 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
597 |Naive requests.get TSV (1) | 0.40 s | 0.67 s | 0.95 s | 1.67 s | 2.52 s |
598 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
599 |Naive requests.get JSON (1) | 0.61 s | 1.23 s | 2.09 s | 3.52 s | 5.20 s |
600 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
601 |**Plain text without parsing: memory** |
602 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
603 |Naive requests.get TSV (1) | 49 MB | 107 MB | 165 MB | 322 MB | 488 MB |
604 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
605 |Naive requests.get JSON (1) | 206 MB | 564 MB | 916 MB | 1.83 GB | 2.83 GB |
606 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
607 |**Parsed rows: timing** |
608 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
609 |requests.get TSV (2) | 0.81 s | 1.81 s | 3.09 s | 7.22 s | 11.87 s |
610 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
611 |requests.get TSV with cast (2.5) | 1.78 s | 4.58 s | 7.42 s | 16.12 s | 25.52 s |
612 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
613 |requests.get JSON (3) | 2.14 s | 5.65 s | 9.20 s | 20.43 s | 31.72 s |
614 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
615 |clickhouse-driver Native (4) | 0.73 s | 1.40 s | 2.08 s | 4.03 s | 6.20 s |
616 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
617 |**Parsed rows: memory** |
618 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
619 |requests.get TSV (2) | 171 MB | 462 MB | 753 MB | 1.51 GB | 2.33 GB |
620 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
621 |requests.get TSV with cast (2.5) | 135 MB | 356 MB | 576 MB | 1.15 GB | 1.78 GB |
622 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
623 |requests.get JSON (3) | 139 MB | 366 MB | 591 MB | 1.18 GB | 1.82 GB |
624 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
625 |clickhouse-driver Native (4) | 135 MB | 337 MB | 535 MB | 1.05 GB | 1.62 GB |
626 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
627 |**Iteration over rows: timing** |
628 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
629 |requests.get TSV (5) | 0.49 s | 0.99 s | 1.34 s | 2.58 s | 4.00 s |
630 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
631 |requests.get TSV with cast (5.5) | 1.38 s | 3.38 s | 5.40 s | 10.89 s | 16.59 s |
632 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
633 |requests.get JSON (6) | 1.89 s | 4.73 s | 7.63 s | 15.63 s | 24.60 s |
634 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
635 |clickhouse-driver Native (7) | 0.62 s | 1.28 s | 1.93 s | 3.68 s | 5.54 s |
636 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
637 |**Iteration over rows: memory** |
638 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
639 |requests.get TSV (5) | 19 MB | 19 MB | 19 MB | 19 MB | 19 MB |
640 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
641 |requests.get TSV with cast (5.5) | 19 MB | 19 MB | 19 MB | 19 MB | 19 MB |
642 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
643 |requests.get JSON (6) | 20 MB | 20 MB | 20 MB | 20 MB | 20 MB |
644 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
645 |clickhouse-driver Native (7) | 56 MB | 70 MB | 71 MB | 71 MB | 71 MB |
646 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
647 |**Iteration over string rows: timing** |
648 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
649 |requests.get TSV (8) | 0.40 s | 0.67 s | 0.80 s | 1.55 s | 2.18 s |
650 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
651 |requests.get JSON (9) | 1.14 s | 2.64 s | 4.22 s | 8.48 s | 12.96 s |
652 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
653 |clickhouse-driver Native (10) | 0.46 s | 0.91 s | 1.35 s | 2.49 s | 3.67 s |
654 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
655 |**Iteration over string rows: memory** |
656 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
657 |requests.get TSV (8) | 19 MB | 19 MB | 19 MB | 19 MB | 19 MB |
658 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
659 |requests.get JSON (9) | 20 MB | 20 MB | 20 MB | 20 MB | 20 MB |
660 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
661 |clickhouse-driver Native (10) | 46 MB | 56 MB | 57 MB | 57 MB | 57 MB |
662 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
663 |**Iteration over int rows: timing** |
664 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
665 |requests.get TSV (11) | 0.84 s | 2.06 s | 3.22 s | 6.27 s | 10.06 s |
666 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
667 |requests.get JSON (12) | 0.95 s | 2.15 s | 3.55 s | 6.93 s | 10.82 s |
668 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
669 |clickhouse-driver Native (13) | 0.43 s | 0.61 s | 0.86 s | 1.53 s | 2.27 s |
670 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
671 |**Iteration over int rows: memory** |
672 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
673 |requests.get TSV (11) | 19 MB | 19 MB | 19 MB | 19 MB | 19 MB |
674 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
675 |requests.get JSON (12) | 20 MB | 20 MB | 20 MB | 20 MB | 20 MB |
676 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
677 |clickhouse-driver Native (13) | 41 MB | 48 MB | 48 MB | 48 MB | 49 MB |
678 +----------------------------------+-----------+-----------+-----------+-----------+-----------+
679
680
681 Conclusion
682 ----------
683
684 If you need to get significant number of rows from ClickHouse server **as text** then TSV format is your choice.
685 See **Iteration over string rows** results.
686
687 But if you need to manipulate over python data types then you should take a look on drivers with Native format.
688 For most data types driver uses binary :func:`~struct.pack` / :func:`~struct.unpack` for serialization / deserialization.
689 Which is obviously faster than ``cls() for x in lst``. See (2.5) and (5.5).
690
691 It doesn't matter which interface to use if you manipulate small amount of rows.
5454 ... {'date': date.today(), 'a': 1, 'b': 2}
5555 ... )
5656 [('2018-10-21', 3)]
57
58 Customisation ``SELECT`` output with ``FORMAT`` clause is not supported.
5759
5860 .. _execute-with-progress:
5961
133135 ... )
134136
135137
136 To insert data efficiently, provide data separately, and end your statement with a `VALUES` clause:
138 To insert data efficiently, provide data separately, and end your statement with a ``VALUES`` clause:
137139
138140 .. code-block:: python
139141
171173 ... )
172174
173175
174 Of course for `INSERT ... SELECT` queries data is not needed:
176 Of course for ``INSERT ... SELECT`` queries data is not needed:
175177
176178 .. code-block:: python
177179
182184 ... )
183185 []
184186
185 ClickHouse will execute this query like a usual `SELECT` query.
187 ClickHouse will execute this query like a usual ``SELECT`` query.
188
189 Inserting data in different formats with ``FORMAT`` clause is not supported.
190
191 See :ref:`insert-from-csv-file` if you need to data in custom format.
186192
187193 DDL
188194 ---
2929
3030 SELECT type: :class:`~datetime.date`.
3131
32 Only values after the beginning of the epoch (1970-01-01) are supported.
3233
3334 DateTime('timezone')/DateTime64('timezone')
3435 -------------------------------------------
4950
5051 Due to Python's current limitations minimal DateTime64 resolution is one microsecond.
5152
53 Only values after the beginning of the epoch (1970-01-01) are supported.
54
5255
5356 String/FixedString(N)
5457 ---------------------
5558
56 INSERT types: :class:`str`/:func:`basestring <basestring>`, :class:`bytearray`, :class:`bytes`. See note below.
59 INSERT types: :class:`str`/:func:`basestring <basestring>`, :class:`bytes`. See note below.
5760
5861 SELECT type: :class:`str`/:func:`basestring <basestring>`, :class:`bytes`. See note below.
5962
60 String column is encoded/decoded using UTF-8 encoding.
61
62 String column can be returned without decoding. Return values are `bytes`:
63 String column is encoded/decoded with encoding specified by ``strings_encoding`` setting. Default encoding is UTF-8.
64
65 You can specify custom encoding:
66
67 .. code-block:: python
68
69 >>> settings = {'strings_encoding': 'cp1251'}
70 >>> rows = client.execute(
71 ... 'SELECT * FROM table_with_strings',
72 ... settings=settings
73 ... )
74
75 Encoding is applied to all string fields in query.
76
77 String columns can be returned without any decoding. In this case return values are `bytes`:
6378
6479 .. code-block:: python
6580
7388 If a column has FixedString type, upon returning from SELECT it may contain trailing zeroes
7489 in accordance with ClickHouse's storage format. Trailing zeroes are stripped by driver for convenience.
7590
76 During SELECT, if a string cannot be decoded with UTF-8 encoding, it will return as :class:`bytes`.
77
78 During INSERT, if ``strings_as_bytes`` setting is not specified and string cannot be encoded with ``UTF-8``,
91 During SELECT, if a string cannot be decoded with specified encoding, it will return as :class:`bytes`.
92
93 During INSERT, if ``strings_as_bytes`` setting is not specified and string cannot be encoded with encoding,
7994 a ``UnicodeEncodeError`` will be raised.
8095
8196
125140
126141 INSERT types: :class:`list`, :class:`tuple`.
127142
128 SELECT type: :func:`tuple <tuple>`.
143 SELECT type: :class:`list`.
144
145 *Versions before 0.1.4:* SELECT type: :class:`tuple`.
129146
130147
131148 .. code-block:: python
243260 SELECT type: ``T``.
244261
245262 AggregateFunctions for `AggregatingMergeTree` Engine are not supported.
263
264
265 Tuple(T1, T2, ...)
266 ------------------
267
268 *New in version 0.1.4.*
269
270 INSERT types: :class:`list`, :class:`tuple`.
271
272 SELECT type: :class:`tuple`.
273
274
275 Nested
276 ------
277
278 Nested type is represented by sequence of arrays. In example below actual
279 columns for are ``col.name`` and ``col.version``.
280
281 .. code-block:: sql
282
283 :) CREATE TABLE test_nested (col Nested(name String, version UInt16)) Engine = Memory;
284
285 CREATE TABLE test_nested
286 (
287 `col` Nested(
288 name String,
289 version UInt16)
290 )
291 ENGINE = Memory
292
293 Ok.
294
295 0 rows in set. Elapsed: 0.005 sec.
296
297 :) DESCRIBE TABLE test_nested FORMAT TSV;
298
299 DESCRIBE TABLE test_nested
300 FORMAT TSV
301
302 col.name Array(String)
303 col.version Array(UInt16)
304
305 2 rows in set. Elapsed: 0.004 sec.
306
307 Inserting data into nested column in ``clickhouse-client``:
308
309 .. code-block:: sql
310
311 :) INSERT INTO test_nested VALUES (['a', 'b', 'c'], [100, 200, 300]);
312
313 INSERT INTO test_nested VALUES
314
315 Ok.
316
317 1 rows in set. Elapsed: 0.003 sec.
318
319 Inserting data into nested column with ``clickhouse-driver``:
320
321 .. code-block:: python
322
323 client.execute('INSERT INTO test_nested VALUES', [
324 (['a', 'b', 'c'], [100, 200, 300]),
325 ])
0
1 Unsupported server versions
2 ===========================
3
4 Following versions are not supported by this package:
5
6 - 20.1.*. Due to keeping alias type name to metadata.
7
8 However you can use these versions for your own risk.
1010 USE_CYTHON = False
1111 else:
1212 USE_CYTHON = True
13
14 USE_NUMPY = bool(os.getenv('USE_NUMPY', False))
1315
1416
1517 here = os.path.abspath(os.path.dirname(__file__))
4446 ['clickhouse_driver/bufferedwriter' + ext]
4547 ),
4648 Extension(
47 'clickhouse_driver.columns.stringcolumn',
48 ['clickhouse_driver/columns/stringcolumn' + ext]
49 ),
50 Extension(
5149 'clickhouse_driver.varint',
5250 ['clickhouse_driver/varint' + ext]
5351 )
5856 extensions, compiler_directives={'language_level': '3'}
5957 )
6058
59 tests_require = [
60 'nose',
61 'mock',
62 'freezegun',
63 'lz4<=3.0.1',
64 'zstd',
65 'clickhouse-cityhash>=1.0.2.1'
66 ]
67
68 if USE_NUMPY:
69 tests_require.extend(['numpy', 'pandas'])
6170
6271 setup(
6372 name='clickhouse-driver',
98107 'Programming Language :: Python :: 3.6',
99108 'Programming Language :: Python :: 3.7',
100109 'Programming Language :: Python :: 3.8',
110 'Programming Language :: Python :: 3.9',
101111 'Programming Language :: Python :: Implementation :: PyPy',
102112
103113 'Topic :: Database',
110120
111121 keywords='ClickHouse db database cloud analytics',
112122
123 project_urls={
124 'Documentation': 'https://clickhouse-driver.readthedocs.io',
125 },
113126 packages=find_packages('.', exclude=['tests*']),
114127 python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
115128 install_requires=[
116129 'pytz',
117130 'enum34; python_version<"3.4"',
118131 'ipaddress; python_version<"3.4"',
119 'tzlocal'
132 'tzlocal<3.0'
120133 ],
121134 ext_modules=extensions,
122135 extras_require={
123136 'lz4': ['lz4<=3.0.1', 'clickhouse-cityhash>=1.0.2.1'],
124 'zstd': ['zstd', 'clickhouse-cityhash>=1.0.2.1']
137 'zstd': ['zstd', 'clickhouse-cityhash>=1.0.2.1'],
138 'numpy': ['numpy>=1.12.0', 'pandas>=0.24.0']
125139 },
126140 test_suite='nose.collector',
127 tests_require=[
128 'nose',
129 'mock',
130 'freezegun',
131 'lz4<=3.0.1',
132 'zstd',
133 'clickhouse-cityhash>=1.0.2.1'
134 ],
141 tests_require=tests_require
135142 )
44
55
66 class ArrayTestCase(BaseTestCase):
7 def entuple(self, lst):
8 return tuple(
9 self.entuple(x) if isinstance(x, list) else x for x in lst
10 )
11
127 def test_empty(self):
138 columns = 'a Array(Int32)'
149
15 data = [(tuple(), )]
10 data = [([], )]
1611 with self.create_table(columns):
1712 self.client.execute(
1813 'INSERT INTO test (a) VALUES', data
2924
3025 def test_simple(self):
3126 columns = 'a Array(Int32)'
32 data = [(self.entuple([100, 500]), )]
27 data = [([100, 500], )]
3328
3429 with self.create_table(columns):
3530 self.client.execute(
4742
4843 def test_write_column_as_nested_array(self):
4944 columns = 'a Array(Int32)'
50 data = [(self.entuple([100, 500]), ), (self.entuple([100, 500]), )]
45 data = [([100, 500], ), ([100, 500], )]
5146
5247 with self.create_table(columns):
5348 self.client.execute(
6661 def test_nested_with_enum(self):
6762 columns = "a Array(Array(Enum8('hello' = -1, 'world' = 2)))"
6863
69 data = [(self.entuple([['hello', 'world'], ['hello']]), )]
64 data = [([['hello', 'world'], ['hello']], )]
7065 with self.create_table(columns):
7166 self.client.execute(
7267 'INSERT INTO test (a) VALUES', data
8378
8479 def test_nested_of_nested(self):
8580 columns = 'a Array(Array(Array(Int32))), b Array(Array(Array(Int32)))'
86 data = [(self.entuple([
81 data = [([
8782 [[255, 170], [127, 127, 127, 127, 127], [170, 170, 170], [170]],
8883 [[255, 255, 255], [255]], [[255], [255], [255]]
89 ]), self.entuple([
84 ], [
9085 [[255, 170], [127, 127, 127, 127, 127], [170, 170, 170], [170]],
9186 [[255, 255, 255], [255]], [[255], [255], [255]]
92 ]))]
87 ])]
9388
9489 with self.create_table(columns):
9590 self.client.execute(
109104 inserted = self.client.execute(query)
110105 self.assertEqual(inserted, data)
111106
107 def test_empty_nested(self):
108 columns = "a Array(Array(Array(Int32))), b Array(Array(Array(Int32)))"
109 data = [
110 ([], [[]],),
111 ]
112
113 with self.create_table(columns):
114 self.client.execute("INSERT INTO test (a, b) VALUES", data)
115
116 query = "SELECT * FROM test"
117 inserted = self.emit_cli(query)
118 self.assertEqual(
119 inserted, "[]\t[[]]\n",
120 )
121
122 inserted = self.client.execute(query)
123 self.assertEqual(inserted, data)
124
112125 def test_type_mismatch_error(self):
113126 columns = 'a Array(Int32)'
114127 data = [('test', )]
117130 with self.assertRaises(errors.TypeMismatchError):
118131 self.client.execute('INSERT INTO test (a) VALUES', data)
119132
120 data = [(self.entuple(['test']), )]
133 data = [(['test'], )]
121134
122135 with self.create_table(columns):
123136 with self.assertRaises(errors.TypeMismatchError):
125138
126139 def test_string_array(self):
127140 columns = 'a Array(String)'
128 data = [(self.entuple(['aaa', 'bbb']), )]
141 data = [(['aaa', 'bbb'], )]
129142
130143 with self.create_table(columns):
131144 self.client.execute(
143156
144157 def test_string_nullable_array(self):
145158 columns = 'a Array(Nullable(String))'
146 data = [(self.entuple(['aaa', None, 'bbb']), )]
159 data = [(['aaa', None, 'bbb'], )]
147160
148161 with self.create_table(columns):
149162 self.client.execute(
161174
162175 def test_uuid_array(self):
163176 columns = 'a Array(UUID)'
164 data = [(self.entuple([
177 data = [([
165178 UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'),
166179 UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0')
167 ]), )]
180 ], )]
168181
169182 with self.create_table(columns):
170183 self.client.execute(
184197
185198 def test_uuid_nullable_array(self):
186199 columns = 'a Array(Nullable(UUID))'
187 data = [(self.entuple([
200 data = [([
188201 UUID('c0fcbba9-0752-44ed-a5d6-4dfb4342b89d'),
189202 None,
190203 UUID('2efcead4-ff55-4db5-bdb4-6b36a308d8e0')
191 ]), )]
204 ], )]
192205
193206 with self.create_table(columns):
194207 self.client.execute(
4242 )
4343 query = 'SELECT * FROM test'
4444 inserted = self.emit_cli(query)
45 self.assertEqual(inserted, '0000-00-00\n0000-00-00\n')
45 expected = (
46 '1970-01-01\n1970-01-01\n' if self.server_version > (20, 7, 2)
47 else '0000-00-00\n0000-00-00\n'
48 )
49 self.assertEqual(inserted, expected)
101101 self.assertEqual(
102102 inserted, [(datetime(2012, 10, 25, 14, 7, 19, 125000), )]
103103 )
104
105 def test_insert_integers(self):
106 with self.create_table('a DateTime'):
107 self.client.execute(
108 'INSERT INTO test (a) VALUES', [(1530211034, )]
109 )
110
111 query = 'SELECT toUInt32(a), a FROM test'
112 inserted = self.emit_cli(query)
113 self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14\n')
114
115 @require_server_version(20, 1, 2)
116 def test_insert_integers_datetime64(self):
117 with self.create_table('a DateTime64'):
118 self.client.execute(
119 'INSERT INTO test (a) VALUES', [(1530211034123, )]
120 )
121
122 query = 'SELECT toUInt32(a), a FROM test'
123 inserted = self.emit_cli(query)
124 self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14.123\n')
125
126 def test_insert_integer_bounds(self):
127 with self.create_table('a DateTime'):
128 self.client.execute(
129 'INSERT INTO test (a) VALUES',
130 [(0, ), (1, ), (1500000000, ), (2**32-1, )]
131 )
132
133 query = 'SELECT toUInt32(a) FROM test ORDER BY a'
134 inserted = self.emit_cli(query)
135 self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n')
104136
105137
106138 class DateTimeTimezonesTestCase(BaseDateTimeTestCase):
207239 inserted = self.client.execute(query, settings=settings)
208240 self.assertEqual(inserted, [(self.dt, ), (self.dt, )])
209241
210 def test_insert_integers(self):
211 settings = {'use_client_time_zone': True}
212
213 with self.patch_env_tz('Europe/Moscow'):
214 with self.create_table(self.table_columns()):
215 self.client.execute(
216 'INSERT INTO test (a) VALUES', [(1530211034, )],
217 settings=settings
218 )
219
220 query = 'SELECT toUInt32(a), a FROM test'
221 inserted = self.emit_cli(query, use_client_time_zone=1)
222 self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14\n')
223
224 def test_insert_integer_bounds(self):
225 with self.create_table('a DateTime'):
226 self.client.execute(
227 'INSERT INTO test (a) VALUES',
228 [(0, ), (1, ), (1500000000, ), (2**32-1, )]
229 )
230
231 query = 'SELECT toUInt32(a) FROM test ORDER BY a'
232 inserted = self.emit_cli(query)
233 self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n')
234
235242 @require_server_version(1, 1, 54337)
236243 def test_datetime_with_timezone_use_server_timezone(self):
237244 # Insert datetime with timezone Asia/Kamchatka
22
33 from tests.testcase import BaseTestCase
44 from clickhouse_driver import errors
5 from clickhouse_driver.util.compat import text_type
56
67
78 class FixedStringTestCase(BaseTestCase):
89 def test_simple(self):
9 columns = 'a FixedString(4)'
10
1110 data = [('a', ), ('bb', ), ('ccc', ), ('dddd', ), ('я', )]
12 with self.create_table(columns):
11 with self.create_table('a FixedString(4)'):
1312 self.client.execute(
1413 'INSERT INTO test (a) VALUES', data
1514 )
3029 self.assertEqual(inserted, data)
3130
3231 def test_non_utf(self):
33 columns = 'a FixedString(6)'
34
3532 data = [('яндекс'.encode('koi8-r'), )]
36 with self.create_table(columns):
33 with self.create_table('a FixedString(6)'):
3734 self.client.execute(
3835 'INSERT INTO test (a) VALUES', data
3936 )
8077 self.assertEqual(inserted, data)
8178
8279 def test_null_byte_in_the_middle(self):
83 columns = 'a FixedString(9)'
84
8580 data = [('test\0test', )]
86 with self.create_table(columns):
81 with self.create_table('a FixedString(9)'):
8782 self.client.execute(
8883 'INSERT INTO test (a) VALUES', data
8984 )
9388 self.assertEqual(inserted, data)
9489
9590 def test_empty(self):
96 columns = 'a FixedString(5)'
97
9891 data = [('',)]
99 with self.create_table(columns):
100 self.client.execute(
101 'INSERT INTO test (a) VALUES', data
102 )
103
104 query = 'SELECT * FROM test'
105 inserted = self.client.execute(query)
106 self.assertEqual(inserted, data)
92 with self.create_table('a FixedString(5)'):
93 self.client.execute(
94 'INSERT INTO test (a) VALUES', data
95 )
96
97 query = 'SELECT * FROM test'
98 inserted = self.client.execute(query)
99 self.assertEqual(inserted, data)
100
101 def test_custom_encoding(self):
102 settings = {'strings_encoding': 'cp1251'}
103
104 data = [(('яндекс'), ), (('test'), )]
105 with self.create_table('a FixedString(10)'):
106 self.client.execute(
107 'INSERT INTO test (a) VALUES', data, settings=settings
108 )
109
110 query = 'SELECT * FROM test'
111 inserted = self.emit_cli(query, encoding='cp1251')
112 self.assertEqual(
113 inserted,
114 'яндекс\\0\\0\\0\\0\n'
115 'test\\0\\0\\0\\0\\0\\0\n'
116 )
117
118 inserted = self.client.execute(query, settings=settings)
119 self.assertEqual(inserted, data)
120 self.assertIsInstance(inserted[0][0], text_type)
121 self.assertIsInstance(inserted[1][0], text_type)
122
123 def test_not_supported_types(self):
124 datas = [
125 [(bytearray(b'asd'), )],
126 [(123, )]
127 ]
128 with self.create_table('a String'):
129 for data in datas:
130 with self.assertRaises(errors.TypeMismatchError) as e:
131 self.client.execute(
132 'INSERT INTO test (a) VALUES', data,
133 types_check=True
134 )
135
136 self.assertIn('for column "a"', str(e.exception))
137
138 with self.assertRaises(AttributeError):
139 self.client.execute(
140 'INSERT INTO test (a) VALUES', data
141 )
107142
108143
109144 class ByteFixedStringTestCase(BaseTestCase):
127162 )
128163
129164 def test_not_decoded(self):
130 columns = 'a FixedString(8)'
131
132165 data = [
133 (bytearray('яндекс'.encode('cp1251')), ),
166 (bytes('яндекс'.encode('cp1251')), ),
134167 (bytes('test'.encode('cp1251')), ),
135168 ]
136 with self.create_table(columns):
169 with self.create_table('a FixedString(8)'):
137170 self.client.execute(
138171 'INSERT INTO test (a) VALUES', data
139172 )
176209
177210 inserted = self.client.execute(query)
178211 self.assertEqual(inserted, data)
212
213 def test_not_supported_types(self):
214 datas = [
215 [('asd', )],
216 [(bytearray(b'asd'), )],
217 [(123, )]
218 ]
219 with self.create_table('a String'):
220 for data in datas:
221 with self.assertRaises(errors.TypeMismatchError) as e:
222 self.client.execute(
223 'INSERT INTO test (a) VALUES', data,
224 types_check=True
225 )
226
227 self.assertIn('for column "a"', str(e.exception))
228
229 with self.assertRaises(ValueError) as e:
230 self.client.execute(
231 'INSERT INTO test (a) VALUES', data
232 )
233
234 self.assertIn('bytes object expected', str(e.exception))
1818 'INSERT INTO test (a, b) VALUES', data
1919 )
2020
21 self.assertIn('Column a', str(e.exception))
21 self.assertIn('Column a', str(e.exception))
2222
2323 def test_simple(self):
2424 with self.create_table('a Float32, b Float64'):
3535 'INSERT INTO test (a) VALUES', data
3636 )
3737
38 exc = str(e.exception)
39 self.assertIn('Column a', exc)
40 self.assertIn('types_check=True', exc)
38 exc = str(e.exception)
39 self.assertIn('Column a', exc)
40 self.assertIn('types_check=True', exc)
4141
4242 def test_uint_type_mismatch(self):
4343 data = [(-1, )]
8484
8585 def test_array(self):
8686 with self.create_table('a Array(LowCardinality(Int16))'):
87 data = [((100, 500), )]
87 data = [([100, 500], )]
8888 self.client.execute('INSERT INTO test (a) VALUES', data)
8989
9090 query = 'SELECT * FROM test'
9696
9797 def test_empty_array(self):
9898 with self.create_table('a Array(LowCardinality(Int16))'):
99 data = [(tuple(), )]
99 data = [([], )]
100100 self.client.execute('INSERT INTO test (a) VALUES', data)
101101
102102 query = 'SELECT * FROM test'
0 from enum import IntEnum
1
02 from tests.testcase import BaseTestCase
13
24
3840
3941 inserted = self.client.execute(query)
4042 self.assertEqual(inserted, data)
43
44 def test_simple_agg_function(self):
45 class A(IntEnum):
46 hello = -1
47 world = 2
48
49 columns = "a SimpleAggregateFunction(anyLast, " \
50 "Enum8('hello' = -1, 'world' = 2))"
51
52 data = [(A.hello,), (A.world,), (-1,), (2,)]
53 with self.create_table(columns):
54 self.client.execute(
55 'INSERT INTO test (a) VALUES', data
56 )
57
58 query = 'SELECT * FROM test'
59 inserted = self.emit_cli(query)
60 self.assertEqual(
61 inserted, (
62 'hello\n'
63 'world\n'
64 'hello\n'
65 'world\n'
66 )
67 )
68
69 inserted = self.client.execute(query)
70 self.assertEqual(
71 inserted, [
72 ('hello',), ('world',),
73 ('hello',), ('world',)
74 ]
75 )
76
77 def test_simple_agg_function_nullable(self):
78 class A(IntEnum):
79 hello = -1
80 world = 2
81
82 columns = "a SimpleAggregateFunction(anyLast, " \
83 "Nullable(Enum8('hello' = -1, 'world' = 2)))"
84
85 data = [(A.hello,), (A.world,), (None,), (-1,), (2,)]
86 with self.create_table(columns):
87 self.client.execute(
88 'INSERT INTO test (a) VALUES', data
89 )
90
91 query = 'SELECT * FROM test'
92 inserted = self.emit_cli(query)
93 self.assertEqual(
94 inserted, (
95 'hello\n'
96 'world\n'
97 '\\N\n'
98 'hello\n'
99 'world\n'
100 )
101 )
102
103 inserted = self.client.execute(query)
104 self.assertEqual(
105 inserted, [
106 ('hello',), ('world',),
107 (None, ),
108 ('hello',), ('world',)
109 ]
110 )
22
33 from tests.testcase import BaseTestCase
44 from clickhouse_driver import errors
5 from clickhouse_driver.util.compat import text_type
56
67
78 class StringTestCase(BaseTestCase):
89 def test_unicode(self):
9 columns = 'a String'
10
1110 data = [('яндекс', )]
12 with self.create_table(columns):
11 with self.create_table('a String'):
1312 self.client.execute(
1413 'INSERT INTO test (a) VALUES', data
1514 )
2221 self.assertEqual(inserted, data)
2322
2423 def test_non_utf(self):
25 columns = 'a String'
26
2724 data = [('яндекс'.encode('koi8-r'), )]
28 with self.create_table(columns):
25 with self.create_table('a String'):
2926 self.client.execute(
3027 'INSERT INTO test (a) VALUES', data
3128 )
3835 self.assertEqual(inserted, data)
3936
4037 def test_null_byte_in_the_middle(self):
41 columns = 'a String'
42
4338 data = [('a\x00b', )]
44 with self.create_table(columns):
39 with self.create_table('a String'):
4540 self.client.execute(
4641 'INSERT INTO test (a) VALUES', data
4742 )
6863 self.assertEqual(inserted, data)
6964
7065 def test_buffer_reader(self):
71 columns = 'a String'
72
7366 data = [('a' * 300, )] * 300
74 with self.create_table(columns):
67 with self.create_table('a String'):
7568 self.client.execute(
7669 'INSERT INTO test (a) VALUES', data
7770 )
8275 self.assertEqual(inserted, data)
8376
8477 def test_compressed_client(self):
85 columns = 'a String'
86
8778 with self.created_client(compression=True) as client:
8879 data = [('a' * 300, )]
89 with self.create_table(columns):
80 with self.create_table('a String'):
9081 client.execute(
9182 'INSERT INTO test (a) VALUES', data
9283 )
9687 inserted = client.execute(query)
9788 self.assertEqual(inserted, data)
9889
90 def test_custom_encoding(self):
91 settings = {'strings_encoding': 'cp1251'}
92
93 data = [(('яндекс'), ), (('test'), )]
94 with self.create_table('a String'):
95 self.client.execute(
96 'INSERT INTO test (a) VALUES', data, settings=settings
97 )
98
99 query = 'SELECT * FROM test'
100 inserted = self.emit_cli(query, encoding='cp1251')
101 self.assertEqual(inserted, 'яндекс\ntest\n')
102
103 inserted = self.client.execute(query, settings=settings)
104 self.assertEqual(inserted, data)
105 self.assertIsInstance(inserted[0][0], text_type)
106 self.assertIsInstance(inserted[1][0], text_type)
107
108 def test_not_supported_types(self):
109 datas = [
110 [(bytearray(b'asd'), )],
111 [(123, )]
112 ]
113 with self.create_table('a String'):
114 for data in datas:
115 with self.assertRaises(errors.TypeMismatchError) as e:
116 self.client.execute(
117 'INSERT INTO test (a) VALUES', data,
118 types_check=True
119 )
120
121 self.assertIn('for column "a"', str(e.exception))
122
123 with self.assertRaises(AttributeError):
124 self.client.execute(
125 'INSERT INTO test (a) VALUES', data
126 )
127
99128
100129 class ByteStringTestCase(BaseTestCase):
101130 client_kwargs = {'settings': {'strings_as_bytes': True}}
102131
103132 def test_not_decoded(self):
104 columns = 'a String'
105
106133 data = [
107 (bytearray('яндекс'.encode('cp1251')), ),
134 (bytes('яндекс'.encode('cp1251')), ),
108135 (bytes('test'.encode('cp1251')), ),
109136 ]
110 with self.create_table(columns):
137 with self.create_table('a String'):
111138 self.client.execute(
112139 'INSERT INTO test (a) VALUES', data
113140 )
120147 self.assertEqual(inserted, data)
121148 self.assertIsInstance(inserted[0][0], bytes)
122149 self.assertIsInstance(inserted[1][0], bytes)
123
124 def test_not_decoded_bytearray_expected(self):
125 columns = 'a String'
126
127 data = [('asd', )]
128 with self.create_table(columns):
129 with self.assertRaises(errors.TypeMismatchError) as e:
130 self.client.execute(
131 'INSERT INTO test (a) VALUES', data,
132 types_check=True
133 )
134
135 self.assertIn('Column a', str(e.exception))
136150
137151 def test_nullable(self):
138152 with self.create_table('a Nullable(String)'):
147161
148162 inserted = self.client.execute(query)
149163 self.assertEqual(inserted, data)
164
165 def test_not_supported_types(self):
166 datas = [
167 [('asd', )],
168 [(bytearray(b'asd'), )],
169 [(123, )]
170 ]
171 with self.create_table('a String'):
172 for data in datas:
173 with self.assertRaises(errors.TypeMismatchError) as e:
174 self.client.execute(
175 'INSERT INTO test (a) VALUES', data,
176 types_check=True
177 )
178
179 self.assertIn('for column "a"', str(e.exception))
180
181 with self.assertRaises(ValueError) as e:
182 self.client.execute(
183 'INSERT INTO test (a) VALUES', data
184 )
185
186 self.assertIn('bytes object expected', str(e.exception))
0 from datetime import date
1
2 from clickhouse_driver import errors
3 from tests.testcase import BaseTestCase
4 from tests.util import require_server_version
5
6
7 class TupleTestCase(BaseTestCase):
8 def entuple(self, lst):
9 return tuple(
10 self.entuple(x) if isinstance(x, list) else x for x in lst
11 )
12
13 def test_simple(self):
14 columns = 'a Tuple(Int32, String)'
15 data = [((1, 'a'), ), ((2, 'b'), )]
16
17 with self.create_table(columns):
18 self.client.execute(
19 'INSERT INTO test (a) VALUES', data
20 )
21
22 query = 'SELECT * FROM test'
23 inserted = self.emit_cli(query)
24 self.assertEqual(inserted, "(1,'a')\n(2,'b')\n")
25
26 inserted = self.client.execute(query)
27 self.assertEqual(inserted, data)
28
29 def test_tuple_single_element(self):
30 columns = 'a Tuple(Int32)'
31 data = [((1, ), ), ((2, ), )]
32
33 with self.create_table(columns):
34 self.client.execute(
35 'INSERT INTO test (a) VALUES', data
36 )
37
38 query = 'SELECT * FROM test'
39 inserted = self.emit_cli(query)
40 self.assertEqual(inserted, "(1)\n(2)\n")
41
42 inserted = self.client.execute(query)
43 self.assertEqual(inserted, data)
44
45 def test_nullable(self):
46 with self.create_table('a Tuple(Nullable(Int32), Nullable(String))'):
47 data = [
48 ((1, 'a'), ),
49 ((2, None), ), ((None, None), ), ((None, 'd'), ),
50 ((5, 'e'), )
51 ]
52 self.client.execute(
53 'INSERT INTO test (a) VALUES', data
54 )
55
56 query = 'SELECT * FROM test'
57 inserted = self.emit_cli(query)
58 self.assertEqual(
59 inserted,
60 "(1,'a')\n"
61 "(2,NULL)\n(NULL,NULL)\n(NULL,'d')\n"
62 "(5,'e')\n"
63 )
64
65 inserted = self.client.execute(query)
66 self.assertEqual(inserted, data)
67
68 def test_nested_tuple_with_common_types(self):
69 columns = 'a Tuple(String, Tuple(Int32, String), String)'
70
71 with self.create_table(columns):
72 data = [
73 (('one', (1, 'a'), 'two'), ),
74 (('three', (2, 'b'), 'four'), )
75 ]
76 self.client.execute(
77 'INSERT INTO test (a) VALUES', data
78 )
79
80 query = 'SELECT * FROM test'
81 inserted = self.emit_cli(query)
82 self.assertEqual(
83 inserted,
84 "('one',(1,'a'),'two')\n"
85 "('three',(2,'b'),'four')\n"
86 )
87
88 inserted = self.client.execute(query)
89 self.assertEqual(inserted, data)
90
91 def test_tuple_of_tuples(self):
92 columns = (
93 "a Tuple("
94 "Tuple(Int32, String),"
95 "Tuple(Enum8('hello' = 1, 'world' = 2), Date)"
96 ")"
97 )
98
99 with self.create_table(columns):
100 data = [
101 (((1, 'a'), (1, date(2020, 3, 11))), ),
102 (((2, 'b'), (2, date(2020, 3, 12))), )
103 ]
104 self.client.execute(
105 'INSERT INTO test (a) VALUES', data
106 )
107
108 query = 'SELECT * FROM test'
109 inserted = self.emit_cli(query)
110 self.assertEqual(
111 inserted,
112 "((1,'a'),('hello','2020-03-11'))\n"
113 "((2,'b'),('world','2020-03-12'))\n"
114 )
115
116 inserted = self.client.execute(query)
117 self.assertEqual(
118 inserted, [
119 (((1, 'a'), ('hello', date(2020, 3, 11))), ),
120 (((2, 'b'), ('world', date(2020, 3, 12))), )
121 ]
122 )
123
124 def test_tuple_of_arrays(self):
125 with self.create_table('a Tuple(Array(Int32))'):
126 data = [(([1, 2, 3], ), ), (([4, 5, 6], ), )]
127 self.client.execute(
128 'INSERT INTO test (a) VALUES', data
129 )
130
131 query = 'SELECT * FROM test'
132 inserted = self.emit_cli(query)
133 self.assertEqual(
134 inserted,
135 "([1,2,3])\n([4,5,6])\n"
136 )
137
138 inserted = self.client.execute(query)
139 self.assertEqual(inserted, data)
140
141 # Bug in Array of Tuple handing before 19.16.13:
142 # DESCRIBE TABLE test
143 #
144 # | a.1 | Array(UInt8) |
145 # | a.2 | Array(UInt8) |
146 # | a.3 | Array(UInt8) |
147 # https://github.com/ClickHouse/ClickHouse/pull/8866
148 @require_server_version(19, 16, 13)
149 def test_array_of_tuples(self):
150 with self.create_table('a Array(Tuple(UInt8, UInt8, UInt8))'):
151 data = [
152 ([(1, 2, 3), (4, 5, 6)], ),
153 ([(7, 8, 9)],),
154 ]
155 self.client.execute(
156 'INSERT INTO test (a) VALUES', data
157 )
158
159 query = 'SELECT * FROM test'
160 inserted = self.emit_cli(query)
161 self.assertEqual(
162 inserted,
163 "[(1,2,3),(4,5,6)]\n"
164 "[(7,8,9)]\n"
165 )
166
167 inserted = self.client.execute(query)
168 self.assertEqual(inserted, data)
169
170 def test_type_mismatch_error(self):
171 columns = 'a Tuple(Int32)'
172 data = [('test', )]
173
174 with self.create_table(columns):
175 with self.assertRaises(errors.TypeMismatchError):
176 self.client.execute('INSERT INTO test (a) VALUES', data)
77 class UnknownColumnTestCase(TestCase):
88 def test_get_unknown_column(self):
99 with self.assertRaises(errors.UnknownTypeError) as e:
10 get_column_by_spec('Unicorn')
10 get_column_by_spec('Unicorn', {'context': {}})
1111
12 self.assertIn('Unicorn', str(e.exception))
12 self.assertIn('Unicorn', str(e.exception))
(New empty file)
0 from contextlib import contextmanager
1 from datetime import datetime
2 import os
3 from time import tzset
4
5 from mock import patch
6
7 try:
8 import numpy as np
9 except ImportError:
10 np = None
11
12 try:
13 import pandas as pd
14 except ImportError:
15 pd = None
16
17 from pytz import timezone, utc, UnknownTimeZoneError
18 import tzlocal
19
20 from tests.numpy.testcase import NumpyBaseTestCase
21 from tests.util import require_server_version
22
23
24 class BaseDateTimeTestCase(NumpyBaseTestCase):
25 def setUp(self):
26 super(BaseDateTimeTestCase, self).setUp()
27
28 # Bust tzlocal cache.
29 try:
30 tzlocal.unix._cache_tz = None
31 except AttributeError:
32 pass
33
34 try:
35 tzlocal.win32._cache_tz = None
36 except AttributeError:
37 pass
38
39 def make_numpy_d64ns(self, items):
40 return np.array(items, dtype='datetime64[ns]')
41
42
43 class DateTimeTestCase(BaseDateTimeTestCase):
44 def test_datetime_type(self):
45 query = 'SELECT now()'
46
47 rv = self.client.execute(query, columnar=True)
48 self.assertIsInstance(rv[0][0], np.datetime64)
49
50 @require_server_version(20, 1, 2)
51 def test_datetime64_type(self):
52 query = 'SELECT now64()'
53
54 rv = self.client.execute(query, columnar=True)
55 self.assertIsInstance(rv[0][0], np.datetime64)
56
57 def test_simple(self):
58 with self.create_table('a Date, b DateTime'):
59 data = [
60 np.array(['2012-10-25'], dtype='datetime64[D]'),
61 np.array(['2012-10-25T14:07:19'], dtype='datetime64[ns]')
62 ]
63 self.client.execute(
64 'INSERT INTO test (a, b) VALUES', data, columnar=True
65 )
66
67 query = 'SELECT * FROM test'
68 inserted = self.emit_cli(query)
69 self.assertEqual(inserted, '2012-10-25\t2012-10-25 14:07:19\n')
70
71 inserted = self.client.execute(query, columnar=True)
72 self.assertArraysEqual(
73 inserted[0], np.array(['2012-10-25'], dtype='datetime64[D]')
74 )
75 self.assertArraysEqual(
76 inserted[1], self.make_numpy_d64ns(['2012-10-25T14:07:19'])
77 )
78
79 def test_handle_errors_from_tzlocal(self):
80 with patch('tzlocal.get_localzone') as mocked_get_localzone:
81 mocked_get_localzone.side_effect = UnknownTimeZoneError()
82 self.client.execute('SELECT now()')
83
84 @require_server_version(20, 1, 2)
85 def test_datetime64_frac_trunc(self):
86 with self.create_table('a DateTime64'):
87 data = [self.make_numpy_d64ns(['2012-10-25T14:07:19.125600'])]
88 self.client.execute(
89 'INSERT INTO test (a) VALUES', data, columnar=True
90 )
91
92 query = 'SELECT * FROM test'
93 inserted = self.emit_cli(query)
94 self.assertEqual(inserted, '2012-10-25 14:07:19.125\n')
95
96 inserted = self.client.execute(query, columnar=True)
97 self.assertArraysEqual(
98 inserted[0], self.make_numpy_d64ns(['2012-10-25T14:07:19.125'])
99 )
100
101 @require_server_version(20, 1, 2)
102 def test_datetime64_explicit_frac(self):
103 with self.create_table('a DateTime64(1)'):
104 data = [self.make_numpy_d64ns(['2012-10-25T14:07:19.125600'])]
105 self.client.execute(
106 'INSERT INTO test (a) VALUES', data, columnar=True
107 )
108
109 query = 'SELECT * FROM test'
110 inserted = self.emit_cli(query)
111 self.assertEqual(inserted, '2012-10-25 14:07:19.1\n')
112
113 inserted = self.client.execute(query, columnar=True)
114 self.assertArraysEqual(
115 inserted[0], self.make_numpy_d64ns(['2012-10-25T14:07:19.1'])
116 )
117
118 def test_insert_integers_datetime(self):
119 with self.create_table('a DateTime'):
120 self.client.execute(
121 'INSERT INTO test (a) VALUES',
122 [np.array([1530211034], dtype=np.uint32)], columnar=True
123 )
124
125 query = 'SELECT toUInt32(a), a FROM test'
126 inserted = self.emit_cli(query)
127 self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14\n')
128
129 @require_server_version(20, 1, 2)
130 def test_insert_integers_datetime64(self):
131 with self.create_table('a DateTime64'):
132 self.client.execute(
133 'INSERT INTO test (a) VALUES',
134 [np.array([1530211034123], dtype=np.uint64)], columnar=True
135 )
136
137 query = 'SELECT toUInt32(a), a FROM test'
138 inserted = self.emit_cli(query)
139 self.assertEqual(inserted, '1530211034\t2018-06-28 21:37:14.123\n')
140
141 def test_insert_integer_bounds(self):
142 with self.create_table('a DateTime'):
143 self.client.execute(
144 'INSERT INTO test (a) VALUES',
145 [np.array([0, 1, 1500000000, 2**32-1], dtype=np.uint32)],
146 columnar=True
147 )
148
149 query = 'SELECT toUInt32(a) FROM test ORDER BY a'
150 inserted = self.emit_cli(query)
151 self.assertEqual(inserted, '0\n1\n1500000000\n4294967295\n')
152
153
154 class DateTimeTimezonesTestCase(BaseDateTimeTestCase):
155 dt_type = 'DateTime'
156
157 def make_tz_numpy_array(self, dt, tz_name):
158 dtype = 'datetime64[ns]'
159
160 return pd.to_datetime(np.array([dt] * 2, dtype=dtype)) \
161 .tz_localize(tz_name).to_numpy(dtype)
162
163 @contextmanager
164 def patch_env_tz(self, tz_name):
165 # Although in many cases, changing the TZ environment variable may
166 # affect the output of functions like localtime() without calling
167 # tzset(), this behavior should not be relied on.
168 # https://docs.python.org/3/library/time.html#time.tzset
169 with patch.dict(os.environ, {'TZ': tz_name}):
170 tzset()
171 yield
172
173 tzset()
174
175 # Asia/Kamchatka = UTC+12
176 # Asia/Novosibirsk = UTC+7
177 # Europe/Moscow = UTC+3
178
179 # 1500010800 second since epoch in Europe/Moscow.
180 # 1500000000 second since epoch in UTC.
181 dt = datetime(2017, 7, 14, 5, 40)
182 dt_str = dt.isoformat()
183
184 # properties for lazy evaluation for dealing with AttributeError when no
185 # numpy/pandas installed
186 @property
187 def dt_arr(self):
188 return np.array([self.dt_str], dtype='datetime64[s]')
189
190 @property
191 def dt_tz(self):
192 return pd.to_datetime(self.dt_arr).tz_localize('Asia/Kamchatka')
193
194 col_tz_name = 'Asia/Novosibirsk'
195 col_tz = timezone(col_tz_name)
196
197 # INSERTs and SELECTs must be the same as clickhouse-client's
198 # if column has no timezone.
199
200 def table_columns(self, with_tz=False):
201 if not with_tz:
202 return 'a {}'.format(self.dt_type)
203
204 return "a {}('{}')".format(self.dt_type, self.col_tz_name)
205
206 def test_use_server_timezone(self):
207 # Insert datetime with timezone UTC
208 # into column with no timezone
209 # using server's timezone (Europe/Moscow)
210
211 # Determine server timezone and calculate expected timestamp.
212 server_tz_name = self.client.execute('SELECT timezone()')[0][0]
213 offset = timezone(server_tz_name).utcoffset(self.dt).total_seconds()
214 timestamp = 1500010800 - int(offset)
215
216 with self.patch_env_tz('Asia/Novosibirsk'):
217 with self.create_table(self.table_columns()):
218 self.client.execute(
219 'INSERT INTO test (a) VALUES', [self.dt_arr], columnar=True
220 )
221
222 self.emit_cli(
223 "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')"
224 )
225
226 query = 'SELECT toInt32(a) FROM test'
227 inserted = self.emit_cli(query)
228 self.assertEqual(inserted, '{ts}\n{ts}\n'.format(ts=timestamp))
229
230 query = 'SELECT * FROM test'
231 inserted = self.emit_cli(query)
232 self.assertEqual(
233 inserted,
234 '2017-07-14 05:40:00\n2017-07-14 05:40:00\n'
235 )
236
237 inserted = self.client.execute(query, columnar=True)
238 self.assertArraysEqual(
239 inserted[0], self.make_numpy_d64ns([self.dt_str] * 2)
240 )
241
242 def test_use_client_timezone(self):
243 # Insert datetime with timezone UTC
244 # into column with no timezone
245 # using client's timezone Asia/Novosibirsk
246
247 settings = {'use_client_time_zone': True}
248
249 with self.patch_env_tz('Asia/Novosibirsk'):
250 with self.create_table(self.table_columns()):
251 self.client.execute(
252 'INSERT INTO test (a) VALUES', [self.dt_arr],
253 settings=settings, columnar=True
254 )
255
256 self.emit_cli(
257 "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')",
258 use_client_time_zone=1
259 )
260
261 query = 'SELECT toInt32(a) FROM test'
262 inserted = self.emit_cli(query, use_client_time_zone=1)
263 # 1499985600 = 1500000000 - 4 * 3600
264 self.assertEqual(inserted, '1499985600\n1499985600\n')
265
266 query = 'SELECT * FROM test'
267 inserted = self.emit_cli(query, use_client_time_zone=1)
268 self.assertEqual(
269 inserted,
270 '2017-07-14 05:40:00\n2017-07-14 05:40:00\n'
271 )
272
273 inserted = self.client.execute(query, columnar=True,
274 settings=settings)
275 self.assertArraysEqual(
276 inserted[0], self.make_numpy_d64ns([self.dt_str] * 2)
277 )
278
279 @require_server_version(1, 1, 54337)
280 def test_datetime_with_timezone_use_server_timezone(self):
281 # Insert datetime with timezone Asia/Kamchatka
282 # into column with no timezone
283 # using server's timezone (Europe/Moscow)
284
285 server_tz_name = self.client.execute('SELECT timezone()')[0][0]
286 offset = timezone(server_tz_name).utcoffset(self.dt)
287
288 with self.patch_env_tz('Asia/Novosibirsk'):
289 with self.create_table(self.table_columns()):
290 self.client.execute(
291 'INSERT INTO test (a) VALUES', [self.dt_tz], columnar=True
292 )
293
294 self.emit_cli(
295 "INSERT INTO test (a) VALUES "
296 "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))",
297 )
298
299 query = 'SELECT toInt32(a) FROM test'
300 inserted = self.emit_cli(query)
301 # 1499967600 = 1500000000 - 12 * 3600
302 self.assertEqual(inserted, '1499967600\n1499967600\n')
303
304 query = 'SELECT * FROM test'
305 inserted = self.emit_cli(query)
306
307 dt = (self.dt_tz.to_pydatetime()[0].astimezone(utc) + offset) \
308 .replace(tzinfo=None)
309 self.assertEqual(inserted, '{dt}\n{dt}\n'.format(dt=dt))
310
311 inserted = self.client.execute(query, columnar=True)
312 self.assertArraysEqual(
313 inserted[0], self.make_numpy_d64ns([dt.isoformat()] * 2)
314 )
315
316 @require_server_version(1, 1, 54337)
317 def test_datetime_with_timezone_use_client_timezone(self):
318 # Insert datetime with timezone Asia/Kamchatka
319 # into column with no timezone
320 # using client's timezone Asia/Novosibirsk
321
322 settings = {'use_client_time_zone': True}
323
324 with self.patch_env_tz('Asia/Novosibirsk'):
325 with self.create_table(self.table_columns()):
326 self.client.execute(
327 'INSERT INTO test (a) VALUES', [self.dt_tz],
328 settings=settings, columnar=True
329 )
330
331 self.emit_cli(
332 "INSERT INTO test (a) VALUES "
333 "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))",
334 use_client_time_zone=1
335 )
336
337 query = 'SELECT toInt32(a) FROM test'
338 inserted = self.emit_cli(query, use_client_time_zone=1)
339 # 1499967600 = 1500000000 - 12 * 3600
340 self.assertEqual(inserted, '1499967600\n1499967600\n')
341
342 query = 'SELECT * FROM test'
343 inserted = self.emit_cli(query, use_client_time_zone=1)
344 # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00
345 # (Kamchatka - Novosibirsk)
346 self.assertEqual(
347 inserted,
348 '2017-07-14 00:40:00\n2017-07-14 00:40:00\n'
349 )
350
351 inserted = self.client.execute(query, columnar=True,
352 settings=settings)
353 dt = datetime(2017, 7, 14, 0, 40)
354 self.assertArraysEqual(
355 inserted[0], self.make_numpy_d64ns([dt.isoformat()] * 2)
356 )
357
358 @require_server_version(1, 1, 54337)
359 def test_column_use_server_timezone(self):
360 # Insert datetime with no timezone
361 # into column with timezone Asia/Novosibirsk
362 # using server's timezone (Europe/Moscow)
363
364 with self.patch_env_tz('Europe/Moscow'):
365 with self.create_table(self.table_columns(with_tz=True)):
366 self.client.execute(
367 'INSERT INTO test (a) VALUES', [self.dt_arr], columnar=True
368 )
369
370 self.emit_cli(
371 "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')"
372 )
373
374 query = 'SELECT toInt32(a) FROM test'
375 inserted = self.emit_cli(query)
376 # 1499985600 = 1500000000 - 4 * 3600
377 self.assertEqual(inserted, '1499985600\n1499985600\n')
378
379 query = 'SELECT * FROM test'
380 inserted = self.emit_cli(query)
381 self.assertEqual(
382 inserted,
383 '2017-07-14 05:40:00\n2017-07-14 05:40:00\n'
384 )
385
386 inserted = self.client.execute(query, columnar=True)
387 self.assertArraysEqual(
388 inserted[0],
389 self.make_tz_numpy_array(self.dt, self.col_tz_name)
390 )
391
392 @require_server_version(1, 1, 54337)
393 def test_column_use_client_timezone(self):
394 # Insert datetime with no timezone
395 # into column with timezone Asia/Novosibirsk
396 # using client's timezone Europe/Moscow
397
398 settings = {'use_client_time_zone': True}
399
400 with self.patch_env_tz('Europe/Moscow'):
401 with self.create_table(self.table_columns(with_tz=True)):
402 self.client.execute(
403 'INSERT INTO test (a) VALUES', [self.dt_arr],
404 settings=settings, columnar=True
405 )
406 self.emit_cli(
407 "INSERT INTO test (a) VALUES ('2017-07-14 05:40:00')",
408 use_client_time_zone=1
409 )
410
411 query = 'SELECT toInt32(a) FROM test'
412 inserted = self.emit_cli(query, use_client_time_zone=1)
413 # 1499985600 = 1500000000 - 4 * 3600
414 self.assertEqual(inserted, '1499985600\n1499985600\n')
415
416 query = 'SELECT * FROM test'
417 inserted = self.emit_cli(query, use_client_time_zone=1)
418 self.assertEqual(
419 inserted,
420 '2017-07-14 05:40:00\n2017-07-14 05:40:00\n'
421 )
422
423 inserted = self.client.execute(query, columnar=True,
424 settings=settings)
425 self.assertArraysEqual(
426 inserted[0],
427 self.make_tz_numpy_array(self.dt, self.col_tz_name)
428 )
429
430 @require_server_version(1, 1, 54337)
431 def test_datetime_with_timezone_column_use_server_timezone(self):
432 # Insert datetime with timezone Asia/Kamchatka
433 # into column with timezone Asia/Novosibirsk
434 # using server's timezone (Europe/Moscow)
435
436 with self.patch_env_tz('Europe/Moscow'):
437 with self.create_table(self.table_columns(with_tz=True)):
438 self.client.execute(
439 'INSERT INTO test (a) VALUES', [self.dt_tz], columnar=True
440 )
441
442 self.emit_cli(
443 "INSERT INTO test (a) VALUES "
444 "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))",
445 )
446
447 query = 'SELECT toInt32(a) FROM test'
448 inserted = self.emit_cli(query)
449 # 1499967600 = 1500000000 - 12 * 3600
450 self.assertEqual(inserted, '1499967600\n1499967600\n')
451
452 query = 'SELECT * FROM test'
453 inserted = self.emit_cli(query)
454 # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00
455 # (Kamchatka - Novosibirsk)
456 self.assertEqual(
457 inserted,
458 '2017-07-14 00:40:00\n2017-07-14 00:40:00\n'
459 )
460
461 inserted = self.client.execute(query, columnar=True)
462 dt = datetime(2017, 7, 14, 0, 40)
463 self.assertArraysEqual(
464 inserted[0], self.make_tz_numpy_array(dt, self.col_tz_name)
465 )
466
467 @require_server_version(1, 1, 54337)
468 def test_datetime_with_timezone_column_use_client_timezone(self):
469 # Insert datetime with timezone Asia/Kamchatka
470 # into column with timezone Asia/Novosibirsk
471 # using client's timezone (Europe/Moscow)
472
473 settings = {'use_client_time_zone': True}
474
475 with self.patch_env_tz('Europe/Moscow'):
476 with self.create_table(self.table_columns(with_tz=True)):
477 self.client.execute(
478 'INSERT INTO test (a) VALUES', [self.dt_tz],
479 settings=settings, columnar=True
480 )
481
482 self.emit_cli(
483 "INSERT INTO test (a) VALUES "
484 "(toDateTime('2017-07-14 05:40:00', 'Asia/Kamchatka'))",
485 use_client_time_zone=1
486 )
487
488 query = 'SELECT toInt32(a) FROM test'
489 inserted = self.emit_cli(query, use_client_time_zone=1)
490 # 1499967600 = 1500000000 - 12 * 3600
491 self.assertEqual(inserted, '1499967600\n1499967600\n')
492
493 query = 'SELECT * FROM test'
494 inserted = self.emit_cli(query, use_client_time_zone=1)
495 # 2017-07-14 00:40:00 = 2017-07-14 05:40:00 - 05:00:00
496 # (Kamchatka - Novosibirsk)
497 self.assertEqual(
498 inserted,
499 '2017-07-14 00:40:00\n2017-07-14 00:40:00\n'
500 )
501
502 inserted = self.client.execute(query, columnar=True,
503 settings=settings)
504 dt = datetime(2017, 7, 14, 0, 40)
505 self.assertArraysEqual(
506 inserted[0], self.make_tz_numpy_array(dt, self.col_tz_name)
507 )
508
509
510 class DateTime64TimezonesTestCase(DateTimeTimezonesTestCase):
511 dt_type = 'DateTime64'
512 required_server_version = (20, 1, 2)
513
514 def table_columns(self, with_tz=False):
515 if not with_tz:
516 return 'a {}(0)'.format(self.dt_type)
517
518 return "a {}(0, '{}')".format(self.dt_type, self.col_tz_name)
0 try:
1 import numpy as np
2 except ImportError:
3 np = None
4
5 from tests.numpy.testcase import NumpyBaseTestCase
6
7
8 class FloatTestCase(NumpyBaseTestCase):
9 n = 10
10
11 def check_result(self, rv, col_type):
12 self.assertArraysEqual(rv[0], np.array(range(self.n)))
13 self.assertIsInstance(rv[0][0], (col_type, ))
14
15 def get_query(self, ch_type):
16 with self.create_table('a {}'.format(ch_type)):
17 data = [np.array(range(self.n))]
18 self.client.execute(
19 'INSERT INTO test (a) VALUES', data, columnar=True
20 )
21
22 query = 'SELECT * FROM test'
23 inserted = self.emit_cli(query)
24 self.assertEqual(
25 inserted, '\n'.join(str(x) for x in data[0]) + '\n'
26 )
27 return self.client.execute(query, columnar=True)
28
29 def test_float32(self):
30 rv = self.get_query('Float32')
31 self.check_result(rv, np.float32)
32
33 def test_float64(self):
34 rv = self.get_query('Float64')
35 self.check_result(rv, np.float64)
36
37 def test_fractional_round_trip(self):
38 with self.create_table('a Float32'):
39 data = [np.array([0.5, 1.5], dtype=np.float32)]
40 self.client.execute(
41 'INSERT INTO test (a) VALUES', data, columnar=True
42 )
43
44 query = 'SELECT * FROM test'
45 inserted = self.emit_cli(query)
46 self.assertEqual(inserted, '0.5\n1.5\n')
47
48 inserted = self.client.execute(query, columnar=True)
49 self.assertArraysEqual(inserted[0], data[0])
0 try:
1 import numpy as np
2 except ImportError:
3 np = None
4
5 from tests.numpy.testcase import NumpyBaseTestCase
6
7
8 class IntTestCase(NumpyBaseTestCase):
9 n = 10
10
11 def check_result(self, rv, col_type):
12 self.assertArraysEqual(rv[0], np.array(range(self.n)))
13 self.assertIsInstance(rv[0][0], (col_type, ))
14
15 def get_query(self, ch_type):
16 with self.create_table('a {}'.format(ch_type)):
17 data = [np.array(range(self.n))]
18 self.client.execute(
19 'INSERT INTO test (a) VALUES', data, columnar=True
20 )
21
22 query = 'SELECT * FROM test'
23 inserted = self.emit_cli(query)
24 self.assertEqual(
25 inserted, '\n'.join(str(x) for x in data[0]) + '\n'
26 )
27 return self.client.execute(query, columnar=True)
28
29 def test_int8(self):
30 rv = self.get_query('Int8')
31 self.check_result(rv, np.int8)
32
33 def test_int16(self):
34 rv = self.get_query('Int16')
35 self.check_result(rv, np.int16)
36
37 def test_int32(self):
38 rv = self.get_query('Int32')
39 self.check_result(rv, np.int32)
40
41 def test_int64(self):
42 rv = self.get_query('Int64')
43 self.check_result(rv, np.int64)
44
45 def test_uint8(self):
46 rv = self.get_query('UInt8')
47 self.check_result(rv, np.uint8)
48
49 def test_uint16(self):
50 rv = self.get_query('UInt16')
51 self.check_result(rv, np.uint16)
52
53 def test_uint32(self):
54 rv = self.get_query('UInt32')
55 self.check_result(rv, np.uint32)
56
57 def test_uint64(self):
58 rv = self.get_query('UInt64')
59 self.check_result(rv, np.uint64)
0 try:
1 import numpy as np
2 except ImportError:
3 np = None
4
5 from tests.numpy.testcase import NumpyBaseTestCase
6
7 # from decimal import Decimal
8
9
10 class LowCardinalityTestCase(NumpyBaseTestCase):
11 required_server_version = (19, 3, 3)
12 stable_support_version = (19, 9, 2)
13
14 def cli_client_kwargs(self):
15 if self.server_version >= self.stable_support_version:
16 return {'allow_suspicious_low_cardinality_types': 1}
17
18 def test_uint8(self):
19 with self.create_table('a LowCardinality(UInt8)'):
20 data = [np.array(range(255))]
21 self.client.execute(
22 'INSERT INTO test (a) VALUES', data, columnar=True
23 )
24
25 query = 'SELECT * FROM test'
26 inserted = self.emit_cli(query)
27 self.assertEqual(
28 inserted,
29 '\n'.join(str(x) for x in data[0]) + '\n'
30 )
31
32 inserted = self.client.execute(query, columnar=True)
33 self.assertArraysEqual(inserted[0], data[0])
34
35 def test_int8(self):
36 with self.create_table('a LowCardinality(Int8)'):
37 data = [np.array([x - 127 for x in range(255)])]
38 self.client.execute(
39 'INSERT INTO test (a) VALUES', data, columnar=True
40 )
41
42 query = 'SELECT * FROM test'
43 inserted = self.emit_cli(query)
44 self.assertEqual(
45 inserted,
46 '\n'.join(str(x) for x in data[0]) + '\n'
47
48 )
49
50 inserted = self.client.execute(query, columnar=True)
51 self.assertArraysEqual(inserted[0], data[0])
52
53 # def test_nullable_int8(self):
54 # with self.create_table('a LowCardinality(Nullable(Int8))'):
55 # data = [(None, ), (-1, ), (0, ), (1, ), (None, )]
56 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
57 #
58 # query = 'SELECT * FROM test'
59 # inserted = self.emit_cli(query)
60 # self.assertEqual(inserted, '\\N\n-1\n0\n1\n\\N\n')
61 #
62 # inserted = self.client.execute(query)
63 # self.assertEqual(inserted, data[0])
64
65 def test_date(self):
66 with self.create_table('a LowCardinality(Date)'):
67 data = [np.array(list(range(300)), dtype='datetime64[D]')]
68 self.client.execute(
69 'INSERT INTO test (a) VALUES', data, columnar=True
70 )
71
72 query = 'SELECT * FROM test'
73 inserted = self.client.execute(query, columnar=True)
74 self.assertArraysEqual(inserted[0], data[0])
75
76 def test_float(self):
77 with self.create_table('a LowCardinality(Float)'):
78 data = [np.array([float(x) for x in range(300)])]
79 self.client.execute(
80 'INSERT INTO test (a) VALUES', data, columnar=True
81 )
82
83 query = 'SELECT * FROM test'
84 inserted = self.client.execute(query, columnar=True)
85 self.assertArraysEqual(inserted[0], data[0])
86
87 # def test_decimal(self):
88 # with self.create_table('a LowCardinality(Float)'):
89 # data = [(Decimal(x),) for x in range(300)]
90 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
91 #
92 # query = 'SELECT * FROM test'
93 # inserted = self.client.execute(query)
94 # self.assertEqual(inserted, data[0])
95 #
96 # def test_array(self):
97 # with self.create_table('a Array(LowCardinality(Int16))'):
98 # data = [([100, 500], )]
99 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
100 #
101 # query = 'SELECT * FROM test'
102 # inserted = self.emit_cli(query)
103 # self.assertEqual(inserted, '[100,500]\n')
104 #
105 # inserted = self.client.execute(query)
106 # self.assertEqual(inserted, data[0])
107 #
108 # def test_empty_array(self):
109 # with self.create_table('a Array(LowCardinality(Int16))'):
110 # data = [([], )]
111 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
112 #
113 # query = 'SELECT * FROM test'
114 # inserted = self.emit_cli(query)
115 # self.assertEqual(inserted, '[]\n')
116 #
117 # inserted = self.client.execute(query)
118 # self.assertEqual(inserted, data[0])
119 #
120 def test_string(self):
121 with self.create_table('a LowCardinality(String)'):
122 data = [
123 np.array(['test', 'low', 'cardinality', 'test', 'test', ''])
124 ]
125 self.client.execute(
126 'INSERT INTO test (a) VALUES', data, columnar=True
127 )
128
129 query = 'SELECT * FROM test'
130 inserted = self.emit_cli(query)
131 self.assertEqual(
132 inserted,
133 'test\nlow\ncardinality\ntest\ntest\n\n'
134 )
135
136 inserted = self.client.execute(query, columnar=True)
137 self.assertArraysEqual(inserted[0], data[0])
138
139 # def test_fixed_string(self):
140 # with self.create_table('a LowCardinality(FixedString(12))'):
141 # data = [
142 # ('test', ), ('low', ), ('cardinality', ),
143 # ('test', ), ('test', ), ('', )
144 # ]
145 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
146 #
147 # query = 'SELECT * FROM test'
148 # inserted = self.emit_cli(query)
149 # self.assertEqual(
150 # inserted,
151 # 'test\\0\\0\\0\\0\\0\\0\\0\\0\n'
152 # 'low\\0\\0\\0\\0\\0\\0\\0\\0\\0\n'
153 # 'cardinality\\0\n'
154 # 'test\\0\\0\\0\\0\\0\\0\\0\\0\n'
155 # 'test\\0\\0\\0\\0\\0\\0\\0\\0\n'
156 # '\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\n'
157 # )
158 #
159 # inserted = self.client.execute(query)
160 # self.assertEqual(inserted, data[0])
161 #
162 # def test_nullable_string(self):
163 # with self.create_table('a LowCardinality(Nullable(String))'):
164 # data = [
165 # ('test', ), ('', ), (None, )
166 # ]
167 # self.client.execute('INSERT INTO test (a) VALUES', data[0])
168 #
169 # query = 'SELECT * FROM test'
170 # inserted = self.emit_cli(query)
171 # self.assertEqual(
172 # inserted,
173 # 'test\n\n\\N\n'
174 # )
175 #
176 # inserted = self.client.execute(query)
177 # self.assertEqual(inserted, data[0])
0 from clickhouse_driver import errors
1
2 try:
3 from clickhouse_driver.columns.numpy.service import \
4 get_numpy_column_by_spec
5 except ImportError:
6 get_numpy_column_by_spec = None
7
8 from clickhouse_driver.context import Context
9
10 from tests.numpy.testcase import NumpyBaseTestCase
11
12
13 class OtherColumnsTestCase(NumpyBaseTestCase):
14 def get_column(self, spec):
15 ctx = Context()
16 ctx.client_settings = {'strings_as_bytes': False}
17 return get_numpy_column_by_spec(spec, {'context': ctx})
18
19 def test_enum(self):
20 col = self.get_column("Enum8('hello' = 1, 'world' = 2)")
21 self.assertIsNotNone(col)
22
23 def test_decimal(self):
24 col = self.get_column('Decimal(8, 4)')
25 self.assertIsNotNone(col)
26
27 def test_array(self):
28 col = self.get_column('Array(String)')
29 self.assertIsNotNone(col)
30
31 def test_tuple(self):
32 col = self.get_column('Tuple(String)')
33 self.assertIsNotNone(col)
34
35 def test_simple_aggregation_function(self):
36 col = self.get_column('SimpleAggregateFunction(any, Int32)')
37 self.assertIsNotNone(col)
38
39 def test_get_unknown_column(self):
40 with self.assertRaises(errors.UnknownTypeError) as e:
41 self.get_column('Unicorn')
42
43 self.assertIn('Unicorn', str(e.exception))
0 try:
1 import numpy as np
2 except ImportError:
3 np = None
4
5 from tests.numpy.testcase import NumpyBaseTestCase
6
7
8 class StringTestCase(NumpyBaseTestCase):
9 def test_string(self):
10 with self.create_table('a String'):
11 data = [np.array(['a', 'b', 'c'])]
12 self.client.execute(
13 'INSERT INTO test (a) VALUES', data, columnar=True
14 )
15
16 query = 'SELECT * FROM test'
17 inserted = self.emit_cli(query)
18 self.assertEqual(inserted, 'a\nb\nc\n')
19 rv = self.client.execute(query, columnar=True)
20
21 self.assertArraysEqual(rv[0], data)
22 self.assertIsInstance(rv[0][0], (object, ))
23
24
25 class ByteStringTestCase(NumpyBaseTestCase):
26 client_kwargs = {'settings': {'strings_as_bytes': True, 'use_numpy': True}}
27
28 def test_string(self):
29 with self.create_table('a String'):
30 data = [np.array([b'a', b'b', b'c'])]
31 self.client.execute(
32 'INSERT INTO test (a) VALUES', data, columnar=True
33 )
34
35 query = 'SELECT * FROM test'
36 inserted = self.emit_cli(query)
37 self.assertEqual(inserted, 'a\nb\nc\n')
38 rv = self.client.execute(query, columnar=True)
39
40 self.assertArraysEqual(rv[0], data)
41 self.assertIsInstance(rv[0][0], (object, ))
42
43
44 class FixedStringTestCase(NumpyBaseTestCase):
45 def test_string(self):
46 with self.create_table('a FixedString(3)'):
47 data = [np.array(['a', 'b', 'c'])]
48 self.client.execute(
49 'INSERT INTO test (a) VALUES', data, columnar=True
50 )
51
52 query = 'SELECT * FROM test'
53 inserted = self.emit_cli(query)
54 self.assertEqual(inserted, 'a\\0\\0\nb\\0\\0\nc\\0\\0\n')
55 rv = self.client.execute(query, columnar=True)
56
57 self.assertArraysEqual(rv[0], data)
58 self.assertIsInstance(rv[0][0], (object, ))
59
60
61 class ByteFixedStringTestCase(NumpyBaseTestCase):
62 client_kwargs = {'settings': {'strings_as_bytes': True, 'use_numpy': True}}
63
64 def test_string(self):
65 with self.create_table('a FixedString(3)'):
66 data = [np.array([b'a', b'b', b'c'])]
67 self.client.execute(
68 'INSERT INTO test (a) VALUES', data, columnar=True
69 )
70
71 query = 'SELECT * FROM test'
72 inserted = self.emit_cli(query)
73 self.assertEqual(inserted, 'a\\0\\0\nb\\0\\0\nc\\0\\0\n')
74 rv = self.client.execute(query, columnar=True)
75
76 self.assertArraysEqual(rv[0], data)
77 self.assertIsInstance(rv[0][0], (object, ))
0 import types
1
2 try:
3 import numpy as np
4 import pandas as pd
5 except ImportError:
6 np = None
7 pd = None
8
9 from tests.testcase import BaseTestCase
10 from tests.numpy.testcase import NumpyBaseTestCase
11
12
13 class GenericTestCase(NumpyBaseTestCase):
14 n = 10
15
16 def test_columnar(self):
17 rv = self.client.execute(
18 'SELECT number FROM numbers({})'.format(self.n), columnar=True
19 )
20
21 self.assertEqual(len(rv), 1)
22 self.assertIsInstance(rv[0], (np.ndarray, ))
23
24 def test_rowwise(self):
25 rv = self.client.execute(
26 'SELECT number FROM numbers({})'.format(self.n)
27 )
28
29 self.assertEqual(len(rv), self.n)
30 self.assertIsInstance(rv[0], (np.ndarray, ))
31
32 def test_insert_not_supported(self):
33 data = [np.array(range(self.n))]
34
35 with self.create_table('a Int32'):
36 with self.assertRaises(ValueError) as e:
37 self.client.execute(
38 'INSERT INTO test (a) VALUES', data
39 )
40
41 self.assertEqual(
42 'NumPy inserts is only allowed with columnar=True',
43 str(e.exception)
44 )
45
46 def test_with_column_types(self):
47 rv = self.client.execute(
48 'SELECT CAST(2 AS Int32) AS x', with_column_types=True
49 )
50
51 self.assertEqual(rv, ([(2, )], [('x', 'Int32')]))
52
53
54 class NumpyProgressTestCase(NumpyBaseTestCase):
55 def test_select_with_progress(self):
56 progress = self.client.execute_with_progress('SELECT 2')
57 self.assertEqual(
58 list(progress),
59 [(1, 0), (1, 0)] if self.server_version > (20,) else [(1, 0)]
60 )
61 self.assertEqual(progress.get_result(), [(2,)])
62 self.assertTrue(self.client.connection.connected)
63
64 def test_select_with_progress_no_progress_obtaining(self):
65 progress = self.client.execute_with_progress('SELECT 2')
66 self.assertEqual(progress.get_result(), [(2,)])
67
68
69 class NumpyIteratorTestCase(NumpyBaseTestCase):
70 def test_select_with_iter(self):
71 result = self.client.execute_iter(
72 'SELECT number FROM system.numbers LIMIT 10'
73 )
74 self.assertIsInstance(result, types.GeneratorType)
75
76 self.assertEqual(list(result), list(zip(range(10))))
77 self.assertEqual(list(result), [])
78
79 def test_select_with_iter_with_column_types(self):
80 result = self.client.execute_iter(
81 'SELECT CAST(number AS UInt32) as number '
82 'FROM system.numbers LIMIT 10',
83 with_column_types=True
84 )
85 self.assertIsInstance(result, types.GeneratorType)
86
87 self.assertEqual(
88 list(result),
89 [[('number', 'UInt32')]] + list(zip(range(10)))
90 )
91 self.assertEqual(list(result), [])
92
93
94 class DataFrameTestCase(NumpyBaseTestCase):
95 def test_query_simple(self):
96 df = self.client.query_dataframe(
97 'SELECT CAST(number AS Int64) AS x FROM system.numbers LIMIT 100'
98 )
99
100 self.assertTrue(df.equals(pd.DataFrame({'x': range(100)})))
101
102 def test_query_replace_whitespace_in_column_names(self):
103 df = self.client.query_dataframe(
104 'SELECT number AS "test me" FROM system.numbers LIMIT 100'
105 )
106
107 self.assertIn('test_me', df)
108
109 def test_insert_simple(self):
110 n = 10
111 df = pd.DataFrame({
112 'a': range(n),
113 'b': [float(x) for x in range(n)]
114 })
115
116 with self.create_table('a Int64, b Float64'):
117 rv = self.client.insert_dataframe('INSERT INTO test VALUES', df)
118 self.assertEqual(rv, n)
119 df2 = self.client.query_dataframe('SELECT * FROM test ORDER BY a')
120 self.assertTrue(df.equals(df2))
121
122 def test_insert_transposed(self):
123 n = 10
124 df = pd.DataFrame({
125 'a': range(n),
126 'b': [float(x) for x in range(n)]
127 })
128
129 with self.create_table('a Int64, b Float64'):
130 rv = self.client.insert_dataframe(
131 'INSERT INTO test VALUES', df.transpose(), transpose=False
132 )
133 self.assertEqual(rv, n)
134 df2 = self.client.query_dataframe('SELECT * FROM test ORDER BY a')
135 self.assertTrue(df.equals(df2))
136
137
138 class NoNumPyTestCase(BaseTestCase):
139 def setUp(self):
140 super(NoNumPyTestCase, self).setUp()
141
142 try:
143 import numpy # noqa: F401
144 import pandas # noqa: F401
145 except Exception:
146 pass
147
148 else:
149 self.skipTest('NumPy extras are installed')
150
151 def test_runtime_error_without_numpy(self):
152 with self.assertRaises(RuntimeError) as e:
153 with self.created_client(settings={'use_numpy': True}) as client:
154 client.execute('SELECT 1')
155
156 self.assertEqual(
157 'Extras for NumPy must be installed', str(e.exception)
158 )
159
160 def test_query_dataframe(self):
161 with self.assertRaises(RuntimeError) as e:
162 with self.created_client(settings={'use_numpy': True}) as client:
163 client.query_dataframe('SELECT 1 AS x')
164
165 self.assertEqual(
166 'Extras for NumPy must be installed', str(e.exception)
167 )
0 from tests.numpy.util import check_numpy
1 from tests.testcase import BaseTestCase
2
3
4 class NumpyBaseTestCase(BaseTestCase):
5 client_kwargs = {'settings': {'use_numpy': True}}
6
7 @check_numpy
8 def setUp(self):
9 super(NumpyBaseTestCase, self).setUp()
10
11 def assertArraysEqual(self, first, second):
12 return self.assertTrue((first == second).all())
0 from functools import wraps
1 from unittest import SkipTest
2
3
4 def check_numpy(f):
5 @wraps(f)
6 def wrapper(*args, **kwargs):
7 try:
8 return f(*args, **kwargs)
9 except RuntimeError as e:
10 if 'NumPy' in str(e):
11 raise SkipTest('Numpy package is not installed')
12
13 return wrapper
8484 class ProgressTestCase(BaseTestCase):
8585 def test_select_with_progress(self):
8686 progress = self.client.execute_with_progress('SELECT 2')
87 self.assertEqual(list(progress), [(1, 0)])
87 self.assertEqual(
88 list(progress),
89 [(1, 0), (1, 0)] if self.server_version > (20,) else [(1, 0)]
90 )
8891 self.assertEqual(progress.get_result(), [(2,)])
8992 self.assertTrue(self.client.connection.connected)
9093
192195 query = 'SELECT 1'
193196 self.client.execute(query, settings=settings)
194197 self.assertIn(query, buffer.getvalue())
198
199 def test_logs_insert(self):
200 with capture_logging('clickhouse_driver.log', 'INFO') as buffer:
201 with self.create_table('a Int32'):
202 settings = {'send_logs_level': 'debug'}
203
204 query = 'INSERT INTO test (a) VALUES'
205 self.client.execute(query, [(1, )], settings=settings)
206 logs = buffer.getvalue()
207 self.assertIn(query, logs)
208
209 if self.server_version > (19, ):
210 self.assertIn('MemoryTracker', logs)
211
212 # Test all packets of INSERT query are consumed.
213 rv = self.client.execute('SELECT 1', settings=settings)
214 self.assertEqual(rv, [(1, )])
0 import socket
1 from unittest import TestCase
2
3 import mock
4 from clickhouse_driver.bufferedreader import BufferedSocketReader
5
6
7 class BufferedReaderTestCase(TestCase):
8 def test_overflow_signed_int_string_size(self):
9 data = b'\xFF\xFE\xFC\xFE\x29\x80\x40\x00\x00\x01'
10
11 def recv_into(buf):
12 size = len(data)
13 buf[0:size] = data
14 return size
15
16 with mock.patch('socket.socket') as mock_socket:
17 mock_socket.return_value.recv_into.side_effect = recv_into
18 reader = BufferedSocketReader(socket.socket(), 1024)
19
20 # Trying to allocate huge amount of memory.
21 with self.assertRaises(MemoryError):
22 reader.read_strings(5, encoding='utf-8')
55 from clickhouse_driver.compression.lz4hc import Compressor as LZHC4Compressor
66 from clickhouse_driver.compression.zstd import Compressor as ZSTDCompressor
77 from clickhouse_driver.protocol import Compression
8 from tests.numpy.util import check_numpy
89
910
1011 class ClientFromUrlTestCase(TestCase):
12 def assertHostsEqual(self, client, another, msg=None):
13 self.assertEqual(list(client.connection.hosts), another, msg=msg)
1114
1215 def test_simple(self):
1316 c = Client.from_url('clickhouse://host')
1417
15 assert c.connection.hosts == [('host', 9000)]
16 assert c.connection.database == 'default'
18 self.assertHostsEqual(c, [('host', 9000)])
19 self.assertEqual(c.connection.database, 'default')
1720
1821 c = Client.from_url('clickhouse://host/db')
1922
20 assert c.connection.hosts == [('host', 9000)]
21 assert c.connection.database == 'db'
23 self.assertHostsEqual(c, [('host', 9000)])
24 self.assertEqual(c.connection.database, 'db')
2225
2326 def test_credentials(self):
2427 c = Client.from_url('clickhouse://host/db')
2528
26 assert c.connection.user == 'default'
27 assert c.connection.password == ''
29 self.assertEqual(c.connection.user, 'default')
30 self.assertEqual(c.connection.password, '')
2831
2932 c = Client.from_url('clickhouse://admin:secure@host/db')
3033
31 assert c.connection.user == 'admin'
32 assert c.connection.password == 'secure'
34 self.assertEqual(c.connection.user, 'admin')
35 self.assertEqual(c.connection.password, 'secure')
3336
3437 c = Client.from_url('clickhouse://user:@host/db')
3538
36 assert c.connection.user == 'user'
37 assert c.connection.password == ''
39 self.assertEqual(c.connection.user, 'user')
40 self.assertEqual(c.connection.password, '')
41
42 def test_credentials_unquoting(self):
43 c = Client.from_url('clickhouse://ad%3Amin:se%2Fcure@host/db')
44
45 self.assertEqual(c.connection.user, 'ad:min')
46 self.assertEqual(c.connection.password, 'se/cure')
3847
3948 def test_schema(self):
4049 c = Client.from_url('clickhouse://host')
41 assert c.connection.secure_socket is False
50 self.assertFalse(c.connection.secure_socket)
4251
4352 c = Client.from_url('clickhouses://host')
44 assert c.connection.secure_socket is True
53 self.assertTrue(c.connection.secure_socket)
4554
4655 c = Client.from_url('test://host')
47 assert c.connection.secure_socket is False
56 self.assertFalse(c.connection.secure_socket)
4857
4958 def test_port(self):
5059 c = Client.from_url('clickhouse://host')
51 assert c.connection.hosts == [('host', 9000)]
60 self.assertHostsEqual(c, [('host', 9000)])
5261
5362 c = Client.from_url('clickhouses://host')
54 assert c.connection.hosts == [('host', 9440)]
63 self.assertHostsEqual(c, [('host', 9440)])
5564
5665 c = Client.from_url('clickhouses://host:1234')
57 assert c.connection.hosts == [('host', 1234)]
66 self.assertHostsEqual(c, [('host', 1234)])
5867
5968 def test_secure(self):
6069 c = Client.from_url('clickhouse://host?secure=n')
61 assert c.connection.hosts == [('host', 9000)]
62 assert c.connection.secure_socket is False
70 self.assertHostsEqual(c, [('host', 9000)])
71 self.assertFalse(c.connection.secure_socket)
6372
6473 c = Client.from_url('clickhouse://host?secure=y')
65 assert c.connection.hosts == [('host', 9440)]
66 assert c.connection.secure_socket is True
74 self.assertHostsEqual(c, [('host', 9440)])
75 self.assertTrue(c.connection.secure_socket)
6776
6877 c = Client.from_url('clickhouse://host:1234?secure=y')
69 assert c.connection.hosts == [('host', 1234)]
70 assert c.connection.secure_socket is True
78 self.assertHostsEqual(c, [('host', 1234)])
79 self.assertTrue(c.connection.secure_socket)
7180
7281 with self.assertRaises(ValueError):
7382 Client.from_url('clickhouse://host:1234?secure=nonono')
7483
7584 def test_compression(self):
7685 c = Client.from_url('clickhouse://host?compression=n')
77 assert c.connection.compression == Compression.DISABLED
78 assert c.connection.compressor_cls is None
86 self.assertEqual(c.connection.compression, Compression.DISABLED)
87 self.assertIsNone(c.connection.compressor_cls)
7988
8089 c = Client.from_url('clickhouse://host?compression=y')
81 assert c.connection.compression == Compression.ENABLED
82 assert c.connection.compressor_cls is LZ4Compressor
90 self.assertEqual(c.connection.compression, Compression.ENABLED)
91 self.assertIs(c.connection.compressor_cls, LZ4Compressor)
8392
8493 c = Client.from_url('clickhouse://host?compression=lz4')
85 assert c.connection.compression == Compression.ENABLED
86 assert c.connection.compressor_cls is LZ4Compressor
94 self.assertEqual(c.connection.compression, Compression.ENABLED)
95 self.assertIs(c.connection.compressor_cls, LZ4Compressor)
8796
8897 c = Client.from_url('clickhouse://host?compression=lz4hc')
89 assert c.connection.compression == Compression.ENABLED
90 assert c.connection.compressor_cls is LZHC4Compressor
98 self.assertEqual(c.connection.compression, Compression.ENABLED)
99 self.assertIs(c.connection.compressor_cls, LZHC4Compressor)
91100
92101 c = Client.from_url('clickhouse://host?compression=zstd')
93 assert c.connection.compression == Compression.ENABLED
94 assert c.connection.compressor_cls is ZSTDCompressor
102 self.assertEqual(c.connection.compression, Compression.ENABLED)
103 self.assertIs(c.connection.compressor_cls, ZSTDCompressor)
95104
96105 with self.assertRaises(ValueError):
97106 Client.from_url('clickhouse://host:1234?compression=custom')
98107
99108 def test_client_name(self):
100109 c = Client.from_url('clickhouse://host?client_name=native')
101 assert c.connection.client_name == 'ClickHouse native'
110 self.assertEqual(c.connection.client_name, 'ClickHouse native')
102111
103112 def test_timeouts(self):
104113 with self.assertRaises(ValueError):
105114 Client.from_url('clickhouse://host?connect_timeout=test')
106115
107116 c = Client.from_url('clickhouse://host?connect_timeout=1.2')
108 assert c.connection.connect_timeout == 1.2
117 self.assertEqual(c.connection.connect_timeout, 1.2)
109118
110119 c = Client.from_url('clickhouse://host?send_receive_timeout=1.2')
111 assert c.connection.send_receive_timeout == 1.2
120 self.assertEqual(c.connection.send_receive_timeout, 1.2)
112121
113122 c = Client.from_url('clickhouse://host?sync_request_timeout=1.2')
114 assert c.connection.sync_request_timeout == 1.2
123 self.assertEqual(c.connection.sync_request_timeout, 1.2)
115124
116125 def test_compress_block_size(self):
117126 with self.assertRaises(ValueError):
119128
120129 c = Client.from_url('clickhouse://host?compress_block_size=100500')
121130 # compression is not set
122 assert c.connection.compress_block_size is None
131 self.assertIsNone(c.connection.compress_block_size)
123132
124133 c = Client.from_url(
125134 'clickhouse://host?'
126135 'compress_block_size=100500&'
127136 'compression=1'
128137 )
129 assert c.connection.compress_block_size == 100500
138 self.assertEqual(c.connection.compress_block_size, 100500)
130139
131140 def test_settings(self):
132141 c = Client.from_url(
134143 'send_logs_level=trace&'
135144 'max_block_size=123'
136145 )
137 assert c.settings == {
146 self.assertEqual(c.settings, {
138147 'send_logs_level': 'trace',
139148 'max_block_size': '123'
140 }
149 })
141150
142151 def test_ssl(self):
143152 c = Client.from_url(
147156 'ca_certs=/tmp/certs&'
148157 'ciphers=HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5'
149158 )
150 assert c.connection.ssl_options == {
159 self.assertEqual(c.connection.ssl_options, {
151160 'ssl_version': ssl.PROTOCOL_SSLv23,
152161 'ca_certs': '/tmp/certs',
153162 'ciphers': 'HIGH:-aNULL:-eNULL:-PSK:RC4-SHA:RC4-MD5'
154 }
163 })
155164
156165 def test_alt_hosts(self):
157166 c = Client.from_url('clickhouse://host?alt_hosts=host2:1234')
158 assert c.connection.hosts == [('host', 9000), ('host2', 1234)]
167 self.assertHostsEqual(c, [('host', 9000), ('host2', 1234)])
159168
160169 c = Client.from_url('clickhouse://host?alt_hosts=host2')
161 assert c.connection.hosts == [('host', 9000), ('host2', 9000)]
170 self.assertHostsEqual(c, [('host', 9000), ('host2', 9000)])
162171
163172 def test_parameters_cast(self):
164173 c = Client.from_url('clickhouse://host?insert_block_size=123')
165 assert c.connection.context.client_settings['insert_block_size'] == 123
174 self.assertEqual(
175 c.connection.context.client_settings['insert_block_size'], 123
176 )
177
178 def test_settings_is_important(self):
179 c = Client.from_url('clickhouse://host?settings_is_important=1')
180 self.assertEqual(c.connection.settings_is_important, True)
181
182 with self.assertRaises(ValueError):
183 c = Client.from_url('clickhouse://host?settings_is_important=2')
184 self.assertEqual(c.connection.settings_is_important, True)
185
186 c = Client.from_url('clickhouse://host?settings_is_important=0')
187 self.assertEqual(c.connection.settings_is_important, False)
188
189 @check_numpy
190 def test_use_numpy(self):
191 c = Client.from_url('clickhouse://host?use_numpy=true')
192 self.assertTrue(c.connection.context.client_settings['use_numpy'])
4646 client.execute('SHOW TABLES')
4747
4848 def test_timeout_error(self):
49 with patch('socket.socket') as mocked_socket:
50 mocked_socket.return_value.connect.side_effect = socket.timeout
51
52 with self.assertRaises(errors.SocketTimeoutError):
49 with patch('socket.socket') as ms:
50 ms.return_value.connect.side_effect = socket.timeout
51
52 with self.assertRaises(errors.SocketTimeoutError) as e:
5353 self.client.execute('SHOW TABLES')
54 self.assertEqual(
55 str(e.exception),
56 'Code: 209. ({}:{})'.format(self.host, self.port)
57 )
58
59 ms.return_value.connect.side_effect = socket.timeout(42, 'Test')
60
61 with self.assertRaises(errors.SocketTimeoutError) as e:
62 self.client.execute('SHOW TABLES')
63 self.assertEqual(
64 str(e.exception),
65 'Code: 209. Test ({}:{})'.format(self.host, self.port)
66 )
5467
5568 def test_transport_not_connection_on_disconnect(self):
5669 # Create connection.
128141 alt_hosts='{}:{}'.format(self.host, self.port)
129142 )
130143
144 self.n_calls = 0
131145 getaddrinfo = socket.getaddrinfo
132146
133147 def side_getaddrinfo(host, *args, **kwargs):
134148 if host == 'wrong_host':
149 self.n_calls += 1
135150 raise socket.error(-2, 'Name or service not known')
136151 return getaddrinfo(host, *args, **kwargs)
137152
140155
141156 rv = client.execute('SELECT 1')
142157 self.assertEqual(rv, [(1,)])
158
159 client.disconnect()
160
161 rv = client.execute('SELECT 1')
162 self.assertEqual(rv, [(1,)])
163 # Last host must be remembered and getaddrinfo must call exactly
164 # once with host == 'wrong_host'.
165 self.assertEqual(self.n_calls, 1)
143166
144167 client.disconnect()
145168
217240
218241 for split in range(1, len(buf) - 1):
219242 for split_2 in range(split + 1, len(buf) - 2):
220 assert buf[:split] + buf[split:split_2] + buf[split_2:] == buf
243 self.assertEqual(
244 buf[:split] + buf[split:split_2] + buf[split_2:], buf
245 )
221246 bufs = [
222247 buf[:split],
223248 buf[split:split_2],
00 import types
11 from contextlib import contextmanager
2 import socket
3
4 from mock import patch
25
36 from clickhouse_driver import connect
47 from clickhouse_driver.dbapi import (
120123 with self.created_cursor(user='wrong_user') as cursor:
121124 with self.assertRaises(OperationalError) as e:
122125 cursor.execute('SELECT 1')
123 self.assertIn('Code: 192', str(e.exception))
126 code = 516 if self.server_version > (20, ) else 192
127 self.assertIn('Code: {}'.format(code), str(e.exception))
124128
125129 def test_exception_executemany(self):
126130 with self.created_cursor(user='wrong_user') as cursor:
127131 with self.assertRaises(OperationalError) as e:
128132 cursor.executemany('INSERT INTO test VALUES', [(0, )])
129 self.assertIn('Code: 192', str(e.exception))
133 code = 516 if self.server_version > (20, ) else 192
134 self.assertIn('Code: {}'.format(code), str(e.exception))
130135 self.assertEqual(cursor.rowcount, -1)
131136
132137 def test_rowcount_insert_from_select(self):
157162 self.assertEqual(cursor.fetchall(), [])
158163 self.assertEqual(cursor.rowcount, -1)
159164
165 def test_remember_last_host(self):
166 self.n_calls = 0
167 getaddrinfo = socket.getaddrinfo
168
169 def side_getaddrinfo(host, *args, **kwargs):
170 if host == 'wrong_host':
171 self.n_calls += 1
172 raise socket.error(-2, 'Name or service not known')
173 return getaddrinfo(host, *args, **kwargs)
174
175 with patch('socket.getaddrinfo') as mocked_getaddrinfo:
176 mocked_getaddrinfo.side_effect = side_getaddrinfo
177
178 conn_kwargs = {
179 'host': 'wrong_host',
180 'port': 1234,
181 'alt_hosts': '{}:{}'.format(self.host, self.port)
182 }
183 with self.created_connection(**conn_kwargs) as connection:
184 cursor = connection.cursor()
185 cursor.execute('SELECT 1')
186 self.assertEqual(cursor.fetchall(), [(1, )])
187 cursor.close()
188
189 cursor = connection.cursor()
190 cursor.execute('SELECT 1')
191 self.assertEqual(cursor.fetchall(), [(1, )])
192 cursor.close()
193
194 # Last host must be remembered and getaddrinfo must call exactly
195 # once with host == 'wrong_host'.
196 self.assertEqual(self.n_calls, 1)
197
160198
161199 class StreamingTestCase(DBAPITestCaseBase):
162200 def test_fetchone(self):
211249
212250
213251 class ExtrasTestCase(DBAPITestCaseBase):
252 def test_columns_with_types_select(self):
253 with self.created_cursor() as cursor:
254 self.assertIsNone(cursor.columns_with_types)
255 cursor.execute(
256 'SELECT CAST(number AS UInt64) AS x '
257 'FROM system.numbers LIMIT 4'
258 )
259 cursor.fetchall()
260 self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')])
261
262 def test_columns_with_types_insert(self):
263 with self.created_cursor() as cursor, self.create_table('a UInt8'):
264 cursor.executemany('INSERT INTO test (a) VALUES', [(123, )])
265 self.assertIsNone(cursor.columns_with_types)
266
267 def test_columns_with_types_streaming(self):
268 with self.created_cursor() as cursor:
269 cursor.set_stream_results(True, 2)
270 cursor.execute(
271 'SELECT CAST(number AS UInt64) AS x '
272 'FROM system.numbers LIMIT 4'
273 )
274 self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')])
275 list(cursor)
276 self.assertEqual(cursor.columns_with_types, [('x', 'UInt64')])
277
214278 def test_set_external_tables(self):
215279 with self.created_cursor() as cursor:
216280 data = [(0, ), (1, ), (2, )]
228292 )
229293 self.assertEqual(cursor.fetchall(), [('max_threads', '100500', 1)])
230294
295 def test_set_query_id(self):
296 with self.created_cursor() as cursor:
297 query_id = 'my_query_id'
298 cursor.set_query_id(query_id)
299 cursor.execute(
300 'SELECT query_id '
301 'FROM system.processes '
302 'WHERE query_id = %(query_id)s',
303 {'query_id': query_id}
304 )
305 self.assertEqual(cursor.fetchall(), [(query_id, )])
306
231307 def test_types_check(self):
232308 with self.created_cursor() as cursor, self.create_table('a UInt8'):
233309 cursor.set_types_check(True)
0 import pickle
1
2 import clickhouse_driver.errors as err
3
4
5 def picklable(o):
6 picked = pickle.loads(pickle.dumps(o))
7 assert repr(o) == repr(picked)
8 assert str(o) == str(picked)
9
10
11 def test_exception_picklable():
12 picklable(err.Error('foo'))
13 picklable(err.Error(message='foo'))
14
15 picklable(err.ServerException('foo', 0, Exception()))
16 picklable(err.ServerException(message='foo', code=0, nested=Exception()))
1212 ]
1313 }]
1414 rv = self.client.execute('SELECT * FROM test', external_tables=tables)
15 self.assertEqual(rv, [(100, (2, 4, 6, 8)), (500, (1, 3, 5, 7))])
15 self.assertEqual(rv, [(100, [2, 4, 6, 8]), (500, [1, 3, 5, 7])])
1818 yield
1919
2020 def test_default_value(self):
21 assert self.client.last_query is None
21 self.assertIsNone(self.client.last_query)
2222
2323 def test_store_last_query_after_execute(self):
2424 with self.sample_table():
2525 self.client.execute(self.sample_query)
2626
2727 last_query = self.client.last_query
28 assert last_query is not None
29 assert last_query.profile_info is not None
30 assert last_query.profile_info.rows_before_limit == 42
28 self.assertIsNotNone(last_query)
29 self.assertIsNotNone(last_query.profile_info)
30 self.assertEqual(last_query.profile_info.rows_before_limit, 42)
3131
32 assert last_query.progress is not None
33 assert last_query.progress.rows == 42
34 assert last_query.progress.bytes == 42
35 assert last_query.progress.total_rows == 0
32 self.assertIsNotNone(last_query.progress)
33 self.assertEqual(last_query.progress.rows, 42)
34 self.assertEqual(last_query.progress.bytes, 42)
35 self.assertEqual(last_query.progress.total_rows, 0)
3636
37 assert last_query.elapsed > 0
37 self.assertGreater(last_query.elapsed, 0)
3838
3939 def test_last_query_after_execute_iter(self):
4040 with self.sample_table():
4141 list(self.client.execute_iter(self.sample_query))
4242
4343 last_query = self.client.last_query
44 assert last_query is not None
45 assert last_query.profile_info is not None
46 assert last_query.profile_info.rows_before_limit == 42
44 self.assertIsNotNone(last_query)
45 self.assertIsNotNone(last_query.profile_info)
46 self.assertEqual(last_query.profile_info.rows_before_limit, 42)
4747
48 assert last_query.progress is not None
49 assert last_query.progress.rows == 42
50 assert last_query.progress.bytes == 42
51 assert last_query.progress.total_rows == 0
48 self.assertIsNotNone(last_query.progress)
49 self.assertEqual(last_query.progress.rows, 42)
50 self.assertEqual(last_query.progress.bytes, 42)
51 self.assertEqual(last_query.progress.total_rows, 0)
5252
53 assert last_query.elapsed == 0
53 self.assertEqual(last_query.elapsed, 0)
5454
5555 def test_last_query_after_execute_with_progress(self):
5656 with self.sample_table():
5959 progress.get_result()
6060
6161 last_query = self.client.last_query
62 assert last_query is not None
63 assert last_query.profile_info is not None
64 assert last_query.profile_info.rows_before_limit == 42
62 self.assertIsNotNone(last_query)
63 self.assertIsNotNone(last_query.profile_info)
64 self.assertEqual(last_query.profile_info.rows_before_limit, 42)
6565
66 assert last_query.progress is not None
67 assert last_query.progress.rows == 42
68 assert last_query.progress.bytes == 42
69 assert last_query.progress.total_rows == 0
66 self.assertIsNotNone(last_query.progress)
67 self.assertEqual(last_query.progress.rows, 42)
68 self.assertEqual(last_query.progress.bytes, 42)
69 self.assertEqual(last_query.progress.total_rows, 0)
7070
71 assert last_query.elapsed == 0
71 self.assertEqual(last_query.elapsed, 0)
7272
7373 def test_last_query_progress_total_rows(self):
7474 self.client.execute('SELECT max(number) FROM numbers(10)')
7575
7676 last_query = self.client.last_query
77 assert last_query is not None
78 assert last_query.profile_info is not None
79 assert last_query.profile_info.rows_before_limit == 10
77 self.assertIsNotNone(last_query)
78 self.assertIsNotNone(last_query.profile_info)
79 self.assertEqual(last_query.profile_info.rows_before_limit, 10)
8080
81 assert last_query.progress is not None
82 assert last_query.progress.rows == 10
83 assert last_query.progress.bytes == 80
81 self.assertIsNotNone(last_query.progress)
82 self.assertEqual(last_query.progress.rows, 10)
83 self.assertEqual(last_query.progress.bytes, 80)
8484
8585 total_rows = 10 if self.server_version > (19, 4) else 0
86 assert last_query.progress.total_rows == total_rows
86 self.assertEqual(last_query.progress.total_rows, total_rows)
8787
88 assert last_query.elapsed > 0
88 self.assertGreater(last_query.elapsed, 0)
8989
9090 def test_last_query_after_execute_insert(self):
9191 with self.sample_table():
9393 [(i,) for i in range(42)])
9494
9595 last_query = self.client.last_query
96 assert last_query is not None
97 assert last_query.progress is not None
98 assert last_query.progress.rows == 0
99 assert last_query.progress.bytes == 0
96 self.assertIsNotNone(last_query)
97 self.assertIsNotNone(last_query.progress)
98 self.assertEqual(last_query.progress.rows, 0)
99 self.assertEqual(last_query.progress.bytes, 0)
100100
101 assert last_query.elapsed > 0
101 self.assertGreater(last_query.elapsed, 0)
102102
103103 def test_override_after_subsequent_queries(self):
104104 query = 'SELECT * FROM test WHERE foo < %(i)s ORDER BY foo LIMIT 5'
107107 self.client.execute(query, {'i': i})
108108
109109 profile_info = self.client.last_query.profile_info
110 assert profile_info.rows_before_limit == i
110 self.assertEqual(profile_info.rows_before_limit, i)
111111
112112 def test_reset_last_query(self):
113113 with self.sample_table():
114114 self.client.execute(self.sample_query)
115115
116 assert self.client.last_query is not None
116 self.assertIsNotNone(self.client.last_query)
117117 self.client.reset_last_query()
118 assert self.client.last_query is None
118 self.assertIsNone(self.client.last_query)
119119
120120 def test_reset_on_query_error(self):
121121 with self.assertRaises(errors.ServerException):
122122 self.client.execute('SELECT answer FROM universe')
123123
124 assert self.client.last_query is None
124 self.assertIsNone(self.client.last_query)
125125
126126 def test_progress_info_increment(self):
127127 self.client.execute(
131131 )
132132
133133 last_query = self.client.last_query
134 assert last_query is not None
135 assert last_query.progress is not None
136 assert last_query.progress.rows > 100000000
137 assert last_query.progress.bytes > 800000000
134 self.assertIsNotNone(last_query)
135 self.assertIsNotNone(last_query.progress)
136 self.assertGreater(last_query.progress.rows, 100000000)
137 self.assertGreater(last_query.progress.bytes, 800000000)
138138
139139 total_rows = 100000000 if self.server_version > (19, 4) else 0
140 assert last_query.progress.total_rows == total_rows
140 self.assertEqual(last_query.progress.total_rows, total_rows)
141141
142142 def test_progress_info_ddl(self):
143143 self.client.execute('DROP TABLE IF EXISTS foo')
144144
145145 last_query = self.client.last_query
146 assert last_query is not None
147 assert last_query.progress is not None
148 assert last_query.progress.rows == 0
149 assert last_query.progress.bytes == 0
146 self.assertIsNotNone(last_query)
147 self.assertIsNotNone(last_query.progress)
148 self.assertEqual(last_query.progress.rows, 0)
149 self.assertEqual(last_query.progress.bytes, 0)
150150
151 assert last_query.elapsed > 0
151 self.assertGreater(last_query.elapsed, 0)
33
44
55 class SettingTestCase(BaseTestCase):
6 def test_settings_immutable(self):
7 settings = {'strings_encoding': 'utf-8'}
8
9 self.client.execute('SELECT 1', settings=settings)
10 self.assertEqual(settings, {'strings_encoding': 'utf-8'})
11
612 def test_int_apply(self):
713 settings = {'max_query_size': 142}
814
2430 self.assertEqual(rv, [('totals_auto_threshold', '1.23', 1)])
2531
2632 def test_bool_apply(self):
27 settings = {'force_index_by_date': 2}
33 settings = {'force_index_by_date': 1}
2834
2935 rv = self.client.execute(
3036 "SELECT name, value, changed FROM system.settings "
3541
3642 @require_server_version(1, 1, 54388)
3743 def test_char_apply(self):
38 settings = {'format_csv_delimiter': 'delimiter'}
44 settings = {'format_csv_delimiter': 'd'}
3945
4046 rv = self.client.execute(
4147 "SELECT name, value, changed FROM system.settings "
6369 )
6470
6571 def test_unknown_setting(self):
72 # For both cases unknown setting will be ignored:
73 # - rev >= DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS
74 # the setting will be ignored by the server with the warning message
75 # (since clickhouse-server does not ignore only important settings,
76 # the one that has important flag)
77 # - otherwise the unknown setting will be ignored by the driver.
6678 settings = {'unknown_setting': 100500}
67 self.client.execute('SHOW tables', settings=settings)
79 self.client.execute('SELECT 1', settings=settings)
80
81 # DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS is 20.1.2+
82 @require_server_version(20, 1, 2)
83 def test_unknown_setting_is_important(self):
84 # In case of rev >=
85 # DBMS_MIN_REVISION_WITH_SETTINGS_SERIALIZED_AS_STRINGS and setting
86 # marked as important, then the query should fail.
87 settings = {'unknown_setting': 100500}
88 with self.created_client(settings_is_important=True) as client:
89 with self.assertRaises(ServerException) as e:
90 client.execute('SELECT 1', settings=settings)
91 self.assertEqual(e.exception.code, ErrorCodes.UNKNOWN_SETTING)
6892
6993 def test_client_settings(self):
7094 settings = {'max_query_size': 142}
93117
94118 class LimitsTestCase(BaseTestCase):
95119 def test_max_result_rows_apply(self):
120 query = 'SELECT number FROM system.numbers LIMIT 10'
96121 settings = {'max_result_rows': 5}
97122
98123 with self.assertRaises(ServerException) as e:
99 self.client.execute(
100 'SELECT arrayJoin(range(10))',
101 settings=settings
102 )
124 self.client.execute(query, settings=settings)
103125 # New servers return TOO_MANY_ROWS_OR_BYTES.
104126 # Old servers return TOO_MANY_ROWS.
105127 error_codes = {
109131 self.assertIn(e.exception.code, error_codes)
110132
111133 settings = {'max_result_rows': 5, 'result_overflow_mode': 'break'}
112 rv = self.client.execute(
113 'SELECT arrayJoin(range(10))',
114 settings=settings
115 )
134 rv = self.client.execute(query, settings=settings)
116135 self.assertEqual(len(rv), 10)
117136
118 rv = self.client.execute('SELECT arrayJoin(range(10))')
137 rv = self.client.execute(query)
119138 self.assertEqual(len(rv), 10)
9393 self.assert_subst(self.single_tpl, params, 'SELECT [1, NULL, 2]')
9494
9595 rv = self.client.execute(self.single_tpl, params)
96 self.assertEqual(rv, [((1, None, 2), )])
96 self.assertEqual(rv, [([1, None, 2], )])
9797
9898 params = {'x': [[1, 2, 3], [4, 5], [6, 7]]}
9999
101101 'SELECT [[1, 2, 3], [4, 5], [6, 7]]')
102102
103103 rv = self.client.execute(self.single_tpl, params)
104 self.assertEqual(rv, [(((1, 2, 3), (4, 5), (6, 7)), )])
104 self.assertEqual(rv, [([[1, 2, 3], [4, 5], [6, 7]], )])
105105
106106 def test_tuple(self):
107107 params = {'x': (1, None, 2)}
0 from io import BytesIO
1 from unittest import TestCase
2
3 from clickhouse_driver.varint import read_varint, write_varint
4
5
6 class VarIntTestCase(TestCase):
7 def test_check_not_negative(self):
8 n = 0x9FFFFFFF
9
10 buf = BytesIO()
11 write_varint(n, buf)
12 val = buf.getvalue()
13 self.assertEqual(b'\xFF\xFF\xFF\xFF\t', val)
14
15 buf = BytesIO(val)
16 buf.read_one = lambda: ord(buf.read(1))
17 m = read_varint(buf)
18 self.assertEqual(m, n)