mirror of
https://github.com/hanzo-ds/driver.git
synced 2026-10-30 20:32:40 +00:00
Imports read `datastore_driver`, distribution `datastore-driver`, so nothing has to import another product's name to talk to Hanzo Datastore. Cut from upstream 0.2.9 — the version this stack already ran — rather than from upstream HEAD, so it is a PURE RENAME with no behaviour change. Forking from HEAD would have dragged versions along with the name (connect alone jumped 0.8.17 -> 1.6.0, a major), which is a different and much riskier change wearing a rename's clothes. X-ClickHouse-* headers are untouched: they are wire protocol the server sends and expects, and a different token shape from the module name.
35 lines
925 B
Python
35 lines
925 B
Python
from ctypes import c_float
|
|
|
|
from .base import FormatColumn
|
|
|
|
|
|
class FloatColumn(FormatColumn):
|
|
py_types = (float, int)
|
|
|
|
|
|
class Float32Column(FloatColumn):
|
|
ch_type = 'Float32'
|
|
format = 'f'
|
|
|
|
def __init__(self, types_check=False, **kwargs):
|
|
super(Float32Column, self).__init__(types_check=types_check, **kwargs)
|
|
|
|
if types_check:
|
|
# Chop only bytes that fit current type.
|
|
# Cast to -nan or nan if overflows.
|
|
def before_write_items(items, nulls_map=None):
|
|
null_value = self.null_value
|
|
|
|
for i, item in enumerate(items):
|
|
if nulls_map and nulls_map[i]:
|
|
items[i] = null_value
|
|
else:
|
|
items[i] = c_float(item).value
|
|
|
|
self.before_write_items = before_write_items
|
|
|
|
|
|
class Float64Column(FloatColumn):
|
|
ch_type = 'Float64'
|
|
format = 'd'
|