30
30
API for fast data ingestion into QuestDB.
31
31
"""
32
32
33
- from libc.stdint cimport uint8_t, int64_t
33
+ from libc.stdint cimport uint8_t, uint64_t, int64_t
34
34
from cpython.datetime cimport datetime
35
35
from cpython.bool cimport bool , PyBool_Check
36
36
from cpython.weakref cimport PyWeakref_NewRef, PyWeakref_GetObject
37
37
from cpython.object cimport PyObject
38
+ from cpython.float cimport PyFloat_Check
39
+ from cpython.int cimport PyInt_Check
40
+ from cpython.unicode cimport PyUnicode_Check
38
41
39
42
from .line_sender cimport *
40
43
@@ -518,16 +521,14 @@ cdef class Buffer:
518
521
return 0
519
522
520
523
cdef inline int _column_i64(
521
- self, line_sender_column_name c_name, int value) except -1:
522
- # TODO: Generally audit for int overflows this in the whole codebase.
523
- # We pretty certainly have one here :-).
524
+ self, line_sender_column_name c_name, int64_t value) except -1:
524
525
cdef line_sender_error* err = NULL
525
526
if not line_sender_buffer_column_i64(self._impl, c_name, value, &err):
526
527
raise c_err_to_py(err)
527
528
return 0
528
529
529
530
cdef inline int _column_f64(
530
- self, line_sender_column_name c_name, float value) except -1:
531
+ self, line_sender_column_name c_name, double value) except -1:
531
532
cdef line_sender_error* err = NULL
532
533
if not line_sender_buffer_column_f64(self._impl, c_name, value, &err):
533
534
raise c_err_to_py(err)
@@ -545,7 +546,7 @@ cdef class Buffer:
545
546
cdef inline int _column_ts(
546
547
self, line_sender_column_name c_name, TimestampMicros ts) except -1:
547
548
cdef line_sender_error* err = NULL
548
- if not line_sender_buffer_column_ts(self._impl, c_name, ts.value , &err):
549
+ if not line_sender_buffer_column_ts(self._impl, c_name, ts._value , &err):
549
550
raise c_err_to_py(err)
550
551
return 0
551
552
@@ -562,11 +563,11 @@ cdef class Buffer:
562
563
cdef bytes owner_name = str_to_column_name(name, &c_name)
563
564
if PyBool_Check(value):
564
565
return self._column_bool(c_name, value)
565
- elif isinstance (value, int ):
566
+ elif PyInt_Check (value):
566
567
return self._column_i64(c_name, value)
567
- elif isinstance (value, float ):
568
+ elif PyFloat_Check (value):
568
569
return self._column_f64(c_name, value)
569
- elif isinstance (value, str ):
570
+ elif PyUnicode_Check (value):
570
571
return self._column_str(c_name, value)
571
572
elif isinstance(value, TimestampMicros):
572
573
return self._column_ts(c_name, value)
@@ -593,7 +594,7 @@ cdef class Buffer:
593
594
594
595
cdef inline int _at_ts(self, TimestampNanos ts) except -1:
595
596
cdef line_sender_error* err = NULL
596
- if not line_sender_buffer_at(self._impl, ts.value , &err):
597
+ if not line_sender_buffer_at(self._impl, ts._value , &err):
597
598
raise c_err_to_py(err)
598
599
return 0
599
600
@@ -1078,9 +1079,9 @@ cdef class Sender:
1078
1079
str interface = None ,
1079
1080
tuple auth = None ,
1080
1081
object tls = False ,
1081
- int read_timeout = 15000 ,
1082
- int init_capacity = 65536 , # 64KiB
1083
- int max_name_len = 127 ,
1082
+ uint64_t read_timeout = 15000 ,
1083
+ uint64_t init_capacity = 65536 , # 64KiB
1084
+ uint64_t max_name_len = 127 ,
1084
1085
object auto_flush = 64512 ): # 63KiB
1085
1086
cdef line_sender_error* err = NULL
1086
1087
@@ -1118,9 +1119,9 @@ cdef class Sender:
1118
1119
self ._impl = NULL
1119
1120
self ._buffer = None
1120
1121
1121
- if isinstance (port, int ):
1122
+ if PyInt_Check (port):
1122
1123
port_str = str (port)
1123
- elif isinstance (port, str ):
1124
+ elif PyUnicode_Check (port):
1124
1125
port_str = port
1125
1126
else :
1126
1127
raise TypeError (
0 commit comments