Generated by Cython 3.0.5
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: ingress.c
+0001: ################################################################################
__pyx_t_17 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_17) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
0002: ## ___ _ ____ ____
0003: ## / _ \ _ _ ___ ___| |_| _ \| __ )
0004: ## | | | | | | |/ _ \/ __| __| | | | _ \
0005: ## | |_| | |_| | __/\__ \ |_| |_| | |_) |
0006: ## \__\_\\__,_|\___||___/\__|____/|____/
0007: ##
0008: ## Copyright (c) 2014-2019 Appsicle
0009: ## Copyright (c) 2019-2022 QuestDB
0010: ##
0011: ## Licensed under the Apache License, Version 2.0 (the "License");
0012: ## you may not use this file except in compliance with the License.
0013: ## You may obtain a copy of the License at
0014: ##
0015: ## http://www.apache.org/licenses/LICENSE-2.0
0016: ##
0017: ## Unless required by applicable law or agreed to in writing, software
0018: ## distributed under the License is distributed on an "AS IS" BASIS,
0019: ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0020: ## See the License for the specific language governing permissions and
0021: ## limitations under the License.
0022: ##
0023: ################################################################################
0024:
0025: # distutils: language=c
0026: # cython: language_level=3
0027: # cython: binding=True
0028:
0029: """
0030: API for fast data ingestion into QuestDB.
0031: """
0032:
0033: # For prototypes: https://github.com/cython/cython/tree/master/Cython/Includes
0034: from libc.stdint cimport uint8_t, uint64_t, int64_t, uint32_t, uintptr_t, \
0035: INT64_MAX, INT64_MIN
0036: from libc.stdlib cimport malloc, calloc, realloc, free, abort, qsort
0037: from libc.string cimport strncmp, memset
0038: from libc.math cimport isnan
0039: from libc.errno cimport errno
0040: # from libc.stdio cimport stderr, fprintf
0041: from cpython.datetime cimport datetime
0042: from cpython.bool cimport bool
0043: from cpython.weakref cimport PyWeakref_NewRef, PyWeakref_GetObject
0044: from cpython.object cimport PyObject
0045: from cpython.buffer cimport Py_buffer, PyObject_CheckBuffer, \
0046: PyObject_GetBuffer, PyBuffer_Release, PyBUF_SIMPLE
0047: from cpython.memoryview cimport PyMemoryView_FromMemory
0048:
0049: from .line_sender cimport *
0050: from .pystr_to_utf8 cimport *
0051: from .arrow_c_data_interface cimport *
0052: from .extra_cpython cimport *
0053: from .ingress_helper cimport *
0054:
0055: # An int we use only for error reporting.
0056: # 0 is success.
0057: # -1 is failure.
0058: ctypedef int void_int
0059:
0060: import cython
0061: include "dataframe.pxi"
0062:
0063:
+0064: from enum import Enum
__pyx_t_20 = PyList_New(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_INCREF(__pyx_n_s_Enum); __Pyx_GIVEREF(__pyx_n_s_Enum); if (__Pyx_PyList_SET_ITEM(__pyx_t_20, 0, __pyx_n_s_Enum)) __PYX_ERR(0, 64, __pyx_L1_error); __pyx_t_2 = __Pyx_Import(__pyx_n_s_enum, __pyx_t_20, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_Enum); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Enum, __pyx_t_20) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0065: from typing import List, Tuple, Dict, Union, Any, Optional, Callable, \
__pyx_t_2 = PyList_New(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_n_s_List); __Pyx_GIVEREF(__pyx_n_s_List); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_List)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Tuple); __Pyx_GIVEREF(__pyx_n_s_Tuple); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_Tuple)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Dict); __Pyx_GIVEREF(__pyx_n_s_Dict); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_Dict)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Union); __Pyx_GIVEREF(__pyx_n_s_Union); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_Union)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Any); __Pyx_GIVEREF(__pyx_n_s_Any); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 4, __pyx_n_s_Any)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Optional); __Pyx_GIVEREF(__pyx_n_s_Optional); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 5, __pyx_n_s_Optional)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Callable); __Pyx_GIVEREF(__pyx_n_s_Callable); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 6, __pyx_n_s_Callable)) __PYX_ERR(0, 65, __pyx_L1_error); __Pyx_INCREF(__pyx_n_s_Iterable); __Pyx_GIVEREF(__pyx_n_s_Iterable); if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 7, __pyx_n_s_Iterable)) __PYX_ERR(0, 65, __pyx_L1_error); __pyx_t_20 = __Pyx_Import(__pyx_n_s_typing, __pyx_t_2, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_List); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_List, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Tuple); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Tuple, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Dict); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Dict, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Union); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Union, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Any); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Any, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Optional); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Optional, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Callable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Callable, __pyx_t_2) < 0) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_20, __pyx_n_s_Iterable); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_Iterable, __pyx_t_2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
0066: Iterable
+0067: import pathlib
__pyx_t_20 = __Pyx_ImportDottedModule(__pyx_n_s_pathlib, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); if (PyDict_SetItem(__pyx_d, __pyx_n_s_pathlib, __pyx_t_20) < 0) __PYX_ERR(0, 67, __pyx_L1_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
0068:
+0069: import sys
__pyx_t_20 = __Pyx_ImportDottedModule(__pyx_n_s_sys, NULL); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_20) < 0) __PYX_ERR(0, 69, __pyx_L1_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
0070:
0071:
+0072: cdef bint _has_gil(PyThreadState** gs):
static int __pyx_f_7questdb_7ingress__has_gil(PyThreadState **__pyx_v_gs) { int __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
+0073: return gs[0] == NULL
__pyx_r = ((__pyx_v_gs[0]) == NULL); goto __pyx_L0;
0074:
0075:
+0076: cdef bint _ensure_doesnt_have_gil(PyThreadState** gs):
static int __pyx_f_7questdb_7ingress__ensure_doesnt_have_gil(PyThreadState **__pyx_v_gs) {
int __pyx_r;
/* … */
/* function exit code */
__pyx_L1_error:;
__Pyx_AddTraceback("questdb.ingress._ensure_doesnt_have_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_r = -1;
__pyx_L0:;
return __pyx_r;
}
0077: """Returns True if previously had the GIL, False otherwise."""
+0078: if _has_gil(gs):
__pyx_t_1 = __pyx_f_7questdb_7ingress__has_gil(__pyx_v_gs); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 78, __pyx_L1_error) if (__pyx_t_1) { /* … */ }
+0079: gs[0] = PyEval_SaveThread()
(__pyx_v_gs[0]) = PyEval_SaveThread();
+0080: return True
__pyx_r = 1; goto __pyx_L0;
+0081: return False
__pyx_r = 0; goto __pyx_L0;
0082:
0083:
+0084: cdef void _ensure_has_gil(PyThreadState** gs):
static void __pyx_f_7questdb_7ingress__ensure_has_gil(PyThreadState **__pyx_v_gs) {
/* … */
/* function exit code */
goto __pyx_L0;
__pyx_L1_error:;
__Pyx_AddTraceback("questdb.ingress._ensure_has_gil", __pyx_clineno, __pyx_lineno, __pyx_filename);
__pyx_L0:;
}
+0085: if not _has_gil(gs):
__pyx_t_1 = __pyx_f_7questdb_7ingress__has_gil(__pyx_v_gs); if (unlikely(__pyx_t_1 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) __pyx_t_2 = (!__pyx_t_1); if (__pyx_t_2) { /* … */ }
+0086: PyEval_RestoreThread(gs[0])
PyEval_RestoreThread((__pyx_v_gs[0]));
+0087: gs[0] = NULL
(__pyx_v_gs[0]) = NULL;
0088:
0089:
+0090: class IngressErrorCode(Enum):
__Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_n_s_Enum); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_20); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_20)) __PYX_ERR(0, 90, __pyx_L1_error); __pyx_t_20 = 0; __pyx_t_20 = __Pyx_PEP560_update_bases(__pyx_t_2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __pyx_t_18 = __Pyx_CalculateMetaclass(NULL, __pyx_t_20); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = __Pyx_Py3MetaclassPrepare(__pyx_t_18, __pyx_t_20, __pyx_n_s_IngressErrorCode, __pyx_n_s_IngressErrorCode, (PyObject *) NULL, __pyx_n_s_questdb_ingress, __pyx_kp_s_Category_of_Error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (__pyx_t_20 != __pyx_t_2) { if (unlikely((PyDict_SetItemString(__pyx_t_17, "__orig_bases__", __pyx_t_2) < 0))) __PYX_ERR(0, 90, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_t_19 = __Pyx_Py3ClassCreate(__pyx_t_18, __pyx_n_s_IngressErrorCode, __pyx_t_20, __pyx_t_17, NULL, 0, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); if (PyDict_SetItem(__pyx_d, __pyx_n_s_IngressErrorCode, __pyx_t_19) < 0) __PYX_ERR(0, 90, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
0091: """Category of Error."""
+0092: CouldNotResolveAddr = line_sender_error_could_not_resolve_addr
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_could_not_resolve_addr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_CouldNotResolveAddr, __pyx_t_2) < 0) __PYX_ERR(0, 92, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0093: InvalidApiCall = line_sender_error_invalid_api_call
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_invalid_api_call); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_InvalidApiCall, __pyx_t_2) < 0) __PYX_ERR(0, 93, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0094: SocketError = line_sender_error_socket_error
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_socket_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_SocketError, __pyx_t_2) < 0) __PYX_ERR(0, 94, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0095: InvalidUtf8 = line_sender_error_invalid_utf8
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_invalid_utf8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_InvalidUtf8, __pyx_t_2) < 0) __PYX_ERR(0, 95, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0096: InvalidName = line_sender_error_invalid_name
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_invalid_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_InvalidName, __pyx_t_2) < 0) __PYX_ERR(0, 96, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0097: InvalidTimestamp = line_sender_error_invalid_timestamp
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_invalid_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_InvalidTimestamp, __pyx_t_2) < 0) __PYX_ERR(0, 97, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0098: AuthError = line_sender_error_auth_error
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_auth_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_AuthError, __pyx_t_2) < 0) __PYX_ERR(0, 98, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0099: TlsError = line_sender_error_tls_error
__pyx_t_2 = __Pyx_PyInt_From_enum__line_sender_error_code(line_sender_error_tls_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_TlsError, __pyx_t_2) < 0) __PYX_ERR(0, 99, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0100: BadDataFrame = <int>line_sender_error_tls_error + 1
__pyx_t_2 = __Pyx_PyInt_From_long((((int)line_sender_error_tls_error) + 1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_BadDataFrame, __pyx_t_2) < 0) __PYX_ERR(0, 100, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
0101:
+0102: def __str__(self) -> str:
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_16IngressErrorCode_1__str__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_16IngressErrorCode___str__, "Return the name of the enum."); static PyMethodDef __pyx_mdef_7questdb_7ingress_16IngressErrorCode_1__str__ = {"__str__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_16IngressErrorCode_1__str__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_16IngressErrorCode___str__}; static PyObject *__pyx_pw_7questdb_7ingress_16IngressErrorCode_1__str__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_self = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_self)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__str__") < 0)) __PYX_ERR(0, 102, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_self = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__str__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 102, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.IngressErrorCode.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7questdb_7ingress_16IngressErrorCode___str__(__pyx_self, __pyx_v_self); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_16IngressErrorCode___str__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.IngressErrorCode.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__42 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__42)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__42); __Pyx_GIVEREF(__pyx_tuple__42); /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_str) < 0) __PYX_ERR(0, 102, __pyx_L1_error) __pyx_t_19 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_16IngressErrorCode_1__str__, 0, __pyx_n_s_IngressErrorCode___str, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__43)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_19, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__Pyx_SetNameInClass(__pyx_t_17, __pyx_n_s_str_2, __pyx_t_19) < 0) __PYX_ERR(0, 102, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __pyx_codeobj__43 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_str_2, 102, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__43)) __PYX_ERR(0, 102, __pyx_L1_error)
0103: """Return the name of the enum."""
+0104: return self.name
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 104, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
0105:
0106:
+0107: class IngressError(Exception):
__pyx_t_20 = PyTuple_New(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); __Pyx_INCREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); __Pyx_GIVEREF((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_20, 0, ((PyObject *)(&((PyTypeObject*)PyExc_Exception)[0])))) __PYX_ERR(0, 107, __pyx_L1_error); __pyx_t_18 = __Pyx_PEP560_update_bases(__pyx_t_20); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = __Pyx_CalculateMetaclass(NULL, __pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_19 = __Pyx_Py3MetaclassPrepare(__pyx_t_17, __pyx_t_18, __pyx_n_s_IngressError, __pyx_n_s_IngressError, (PyObject *) NULL, __pyx_n_s_questdb_ingress, __pyx_kp_s_An_error_whilst_using_the_Sender); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); if (__pyx_t_18 != __pyx_t_20) { if (unlikely((PyDict_SetItemString(__pyx_t_19, "__orig_bases__", __pyx_t_20) < 0))) __PYX_ERR(0, 107, __pyx_L1_error) } __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; __pyx_t_20 = PyList_New(0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_20); /* … */ __pyx_t_2 = __Pyx_Py3ClassCreate(__pyx_t_17, __pyx_n_s_IngressError, __pyx_t_18, __pyx_t_19, NULL, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (__Pyx_CyFunction_InitClassCell(__pyx_t_20, __pyx_t_2) < 0) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_IngressError, __pyx_t_2) < 0) __PYX_ERR(0, 107, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
0108: """An error whilst using the ``Sender`` or constructing its ``Buffer``."""
+0109: def __init__(self, code, msg):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_12IngressError_1__init__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyMethodDef __pyx_mdef_7questdb_7ingress_12IngressError_1__init__ = {"__init__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_12IngressError_1__init__, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_7questdb_7ingress_12IngressError_1__init__(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_self = 0; PyObject *__pyx_v_code = 0; PyObject *__pyx_v_msg = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__init__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_code,&__pyx_n_s_msg,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_self)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_code)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); __PYX_ERR(0, 109, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_msg)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 109, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); __PYX_ERR(0, 109, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__init__") < 0)) __PYX_ERR(0, 109, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_self = values[0]; __pyx_v_code = values[1]; __pyx_v_msg = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 109, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.IngressError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7questdb_7ingress_12IngressError___init__(__pyx_self, __pyx_v_self, __pyx_v_code, __pyx_v_msg); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_12IngressError___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_code, PyObject *__pyx_v_msg) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.IngressError.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__44 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_code, __pyx_n_s_msg); if (unlikely(!__pyx_tuple__44)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__44); __Pyx_GIVEREF(__pyx_tuple__44); /* … */ __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_12IngressError_1__init__, 0, __pyx_n_s_IngressError___init, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__45)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_2); PyList_Append(__pyx_t_20, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_SetNameInClass(__pyx_t_19, __pyx_n_s_init, __pyx_t_2) < 0) __PYX_ERR(0, 109, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__45 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__44, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_init, 109, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__45)) __PYX_ERR(0, 109, __pyx_L1_error)
+0110: super().__init__(msg)
__pyx_t_2 = __Pyx_CyFunction_GetClassObj(__pyx_self); if (!__pyx_t_2) { PyErr_SetString(PyExc_SystemError, "super(): empty __class__ cell"); __PYX_ERR(0, 110, __pyx_L1_error) } __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error); __Pyx_INCREF(__pyx_v_self); __Pyx_GIVEREF(__pyx_v_self); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self)) __PYX_ERR(0, 110, __pyx_L1_error); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_3))) { __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_2)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_msg}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_4, 1+__pyx_t_4); __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0111: self._code = code
if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_code_2, __pyx_v_code) < 0) __PYX_ERR(0, 111, __pyx_L1_error)
0112:
+0113: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_12IngressError_3code(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_12IngressError_2code, "Return the error code."); static PyMethodDef __pyx_mdef_7questdb_7ingress_12IngressError_3code = {"code", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_12IngressError_3code, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_12IngressError_2code}; static PyObject *__pyx_pw_7questdb_7ingress_12IngressError_3code(PyObject *__pyx_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_self = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("code (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_self)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 113, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "code") < 0)) __PYX_ERR(0, 113, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_self = values[0]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("code", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 113, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.IngressError.code", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7questdb_7ingress_12IngressError_2code(__pyx_self, __pyx_v_self); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_12IngressError_2code(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.IngressError.code", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_2, __pyx_n_s_return, __pyx_n_s_IngressErrorCode) < 0) __PYX_ERR(0, 113, __pyx_L1_error) __pyx_t_16 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_12IngressError_3code, 0, __pyx_n_s_IngressError_code, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__46)); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_16); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_16, __pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_property, __pyx_t_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0; if (__Pyx_SetNameInClass(__pyx_t_19, __pyx_n_s_code, __pyx_t_2) < 0) __PYX_ERR(0, 113, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_codeobj__46 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_code, 113, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__46)) __PYX_ERR(0, 113, __pyx_L1_error)
0114: def code(self) -> IngressErrorCode:
0115: """Return the error code."""
+0116: return self._code
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_code_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0117:
0118:
+0119: cdef inline object c_err_code_to_py(line_sender_error_code code):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_c_err_code_to_py(enum line_sender_error_code __pyx_v_code) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.c_err_code_to_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0120: if code == line_sender_error_could_not_resolve_addr:
switch (__pyx_v_code) { case line_sender_error_could_not_resolve_addr: /* … */ break; case line_sender_error_invalid_api_call:
+0121: return IngressErrorCode.CouldNotResolveAddr
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_CouldNotResolveAddr); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 121, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0122: elif code == line_sender_error_invalid_api_call:
break; case line_sender_error_socket_error:
+0123: return IngressErrorCode.InvalidApiCall
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InvalidApiCall); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 123, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0124: elif code == line_sender_error_socket_error:
break; case line_sender_error_invalid_utf8:
+0125: return IngressErrorCode.SocketError
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_SocketError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0126: elif code == line_sender_error_invalid_utf8:
break; case line_sender_error_invalid_name:
+0127: return IngressErrorCode.InvalidUtf8
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InvalidUtf8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0128: elif code == line_sender_error_invalid_name:
break; case line_sender_error_invalid_timestamp:
+0129: return IngressErrorCode.InvalidName
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_InvalidName); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0130: elif code == line_sender_error_invalid_timestamp:
break; case line_sender_error_auth_error:
+0131: return IngressErrorCode.InvalidTimestamp
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_InvalidTimestamp); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
+0132: elif code == line_sender_error_auth_error:
break; case line_sender_error_tls_error:
+0133: return IngressErrorCode.AuthError
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_AuthError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+0134: elif code == line_sender_error_tls_error:
break; default:
+0135: return IngressErrorCode.TlsError
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_TlsError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 135, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0136: else:
+0137: raise ValueError('Internal error converting error code.')
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 137, __pyx_L1_error) break; } /* … */ __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_u_Internal_error_converting_error); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 137, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__29); __Pyx_GIVEREF(__pyx_tuple__29);
0138:
0139:
+0140: cdef inline object c_err_to_code_and_msg(line_sender_error* err):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_c_err_to_code_and_msg(struct line_sender_error *__pyx_v_err) { enum line_sender_error_code __pyx_v_code; size_t __pyx_v_c_len; char const *__pyx_v_c_msg; PyObject *__pyx_v_py_msg = 0; PyObject *__pyx_v_py_code = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.c_err_to_code_and_msg", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_py_msg); __Pyx_XDECREF(__pyx_v_py_code); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0141: """Construct a ``SenderError`` from a C error, which will be freed."""
+0142: cdef line_sender_error_code code = line_sender_error_get_code(err)
__pyx_v_code = line_sender_error_get_code(__pyx_v_err);
+0143: cdef size_t c_len = 0
__pyx_v_c_len = 0;
+0144: cdef const char* c_msg = line_sender_error_msg(err, &c_len)
__pyx_v_c_msg = line_sender_error_msg(__pyx_v_err, (&__pyx_v_c_len));
0145: cdef object py_err
0146: cdef object py_msg
0147: cdef object py_code
+0148: try:
/*try:*/ {
+0149: py_code = c_err_code_to_py(code)
__pyx_t_1 = __pyx_f_7questdb_7ingress_c_err_code_to_py(__pyx_v_code); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_py_code = __pyx_t_1; __pyx_t_1 = 0;
+0150: py_msg = PyUnicode_FromStringAndSize(c_msg, <Py_ssize_t>c_len)
__pyx_t_1 = PyUnicode_FromStringAndSize(__pyx_v_c_msg, ((Py_ssize_t)__pyx_v_c_len)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 150, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_py_msg = __pyx_t_1; __pyx_t_1 = 0;
+0151: return (py_code, py_msg)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_v_py_code); __Pyx_GIVEREF(__pyx_v_py_code); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_py_code)) __PYX_ERR(0, 151, __pyx_L4_error); __Pyx_INCREF(__pyx_v_py_msg); __Pyx_GIVEREF(__pyx_v_py_msg); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_py_msg)) __PYX_ERR(0, 151, __pyx_L4_error); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L3_return; }
0152: finally:
+0153: line_sender_error_free(err)
/*finally:*/ { __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7); __Pyx_XGOTREF(__pyx_t_5); __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_7); __Pyx_XGOTREF(__pyx_t_8); __Pyx_XGOTREF(__pyx_t_9); __Pyx_XGOTREF(__pyx_t_10); __pyx_t_2 = __pyx_lineno; __pyx_t_3 = __pyx_clineno; __pyx_t_4 = __pyx_filename; { line_sender_error_free(__pyx_v_err); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_8); __Pyx_XGIVEREF(__pyx_t_9); __Pyx_XGIVEREF(__pyx_t_10); __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10); } __Pyx_XGIVEREF(__pyx_t_5); __Pyx_XGIVEREF(__pyx_t_6); __Pyx_XGIVEREF(__pyx_t_7); __Pyx_ErrRestore(__pyx_t_5, __pyx_t_6, __pyx_t_7); __pyx_t_5 = 0; __pyx_t_6 = 0; __pyx_t_7 = 0; __pyx_t_8 = 0; __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_lineno = __pyx_t_2; __pyx_clineno = __pyx_t_3; __pyx_filename = __pyx_t_4; goto __pyx_L1_error; } __pyx_L3_return: { __pyx_t_10 = __pyx_r; __pyx_r = 0; line_sender_error_free(__pyx_v_err); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L0; } }
0154:
0155:
+0156: cdef inline object c_err_to_py(line_sender_error* err):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_c_err_to_py(struct line_sender_error *__pyx_v_err) { PyObject *__pyx_v_tup = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.c_err_to_py", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tup); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0157: """Construct an ``IngressError`` from a C error, which will be freed."""
+0158: cdef object tup = c_err_to_code_and_msg(err)
__pyx_t_1 = __pyx_f_7questdb_7ingress_c_err_to_code_and_msg(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_tup = __pyx_t_1; __pyx_t_1 = 0;
+0159: return IngressError(tup[0], tup[1])
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_tup, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_tup, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_3, __pyx_t_4}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0160:
0161:
+0162: cdef inline object c_err_to_py_fmt(line_sender_error* err, str fmt):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_c_err_to_py_fmt(struct line_sender_error *__pyx_v_err, PyObject *__pyx_v_fmt) { PyObject *__pyx_v_tup = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.c_err_to_py_fmt", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_tup); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0163: """Construct an ``IngressError`` from a C error, which will be freed."""
+0164: cdef object tup = c_err_to_code_and_msg(err)
__pyx_t_1 = __pyx_f_7questdb_7ingress_c_err_to_code_and_msg(__pyx_v_err); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_v_tup = __pyx_t_1; __pyx_t_1 = 0;
+0165: return IngressError(tup[0], fmt.format(tup[1]))
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_tup, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_tup, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_CallUnboundCMethod1(&__pyx_umethod_PyUnicode_Type_format, __pyx_v_fmt, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_3, __pyx_t_5}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0166:
0167:
+0168: cdef object _utf8_decode_error(
static PyObject *__pyx_f_7questdb_7ingress__utf8_decode_error(PyObject *__pyx_v_string, uint32_t __pyx_v_bad_codepoint) { PyObject *__pyx_v_s = 0; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("questdb.ingress._utf8_decode_error", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XDECREF(__pyx_v_s); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0169: PyObject* string, uint32_t bad_codepoint):
+0170: cdef str s = <str><object>string
__pyx_t_1 = ((PyObject *)__pyx_v_string);
__Pyx_INCREF(__pyx_t_1);
__pyx_v_s = ((PyObject*)__pyx_t_1);
__pyx_t_1 = 0;
+0171: return IngressError(
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+0172: IngressErrorCode.InvalidUtf8,
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_InvalidUtf8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 172, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+0173: f'Invalid codepoint 0x{bad_codepoint:x} in string {s!r}: ' +
__pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = 0; __pyx_t_6 = 127; __Pyx_INCREF(__pyx_kp_u_Invalid_codepoint_0x); __pyx_t_5 += 20; __Pyx_GIVEREF(__pyx_kp_u_Invalid_codepoint_0x); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Invalid_codepoint_0x); __pyx_t_7 = __Pyx_PyInt_From_uint32_t(__pyx_v_bad_codepoint); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_8 = __Pyx_PyObject_Format(__pyx_t_7, __pyx_n_u_x); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u_in_string); __pyx_t_5 += 11; __Pyx_GIVEREF(__pyx_kp_u_in_string); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_in_string); __pyx_t_8 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_s), __pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __pyx_t_6 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) > __pyx_t_6) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) : __pyx_t_6; __pyx_t_5 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8); __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_3, 3, __pyx_t_8); __pyx_t_8 = 0; __Pyx_INCREF(__pyx_kp_u__21); __pyx_t_5 += 2; __Pyx_GIVEREF(__pyx_kp_u__21); PyTuple_SET_ITEM(__pyx_t_3, 4, __pyx_kp_u__21); __pyx_t_8 = __Pyx_PyUnicode_Join(__pyx_t_3, 5, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_8); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_8, __pyx_kp_u_Cannot_be_encoded_as_UTF_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 173, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; __pyx_t_8 = NULL; __pyx_t_9 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_9 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_t_4, __pyx_t_3}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_9, 2+__pyx_t_9); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0174: 'Cannot be encoded as UTF-8.')
0175:
0176:
+0177: cdef str _fqn(type obj):
static PyObject *__pyx_f_7questdb_7ingress__fqn(PyTypeObject *__pyx_v_obj) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_AddTraceback("questdb.ingress._fqn", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0178: if obj.__module__ == 'builtins':
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_obj), __pyx_n_s_module); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_builtins, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 178, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0179: return obj.__qualname__
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_obj), __pyx_n_s_qualname); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 179, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
0180: else:
+0181: return f'{obj.__module__}.{obj.__qualname__}'
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_3 = 0; __pyx_t_4 = 127; __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_obj), __pyx_n_s_module); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_t_5, __pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6); __pyx_t_6 = 0; __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_3 += 1; __Pyx_GIVEREF(__pyx_kp_u__5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_kp_u__5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_obj), __pyx_n_s_qualname); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_6, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_4 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_4) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_4; __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 181, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0; goto __pyx_L0; }
0182:
0183:
+0184: cdef inline void_int _encode_utf8(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress__encode_utf8(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_utf8 *__pyx_v_utf8_out) { uint32_t __pyx_v_bad_codepoint; size_t __pyx_v_count; int __pyx_v_kind; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress._encode_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0185: qdb_pystr_buf* b,
0186: PyObject* string,
0187: line_sender_utf8* utf8_out) except -1:
+0188: cdef uint32_t bad_codepoint = 0
__pyx_v_bad_codepoint = 0;
+0189: cdef size_t count = <size_t>(PyUnicode_GET_LENGTH(string))
__pyx_v_count = ((size_t)PyUnicode_GET_LENGTH(__pyx_v_string));
+0190: cdef int kind = PyUnicode_KIND(string)
__pyx_v_kind = PyUnicode_KIND(__pyx_v_string);
+0191: if kind == PyUnicode_1BYTE_KIND:
switch (__pyx_v_kind) { case PyUnicode_1BYTE_KIND: /* … */ break; case PyUnicode_2BYTE_KIND:
0192: # No error handling for UCS1: All code points translate into valid UTF8.
+0193: qdb_ucs1_to_utf8(
qdb_ucs1_to_utf8(__pyx_v_b, __pyx_v_count, PyUnicode_1BYTE_DATA(__pyx_v_string), (&__pyx_v_utf8_out->len), (&__pyx_v_utf8_out->buf));
0194: b,
0195: count,
0196: PyUnicode_1BYTE_DATA(string),
0197: &utf8_out.len,
0198: &utf8_out.buf)
+0199: elif kind == PyUnicode_2BYTE_KIND:
break; case PyUnicode_4BYTE_KIND:
+0200: if not qdb_ucs2_to_utf8(
__pyx_t_1 = (!qdb_ucs2_to_utf8(__pyx_v_b, __pyx_v_count, PyUnicode_2BYTE_DATA(__pyx_v_string), (&__pyx_v_utf8_out->len), (&__pyx_v_utf8_out->buf), (&__pyx_v_bad_codepoint))); if (unlikely(__pyx_t_1)) { /* … */ }
0201: b,
0202: count,
0203: PyUnicode_2BYTE_DATA(string),
0204: &utf8_out.len,
0205: &utf8_out.buf,
0206: &bad_codepoint):
+0207: raise _utf8_decode_error(string, bad_codepoint)
__pyx_t_2 = __pyx_f_7questdb_7ingress__utf8_decode_error(__pyx_v_string, __pyx_v_bad_codepoint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 207, __pyx_L1_error)
+0208: elif kind == PyUnicode_4BYTE_KIND:
break; default:
+0209: if not qdb_ucs4_to_utf8(
__pyx_t_1 = (!qdb_ucs4_to_utf8(__pyx_v_b, __pyx_v_count, ((uint32_t const *)PyUnicode_4BYTE_DATA(__pyx_v_string)), (&__pyx_v_utf8_out->len), (&__pyx_v_utf8_out->buf), (&__pyx_v_bad_codepoint))); if (unlikely(__pyx_t_1)) { /* … */ }
0210: b,
0211: count,
0212:
0213: # This cast is required and is possibly a Cython compiler bug.
0214: # It doesn't recognize that `const Py_UCS4*`
0215: # is the same as `const uint32_t*`.
0216: <const uint32_t*>PyUnicode_4BYTE_DATA(string),
0217:
0218: &utf8_out.len,
0219: &utf8_out.buf,
0220: &bad_codepoint):
+0221: raise _utf8_decode_error(string, bad_codepoint)
__pyx_t_2 = __pyx_f_7questdb_7ingress__utf8_decode_error(__pyx_v_string, __pyx_v_bad_codepoint); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 221, __pyx_L1_error)
0222: else:
+0223: raise ValueError(f'Unknown UCS kind: {kind}.')
__pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = 0; __pyx_t_4 = 127; __Pyx_INCREF(__pyx_kp_u_Unknown_UCS_kind); __pyx_t_3 += 18; __Pyx_GIVEREF(__pyx_kp_u_Unknown_UCS_kind); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_kp_u_Unknown_UCS_kind); __pyx_t_5 = __Pyx_PyUnicode_From_int(__pyx_v_kind, 0, ' ', 'd'); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__5); __pyx_t_3 += 1; __Pyx_GIVEREF(__pyx_kp_u__5); PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_kp_u__5); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_2, 3, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 223, __pyx_L1_error) break; }
0224:
0225:
+0226: cdef void_int str_to_utf8(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_utf8(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_utf8 *__pyx_v_utf8_out) { __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_utf8", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0227: qdb_pystr_buf* b,
0228: PyObject* string,
0229: line_sender_utf8* utf8_out) except -1:
0230: """
0231: Convert a Python string to a UTF-8 borrowed buffer.
0232: This is done without allocating new Python `bytes` objects.
0233: In case the string is an ASCII string, it's also generally zero-copy.
0234: The `utf8_out` param will point to (borrow from) either the ASCII buffer
0235: inside the original Python object or a part of memory allocated inside the
0236: `b` buffer.
0237:
0238: If you need to use `utf8_out` without the GIL, call `qdb_pystr_buf_copy`.
0239: """
+0240: if not PyUnicode_CheckExact(string):
__pyx_t_1 = (!PyUnicode_CheckExact(__pyx_v_string));
if (unlikely(__pyx_t_1)) {
/* … */
}
+0241: raise TypeError(
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 241, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 241, __pyx_L1_error)
+0242: 'Expected a str object, not an object of type ' +
__pyx_t_3 = __Pyx_PyUnicode_ConcatSafe(__pyx_kp_u_Expected_a_str_object_not_an_obj, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 242, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0243: _fqn(type(<str><object>string)))
__pyx_t_2 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_string))))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 243, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+0244: PyUnicode_READY(string)
__pyx_t_4 = PyUnicode_READY(__pyx_v_string); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 244, __pyx_L1_error)
0245:
0246: # We optimize the common case of ASCII strings.
0247: # This avoid memory allocations and copies altogether.
0248: # We get away with this because ASCII is a subset of UTF-8.
+0249: if PyUnicode_IS_COMPACT_ASCII(string):
__pyx_t_1 = PyUnicode_IS_COMPACT_ASCII(__pyx_v_string);
if (__pyx_t_1) {
/* … */
}
+0250: utf8_out.len = <size_t>(PyUnicode_GET_LENGTH(string))
__pyx_v_utf8_out->len = ((size_t)PyUnicode_GET_LENGTH(__pyx_v_string));
+0251: utf8_out.buf = <const char*>(PyUnicode_1BYTE_DATA(string))
__pyx_v_utf8_out->buf = ((char const *)PyUnicode_1BYTE_DATA(__pyx_v_string));
+0252: return 0
__pyx_r = 0; goto __pyx_L0;
0253:
+0254: _encode_utf8(b, string, utf8_out)
__pyx_t_5 = __pyx_f_7questdb_7ingress__encode_utf8(__pyx_v_b, __pyx_v_string, __pyx_v_utf8_out); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 254, __pyx_L1_error)
0255:
0256:
0257:
+0258: cdef void_int str_to_utf8_copy(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_utf8_copy(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_utf8 *__pyx_v_utf8_out) { __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_utf8_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0259: qdb_pystr_buf* b,
0260: PyObject* string,
0261: line_sender_utf8* utf8_out) except -1:
0262: """
0263: Variant of `str_to_utf8` that always copies the string to a new buffer.
0264:
0265: The resulting `utf8_out` can be used when not holding the GIL:
0266: The pointed-to memory is owned by `b`.
0267: """
+0268: if not PyUnicode_CheckExact(string):
__pyx_t_1 = (!PyUnicode_CheckExact(__pyx_v_string));
if (unlikely(__pyx_t_1)) {
/* … */
}
+0269: raise TypeError(
__pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 269, __pyx_L1_error)
+0270: 'Expected a str object, not an object of type ' +
__pyx_t_3 = __Pyx_PyUnicode_ConcatSafe(__pyx_kp_u_Expected_a_str_object_not_an_obj, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 270, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+0271: _fqn(type(<str><object>string)))
__pyx_t_2 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(((PyObject *)__pyx_v_string))))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
0272:
+0273: PyUnicode_READY(string)
__pyx_t_4 = PyUnicode_READY(__pyx_v_string); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 273, __pyx_L1_error)
+0274: _encode_utf8(b, string, utf8_out)
__pyx_t_5 = __pyx_f_7questdb_7ingress__encode_utf8(__pyx_v_b, __pyx_v_string, __pyx_v_utf8_out); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 274, __pyx_L1_error)
0275:
0276:
+0277: cdef void_int str_to_table_name(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_table_name(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_table_name *__pyx_v_name_out) { struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_utf8; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_table_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0278: qdb_pystr_buf* b,
0279: PyObject* string,
0280: line_sender_table_name* name_out) except -1:
0281: """
0282: Python string to borrowed C table name.
0283: Also see `str_to_utf8`.
0284: """
+0285: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0286: cdef line_sender_utf8 utf8
+0287: str_to_utf8(b, string, &utf8)
__pyx_t_1 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, __pyx_v_string, (&__pyx_v_utf8)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 287, __pyx_L1_error)
+0288: if not line_sender_table_name_init(name_out, utf8.len, utf8.buf, &err):
__pyx_t_2 = (!line_sender_table_name_init(__pyx_v_name_out, __pyx_v_utf8.len, __pyx_v_utf8.buf, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0289: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 289, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 289, __pyx_L1_error)
0290:
0291:
+0292: cdef void_int str_to_table_name_copy(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_table_name_copy(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_table_name *__pyx_v_name_out) { struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_utf8; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_table_name_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0293: qdb_pystr_buf* b,
0294: PyObject* string,
0295: line_sender_table_name* name_out) except -1:
0296: """
0297: Python string to copied C table name.
0298: Also see `str_to_utf8_copy`.
0299: """
+0300: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0301: cdef line_sender_utf8 utf8
+0302: str_to_utf8_copy(b, string, &utf8)
__pyx_t_1 = __pyx_f_7questdb_7ingress_str_to_utf8_copy(__pyx_v_b, __pyx_v_string, (&__pyx_v_utf8)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 302, __pyx_L1_error)
+0303: if not line_sender_table_name_init(name_out, utf8.len, utf8.buf, &err):
__pyx_t_2 = (!line_sender_table_name_init(__pyx_v_name_out, __pyx_v_utf8.len, __pyx_v_utf8.buf, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0304: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 304, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 304, __pyx_L1_error)
0305:
0306:
+0307: cdef void_int str_to_column_name(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_column_name(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_column_name *__pyx_v_name_out) { struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_utf8; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_column_name", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0308: qdb_pystr_buf* b,
0309: str string,
0310: line_sender_column_name* name_out) except -1:
0311: """
0312: Python string to borrowed C column name.
0313: Also see `str_to_utf8`.
0314: """
+0315: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0316: cdef line_sender_utf8 utf8
+0317: str_to_utf8(b, <PyObject*>string, &utf8)
__pyx_t_1 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_string), (&__pyx_v_utf8)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 317, __pyx_L1_error)
+0318: if not line_sender_column_name_init(name_out, utf8.len, utf8.buf, &err):
__pyx_t_2 = (!line_sender_column_name_init(__pyx_v_name_out, __pyx_v_utf8.len, __pyx_v_utf8.buf, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0319: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 319, __pyx_L1_error)
0320:
0321:
+0322: cdef void_int str_to_column_name_copy(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_str_to_column_name_copy(struct qdb_pystr_buf *__pyx_v_b, PyObject *__pyx_v_string, struct line_sender_column_name *__pyx_v_name_out) { struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_utf8; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.str_to_column_name_copy", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0323: qdb_pystr_buf* b,
0324: str string,
0325: line_sender_column_name* name_out) except -1:
0326: """
0327: Python string to copied C column name.
0328: Also see `str_to_utf8_copy`.
0329: """
+0330: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0331: cdef line_sender_utf8 utf8
+0332: str_to_utf8_copy(b, <PyObject*>string, &utf8)
__pyx_t_1 = __pyx_f_7questdb_7ingress_str_to_utf8_copy(__pyx_v_b, ((PyObject *)__pyx_v_string), (&__pyx_v_utf8)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 332, __pyx_L1_error)
+0333: if not line_sender_column_name_init(name_out, utf8.len, utf8.buf, &err):
__pyx_t_2 = (!line_sender_column_name_init(__pyx_v_name_out, __pyx_v_utf8.len, __pyx_v_utf8.buf, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0334: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 334, __pyx_L1_error)
0335:
0336:
+0337: cdef int64_t datetime_to_micros(datetime dt):
static int64_t __pyx_f_7questdb_7ingress_datetime_to_micros(PyDateTime_DateTime *__pyx_v_dt) { int64_t __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.datetime_to_micros", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0338: """
0339: Convert a `datetime.datetime` to microseconds since the epoch.
0340: """
0341: return (
+0342: <int64_t>(dt.timestamp()) *
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dt), __pyx_n_s_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_5 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0343: <int64_t>(1000000) +
__pyx_r = ((((int64_t)__pyx_t_5) * ((int64_t)0xF4240)) + ((int64_t)__pyx_t_4)); goto __pyx_L0;
+0344: <int64_t>(dt.microsecond))
__pyx_t_4 = __pyx_f_7cpython_8datetime_8datetime_11microsecond_microsecond(__pyx_v_dt); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 344, __pyx_L1_error)
0345:
0346:
+0347: cdef int64_t datetime_to_nanos(datetime dt):
static int64_t __pyx_f_7questdb_7ingress_datetime_to_nanos(PyDateTime_DateTime *__pyx_v_dt) { int64_t __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.datetime_to_nanos", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0348: """
0349: Convert a `datetime.datetime` to nanoseconds since the epoch.
0350: """
0351: return (
+0352: <int64_t>(dt.timestamp()) *
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_dt), __pyx_n_s_timestamp); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __pyx_t_5 = __Pyx_PyInt_As_int64_t(__pyx_t_1); if (unlikely((__pyx_t_5 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 352, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+0353: <int64_t>(1000000000) +
__pyx_r = ((((int64_t)__pyx_t_5) * ((int64_t)0x3B9ACA00)) + ((int64_t)(__pyx_t_4 * 0x3E8))); goto __pyx_L0;
+0354: <int64_t>(dt.microsecond * 1000))
__pyx_t_4 = __pyx_f_7cpython_8datetime_8datetime_11microsecond_microsecond(__pyx_v_dt); if (unlikely(__pyx_t_4 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 354, __pyx_L1_error)
0355:
0356:
+0357: cdef class TimestampMicros:
struct __pyx_obj_7questdb_7ingress_TimestampMicros { PyObject_HEAD int64_t _value; };
0358: """
0359: A timestamp in microseconds since the UNIX epoch (UTC).
0360:
0361: You may construct a ``TimestampMicros`` from an integer or a
0362: ``datetime.datetime``, or simply call the :func:`TimestampMicros.now`
0363: method.
0364:
0365: .. code-block:: python
0366:
0367: # Recommended way to get the current timestamp.
0368: TimestampMicros.now()
0369:
0370: # The above is equivalent to:
0371: TimestampMicros(time.time_ns() // 1000)
0372:
0373: # You can provide a numeric timestamp too. It can't be negative.
0374: TimestampMicros(1657888365426838)
0375:
0376: ``TimestampMicros`` can also be constructed from a ``datetime.datetime``
0377: object.
0378:
0379: .. code-block:: python
0380:
0381: TimestampMicros.from_datetime(
0382: datetime.datetime.now(tz=datetime.timezone.utc))
0383:
0384: We recommend that when using ``datetime`` objects, you explicitly pass in
0385: the timezone to use. This is because ``datetime`` objects without an
0386: associated timezone are assumed to be in the local timezone and it is easy
0387: to make mistakes (e.g. passing ``datetime.datetime.utcnow()`` is a likely
0388: bug).
0389: """
0390: cdef int64_t _value
0391:
+0392: def __cinit__(self, value: int):
/* Python wrapper */ static int __pyx_pw_7questdb_7ingress_15TimestampMicros_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7questdb_7ingress_15TimestampMicros_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_value = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 392, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__cinit__") < 0)) __PYX_ERR(0, 392, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); } __pyx_v_value = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 392, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.TimestampMicros.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyInt_Type), 0, "value", 1))) __PYX_ERR(0, 392, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_15TimestampMicros___cinit__(((struct __pyx_obj_7questdb_7ingress_TimestampMicros *)__pyx_v_self), __pyx_v_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7questdb_7ingress_15TimestampMicros___cinit__(struct __pyx_obj_7questdb_7ingress_TimestampMicros *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.TimestampMicros.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0393: if value < 0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 393, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+0394: raise ValueError('value must be a positive integer.')
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 394, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 394, __pyx_L1_error) /* … */ __pyx_tuple__30 = PyTuple_Pack(1, __pyx_kp_u_value_must_be_a_positive_integer); if (unlikely(!__pyx_tuple__30)) __PYX_ERR(0, 394, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__30); __Pyx_GIVEREF(__pyx_tuple__30);
+0395: self._value = value
__pyx_t_3 = __Pyx_PyInt_As_int64_t(__pyx_v_value); if (unlikely((__pyx_t_3 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 395, __pyx_L1_error) __pyx_v_self->_value = __pyx_t_3;
0396:
+0397: @classmethod
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_3from_datetime(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_15TimestampMicros_2from_datetime, "\n Construct a ``TimestampMicros`` from a ``datetime.datetime`` object.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_15TimestampMicros_3from_datetime = {"from_datetime", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_15TimestampMicros_3from_datetime, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_15TimestampMicros_2from_datetime}; static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_3from_datetime(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyDateTime_DateTime *__pyx_v_dt = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("from_datetime (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dt)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 397, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "from_datetime") < 0)) __PYX_ERR(0, 397, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_dt = ((PyDateTime_DateTime *)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("from_datetime", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 397, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.TimestampMicros.from_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_7cpython_8datetime_datetime, 0, "dt", 0))) __PYX_ERR(0, 398, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_15TimestampMicros_2from_datetime(((PyTypeObject*)__pyx_v_cls), __pyx_v_dt); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_15TimestampMicros_2from_datetime(PyTypeObject *__pyx_v_cls, PyDateTime_DateTime *__pyx_v_dt) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.TimestampMicros.from_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__47 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_dt); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__47); __Pyx_GIVEREF(__pyx_tuple__47); /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_dt, __pyx_n_s_datetime) < 0) __PYX_ERR(0, 397, __pyx_L1_error) __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_15TimestampMicros_3from_datetime, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_TimestampMicros_from_datetime, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__48)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_17, __pyx_t_18); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_from_datetime, __pyx_t_17) < 0) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampMicros); __Pyx_GetNameInClass(__pyx_t_17, (PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_from_datetime); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_Method_ClassMethod(__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_from_datetime, __pyx_t_18) < 0) __PYX_ERR(0, 397, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampMicros); __pyx_codeobj__48 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_from_datetime, 397, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__48)) __PYX_ERR(0, 397, __pyx_L1_error)
0398: def from_datetime(cls, dt: datetime):
0399: """
0400: Construct a ``TimestampMicros`` from a ``datetime.datetime`` object.
0401: """
+0402: if not isinstance(dt, datetime):
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_dt), __pyx_ptype_7cpython_8datetime_datetime);
__pyx_t_2 = (!__pyx_t_1);
if (unlikely(__pyx_t_2)) {
/* … */
}
+0403: raise TypeError('dt must be a datetime object.')
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 403, __pyx_L1_error) /* … */ __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_u_dt_must_be_a_datetime_object); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 403, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__31); __Pyx_GIVEREF(__pyx_tuple__31);
+0404: return cls(datetime_to_micros(dt))
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __pyx_f_7questdb_7ingress_datetime_to_micros(__pyx_v_dt); if (unlikely(__pyx_t_4 == ((int64_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 404, __pyx_L1_error) __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_v_cls), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 404, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
0405:
+0406: @classmethod
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_5now(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_15TimestampMicros_4now, "\n Construct a ``TimestampMicros`` from the current time as UTC.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_15TimestampMicros_5now = {"now", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_15TimestampMicros_5now, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_15TimestampMicros_4now}; static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_5now(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("now (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("now", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "now", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_15TimestampMicros_4now(((PyTypeObject*)__pyx_v_cls)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_15TimestampMicros_4now(PyTypeObject *__pyx_v_cls) { int64_t __pyx_v_value; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.TimestampMicros.now", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__49 = PyTuple_Pack(2, __pyx_n_s_cls, __pyx_n_s_value); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__49); __Pyx_GIVEREF(__pyx_tuple__49); /* … */ __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_15TimestampMicros_5now, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_TimestampMicros_now, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__50)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_now, __pyx_t_18) < 0) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampMicros); __Pyx_GetNameInClass(__pyx_t_18, (PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_now); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = __Pyx_Method_ClassMethod(__pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampMicros, __pyx_n_s_now, __pyx_t_17) < 0) __PYX_ERR(0, 406, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampMicros); __pyx_codeobj__50 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_now, 406, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__50)) __PYX_ERR(0, 406, __pyx_L1_error)
0407: def now(cls):
0408: """
0409: Construct a ``TimestampMicros`` from the current time as UTC.
0410: """
+0411: cdef int64_t value = line_sender_now_micros()
__pyx_v_value = line_sender_now_micros();
+0412: return cls(value)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_v_cls), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 412, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0413:
+0414: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_5value_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_5value_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_15TimestampMicros_5value___get__(((struct __pyx_obj_7questdb_7ingress_TimestampMicros *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_15TimestampMicros_5value___get__(struct __pyx_obj_7questdb_7ingress_TimestampMicros *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.TimestampMicros.value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0415: def value(self) -> int:
0416: """Number of microseconds (Unix epoch timestamp, UTC)."""
+0417: return self._value
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 417, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0418:
+0419: def __repr__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_7__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_15TimestampMicros_7__repr__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_15TimestampMicros_6__repr__(((struct __pyx_obj_7questdb_7ingress_TimestampMicros *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_15TimestampMicros_6__repr__(struct __pyx_obj_7questdb_7ingress_TimestampMicros *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.TimestampMicros.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0420: return f'TimestampMicros.({self._value})'
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 127; __Pyx_INCREF(__pyx_kp_u_TimestampMicros); __pyx_t_2 += 17; __Pyx_GIVEREF(__pyx_kp_u_TimestampMicros); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_TimestampMicros); __pyx_t_4 = __Pyx_PyInt_From_int64_t(__pyx_v_self->_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__12); __pyx_t_2 += 1; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__12); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 420, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
0421:
0422:
+0423: cdef class TimestampNanos:
struct __pyx_obj_7questdb_7ingress_TimestampNanos { PyObject_HEAD int64_t _value; };
0424: """
0425: A timestamp in nanoseconds since the UNIX epoch (UTC).
0426:
0427: You may construct a ``TimestampNanos`` from an integer or a
0428: ``datetime.datetime``, or simply call the :func:`TimestampNanos.now`
0429: method.
0430:
0431: .. code-block:: python
0432:
0433: # Recommended way to get the current timestamp.
0434: TimestampNanos.now()
0435:
0436: # The above is equivalent to:
0437: TimestampNanos(time.time_ns())
0438:
0439: # You can provide a numeric timestamp too. It can't be negative.
0440: TimestampNanos(1657888365426838016)
0441:
0442: ``TimestampNanos`` can also be constructed from a ``datetime`` object.
0443:
0444: .. code-block:: python
0445:
0446: TimestampNanos.from_datetime(
0447: datetime.datetime.now(tz=datetime.timezone.utc))
0448:
0449: We recommend that when using ``datetime`` objects, you explicitly pass in
0450: the timezone to use. This is because ``datetime`` objects without an
0451: associated timezone are assumed to be in the local timezone and it is easy
0452: to make mistakes (e.g. passing ``datetime.datetime.utcnow()`` is a likely
0453: bug).
0454: """
0455: cdef int64_t _value
0456:
+0457: def __cinit__(self, value: int):
/* Python wrapper */ static int __pyx_pw_7questdb_7ingress_14TimestampNanos_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7questdb_7ingress_14TimestampNanos_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_value = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_value,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_value)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 457, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__cinit__") < 0)) __PYX_ERR(0, 457, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); } __pyx_v_value = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 457, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.TimestampNanos.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_value), (&PyInt_Type), 0, "value", 1))) __PYX_ERR(0, 457, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_14TimestampNanos___cinit__(((struct __pyx_obj_7questdb_7ingress_TimestampNanos *)__pyx_v_self), __pyx_v_value); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7questdb_7ingress_14TimestampNanos___cinit__(struct __pyx_obj_7questdb_7ingress_TimestampNanos *__pyx_v_self, PyObject *__pyx_v_value) { int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.TimestampNanos.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0458: if value < 0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 458, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 458, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+0459: raise ValueError('value must be a positive integer.')
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__30, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 459, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 459, __pyx_L1_error)
+0460: self._value = value
__pyx_t_3 = __Pyx_PyInt_As_int64_t(__pyx_v_value); if (unlikely((__pyx_t_3 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 460, __pyx_L1_error) __pyx_v_self->_value = __pyx_t_3;
0461:
+0462: @classmethod
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_3from_datetime(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_14TimestampNanos_2from_datetime, "\n Construct a ``TimestampNanos`` from a ``datetime.datetime`` object.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_14TimestampNanos_3from_datetime = {"from_datetime", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_14TimestampNanos_3from_datetime, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_14TimestampNanos_2from_datetime}; static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_3from_datetime(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyDateTime_DateTime *__pyx_v_dt = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("from_datetime (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_dt,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_dt)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 462, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "from_datetime") < 0)) __PYX_ERR(0, 462, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_dt = ((PyDateTime_DateTime *)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("from_datetime", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 462, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.TimestampNanos.from_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_dt), __pyx_ptype_7cpython_8datetime_datetime, 0, "dt", 0))) __PYX_ERR(0, 463, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_14TimestampNanos_2from_datetime(((PyTypeObject*)__pyx_v_cls), __pyx_v_dt); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_14TimestampNanos_2from_datetime(PyTypeObject *__pyx_v_cls, PyDateTime_DateTime *__pyx_v_dt) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.TimestampNanos.from_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_17 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_dt, __pyx_n_s_datetime) < 0) __PYX_ERR(0, 462, __pyx_L1_error) __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_14TimestampNanos_3from_datetime, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_TimestampNanos_from_datetime, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__53)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_18, __pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_from_datetime, __pyx_t_18) < 0) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampNanos); __Pyx_GetNameInClass(__pyx_t_18, (PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_from_datetime); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __pyx_t_17 = __Pyx_Method_ClassMethod(__pyx_t_18); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_from_datetime, __pyx_t_17) < 0) __PYX_ERR(0, 462, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampNanos); /* … */ __pyx_codeobj__53 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__47, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_from_datetime, 462, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__53)) __PYX_ERR(0, 462, __pyx_L1_error)
0463: def from_datetime(cls, dt: datetime):
0464: """
0465: Construct a ``TimestampNanos`` from a ``datetime.datetime`` object.
0466: """
+0467: if not isinstance(dt, datetime):
__pyx_t_1 = __Pyx_TypeCheck(((PyObject *)__pyx_v_dt), __pyx_ptype_7cpython_8datetime_datetime);
__pyx_t_2 = (!__pyx_t_1);
if (unlikely(__pyx_t_2)) {
/* … */
}
+0468: raise TypeError('dt must be a datetime object.')
__pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 468, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 468, __pyx_L1_error)
+0469: return cls(datetime_to_nanos(dt))
__Pyx_XDECREF(__pyx_r); __pyx_t_4 = __pyx_f_7questdb_7ingress_datetime_to_nanos(__pyx_v_dt); if (unlikely(__pyx_t_4 == ((int64_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 469, __pyx_L1_error) __pyx_t_3 = __Pyx_PyInt_From_int64_t(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_5 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_v_cls), __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
0470:
+0471: @classmethod
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_5now(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_14TimestampNanos_4now, "\n Construct a ``TimestampNanos`` from the current time as UTC.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_14TimestampNanos_5now = {"now", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_14TimestampNanos_5now, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_14TimestampNanos_4now}; static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_5now(PyObject *__pyx_v_cls, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("now (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("now", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "now", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_14TimestampNanos_4now(((PyTypeObject*)__pyx_v_cls)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_14TimestampNanos_4now(PyTypeObject *__pyx_v_cls) { int64_t __pyx_v_value; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.TimestampNanos.now", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_14TimestampNanos_5now, __Pyx_CYFUNCTION_CLASSMETHOD | __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_TimestampNanos_now, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__54)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_now, __pyx_t_17) < 0) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampNanos); __Pyx_GetNameInClass(__pyx_t_17, (PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_now); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __pyx_t_18 = __Pyx_Method_ClassMethod(__pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_TimestampNanos, __pyx_n_s_now, __pyx_t_18) < 0) __PYX_ERR(0, 471, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_TimestampNanos); /* … */ __pyx_codeobj__54 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__49, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_now, 471, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__54)) __PYX_ERR(0, 471, __pyx_L1_error)
0472: def now(cls):
0473: """
0474: Construct a ``TimestampNanos`` from the current time as UTC.
0475: """
+0476: cdef int64_t value = line_sender_now_nanos()
__pyx_v_value = line_sender_now_nanos();
+0477: return cls(value)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)__pyx_v_cls), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
0478:
+0479: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_5value_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_5value_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_14TimestampNanos_5value___get__(((struct __pyx_obj_7questdb_7ingress_TimestampNanos *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_14TimestampNanos_5value___get__(struct __pyx_obj_7questdb_7ingress_TimestampNanos *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.TimestampNanos.value.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0480: def value(self) -> int:
0481: """Number of nanoseconds (Unix epoch timestamp, UTC)."""
+0482: return self._value
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_From_int64_t(__pyx_v_self->_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0483:
+0484: def __repr__(self):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_7__repr__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_14TimestampNanos_7__repr__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_14TimestampNanos_6__repr__(((struct __pyx_obj_7questdb_7ingress_TimestampNanos *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_14TimestampNanos_6__repr__(struct __pyx_obj_7questdb_7ingress_TimestampNanos *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.TimestampNanos.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0485: return f'TimestampNanos({self.value})'
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = 0; __pyx_t_3 = 127; __Pyx_INCREF(__pyx_kp_u_TimestampNanos); __pyx_t_2 += 15; __Pyx_GIVEREF(__pyx_kp_u_TimestampNanos); PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_u_TimestampNanos); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_4, __pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) > __pyx_t_3) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) : __pyx_t_3; __pyx_t_2 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_5); __pyx_t_5 = 0; __Pyx_INCREF(__pyx_kp_u__12); __pyx_t_2 += 1; __Pyx_GIVEREF(__pyx_kp_u__12); PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_kp_u__12); __pyx_t_5 = __Pyx_PyUnicode_Join(__pyx_t_1, 3, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 485, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L0;
0486:
0487:
+0488: cdef class Sender
struct __pyx_obj_7questdb_7ingress_Sender { PyObject_HEAD struct __pyx_vtabstruct_7questdb_7ingress_Sender *__pyx_vtab; PyObject *__weakref__; struct line_sender_opts *_opts; struct line_sender *_impl; struct __pyx_obj_7questdb_7ingress_Buffer *_buffer; int _auto_flush_enabled; Py_ssize_t _auto_flush_watermark; size_t _init_capacity; size_t _max_name_len; };
+0489: cdef class Buffer
struct __pyx_obj_7questdb_7ingress_Buffer { PyObject_HEAD struct __pyx_vtabstruct_7questdb_7ingress_Buffer *__pyx_vtab; struct line_sender_buffer *_impl; struct qdb_pystr_buf *_b; size_t _init_capacity; size_t _max_name_len; PyObject *_row_complete_sender; };
0490:
0491:
+0492: cdef void_int may_flush_on_row_complete(Buffer buffer, Sender sender) except -1:
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_may_flush_on_row_complete(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_buffer, struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_sender) { __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.may_flush_on_row_complete", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0493: if sender._auto_flush_enabled:
if (__pyx_v_sender->_auto_flush_enabled) { /* … */ }
+0494: if len(buffer) >= sender._auto_flush_watermark:
__pyx_t_1 = PyObject_Length(((PyObject *)__pyx_v_buffer)); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 494, __pyx_L1_error) __pyx_t_2 = (__pyx_t_1 >= __pyx_v_sender->_auto_flush_watermark); if (__pyx_t_2) { /* … */ }
+0495: sender.flush(buffer)
__pyx_t_4.__pyx_n = 1; __pyx_t_4.buffer = __pyx_v_buffer; __pyx_t_3 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_sender->__pyx_vtab)->flush(__pyx_v_sender, 0, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 495, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0496:
0497:
+0498: cdef class Buffer:
struct __pyx_vtabstruct_7questdb_7ingress_Buffer { PyObject *(*_cinit_impl)(struct __pyx_obj_7questdb_7ingress_Buffer *, size_t, size_t); PyObject *(*_to_str)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_set_marker)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_rewind_to_marker)(struct __pyx_obj_7questdb_7ingress_Buffer *); PyObject *(*_clear_marker)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_table)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyObject *); struct qdb_pystr_buf *(*_cleared_b)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_symbol)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyObject *, PyObject *); __pyx_t_7questdb_7ingress_void_int (*_column_bool)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, int); __pyx_t_7questdb_7ingress_void_int (*_column_i64)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, int64_t); __pyx_t_7questdb_7ingress_void_int (*_column_f64)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, double); __pyx_t_7questdb_7ingress_void_int (*_column_str)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, PyObject *); __pyx_t_7questdb_7ingress_void_int (*_column_ts)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, struct __pyx_obj_7questdb_7ingress_TimestampMicros *); __pyx_t_7questdb_7ingress_void_int (*_column_dt)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct line_sender_column_name, PyDateTime_DateTime *); __pyx_t_7questdb_7ingress_void_int (*_column)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyObject *, PyObject *); __pyx_t_7questdb_7ingress_void_int (*_may_trigger_row_complete)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_at_ts)(struct __pyx_obj_7questdb_7ingress_Buffer *, struct __pyx_obj_7questdb_7ingress_TimestampNanos *); __pyx_t_7questdb_7ingress_void_int (*_at_dt)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyDateTime_DateTime *); __pyx_t_7questdb_7ingress_void_int (*_at_now)(struct __pyx_obj_7questdb_7ingress_Buffer *); __pyx_t_7questdb_7ingress_void_int (*_at)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyObject *); __pyx_t_7questdb_7ingress_void_int (*_row)(struct __pyx_obj_7questdb_7ingress_Buffer *, PyObject *, struct __pyx_opt_args_7questdb_7ingress_6Buffer__row *__pyx_optional_args); }; static struct __pyx_vtabstruct_7questdb_7ingress_Buffer *__pyx_vtabptr_7questdb_7ingress_Buffer;
0499: """
0500: Construct QuestDB-flavored InfluxDB Line Protocol (ILP) messages.
0501:
0502: The :func:`Buffer.row` method is used to add a row to the buffer.
0503:
0504: You can call this many times.
0505:
0506: .. code-block:: python
0507:
0508: from questdb.ingress import Buffer
0509:
0510: buf = Buffer()
0511: buf.row(
0512: 'table_name1',
0513: symbols={'s1', 'v1', 's2', 'v2'},
0514: columns={'c1': True, 'c2': 0.5})
0515:
0516: buf.row(
0517: 'table_name2',
0518: symbols={'questdb': '❤️'},
0519: columns={'like': 100000})
0520:
0521: # Append any additional rows then, once ready, call
0522: sender.flush(buffer) # a `Sender` instance.
0523:
0524: # The sender auto-cleared the buffer, ready for reuse.
0525:
0526: buf.row(
0527: 'table_name1',
0528: symbols={'s1', 'v1', 's2', 'v2'},
0529: columns={'c1': True, 'c2': 0.5})
0530:
0531: # etc.
0532:
0533:
0534: Buffer Constructor Arguments:
0535: * ``init_capacity`` (``int``): Initial capacity of the buffer in bytes.
0536: Defaults to ``65536`` (64KiB).
0537: * ``max_name_len`` (``int``): Maximum length of a column name.
0538: Defaults to ``127`` which is the same default value as QuestDB.
0539: This should match the ``cairo.max.file.name.length`` setting of the
0540: QuestDB instance you're connecting to.
0541:
0542: .. code-block:: python
0543:
0544: # These two buffer constructions are equivalent.
0545: buf1 = Buffer()
0546: buf2 = Buffer(init_capacity=65536, max_name_len=127)
0547:
0548: To avoid having to manually set these arguments every time, you can call
0549: the sender's ``new_buffer()`` method instead.
0550:
0551: .. code-block:: python
0552:
0553: from questdb.ingress import Sender, Buffer
0554:
0555: sender = Sender(host='localhost', port=9009,
0556: init_capacity=16384, max_name_len=64)
0557: buf = sender.new_buffer()
0558: assert buf.init_capacity == 16384
0559: assert buf.max_name_len == 64
0560:
0561: """
0562: cdef line_sender_buffer* _impl
0563: cdef qdb_pystr_buf* _b
0564: cdef size_t _init_capacity
0565: cdef size_t _max_name_len
0566: cdef object _row_complete_sender
0567:
+0568: def __cinit__(self, init_capacity: int=65536, max_name_len: int=127):
/* Python wrapper */ static int __pyx_pw_7questdb_7ingress_6Buffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7questdb_7ingress_6Buffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_init_capacity = 0; PyObject *__pyx_v_max_name_len = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_init_capacity,&__pyx_n_s_max_name_len,0}; PyObject* values[2] = {0,0}; values[0] = __Pyx_Arg_NewRef_VARARGS(__pyx_k__32); values[1] = __Pyx_Arg_NewRef_VARARGS(__pyx_k__33); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_init_capacity); if (value) { values[0] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 568, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_max_name_len); if (value) { values[1] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 568, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__cinit__") < 0)) __PYX_ERR(0, 568, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_init_capacity = ((PyObject*)values[0]); __pyx_v_max_name_len = ((PyObject*)values[1]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 568, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Buffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_init_capacity), (&PyInt_Type), 0, "init_capacity", 1))) __PYX_ERR(0, 568, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_max_name_len), (&PyInt_Type), 0, "max_name_len", 1))) __PYX_ERR(0, 568, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer___cinit__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self), __pyx_v_init_capacity, __pyx_v_max_name_len); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7questdb_7ingress_6Buffer___cinit__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_init_capacity, PyObject *__pyx_v_max_name_len) { int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.Buffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_65536)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_65536))) __PYX_ERR(0, 568, __pyx_L1_error) __Pyx_INCREF(__pyx_int_65536); __pyx_k__32 = ((PyObject*)__pyx_int_65536); __Pyx_GIVEREF(__pyx_int_65536); if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_int_127)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_int_127))) __PYX_ERR(0, 568, __pyx_L1_error) __Pyx_INCREF(__pyx_int_127); __pyx_k__33 = ((PyObject*)__pyx_int_127); __Pyx_GIVEREF(__pyx_int_127);
0569: """
0570: Create a new buffer with the an initial capacity and max name length.
0571: :param int init_capacity: Initial capacity of the buffer in bytes.
0572: :param int max_name_len: Maximum length of a table or column name.
0573: """
+0574: self._cinit_impl(init_capacity, max_name_len)
__pyx_t_1 = __Pyx_PyInt_As_size_t(__pyx_v_init_capacity); if (unlikely((__pyx_t_1 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 574, __pyx_L1_error) __pyx_t_2 = __Pyx_PyInt_As_size_t(__pyx_v_max_name_len); if (unlikely((__pyx_t_2 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 574, __pyx_L1_error) __pyx_t_3 = __pyx_f_7questdb_7ingress_6Buffer__cinit_impl(__pyx_v_self, __pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 574, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
0575:
+0576: cdef inline _cinit_impl(self, size_t init_capacity, size_t max_name_len):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_6Buffer__cinit_impl(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, size_t __pyx_v_init_capacity, size_t __pyx_v_max_name_len) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0577: self._impl = line_sender_buffer_with_max_name_len(max_name_len)
__pyx_v_self->_impl = line_sender_buffer_with_max_name_len(__pyx_v_max_name_len);
+0578: self._b = qdb_pystr_buf_new()
__pyx_v_self->_b = qdb_pystr_buf_new();
+0579: line_sender_buffer_reserve(self._impl, init_capacity)
line_sender_buffer_reserve(__pyx_v_self->_impl, __pyx_v_init_capacity);
+0580: self._init_capacity = init_capacity
__pyx_v_self->_init_capacity = __pyx_v_init_capacity;
+0581: self._max_name_len = max_name_len
__pyx_v_self->_max_name_len = __pyx_v_max_name_len;
+0582: self._row_complete_sender = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_row_complete_sender); __Pyx_DECREF(__pyx_v_self->_row_complete_sender); __pyx_v_self->_row_complete_sender = Py_None;
0583:
+0584: def __dealloc__(self):
/* Python wrapper */ static void __pyx_pw_7questdb_7ingress_6Buffer_3__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_7questdb_7ingress_6Buffer_3__dealloc__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_pf_7questdb_7ingress_6Buffer_2__dealloc__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_7questdb_7ingress_6Buffer_2__dealloc__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { /* … */ /* function exit code */ __Pyx_RefNannyFinishContext(); }
+0585: self._row_complete_sender = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF(__pyx_v_self->_row_complete_sender); __Pyx_DECREF(__pyx_v_self->_row_complete_sender); __pyx_v_self->_row_complete_sender = Py_None;
+0586: qdb_pystr_buf_free(self._b)
qdb_pystr_buf_free(__pyx_v_self->_b);
+0587: line_sender_buffer_free(self._impl)
line_sender_buffer_free(__pyx_v_self->_impl);
0588:
+0589: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_13init_capacity_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_13init_capacity_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_13init_capacity___get__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_13init_capacity___get__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer.init_capacity.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0590: def init_capacity(self) -> int:
0591: """
0592: The initial capacity of the buffer when first created.
0593:
0594: This may grow over time, see ``capacity()``.
0595: """
+0596: return self._init_capacity
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_init_capacity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 596, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0597:
0598: @property
0599: def max_name_len(self) -> int:
0600: """Maximum length of a table or column name."""
0601: return self._max_name_len
0602:
+0603: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_12max_name_len_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_12max_name_len_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_12max_name_len___get__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_12max_name_len___get__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer.max_name_len.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0604: def max_name_len(self) -> int:
0605: """Maximum length of a table or column name."""
+0606: return self._max_name_len
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_max_name_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 606, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0607:
+0608: def reserve(self, additional: int):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_5reserve(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_4reserve, "\n Ensure the buffer has at least `additional` bytes of future capacity.\n\n :param int additional: Additional bytes to reserve.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Buffer_5reserve = {"reserve", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Buffer_5reserve, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Buffer_4reserve}; static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_5reserve(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_additional = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("reserve (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_additional,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_additional)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 608, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "reserve") < 0)) __PYX_ERR(0, 608, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_additional = ((PyObject*)values[0]); } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("reserve", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 608, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Buffer.reserve", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_additional), (&PyInt_Type), 0, "additional", 1))) __PYX_ERR(0, 608, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_4reserve(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self), __pyx_v_additional); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_4reserve(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_additional) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer.reserve", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__57 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_additional); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__57); __Pyx_GIVEREF(__pyx_tuple__57); /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_additional, __pyx_n_s_int) < 0) __PYX_ERR(0, 608, __pyx_L1_error) __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Buffer_5reserve, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Buffer_reserve, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__58)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_17, __pyx_t_18); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer, __pyx_n_s_reserve, __pyx_t_17) < 0) __PYX_ERR(0, 608, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Buffer); __pyx_codeobj__58 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__57, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_reserve, 608, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__58)) __PYX_ERR(0, 608, __pyx_L1_error)
0609: """
0610: Ensure the buffer has at least `additional` bytes of future capacity.
0611:
0612: :param int additional: Additional bytes to reserve.
0613: """
+0614: if additional < 0:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_additional, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 614, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 614, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (unlikely(__pyx_t_2)) { /* … */ }
+0615: raise ValueError('additional must be non-negative.')
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__34, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 615, __pyx_L1_error) /* … */ __pyx_tuple__34 = PyTuple_Pack(1, __pyx_kp_u_additional_must_be_non_negative); if (unlikely(!__pyx_tuple__34)) __PYX_ERR(0, 615, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__34); __Pyx_GIVEREF(__pyx_tuple__34);
+0616: line_sender_buffer_reserve(self._impl, additional)
__pyx_t_3 = __Pyx_PyInt_As_size_t(__pyx_v_additional); if (unlikely((__pyx_t_3 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 616, __pyx_L1_error) line_sender_buffer_reserve(__pyx_v_self->_impl, __pyx_t_3);
0617:
+0618: def capacity(self) -> int:
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_7capacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_6capacity, "The current buffer capacity."); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Buffer_7capacity = {"capacity", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Buffer_7capacity, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Buffer_6capacity}; static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_7capacity(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("capacity (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("capacity", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "capacity", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_6capacity(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_6capacity(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer.capacity", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_17 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_return, __pyx_n_s_int) < 0) __PYX_ERR(0, 618, __pyx_L1_error) __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Buffer_7capacity, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Buffer_capacity, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__59)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_18, __pyx_t_17); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer, __pyx_n_s_capacity, __pyx_t_18) < 0) __PYX_ERR(0, 618, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Buffer); /* … */ __pyx_codeobj__59 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_capacity, 618, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__59)) __PYX_ERR(0, 618, __pyx_L1_error)
0619: """The current buffer capacity."""
+0620: return line_sender_buffer_capacity(self._impl)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(line_sender_buffer_capacity(__pyx_v_self->_impl)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(__Pyx_Py3Int_CheckExact(__pyx_t_1)) || __Pyx_RaiseUnexpectedTypeError("int", __pyx_t_1))) __PYX_ERR(0, 620, __pyx_L1_error) __pyx_r = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0;
0621:
+0622: def clear(self):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_9clear(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_8clear, "\n Reset the buffer.\n\n Note that flushing a buffer will (unless otherwise specified)\n also automatically clear it.\n\n This method is designed to be called only in conjunction with\n ``sender.flush(buffer, clear=False)``.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Buffer_9clear = {"clear", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Buffer_9clear, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Buffer_8clear}; static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_9clear(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("clear (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("clear", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "clear", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_8clear(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_8clear(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Buffer_9clear, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Buffer_clear, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__60)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer, __pyx_n_s_clear, __pyx_t_18) < 0) __PYX_ERR(0, 622, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Buffer); /* … */ __pyx_codeobj__60 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_clear, 622, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__60)) __PYX_ERR(0, 622, __pyx_L1_error)
0623: """
0624: Reset the buffer.
0625:
0626: Note that flushing a buffer will (unless otherwise specified)
0627: also automatically clear it.
0628:
0629: This method is designed to be called only in conjunction with
0630: ``sender.flush(buffer, clear=False)``.
0631: """
+0632: line_sender_buffer_clear(self._impl)
line_sender_buffer_clear(__pyx_v_self->_impl);
+0633: qdb_pystr_buf_clear(self._b)
qdb_pystr_buf_clear(__pyx_v_self->_b);
0634:
+0635: def __len__(self) -> int:
/* Python wrapper */ static Py_ssize_t __pyx_pw_7questdb_7ingress_6Buffer_11__len__(PyObject *__pyx_v_self); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_10__len__, "\n The current number of bytes currently in the buffer.\n\n Equivalent (but cheaper) to ``len(str(sender))``.\n "); #if CYTHON_UPDATE_DESCRIPTOR_DOC struct wrapperbase __pyx_wrapperbase_7questdb_7ingress_6Buffer_10__len__; #endif static Py_ssize_t __pyx_pw_7questdb_7ingress_6Buffer_11__len__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_10__len__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static Py_ssize_t __pyx_pf_7questdb_7ingress_6Buffer_10__len__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { Py_ssize_t __pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
0636: """
0637: The current number of bytes currently in the buffer.
0638:
0639: Equivalent (but cheaper) to ``len(str(sender))``.
0640: """
+0641: return line_sender_buffer_size(self._impl)
__pyx_r = line_sender_buffer_size(__pyx_v_self->_impl); goto __pyx_L0;
0642:
+0643: def __str__(self) -> str:
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_13__str__(PyObject *__pyx_v_self); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_12__str__, "Return the constructed buffer as a string. Use for debugging."); #if CYTHON_UPDATE_DESCRIPTOR_DOC struct wrapperbase __pyx_wrapperbase_7questdb_7ingress_6Buffer_12__str__; #endif static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_13__str__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_12__str__(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_12__str__(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0644: """Return the constructed buffer as a string. Use for debugging."""
+0645: return self._to_str()
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__to_str(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 645, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0646:
+0647: cdef inline object _to_str(self):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_6Buffer__to_str(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { size_t __pyx_v_size; char const *__pyx_v_utf8; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer._to_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0648: cdef size_t size = 0
__pyx_v_size = 0;
+0649: cdef const char* utf8 = line_sender_buffer_peek(self._impl, &size)
__pyx_v_utf8 = line_sender_buffer_peek(__pyx_v_self->_impl, (&__pyx_v_size));
+0650: return PyUnicode_FromStringAndSize(utf8, <Py_ssize_t>size)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = PyUnicode_FromStringAndSize(__pyx_v_utf8, ((Py_ssize_t)__pyx_v_size)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 650, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
0651:
+0652: cdef inline void_int _set_marker(self) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__set_marker(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._set_marker", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0653: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0654: if not line_sender_buffer_set_marker(self._impl, &err):
__pyx_t_1 = (!line_sender_buffer_set_marker(__pyx_v_self->_impl, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0655: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 655, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 655, __pyx_L1_error)
0656:
+0657: cdef inline void_int _rewind_to_marker(self) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__rewind_to_marker(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._rewind_to_marker", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0658: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0659: if not line_sender_buffer_rewind_to_marker(self._impl, &err):
__pyx_t_1 = (!line_sender_buffer_rewind_to_marker(__pyx_v_self->_impl, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0660: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 660, __pyx_L1_error)
0661:
+0662: cdef inline _clear_marker(self):
static CYTHON_INLINE PyObject *__pyx_f_7questdb_7ingress_6Buffer__clear_marker(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0663: line_sender_buffer_clear_marker(self._impl)
line_sender_buffer_clear_marker(__pyx_v_self->_impl);
0664:
+0665: cdef inline void_int _table(self, str table_name) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__table(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_table_name) { struct line_sender_error *__pyx_v_err; struct line_sender_table_name __pyx_v_c_table_name; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("questdb.ingress.Buffer._table", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0666: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0667: cdef line_sender_table_name c_table_name
+0668: str_to_table_name(
__pyx_t_2 = __pyx_f_7questdb_7ingress_str_to_table_name(__pyx_t_1, ((PyObject *)__pyx_v_table_name), (&__pyx_v_c_table_name)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 668, __pyx_L1_error)
+0669: self._cleared_b(), <PyObject*>table_name, &c_table_name)
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__cleared_b(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 669, __pyx_L1_error)
+0670: if not line_sender_buffer_table(self._impl, c_table_name, &err):
__pyx_t_3 = (!line_sender_buffer_table(__pyx_v_self->_impl, __pyx_v_c_table_name, (&__pyx_v_err))); if (unlikely(__pyx_t_3)) { /* … */ }
+0671: raise c_err_to_py(err)
__pyx_t_4 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 671, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 671, __pyx_L1_error)
0672:
+0673: cdef inline qdb_pystr_buf* _cleared_b(self):
static CYTHON_INLINE struct qdb_pystr_buf *__pyx_f_7questdb_7ingress_6Buffer__cleared_b(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { struct qdb_pystr_buf *__pyx_r; /* … */ /* function exit code */ __pyx_L0:; return __pyx_r; }
+0674: qdb_pystr_buf_clear(self._b)
qdb_pystr_buf_clear(__pyx_v_self->_b);
+0675: return self._b
__pyx_r = __pyx_v_self->_b; goto __pyx_L0;
0676:
+0677: cdef inline void_int _symbol(self, str name, str value) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__symbol(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) { struct line_sender_error *__pyx_v_err; struct line_sender_column_name __pyx_v_c_name; struct line_sender_utf8 __pyx_v_c_value; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("questdb.ingress.Buffer._symbol", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0678: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0679: cdef line_sender_column_name c_name
0680: cdef line_sender_utf8 c_value
+0681: str_to_column_name(self._cleared_b(), name, &c_name)
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__cleared_b(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 681, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_str_to_column_name(__pyx_t_1, __pyx_v_name, (&__pyx_v_c_name)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 681, __pyx_L1_error)
+0682: str_to_utf8(self._b, <PyObject*>value, &c_value)
__pyx_t_2 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_self->_b, ((PyObject *)__pyx_v_value), (&__pyx_v_c_value)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 682, __pyx_L1_error)
+0683: if not line_sender_buffer_symbol(self._impl, c_name, c_value, &err):
__pyx_t_3 = (!line_sender_buffer_symbol(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_c_value, (&__pyx_v_err))); if (unlikely(__pyx_t_3)) { /* … */ }
+0684: raise c_err_to_py(err)
__pyx_t_4 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 684, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 684, __pyx_L1_error)
0685:
+0686: cdef inline void_int _column_bool(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_bool(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, int __pyx_v_value) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._column_bool", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0687: self, line_sender_column_name c_name, bint value) except -1:
+0688: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0689: if not line_sender_buffer_column_bool(self._impl, c_name, value, &err):
__pyx_t_1 = (!line_sender_buffer_column_bool(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_value, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0690: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 690, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 690, __pyx_L1_error)
0691:
+0692: cdef inline void_int _column_i64(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_i64(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, int64_t __pyx_v_value) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._column_i64", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0693: self, line_sender_column_name c_name, int64_t value) except -1:
+0694: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0695: if not line_sender_buffer_column_i64(self._impl, c_name, value, &err):
__pyx_t_1 = (!line_sender_buffer_column_i64(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_value, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0696: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 696, __pyx_L1_error)
+0697: return 0
__pyx_r = 0; goto __pyx_L0;
0698:
+0699: cdef inline void_int _column_f64(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_f64(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, double __pyx_v_value) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._column_f64", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0700: self, line_sender_column_name c_name, double value) except -1:
+0701: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0702: if not line_sender_buffer_column_f64(self._impl, c_name, value, &err):
__pyx_t_1 = (!line_sender_buffer_column_f64(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_value, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0703: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 703, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 703, __pyx_L1_error)
0704:
+0705: cdef inline void_int _column_str(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_str(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, PyObject *__pyx_v_value) { struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_c_value; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.Buffer._column_str", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0706: self, line_sender_column_name c_name, str value) except -1:
+0707: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
0708: cdef line_sender_utf8 c_value
+0709: str_to_utf8(self._b, <PyObject*>value, &c_value)
__pyx_t_1 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_self->_b, ((PyObject *)__pyx_v_value), (&__pyx_v_c_value)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 709, __pyx_L1_error)
+0710: if not line_sender_buffer_column_str(self._impl, c_name, c_value, &err):
__pyx_t_2 = (!line_sender_buffer_column_str(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_c_value, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0711: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 711, __pyx_L1_error)
0712:
+0713: cdef inline void_int _column_ts(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_ts(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, struct __pyx_obj_7questdb_7ingress_TimestampMicros *__pyx_v_ts) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._column_ts", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0714: self, line_sender_column_name c_name, TimestampMicros ts) except -1:
+0715: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0716: if not line_sender_buffer_column_ts_micros(self._impl, c_name, ts._value, &err):
__pyx_t_1 = (!line_sender_buffer_column_ts_micros(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_v_ts->_value, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0717: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 717, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 717, __pyx_L1_error)
0718:
+0719: cdef inline void_int _column_dt(
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column_dt(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct line_sender_column_name __pyx_v_c_name, PyDateTime_DateTime *__pyx_v_dt) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.Buffer._column_dt", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
0720: self, line_sender_column_name c_name, datetime dt) except -1:
+0721: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0722: if not line_sender_buffer_column_ts_micros(
__pyx_t_2 = (!line_sender_buffer_column_ts_micros(__pyx_v_self->_impl, __pyx_v_c_name, __pyx_t_1, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0723: self._impl, c_name, datetime_to_micros(dt), &err):
__pyx_t_1 = __pyx_f_7questdb_7ingress_datetime_to_micros(__pyx_v_dt); if (unlikely(__pyx_t_1 == ((int64_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 723, __pyx_L1_error)
+0724: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 724, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 724, __pyx_L1_error)
0725:
+0726: cdef inline void_int _column(self, str name, object value) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__column(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_value) { struct line_sender_column_name __pyx_v_c_name; PyObject *__pyx_v_valid = NULL; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("questdb.ingress.Buffer._column", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_valid); __Pyx_RefNannyFinishContext(); return __pyx_r; }
0727: cdef line_sender_column_name c_name
+0728: str_to_column_name(self._cleared_b(), name, &c_name)
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__cleared_b(__pyx_v_self); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 728, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_str_to_column_name(__pyx_t_1, __pyx_v_name, (&__pyx_v_c_name)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 728, __pyx_L1_error)
+0729: if PyBool_Check(<PyObject*>value):
__pyx_t_3 = PyBool_Check(((PyObject *)__pyx_v_value));
if (__pyx_t_3) {
/* … */
goto __pyx_L3;
}
+0730: self._column_bool(c_name, value)
__pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 730, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_bool(__pyx_v_self, __pyx_v_c_name, __pyx_t_3); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 730, __pyx_L1_error)
+0731: elif PyLong_CheckExact(<PyObject*>value):
__pyx_t_3 = PyLong_CheckExact(((PyObject *)__pyx_v_value));
if (__pyx_t_3) {
/* … */
goto __pyx_L3;
}
+0732: self._column_i64(c_name, value)
__pyx_t_4 = __Pyx_PyInt_As_int64_t(__pyx_v_value); if (unlikely((__pyx_t_4 == ((int64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 732, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_i64(__pyx_v_self, __pyx_v_c_name, __pyx_t_4); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 732, __pyx_L1_error)
+0733: elif PyFloat_CheckExact(<PyObject*>value):
__pyx_t_3 = PyFloat_CheckExact(((PyObject *)__pyx_v_value));
if (__pyx_t_3) {
/* … */
goto __pyx_L3;
}
+0734: self._column_f64(c_name, value)
__pyx_t_5 = __pyx_PyFloat_AsDouble(__pyx_v_value); if (unlikely((__pyx_t_5 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 734, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_f64(__pyx_v_self, __pyx_v_c_name, __pyx_t_5); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 734, __pyx_L1_error)
+0735: elif PyUnicode_CheckExact(<PyObject*>value):
__pyx_t_3 = PyUnicode_CheckExact(((PyObject *)__pyx_v_value));
if (__pyx_t_3) {
/* … */
goto __pyx_L3;
}
+0736: self._column_str(c_name, value)
if (!(likely(PyUnicode_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_value))) __PYX_ERR(0, 736, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_str(__pyx_v_self, __pyx_v_c_name, ((PyObject*)__pyx_v_value)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 736, __pyx_L1_error)
+0737: elif isinstance(value, TimestampMicros):
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_7questdb_7ingress_TimestampMicros);
if (__pyx_t_3) {
/* … */
goto __pyx_L3;
}
+0738: self._column_ts(c_name, value)
if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7questdb_7ingress_TimestampMicros))))) __PYX_ERR(0, 738, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_ts(__pyx_v_self, __pyx_v_c_name, ((struct __pyx_obj_7questdb_7ingress_TimestampMicros *)__pyx_v_value)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 738, __pyx_L1_error)
+0739: elif isinstance(value, datetime):
__pyx_t_3 = __Pyx_TypeCheck(__pyx_v_value, __pyx_ptype_7cpython_8datetime_datetime);
if (likely(__pyx_t_3)) {
/* … */
goto __pyx_L3;
}
+0740: self._column_dt(c_name, value)
if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 740, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__column_dt(__pyx_v_self, __pyx_v_c_name, ((PyDateTime_DateTime *)__pyx_v_value)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 740, __pyx_L1_error)
0741: else:
+0742: valid = ', '.join((
/*else*/ { /* … */ __pyx_t_6 = PyUnicode_Join(__pyx_kp_u__4, __pyx_tuple__35); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 742, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_v_valid = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0;
+0743: 'bool',
__pyx_tuple__35 = PyTuple_Pack(6, __pyx_n_u_bool, __pyx_n_u_int, __pyx_n_u_float, __pyx_n_u_str, __pyx_n_u_TimestampMicros_2, __pyx_kp_u_datetime_datetime); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 743, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__35); __Pyx_GIVEREF(__pyx_tuple__35);
0744: 'int',
0745: 'float',
0746: 'str',
0747: 'TimestampMicros',
0748: 'datetime.datetime'))
+0749: raise TypeError(
__pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 749, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_6, 0, 0, 0); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __PYX_ERR(0, 749, __pyx_L1_error) } __pyx_L3:;
+0750: f'Unsupported type: {_fqn(type(value))}. Must be one of: {valid}')
__pyx_t_6 = PyTuple_New(4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = 0; __pyx_t_8 = 127; __Pyx_INCREF(__pyx_kp_u_Unsupported_type); __pyx_t_7 += 18; __Pyx_GIVEREF(__pyx_kp_u_Unsupported_type); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_kp_u_Unsupported_type); __pyx_t_9 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_value)))); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_10 = __Pyx_PyUnicode_Unicode(__pyx_t_9); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_10); __pyx_t_10 = 0; __Pyx_INCREF(__pyx_kp_u_Must_be_one_of); __pyx_t_7 += 18; __Pyx_GIVEREF(__pyx_kp_u_Must_be_one_of); PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_kp_u_Must_be_one_of); __pyx_t_10 = __Pyx_PyUnicode_Unicode(__pyx_v_valid); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_8 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) > __pyx_t_8) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) : __pyx_t_8; __pyx_t_7 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyUnicode_Join(__pyx_t_6, 4, __pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 750, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0751:
+0752: cdef inline void_int _may_trigger_row_complete(self) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__may_trigger_row_complete(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { CYTHON_UNUSED struct line_sender_error *__pyx_v_err; PyObject *__pyx_v_sender; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Buffer._may_trigger_row_complete", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0753: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0754: cdef PyObject* sender = NULL
__pyx_v_sender = NULL;
+0755: if self._row_complete_sender != None:
__pyx_t_1 = PyObject_RichCompare(__pyx_v_self->_row_complete_sender, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 755, __pyx_L1_error) __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 755, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; if (__pyx_t_2) { /* … */ }
+0756: sender = PyWeakref_GetObject(self._row_complete_sender)
__pyx_t_1 = __pyx_v_self->_row_complete_sender; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = PyWeakref_GetObject(__pyx_t_1); if (unlikely(__pyx_t_3 == ((PyObject *)NULL))) __PYX_ERR(0, 756, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_v_sender = __pyx_t_3;
+0757: if sender != NULL:
__pyx_t_2 = (__pyx_v_sender != NULL); if (__pyx_t_2) { /* … */ }
+0758: may_flush_on_row_complete(self, <Sender><object>sender)
__pyx_t_4 = __pyx_f_7questdb_7ingress_may_flush_on_row_complete(__pyx_v_self, ((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_sender)); if (unlikely(__pyx_t_4 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 758, __pyx_L1_error)
0759:
+0760: cdef inline void_int _at_ts(self, TimestampNanos ts) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__at_ts(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, struct __pyx_obj_7questdb_7ingress_TimestampNanos *__pyx_v_ts) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._at_ts", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0761: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0762: if not line_sender_buffer_at_nanos(self._impl, ts._value, &err):
__pyx_t_1 = (!line_sender_buffer_at_nanos(__pyx_v_self->_impl, __pyx_v_ts->_value, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0763: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 763, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 763, __pyx_L1_error)
0764:
+0765: cdef inline void_int _at_dt(self, datetime dt) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__at_dt(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyDateTime_DateTime *__pyx_v_dt) { int64_t __pyx_v_value; struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.Buffer._at_dt", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0766: cdef int64_t value = datetime_to_nanos(dt)
__pyx_t_1 = __pyx_f_7questdb_7ingress_datetime_to_nanos(__pyx_v_dt); if (unlikely(__pyx_t_1 == ((int64_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 766, __pyx_L1_error) __pyx_v_value = __pyx_t_1;
+0767: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0768: if not line_sender_buffer_at_nanos(self._impl, value, &err):
__pyx_t_2 = (!line_sender_buffer_at_nanos(__pyx_v_self->_impl, __pyx_v_value, (&__pyx_v_err))); if (unlikely(__pyx_t_2)) { /* … */ }
+0769: raise c_err_to_py(err)
__pyx_t_3 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 769, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 769, __pyx_L1_error)
0770:
+0771: cdef inline void_int _at_now(self) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__at_now(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self) { struct line_sender_error *__pyx_v_err; __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Buffer._at_now", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0772: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+0773: if not line_sender_buffer_at_now(self._impl, &err):
__pyx_t_1 = (!line_sender_buffer_at_now(__pyx_v_self->_impl, (&__pyx_v_err))); if (unlikely(__pyx_t_1)) { /* … */ }
+0774: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 774, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 774, __pyx_L1_error)
0775:
+0776: cdef inline void_int _at(self, object ts) except -1:
static CYTHON_INLINE __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__at(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_ts) { __pyx_t_7questdb_7ingress_void_int __pyx_r; /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("questdb.ingress.Buffer._at", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
+0777: if ts is None:
__pyx_t_1 = (__pyx_v_ts == Py_None); if (__pyx_t_1) { /* … */ goto __pyx_L3; }
+0778: self._at_now()
__pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__at_now(__pyx_v_self); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 778, __pyx_L1_error)
+0779: elif isinstance(ts, TimestampNanos):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_ts, __pyx_ptype_7questdb_7ingress_TimestampNanos);
if (__pyx_t_1) {
/* … */
goto __pyx_L3;
}
+0780: self._at_ts(ts)
if (!(likely(((__pyx_v_ts) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_ts, __pyx_ptype_7questdb_7ingress_TimestampNanos))))) __PYX_ERR(0, 780, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__at_ts(__pyx_v_self, ((struct __pyx_obj_7questdb_7ingress_TimestampNanos *)__pyx_v_ts)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 780, __pyx_L1_error)
+0781: elif isinstance(ts, datetime):
__pyx_t_1 = __Pyx_TypeCheck(__pyx_v_ts, __pyx_ptype_7cpython_8datetime_datetime);
if (likely(__pyx_t_1)) {
/* … */
goto __pyx_L3;
}
+0782: self._at_dt(ts)
if (!(likely(((__pyx_v_ts) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_ts, __pyx_ptype_7cpython_8datetime_datetime))))) __PYX_ERR(0, 782, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_6Buffer__at_dt(__pyx_v_self, ((PyDateTime_DateTime *)__pyx_v_ts)); if (unlikely(__pyx_t_2 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 782, __pyx_L1_error)
0783: else:
+0784: raise TypeError(
/*else*/ { /* … */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_3); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 784, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 784, __pyx_L1_error) } __pyx_L3:;
+0785: f'Unsupported type: {_fqn(type(ts))}. Must be one of: ' +
__pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = 0; __pyx_t_5 = 127; __Pyx_INCREF(__pyx_kp_u_Unsupported_type); __pyx_t_4 += 18; __Pyx_GIVEREF(__pyx_kp_u_Unsupported_type); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_kp_u_Unsupported_type); __pyx_t_6 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_ts)))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_5 = (__Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) > __pyx_t_5) ? __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) : __pyx_t_5; __pyx_t_4 += __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_kp_u_Must_be_one_of); __pyx_t_4 += 18; __Pyx_GIVEREF(__pyx_kp_u_Must_be_one_of); PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_kp_u_Must_be_one_of); __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_3, 3, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyUnicode_ConcatInPlace(__pyx_t_7, __pyx_kp_u_TimestampNanos_datetime_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
0786: 'TimestampNanos, datetime, None')
0787:
+0788: cdef void_int _row(
static __pyx_t_7questdb_7ingress_void_int __pyx_f_7questdb_7ingress_6Buffer__row(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_table_name, struct __pyx_opt_args_7questdb_7ingress_6Buffer__row *__pyx_optional_args) { /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("questdb.ingress.Buffer._row", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_XDECREF(__pyx_v_value); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ struct __pyx_opt_args_7questdb_7ingress_6Buffer__row { int __pyx_n; PyObject *symbols; PyObject *columns; PyObject *at; };
0789: self,
0790: str table_name,
+0791: dict symbols=None,
PyObject *__pyx_v_symbols = ((PyObject*)Py_None);
+0792: dict columns=None,
PyObject *__pyx_v_columns = ((PyObject*)Py_None);
+0793: object at=None) except -1:
PyObject *__pyx_v_at = ((PyObject *)Py_None); int __pyx_v_wrote_fields; PyObject *__pyx_v_name = NULL; PyObject *__pyx_v_value = NULL; __pyx_t_7questdb_7ingress_void_int __pyx_r; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_symbols = __pyx_optional_args->symbols; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_columns = __pyx_optional_args->columns; if (__pyx_optional_args->__pyx_n > 2) { __pyx_v_at = __pyx_optional_args->at; } } } }
0794: """
0795: Add a row to the buffer.
0796: """
+0797: cdef bint wrote_fields = False
__pyx_v_wrote_fields = 0;
+0798: self._set_marker()
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__set_marker(__pyx_v_self); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 798, __pyx_L1_error)
+0799: try:
{ /*try:*/ { /* … */ } __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; goto __pyx_L8_try_end; __pyx_L3_error:; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; /* … */ __pyx_L5_except_error:; __Pyx_XGIVEREF(__pyx_t_2); __Pyx_XGIVEREF(__pyx_t_3); __Pyx_XGIVEREF(__pyx_t_4); __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_3, __pyx_t_4); goto __pyx_L1_error; __pyx_L8_try_end:; }
+0800: self._table(table_name)
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__table(__pyx_v_self, __pyx_v_table_name); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 800, __pyx_L3_error)
+0801: if symbols is not None:
__pyx_t_5 = (__pyx_v_symbols != ((PyObject*)Py_None)); if (__pyx_t_5) { /* … */ }
+0802: for name, value in symbols.items():
__pyx_t_7 = 0; if (unlikely(__pyx_v_symbols == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 802, __pyx_L3_error) } __pyx_t_10 = __Pyx_dict_iterator(__pyx_v_symbols, 1, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 802, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = __pyx_t_10; __pyx_t_10 = 0; while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_8, &__pyx_t_7, &__pyx_t_10, &__pyx_t_11, NULL, __pyx_t_9); if (unlikely(__pyx_t_12 == 0)) break; if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 802, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GOTREF(__pyx_t_11); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_11); __pyx_t_11 = 0;
+0803: if value is not None:
__pyx_t_5 = (__pyx_v_value != Py_None);
if (__pyx_t_5) {
/* … */
}
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0804: self._symbol(name, value)
if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 804, __pyx_L3_error) if (!(likely(PyUnicode_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_value))) __PYX_ERR(0, 804, __pyx_L3_error) __pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__symbol(__pyx_v_self, ((PyObject*)__pyx_v_name), ((PyObject*)__pyx_v_value)); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 804, __pyx_L3_error)
+0805: wrote_fields = True
__pyx_v_wrote_fields = 1;
+0806: if columns is not None:
__pyx_t_5 = (__pyx_v_columns != ((PyObject*)Py_None)); if (__pyx_t_5) { /* … */ }
+0807: for name, value in columns.items():
__pyx_t_8 = 0; if (unlikely(__pyx_v_columns == Py_None)) { PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items"); __PYX_ERR(0, 807, __pyx_L3_error) } __pyx_t_11 = __Pyx_dict_iterator(__pyx_v_columns, 1, __pyx_n_s_items, (&__pyx_t_7), (&__pyx_t_9)); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 807, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = __pyx_t_11; __pyx_t_11 = 0; while (1) { __pyx_t_12 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_7, &__pyx_t_8, &__pyx_t_11, &__pyx_t_10, NULL, __pyx_t_9); if (unlikely(__pyx_t_12 == 0)) break; if (unlikely(__pyx_t_12 == -1)) __PYX_ERR(0, 807, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_11); __Pyx_GOTREF(__pyx_t_10); __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF_SET(__pyx_v_value, __pyx_t_10); __pyx_t_10 = 0;
+0808: if value is not None:
__pyx_t_5 = (__pyx_v_value != Py_None);
if (__pyx_t_5) {
/* … */
}
}
__Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+0809: self._column(name, value)
if (!(likely(PyUnicode_CheckExact(__pyx_v_name))||((__pyx_v_name) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_name))) __PYX_ERR(0, 809, __pyx_L3_error) __pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__column(__pyx_v_self, ((PyObject*)__pyx_v_name), __pyx_v_value); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 809, __pyx_L3_error)
+0810: wrote_fields = True
__pyx_v_wrote_fields = 1;
+0811: if wrote_fields:
if (__pyx_v_wrote_fields) { /* … */ goto __pyx_L17; }
+0812: self._at(at)
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__at(__pyx_v_self, __pyx_v_at); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 812, __pyx_L3_error)
+0813: self._clear_marker()
__pyx_t_6 = __pyx_f_7questdb_7ingress_6Buffer__clear_marker(__pyx_v_self); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 813, __pyx_L3_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
0814: else:
+0815: self._rewind_to_marker()
/*else*/ {
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__rewind_to_marker(__pyx_v_self); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 815, __pyx_L3_error)
}
__pyx_L17:;
+0816: except:
/*except:*/ { __Pyx_AddTraceback("questdb.ingress.Buffer._row", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_10, &__pyx_t_11) < 0) __PYX_ERR(0, 816, __pyx_L5_except_error) __Pyx_XGOTREF(__pyx_t_6); __Pyx_XGOTREF(__pyx_t_10); __Pyx_XGOTREF(__pyx_t_11);
+0817: self._rewind_to_marker()
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__rewind_to_marker(__pyx_v_self); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 817, __pyx_L5_except_error)
+0818: raise
__Pyx_GIVEREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_10); __Pyx_XGIVEREF(__pyx_t_11); __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_10, __pyx_t_11); __pyx_t_6 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __PYX_ERR(0, 818, __pyx_L5_except_error) }
+0819: if wrote_fields:
if (__pyx_v_wrote_fields) { /* … */ }
+0820: self._may_trigger_row_complete()
__pyx_t_1 = __pyx_f_7questdb_7ingress_6Buffer__may_trigger_row_complete(__pyx_v_self); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 820, __pyx_L1_error)
0821:
+0822: def row(
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_15row(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_14row, "\n Add a single row (line) to the buffer.\n\n .. code-block:: python\n\n # All fields specified.\n buffer.row(\n 'table_name',\n symbols={'sym1': 'abc', 'sym2': 'def', 'sym3': None},\n columns={\n 'col1': True,\n 'col2': 123,\n 'col3': 3.14,\n 'col4': 'xyz',\n 'col5': TimestampMicros(123456789),\n 'col6': datetime(2019, 1, 1, 12, 0, 0),\n 'col7': None},\n at=TimestampNanos(123456789))\n\n # Only symbols specified. Designated timestamp assigned by the db.\n buffer.row(\n 'table_name',\n symbols={'sym1': 'abc', 'sym2': 'def'})\n\n # Float columns and timestamp specified as `datetime.datetime`.\n # Pay special attention to the timezone, which if unspecified is\n # assumed to be the local timezone (and not UTC).\n buffer.row(\n 'sensor data',\n columns={\n 'temperature': 24.5,\n 'humidity': 0.5},\n at=datetime.datetime.now(tz=datetime.timezone.utc))\n\n\n Python strings passed as values to ``symbols`` are going to be encoded\n as the ``SYMBOL`` type in QuestDB, whilst Python strings passed as\n values to ``columns`` are going to be encoded as the ``STRING`` type.\n\n Refer to the\n `QuestDB documentation <https://questdb.io/docs/concept/symbol/>`_ to\n understand the difference between the ``SYMBOL`` and ``STRING`` types\n (TL;DR: symbols are interned strings).\n\n Column values can be specified with Python types directly and map as so:\n\n .. list-table::\n :header-rows: 1\n\n * - Python type\n - Serialized as ILP type\n * - ``bool``\n - `BOOLEAN <h""ttps://questdb.io/docs/reference/api/ilp/columnset-types#boolean>`_\n * - ``int``\n - `INTEGER <https://questdb.io/docs/reference/api/ilp/columnset-types#integer>`_\n * - ``float``\n - `FLOAT <https://questdb.io/docs/reference/api/ilp/columnset-types#float>`_\n * - ``str``\n - `STRING <https://questdb.io/docs/reference/api/ilp/columnset-types#string>`_\n * - ``datetime.datetime`` and ``TimestampMicros``\n - `TIMESTAMP <https://questdb.io/docs/reference/api/ilp/columnset-types#timestamp>`_\n * - ``None``\n - *Column is skipped and not serialized.*\n\n If the destination table was already created, then the columns types\n will be cast to the types of the existing columns whenever possible\n (Refer to the QuestDB documentation pages linked above).\n\n :param table_name: The name of the table to which the row belongs.\n :param symbols: A dictionary of symbol column names to ``str`` values.\n As a convenience, you can also pass a ``None`` value which will\n have the same effect as skipping the key: If the column already\n existed, it will be recorded as ``NULL``, otherwise it will not be\n created.\n :param columns: A dictionary of column names to ``bool``, ``int``,\n ``float``, ``str``, ``TimestampMicros`` or ``datetime`` values.\n As a convenience, you can also pass a ``None`` value which will\n have the same effect as skipping the key: If the column already\n existed, it will be recorded as ``NULL``, otherwise it will not be\n created.\n :param at: The timestamp of the row. If ``None``, timestamp is assigned\n by the server. If ``datetime``, the timestamp is converted to\n nanoseconds. A nanosecond unix epoch timestamp can be passed\n explicitly as a ``TimestampNanos`` obj""ect.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Buffer_15row = {"row", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Buffer_15row, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Buffer_14row}; static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_15row(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_symbols = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_at = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("row (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table_name,&__pyx_n_s_symbols,&__pyx_n_s_columns,&__pyx_n_s_at,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_14row(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_symbols, PyObject *__pyx_v_columns, PyObject *__pyx_v_at) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("questdb.ingress.Buffer.row", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__61 = PyTuple_Pack(5, __pyx_n_s_self, __pyx_n_s_table_name, __pyx_n_s_symbols, __pyx_n_s_columns, __pyx_n_s_at); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__61); __Pyx_GIVEREF(__pyx_tuple__61); /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); /* … */ __pyx_t_17 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_table_name, __pyx_n_s_str) < 0) __PYX_ERR(0, 822, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_symbols, __pyx_kp_s_Optional_Dict_str_Optional_str) < 0) __PYX_ERR(0, 822, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_columns, __pyx_kp_s_Optional_Dict_str_Union_None_boo) < 0) __PYX_ERR(0, 822, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_at, __pyx_kp_s_Union_None_TimestampNanos_dateti) < 0) __PYX_ERR(0, 822, __pyx_L1_error) __pyx_t_19 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Buffer_15row, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Buffer_row, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__62)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_19, __pyx_t_18); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_19, __pyx_t_17); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer, __pyx_n_s_row, __pyx_t_19) < 0) __PYX_ERR(0, 822, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Buffer); __pyx_codeobj__62 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_row, 822, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__62)) __PYX_ERR(0, 822, __pyx_L1_error)
0823: self,
0824: table_name: str,
0825: *,
+0826: symbols: Optional[Dict[str, Optional[str]]]=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_symbols, Py_None) < 0) __PYX_ERR(0, 822, __pyx_L1_error)
0827: columns: Optional[Dict[
0828: str,
0829: Union[None, bool, int, float, str, TimestampMicros, datetime]]
+0830: ]=None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_columns, Py_None) < 0) __PYX_ERR(0, 822, __pyx_L1_error)
+0831: at: Union[None, TimestampNanos, datetime]=None):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_table_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 3)) { Py_ssize_t index; for (index = 1; index < 4 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 822, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "row") < 0)) __PYX_ERR(0, 822, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_table_name = ((PyObject*)values[0]); __pyx_v_symbols = ((PyObject*)values[1]); __pyx_v_columns = ((PyObject*)values[2]); __pyx_v_at = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("row", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 822, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Buffer.row", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table_name), (&PyUnicode_Type), 0, "table_name", 1))) __PYX_ERR(0, 824, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_symbols), (&PyDict_Type), 1, "symbols", 1))) __PYX_ERR(0, 826, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_columns), (&PyDict_Type), 1, "columns", 1))) __PYX_ERR(0, 827, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_14row(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self), __pyx_v_table_name, __pyx_v_symbols, __pyx_v_columns, __pyx_v_at); /* … */ if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_at, Py_None) < 0) __PYX_ERR(0, 822, __pyx_L1_error)
0832: """
0833: Add a single row (line) to the buffer.
0834:
0835: .. code-block:: python
0836:
0837: # All fields specified.
0838: buffer.row(
0839: 'table_name',
0840: symbols={'sym1': 'abc', 'sym2': 'def', 'sym3': None},
0841: columns={
0842: 'col1': True,
0843: 'col2': 123,
0844: 'col3': 3.14,
0845: 'col4': 'xyz',
0846: 'col5': TimestampMicros(123456789),
0847: 'col6': datetime(2019, 1, 1, 12, 0, 0),
0848: 'col7': None},
0849: at=TimestampNanos(123456789))
0850:
0851: # Only symbols specified. Designated timestamp assigned by the db.
0852: buffer.row(
0853: 'table_name',
0854: symbols={'sym1': 'abc', 'sym2': 'def'})
0855:
0856: # Float columns and timestamp specified as `datetime.datetime`.
0857: # Pay special attention to the timezone, which if unspecified is
0858: # assumed to be the local timezone (and not UTC).
0859: buffer.row(
0860: 'sensor data',
0861: columns={
0862: 'temperature': 24.5,
0863: 'humidity': 0.5},
0864: at=datetime.datetime.now(tz=datetime.timezone.utc))
0865:
0866:
0867: Python strings passed as values to ``symbols`` are going to be encoded
0868: as the ``SYMBOL`` type in QuestDB, whilst Python strings passed as
0869: values to ``columns`` are going to be encoded as the ``STRING`` type.
0870:
0871: Refer to the
0872: `QuestDB documentation <https://questdb.io/docs/concept/symbol/>`_ to
0873: understand the difference between the ``SYMBOL`` and ``STRING`` types
0874: (TL;DR: symbols are interned strings).
0875:
0876: Column values can be specified with Python types directly and map as so:
0877:
0878: .. list-table::
0879: :header-rows: 1
0880:
0881: * - Python type
0882: - Serialized as ILP type
0883: * - ``bool``
0884: - `BOOLEAN <https://questdb.io/docs/reference/api/ilp/columnset-types#boolean>`_
0885: * - ``int``
0886: - `INTEGER <https://questdb.io/docs/reference/api/ilp/columnset-types#integer>`_
0887: * - ``float``
0888: - `FLOAT <https://questdb.io/docs/reference/api/ilp/columnset-types#float>`_
0889: * - ``str``
0890: - `STRING <https://questdb.io/docs/reference/api/ilp/columnset-types#string>`_
0891: * - ``datetime.datetime`` and ``TimestampMicros``
0892: - `TIMESTAMP <https://questdb.io/docs/reference/api/ilp/columnset-types#timestamp>`_
0893: * - ``None``
0894: - *Column is skipped and not serialized.*
0895:
0896: If the destination table was already created, then the columns types
0897: will be cast to the types of the existing columns whenever possible
0898: (Refer to the QuestDB documentation pages linked above).
0899:
0900: :param table_name: The name of the table to which the row belongs.
0901: :param symbols: A dictionary of symbol column names to ``str`` values.
0902: As a convenience, you can also pass a ``None`` value which will
0903: have the same effect as skipping the key: If the column already
0904: existed, it will be recorded as ``NULL``, otherwise it will not be
0905: created.
0906: :param columns: A dictionary of column names to ``bool``, ``int``,
0907: ``float``, ``str``, ``TimestampMicros`` or ``datetime`` values.
0908: As a convenience, you can also pass a ``None`` value which will
0909: have the same effect as skipping the key: If the column already
0910: existed, it will be recorded as ``NULL``, otherwise it will not be
0911: created.
0912: :param at: The timestamp of the row. If ``None``, timestamp is assigned
0913: by the server. If ``datetime``, the timestamp is converted to
0914: nanoseconds. A nanosecond unix epoch timestamp can be passed
0915: explicitly as a ``TimestampNanos`` object.
0916: """
+0917: self._row(table_name, symbols, columns, at)
__pyx_t_2.__pyx_n = 3;
__pyx_t_2.symbols = __pyx_v_symbols;
__pyx_t_2.columns = __pyx_v_columns;
__pyx_t_2.at = __pyx_v_at;
__pyx_t_1 = ((struct __pyx_vtabstruct_7questdb_7ingress_Buffer *)__pyx_v_self->__pyx_vtab)->_row(__pyx_v_self, __pyx_v_table_name, &__pyx_t_2); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 917, __pyx_L1_error)
+0918: return self
__Pyx_XDECREF(__pyx_r); __Pyx_INCREF((PyObject *)__pyx_v_self); __pyx_r = ((PyObject *)__pyx_v_self); goto __pyx_L0;
0919:
+0920: def dataframe(
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_17dataframe(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Buffer_16dataframe, "\n Add a pandas DataFrame to the buffer.\n\n Also see the :func:`Sender.dataframe` method if you're\n not using the buffer explicitly. It supports the same parameters\n and also supports auto-flushing.\n\n This feature requires the ``pandas``, ``numpy`` and ``pyarrow``\n package to be installed.\n\n :param df: The pandas DataFrame to serialize to the buffer.\n :type df: pandas.DataFrame\n\n :param table_name: The name of the table to which the rows belong.\n\n If ``None``, the table name is taken from the ``table_name_col``\n parameter. If both ``table_name`` and ``table_name_col`` are\n ``None``, the table name is taken from the DataFrame's index\n name (``df.index.name`` attribute).\n :type table_name: str or None\n\n :param table_name_col: The name or index of the column in the DataFrame\n that contains the table name.\n \n If ``None``, the table name is taken\n from the ``table_name`` parameter. If both ``table_name`` and\n ``table_name_col`` are ``None``, the table name is taken from the\n DataFrame's index name (``df.index.name`` attribute).\n\n If ``table_name_col`` is an integer, it is interpreted as the index\n of the column starting from ``0``. The index of the column can be\n negative, in which case it is interpreted as an offset from the end\n of the DataFrame. E.g. ``-1`` is the last column.\n :type table_name_col: str or int or None\n\n :param symbols: The columns to be serialized as symbols.\n \n If ``'auto'`` (default), all columns of dtype ``'categorical'`` are\n serialized as symbols. If ``True``, all ``str`` columns are\n serialized as symbols. If ``False``, no columns are serialized as\n symbols.\n \n The list of symbols can also be s""pecified explicitly as a ``list``\n of column names (``str``) or indices (``int``). Integer indices\n start at ``0`` and can be negative, offset from the end of the\n DataFrame. E.g. ``-1`` is the last column.\n\n Only columns containing strings can be serialized as symbols.\n\n :type symbols: str or bool or list of str or list of int\n\n :param at: The designated timestamp of the rows.\n \n You can specify a single value for all rows or column name or index.\n If ``None``, timestamp is assigned by the server for all rows.\n To pass in a timestamp explicity as an integer use the\n ``TimestampNanos`` wrapper type. To get the current timestamp,\n use ``TimestampNanos.now()``.\n When passing a ``datetime.datetime`` object, the timestamp is\n converted to nanoseconds.\n A ``datetime`` object is assumed to be in the local timezone unless\n one is specified explicitly (so call\n ``datetime.datetime.now(tz=datetime.timezone.utc)`` instead\n of ``datetime.datetime.utcnow()`` for the current timestamp to\n avoid bugs).\n\n To specify a different timestamp for each row, pass in a column name\n (``str``) or index (``int``, 0-based index, negative index\n supported): In this case, the column needs to be of dtype\n ``datetime64[ns]`` (assumed to be in the **UTC timezone** and not\n local, due to differences in Pandas and Python datetime handling) or\n ``datetime64[ns, tz]``. When a timezone is specified in the column,\n it is converted to UTC automatically.\n\n A timestamp column can also contain ``None`` values. The server will\n assign the current timestamp to those rows.\n\n **Note**: All timestamps are always converted to nanoseconds and in\n the UTC timezone. Ti""mezone information is dropped before sending and\n QuestDB will not store any timezone information.\n :type at: TimestampNanos, datetime.datetime, int or str or None\n\n **Note**: It is an error to specify both ``table_name`` and\n ``table_name_col``.\n\n **Note**: The \"index\" column of the DataFrame is never serialized,\n even if it is named.\n\n Example:\n\n .. code-block:: python\n\n import pandas as pd\n import questdb.ingress as qi\n\n buf = qi.Buffer()\n # ...\n\n df = pd.DataFrame({\n 'location': ['London', 'Managua', 'London'],\n 'temperature': [24.5, 35.0, 25.5],\n 'humidity': [0.5, 0.6, 0.45],\n 'ts': pd.date_range('2021-07-01', periods=3)})\n buf.dataframe(\n df, table_name='weather', at='ts', symbols=['location'])\n\n # ...\n sender.flush(buf)\n\n **Pandas to ILP datatype mappings**\n\n .. seealso:: https://questdb.io/docs/reference/api/ilp/columnset-types/\n\n .. list-table:: Pandas Mappings\n :header-rows: 1\n\n * - Pandas ``dtype``\n - Nulls\n - ILP Datatype\n * - ``'bool'``\n - N\n - ``BOOLEAN``\n * - ``'boolean'``\n - N **\316\261**\n - ``BOOLEAN``\n * - ``'object'`` (``bool`` objects)\n - N **\316\261**\n - ``BOOLEAN``\n * - ``'uint8'``\n - N\n - ``INTEGER``\n * - ``'int8'``\n - N\n - ``INTEGER``\n * - ``'uint16'``\n - N\n - ``INTEGER``\n * - ``'int16'``\n - N\n - ``INTEGER``\n * - ``'uint32'``\n - N\n - ``INTEGER``\n * - ``'int32'``\n - N\n "" - ``INTEGER``\n * - ``'uint64'``\n - N\n - ``INTEGER`` **\316\262**\n * - ``'int64'``\n - N\n - ``INTEGER``\n * - ``'UInt8'``\n - Y\n - ``INTEGER``\n * - ``'Int8'``\n - Y\n - ``INTEGER``\n * - ``'UInt16'``\n - Y\n - ``INTEGER``\n * - ``'Int16'``\n - Y\n - ``INTEGER``\n * - ``'UInt32'``\n - Y\n - ``INTEGER``\n * - ``'Int32'``\n - Y\n - ``INTEGER``\n * - ``'UInt64'``\n - Y\n - ``INTEGER`` **\316\262**\n * - ``'Int64'``\n - Y\n - ``INTEGER``\n * - ``'object'`` (``int`` objects)\n - Y\n - ``INTEGER`` **\316\262**\n * - ``'float32'`` **\316\263**\n - Y (``NaN``)\n - ``FLOAT``\n * - ``'float64'``\n - Y (``NaN``)\n - ``FLOAT``\n * - ``'object'`` (``float`` objects)\n - Y (``NaN``)\n - ``FLOAT``\n * - ``'string'`` (``str`` objects)\n - Y\n - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **\316\264**\n * - ``'string[pyarrow]'``\n - Y\n - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **\316\264**\n * - ``'category'`` (``str`` objects) **\316\265**\n - Y\n - ``SYMBOL`` (default), ``STRING`` via ``symbols`` arg. **\316\264**\n * - ``'object'`` (``str`` objects)\n - Y\n - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **\316\264**\n * - ``'datetime64[ns]'``\n - Y\n - ``TIMESTAMP`` **\316\266**\n * - ``'datetime64[ns, tz]'``\n - Y\n "" - ``TIMESTAMP`` **\316\266**\n\n .. note::\n\n * **\316\261**: Note some pandas dtypes allow nulls (e.g. ``'boolean'``),\n where the QuestDB database does not.\n\n * **\316\262**: The valid range for integer values is -2^63 to 2^63-1.\n Any ``'uint64'``, ``'UInt64'`` or python ``int`` object values\n outside this range will raise an error during serialization.\n\n * **\316\263**: Upcast to 64-bit float during serialization.\n\n * **\316\264**: Columns containing strings can also be used to specify the\n table name. See ``table_name_col``.\n\n * **\316\265**: We only support categories containing strings. If the\n category contains non-string values, an error will be raised.\n\n * **\316\266**: The '.dataframe()' method only supports datetimes with\n nanosecond precision. The designated timestamp column (see ``at``\n parameter) maintains the nanosecond precision, whilst values\n stored as columns have their precision truncated to microseconds.\n All dates are sent as UTC and any additional timezone information\n is dropped. If no timezone is specified, we follow\n the pandas convention of assuming the timezone is UTC.\n Datetimes before 1970-01-01 00:00:00 UTC are not supported.\n If a datetime value is specified as ``None`` (``NaT``), it is\n interpreted as the current QuestDB server time set on receipt of\n message.\n\n **Error Handling and Recovery**\n\n In case an exception is raised during dataframe serialization, the\n buffer is left in its previous state.\n The buffer remains in a valid state and can be used for further calls\n even after an error.\n\n For clarification, as an example, if an invalid ``None``\n value appears at the 3rd row"" for a ``bool`` column, neither the 3rd nor\n the preceding rows are added to the buffer.\n\n **Note**: This differs from the :func:`Sender.dataframe` method, which\n modifies this guarantee due to its ``auto_flush`` logic.\n\n **Performance Considerations**\n\n The Python GIL is released during serialization if it is not needed.\n If any column requires the GIL, the entire serialization is done whilst\n holding the GIL.\n\n Column types that require the GIL are:\n\n * Columns of ``str``, ``float`` or ``int`` or ``float`` Python objects.\n * The ``'string[python]'`` dtype.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Buffer_17dataframe = {"dataframe", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Buffer_17dataframe, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Buffer_16dataframe}; static PyObject *__pyx_pw_7questdb_7ingress_6Buffer_17dataframe(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_table_name_col = 0; PyObject *__pyx_v_symbols = 0; PyObject *__pyx_v_at = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dataframe (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_table_name,&__pyx_n_s_table_name_col,&__pyx_n_s_symbols,&__pyx_n_s_at,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Buffer_16dataframe(struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_self, PyObject *__pyx_v_df, PyObject *__pyx_v_table_name, PyObject *__pyx_v_table_name_col, PyObject *__pyx_v_symbols, PyObject *__pyx_v_at) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("questdb.ingress.Buffer.dataframe", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__63 = PyTuple_Pack(6, __pyx_n_s_self, __pyx_n_s_df, __pyx_n_s_table_name, __pyx_n_s_table_name_col, __pyx_n_s_symbols, __pyx_n_s_at); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__63); __Pyx_GIVEREF(__pyx_tuple__63); /* … */ __pyx_t_19 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); /* … */ __pyx_t_17 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_table_name, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 920, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_table_name_col, __pyx_kp_s_Union_None_int_str) < 0) __PYX_ERR(0, 920, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_symbols, __pyx_kp_s_Union_str_bool_List_int_List_str) < 0) __PYX_ERR(0, 920, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_at, __pyx_kp_s_Union_None_int_str_TimestampNano) < 0) __PYX_ERR(0, 920, __pyx_L1_error) __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Buffer_17dataframe, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Buffer_dataframe, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__64)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_18, __pyx_t_19); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_18, __pyx_t_17); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer, __pyx_n_s_dataframe, __pyx_t_18) < 0) __PYX_ERR(0, 920, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Buffer); __pyx_codeobj__64 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__63, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_dataframe, 920, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__64)) __PYX_ERR(0, 920, __pyx_L1_error)
0921: self,
0922: df, # : pd.DataFrame
0923: *,
+0924: table_name: Optional[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_table_name, Py_None) < 0) __PYX_ERR(0, 920, __pyx_L1_error)
+0925: table_name_col: Union[None, int, str] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)__pyx_n_u_auto)); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_table_name_col, Py_None) < 0) __PYX_ERR(0, 920, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_symbols, __pyx_n_u_auto) < 0) __PYX_ERR(0, 920, __pyx_L1_error)
0926: symbols: Union[str, bool, List[int], List[str]] = 'auto',
+0927: at: Union[None, int, str, TimestampNanos, datetime] = None):
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 920, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 4)) { Py_ssize_t index; for (index = 1; index < 5 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 920, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "dataframe") < 0)) __PYX_ERR(0, 920, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_df = values[0]; __pyx_v_table_name = ((PyObject*)values[1]); __pyx_v_table_name_col = values[2]; __pyx_v_symbols = values[3]; __pyx_v_at = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dataframe", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 920, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Buffer.dataframe", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table_name), (&PyUnicode_Type), 1, "table_name", 1))) __PYX_ERR(0, 924, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Buffer_16dataframe(((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_v_self), __pyx_v_df, __pyx_v_table_name, __pyx_v_table_name_col, __pyx_v_symbols, __pyx_v_at); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_at, Py_None) < 0) __PYX_ERR(0, 920, __pyx_L1_error)
0928: """
0929: Add a pandas DataFrame to the buffer.
0930:
0931: Also see the :func:`Sender.dataframe` method if you're
0932: not using the buffer explicitly. It supports the same parameters
0933: and also supports auto-flushing.
0934:
0935: This feature requires the ``pandas``, ``numpy`` and ``pyarrow``
0936: package to be installed.
0937:
0938: :param df: The pandas DataFrame to serialize to the buffer.
0939: :type df: pandas.DataFrame
0940:
0941: :param table_name: The name of the table to which the rows belong.
0942:
0943: If ``None``, the table name is taken from the ``table_name_col``
0944: parameter. If both ``table_name`` and ``table_name_col`` are
0945: ``None``, the table name is taken from the DataFrame's index
0946: name (``df.index.name`` attribute).
0947: :type table_name: str or None
0948:
0949: :param table_name_col: The name or index of the column in the DataFrame
0950: that contains the table name.
0951:
0952: If ``None``, the table name is taken
0953: from the ``table_name`` parameter. If both ``table_name`` and
0954: ``table_name_col`` are ``None``, the table name is taken from the
0955: DataFrame's index name (``df.index.name`` attribute).
0956:
0957: If ``table_name_col`` is an integer, it is interpreted as the index
0958: of the column starting from ``0``. The index of the column can be
0959: negative, in which case it is interpreted as an offset from the end
0960: of the DataFrame. E.g. ``-1`` is the last column.
0961: :type table_name_col: str or int or None
0962:
0963: :param symbols: The columns to be serialized as symbols.
0964:
0965: If ``'auto'`` (default), all columns of dtype ``'categorical'`` are
0966: serialized as symbols. If ``True``, all ``str`` columns are
0967: serialized as symbols. If ``False``, no columns are serialized as
0968: symbols.
0969:
0970: The list of symbols can also be specified explicitly as a ``list``
0971: of column names (``str``) or indices (``int``). Integer indices
0972: start at ``0`` and can be negative, offset from the end of the
0973: DataFrame. E.g. ``-1`` is the last column.
0974:
0975: Only columns containing strings can be serialized as symbols.
0976:
0977: :type symbols: str or bool or list of str or list of int
0978:
0979: :param at: The designated timestamp of the rows.
0980:
0981: You can specify a single value for all rows or column name or index.
0982: If ``None``, timestamp is assigned by the server for all rows.
0983: To pass in a timestamp explicity as an integer use the
0984: ``TimestampNanos`` wrapper type. To get the current timestamp,
0985: use ``TimestampNanos.now()``.
0986: When passing a ``datetime.datetime`` object, the timestamp is
0987: converted to nanoseconds.
0988: A ``datetime`` object is assumed to be in the local timezone unless
0989: one is specified explicitly (so call
0990: ``datetime.datetime.now(tz=datetime.timezone.utc)`` instead
0991: of ``datetime.datetime.utcnow()`` for the current timestamp to
0992: avoid bugs).
0993:
0994: To specify a different timestamp for each row, pass in a column name
0995: (``str``) or index (``int``, 0-based index, negative index
0996: supported): In this case, the column needs to be of dtype
0997: ``datetime64[ns]`` (assumed to be in the **UTC timezone** and not
0998: local, due to differences in Pandas and Python datetime handling) or
0999: ``datetime64[ns, tz]``. When a timezone is specified in the column,
1000: it is converted to UTC automatically.
1001:
1002: A timestamp column can also contain ``None`` values. The server will
1003: assign the current timestamp to those rows.
1004:
1005: **Note**: All timestamps are always converted to nanoseconds and in
1006: the UTC timezone. Timezone information is dropped before sending and
1007: QuestDB will not store any timezone information.
1008: :type at: TimestampNanos, datetime.datetime, int or str or None
1009:
1010: **Note**: It is an error to specify both ``table_name`` and
1011: ``table_name_col``.
1012:
1013: **Note**: The "index" column of the DataFrame is never serialized,
1014: even if it is named.
1015:
1016: Example:
1017:
1018: .. code-block:: python
1019:
1020: import pandas as pd
1021: import questdb.ingress as qi
1022:
1023: buf = qi.Buffer()
1024: # ...
1025:
1026: df = pd.DataFrame({
1027: 'location': ['London', 'Managua', 'London'],
1028: 'temperature': [24.5, 35.0, 25.5],
1029: 'humidity': [0.5, 0.6, 0.45],
1030: 'ts': pd.date_range('2021-07-01', periods=3)})
1031: buf.dataframe(
1032: df, table_name='weather', at='ts', symbols=['location'])
1033:
1034: # ...
1035: sender.flush(buf)
1036:
1037: **Pandas to ILP datatype mappings**
1038:
1039: .. seealso:: https://questdb.io/docs/reference/api/ilp/columnset-types/
1040:
1041: .. list-table:: Pandas Mappings
1042: :header-rows: 1
1043:
1044: * - Pandas ``dtype``
1045: - Nulls
1046: - ILP Datatype
1047: * - ``'bool'``
1048: - N
1049: - ``BOOLEAN``
1050: * - ``'boolean'``
1051: - N **α**
1052: - ``BOOLEAN``
1053: * - ``'object'`` (``bool`` objects)
1054: - N **α**
1055: - ``BOOLEAN``
1056: * - ``'uint8'``
1057: - N
1058: - ``INTEGER``
1059: * - ``'int8'``
1060: - N
1061: - ``INTEGER``
1062: * - ``'uint16'``
1063: - N
1064: - ``INTEGER``
1065: * - ``'int16'``
1066: - N
1067: - ``INTEGER``
1068: * - ``'uint32'``
1069: - N
1070: - ``INTEGER``
1071: * - ``'int32'``
1072: - N
1073: - ``INTEGER``
1074: * - ``'uint64'``
1075: - N
1076: - ``INTEGER`` **β**
1077: * - ``'int64'``
1078: - N
1079: - ``INTEGER``
1080: * - ``'UInt8'``
1081: - Y
1082: - ``INTEGER``
1083: * - ``'Int8'``
1084: - Y
1085: - ``INTEGER``
1086: * - ``'UInt16'``
1087: - Y
1088: - ``INTEGER``
1089: * - ``'Int16'``
1090: - Y
1091: - ``INTEGER``
1092: * - ``'UInt32'``
1093: - Y
1094: - ``INTEGER``
1095: * - ``'Int32'``
1096: - Y
1097: - ``INTEGER``
1098: * - ``'UInt64'``
1099: - Y
1100: - ``INTEGER`` **β**
1101: * - ``'Int64'``
1102: - Y
1103: - ``INTEGER``
1104: * - ``'object'`` (``int`` objects)
1105: - Y
1106: - ``INTEGER`` **β**
1107: * - ``'float32'`` **γ**
1108: - Y (``NaN``)
1109: - ``FLOAT``
1110: * - ``'float64'``
1111: - Y (``NaN``)
1112: - ``FLOAT``
1113: * - ``'object'`` (``float`` objects)
1114: - Y (``NaN``)
1115: - ``FLOAT``
1116: * - ``'string'`` (``str`` objects)
1117: - Y
1118: - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **δ**
1119: * - ``'string[pyarrow]'``
1120: - Y
1121: - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **δ**
1122: * - ``'category'`` (``str`` objects) **ε**
1123: - Y
1124: - ``SYMBOL`` (default), ``STRING`` via ``symbols`` arg. **δ**
1125: * - ``'object'`` (``str`` objects)
1126: - Y
1127: - ``STRING`` (default), ``SYMBOL`` via ``symbols`` arg. **δ**
1128: * - ``'datetime64[ns]'``
1129: - Y
1130: - ``TIMESTAMP`` **ζ**
1131: * - ``'datetime64[ns, tz]'``
1132: - Y
1133: - ``TIMESTAMP`` **ζ**
1134:
1135: .. note::
1136:
1137: * **α**: Note some pandas dtypes allow nulls (e.g. ``'boolean'``),
1138: where the QuestDB database does not.
1139:
1140: * **β**: The valid range for integer values is -2^63 to 2^63-1.
1141: Any ``'uint64'``, ``'UInt64'`` or python ``int`` object values
1142: outside this range will raise an error during serialization.
1143:
1144: * **γ**: Upcast to 64-bit float during serialization.
1145:
1146: * **δ**: Columns containing strings can also be used to specify the
1147: table name. See ``table_name_col``.
1148:
1149: * **ε**: We only support categories containing strings. If the
1150: category contains non-string values, an error will be raised.
1151:
1152: * **ζ**: The '.dataframe()' method only supports datetimes with
1153: nanosecond precision. The designated timestamp column (see ``at``
1154: parameter) maintains the nanosecond precision, whilst values
1155: stored as columns have their precision truncated to microseconds.
1156: All dates are sent as UTC and any additional timezone information
1157: is dropped. If no timezone is specified, we follow
1158: the pandas convention of assuming the timezone is UTC.
1159: Datetimes before 1970-01-01 00:00:00 UTC are not supported.
1160: If a datetime value is specified as ``None`` (``NaT``), it is
1161: interpreted as the current QuestDB server time set on receipt of
1162: message.
1163:
1164: **Error Handling and Recovery**
1165:
1166: In case an exception is raised during dataframe serialization, the
1167: buffer is left in its previous state.
1168: The buffer remains in a valid state and can be used for further calls
1169: even after an error.
1170:
1171: For clarification, as an example, if an invalid ``None``
1172: value appears at the 3rd row for a ``bool`` column, neither the 3rd nor
1173: the preceding rows are added to the buffer.
1174:
1175: **Note**: This differs from the :func:`Sender.dataframe` method, which
1176: modifies this guarantee due to its ``auto_flush`` logic.
1177:
1178: **Performance Considerations**
1179:
1180: The Python GIL is released during serialization if it is not needed.
1181: If any column requires the GIL, the entire serialization is done whilst
1182: holding the GIL.
1183:
1184: Column types that require the GIL are:
1185:
1186: * Columns of ``str``, ``float`` or ``int`` or ``float`` Python objects.
1187: * The ``'string[python]'`` dtype.
1188: """
+1189: _dataframe(
__pyx_t_1 = __pyx_f_7questdb_7ingress__dataframe(__pyx_f_7questdb_7ingress_auto_flush_blank(), __pyx_v_self->_impl, __pyx_v_self->_b, __pyx_v_df, __pyx_v_table_name, __pyx_v_table_name_col, __pyx_v_symbols, __pyx_v_at); if (unlikely(__pyx_t_1 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1189, __pyx_L1_error)
1190: auto_flush_blank(),
1191: self._impl,
1192: self._b,
1193: df,
1194: table_name,
1195: table_name_col,
1196: symbols,
1197: at)
1198:
1199:
+1200: _FLUSH_FMT = ('{} - See https://py-questdb-client.readthedocs.io/en/'
if (PyDict_SetItem(__pyx_d, __pyx_n_s_FLUSH_FMT, __pyx_kp_u_See_https_py_questdb_client_rea) < 0) __PYX_ERR(0, 1200, __pyx_L1_error)
1201: 'v1.2.0'
1202: '/troubleshooting.html#inspecting-and-debugging-errors#flush-failed')
1203:
1204:
+1205: cdef class Sender:
struct __pyx_vtabstruct_7questdb_7ingress_Sender { PyObject *(*flush)(struct __pyx_obj_7questdb_7ingress_Sender *, int __pyx_skip_dispatch, struct __pyx_opt_args_7questdb_7ingress_6Sender_flush *__pyx_optional_args); PyObject *(*_close)(struct __pyx_obj_7questdb_7ingress_Sender *); PyObject *(*close)(struct __pyx_obj_7questdb_7ingress_Sender *, int __pyx_skip_dispatch, struct __pyx_opt_args_7questdb_7ingress_6Sender_close *__pyx_optional_args); }; static struct __pyx_vtabstruct_7questdb_7ingress_Sender *__pyx_vtabptr_7questdb_7ingress_Sender;
1206: """
1207: A sender is a client that inserts rows into QuestDB via the ILP protocol.
1208:
1209: **Inserting two rows**
1210:
1211: In this example, data will be flushed and sent at the end of the ``with``
1212: block.
1213:
1214: .. code-block:: python
1215:
1216: with Sender('localhost', 9009) as sender:
1217: sender.row(
1218: 'weather_sensor',
1219: symbols={'id': 'toronto1'},
1220: columns={'temperature': 23.5, 'humidity': 0.49},
1221: at=TimestampNanos.now())
1222: sensor.row(
1223: 'weather_sensor',
1224: symbols={'id': 'dubai2'},
1225: columns={'temperature': 41.2, 'humidity': 0.34},
1226: at=TimestampNanos.now())
1227:
1228: The ``Sender`` object holds an internal buffer. The call to ``.row()``
1229: simply forwards all arguments to the :func:`Buffer.row` method.
1230:
1231:
1232: **Explicit flushing**
1233:
1234: An explicit call to :func:`Sender.flush` will send any pending data
1235: immediately.
1236:
1237: .. code-block:: python
1238:
1239: with Sender('localhost', 9009) as sender:
1240: sender.row(
1241: 'weather_sensor',
1242: symbols={'id': 'toronto1'},
1243: columns={'temperature': 23.5, 'humidity': 0.49},
1244: at=TimestampNanos.now())
1245: sender.flush()
1246: sender.row(
1247: 'weather_sensor',
1248: symbols={'id': 'dubai2'},
1249: columns={'temperature': 41.2, 'humidity': 0.34},
1250: at=TimestampNanos.now())
1251: sender.flush()
1252:
1253:
1254: **Auto-flushing (on by default, watermark at 63KiB)**
1255:
1256: To avoid accumulating very large buffers, the sender will flush the buffer
1257: automatically once its buffer reaches a certain byte-size watermark.
1258:
1259: You can control this behavior by setting the ``auto_flush`` argument.
1260:
1261: .. code-block:: python
1262:
1263: # Never flushes automatically.
1264: sender = Sender('localhost', 9009, auto_flush=False)
1265: sender = Sender('localhost', 9009, auto_flush=None) # Ditto.
1266: sender = Sender('localhost', 9009, auto_flush=0) # Ditto.
1267:
1268: # Flushes automatically when the buffer reaches 1KiB.
1269: sender = Sender('localhost', 9009, auto_flush=1024)
1270:
1271: # Flushes automatically after every row.
1272: sender = Sender('localhost', 9009, auto_flush=True)
1273: sender = Sender('localhost', 9009, auto_flush=1) # Ditto.
1274:
1275:
1276: **Authentication and TLS Encryption**
1277:
1278: This implementation supports authentication and TLS full-connection
1279: encryption.
1280:
1281: The ``Sender(.., auth=..)`` argument is a tuple of ``(kid, d, x, y)`` as
1282: documented on the `QuestDB ILP authentication
1283: <https://questdb.io/docs/reference/api/ilp/authenticate>`_ documentation.
1284: Authentication is optional and disabled by default.
1285:
1286: The ``Sender(.., tls=..)`` argument is one of:
1287:
1288: * ``False``: No TLS encryption (default).
1289:
1290: * ``True``: TLS encryption, accepting all common certificates as recognized
1291: by either the `webpki-roots <https://crates.io/crates/webpki-roots>`_ Rust
1292: crate (which in turn relies on https://mkcert.org/), or the OS-provided
1293: certificate store.
1294:
1295: * A ``str`` or ``pathlib.Path``: Path to a PEM-encoded certificate authority
1296: file. This is useful for testing with self-signed certificates.
1297:
1298: * The special ``'os_roots'`` string: Use the OS-provided certificate store.
1299:
1300: * The special ``'webpki_roots'`` string: Use the `webpki-roots
1301: <https://crates.io/crates/webpki-roots>`_ Rust crate to recognize
1302: certificates.
1303:
1304: * The special ``'webpki_and_os_roots'`` string: Use both the `webpki-roots
1305: <https://crates.io/crates/webpki-roots>`_ Rust crate and the OS-provided
1306: certificate store to recognize certificates. (equivalent to `True`).
1307:
1308: * The special ``'insecure_skip_verify'`` string: Dangerously disable all
1309: TLS certificate verification (do *NOT* use in production environments).
1310:
1311: **Positional constructor arguments for the Sender(..)**
1312:
1313: * ``host``: Hostname or IP address of the QuestDB server.
1314:
1315: * ``port``: Port number of the QuestDB server.
1316:
1317:
1318: **Keyword-only constructor arguments for the Sender(..)**
1319:
1320: * ``interface`` (``str``): Network interface to bind to.
1321: Set this if you have an accelerated network interface (e.g. Solarflare)
1322: and want to use it.
1323:
1324: * ``auth`` (``tuple``): Authentication tuple or ``None`` (default).
1325: *See above for details*.
1326:
1327: * ``tls`` (``bool``, ``pathlib.Path`` or ``str``): TLS configuration or
1328: ``False`` (default). *See above for details*.
1329:
1330: * ``read_timeout`` (``int``): How long to wait for messages from the QuestDB server
1331: during the TLS handshake or authentication process.
1332: This field is expressed in milliseconds. The default is 15 seconds.
1333:
1334: * ``init_capacity`` (``int``): Initial buffer capacity of the internal buffer.
1335: *Default: 65536 (64KiB).*
1336: *See Buffer's constructor for more details.*
1337:
1338: * ``max_name_length`` (``int``): Maximum length of a table or column name.
1339: *See Buffer's constructor for more details.*
1340:
1341: * ``auto_flush`` (``bool`` or ``int``): Whether to automatically flush the
1342: buffer when it reaches a certain byte-size watermark.
1343: *Default: 64512 (63KiB).*
1344: *See above for details.*
1345: """
1346:
1347: # We need the Buffer held by a Sender can hold a weakref to its Sender.
1348: # This avoids a circular reference that requires the GC to clean up.
1349: cdef object __weakref__
1350:
1351: cdef line_sender_opts* _opts
1352: cdef line_sender* _impl
1353: cdef Buffer _buffer
1354: cdef bint _auto_flush_enabled
1355: cdef ssize_t _auto_flush_watermark
1356: cdef size_t _init_capacity
1357: cdef size_t _max_name_len
1358:
+1359: def __cinit__(
/* Python wrapper */ static int __pyx_pw_7questdb_7ingress_6Sender_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static int __pyx_pw_7questdb_7ingress_6Sender_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_host = 0; PyObject *__pyx_v_port = 0; PyObject *__pyx_v_interface = 0; PyObject *__pyx_v_auth = 0; PyObject *__pyx_v_tls = 0; uint64_t __pyx_v_read_timeout; uint64_t __pyx_v_init_capacity; uint64_t __pyx_v_max_name_len; PyObject *__pyx_v_auto_flush = 0; CYTHON_UNUSED Py_ssize_t __pyx_nargs; CYTHON_UNUSED PyObject *const *__pyx_kwvalues; int __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return -1; #endif __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_host,&__pyx_n_s_port,&__pyx_n_s_interface,&__pyx_n_s_auth,&__pyx_n_s_tls,&__pyx_n_s_read_timeout,&__pyx_n_s_init_capacity,&__pyx_n_s_max_name_len,&__pyx_n_s_auto_flush,0}; PyObject* values[9] = {0,0,0,0,0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = -1; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static int __pyx_pf_7questdb_7ingress_6Sender___cinit__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, PyObject *__pyx_v_host, PyObject *__pyx_v_port, PyObject *__pyx_v_interface, PyObject *__pyx_v_auth, PyObject *__pyx_v_tls, uint64_t __pyx_v_read_timeout, uint64_t __pyx_v_init_capacity, uint64_t __pyx_v_max_name_len, PyObject *__pyx_v_auto_flush) { CYTHON_UNUSED struct line_sender_error *__pyx_v_err; struct line_sender_utf8 __pyx_v_host_utf8; PyObject *__pyx_v_port_str = 0; struct line_sender_utf8 __pyx_v_port_utf8; struct line_sender_utf8 __pyx_v_interface_utf8; PyObject *__pyx_v_a_key_id = 0; struct line_sender_utf8 __pyx_v_a_key_id_utf8; PyObject *__pyx_v_a_priv_key = 0; struct line_sender_utf8 __pyx_v_a_priv_key_utf8; PyObject *__pyx_v_a_pub_key_x = 0; struct line_sender_utf8 __pyx_v_a_pub_key_x_utf8; PyObject *__pyx_v_a_pub_key_y = 0; struct line_sender_utf8 __pyx_v_a_pub_key_y_utf8; struct line_sender_utf8 __pyx_v_ca_utf8; struct qdb_pystr_buf *__pyx_v_b; int __pyx_r; __Pyx_INCREF(__pyx_v_tls); /* … */ /* function exit code */ __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_7); __Pyx_AddTraceback("questdb.ingress.Sender.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_XDECREF(__pyx_v_port_str); __Pyx_XDECREF(__pyx_v_a_key_id); __Pyx_XDECREF(__pyx_v_a_priv_key); __Pyx_XDECREF(__pyx_v_a_pub_key_x); __Pyx_XDECREF(__pyx_v_a_pub_key_y); __Pyx_XDECREF(__pyx_v_tls); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1360: self,
1361: str host,
1362: object port,
1363: *,
+1364: str interface=None,
values[2] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)Py_None));
+1365: tuple auth=None,
values[3] = __Pyx_Arg_NewRef_VARARGS(((PyObject*)Py_None));
+1366: object tls=False,
values[4] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)Py_False)); values[8] = __Pyx_Arg_NewRef_VARARGS(((PyObject *)__pyx_int_64512)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_VARARGS(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_host)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1359, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_port)) != 0)) { (void)__Pyx_Arg_NewRef_VARARGS(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1359, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 1359, __pyx_L3_error) } } if (kw_args > 0 && likely(kw_args <= 7)) { Py_ssize_t index; for (index = 2; index < 9 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_VARARGS(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_VARARGS(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1359, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__cinit__") < 0)) __PYX_ERR(0, 1359, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 2)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_VARARGS(__pyx_args, 0); values[1] = __Pyx_Arg_VARARGS(__pyx_args, 1); } __pyx_v_host = ((PyObject*)values[0]); __pyx_v_port = values[1]; __pyx_v_interface = ((PyObject*)values[2]); __pyx_v_auth = ((PyObject*)values[3]); __pyx_v_tls = values[4]; if (values[5]) { __pyx_v_read_timeout = __Pyx_PyInt_As_uint64_t(values[5]); if (unlikely((__pyx_v_read_timeout == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1367, __pyx_L3_error) } else { __pyx_v_read_timeout = ((uint64_t)0x3A98); } if (values[6]) { __pyx_v_init_capacity = __Pyx_PyInt_As_uint64_t(values[6]); if (unlikely((__pyx_v_init_capacity == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1368, __pyx_L3_error) } else { __pyx_v_init_capacity = ((uint64_t)0x10000); } if (values[7]) { __pyx_v_max_name_len = __Pyx_PyInt_As_uint64_t(values[7]); if (unlikely((__pyx_v_max_name_len == ((uint64_t)-1)) && PyErr_Occurred())) __PYX_ERR(0, 1369, __pyx_L3_error) } else { __pyx_v_max_name_len = ((uint64_t)0x7F); } __pyx_v_auto_flush = values[8]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1359, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_VARARGS(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return -1; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_host), (&PyUnicode_Type), 1, "host", 1))) __PYX_ERR(0, 1361, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_interface), (&PyUnicode_Type), 1, "interface", 1))) __PYX_ERR(0, 1364, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_auth), (&PyTuple_Type), 1, "auth", 1))) __PYX_ERR(0, 1365, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Sender___cinit__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_host, __pyx_v_port, __pyx_v_interface, __pyx_v_auth, __pyx_v_tls, __pyx_v_read_timeout, __pyx_v_init_capacity, __pyx_v_max_name_len, __pyx_v_auto_flush);
1367: uint64_t read_timeout=15000,
1368: uint64_t init_capacity=65536, # 64KiB
1369: uint64_t max_name_len=127,
1370: object auto_flush=64512): # 63KiB
+1371: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
1372:
1373: cdef line_sender_utf8 host_utf8
1374:
1375: cdef str port_str
1376: cdef line_sender_utf8 port_utf8
1377:
1378: cdef str interface_str
1379: cdef line_sender_utf8 interface_utf8
1380:
1381: cdef str a_key_id
1382: cdef bytes a_key_id_owner
1383: cdef line_sender_utf8 a_key_id_utf8
1384:
1385: cdef str a_priv_key
1386: cdef bytes a_priv_key_owner
1387: cdef line_sender_utf8 a_priv_key_utf8
1388:
1389: cdef str a_pub_key_x
1390: cdef bytes a_pub_key_x_owner
1391: cdef line_sender_utf8 a_pub_key_x_utf8
1392:
1393: cdef str a_pub_key_y
1394: cdef bytes a_pub_key_y_owner
1395: cdef line_sender_utf8 a_pub_key_y_utf8
1396:
1397: cdef line_sender_utf8 ca_utf8
1398:
1399: cdef qdb_pystr_buf* b
1400:
+1401: self._opts = NULL
__pyx_v_self->_opts = NULL;
+1402: self._impl = NULL
__pyx_v_self->_impl = NULL;
1403:
+1404: self._init_capacity = init_capacity
__pyx_v_self->_init_capacity = __pyx_v_init_capacity;
+1405: self._max_name_len = max_name_len
__pyx_v_self->_max_name_len = __pyx_v_max_name_len;
1406:
+1407: self._buffer = Buffer(
__pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1407, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF((PyObject *)__pyx_v_self->_buffer); __Pyx_DECREF((PyObject *)__pyx_v_self->_buffer); __pyx_v_self->_buffer = ((struct __pyx_obj_7questdb_7ingress_Buffer *)__pyx_t_2); __pyx_t_2 = 0;
+1408: init_capacity=init_capacity,
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_init_capacity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_init_capacity, __pyx_t_2) < 0) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1409: max_name_len=max_name_len)
__pyx_t_2 = __Pyx_PyInt_From_uint64_t(__pyx_v_max_name_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1409, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_name_len, __pyx_t_2) < 0) __PYX_ERR(0, 1408, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1410:
+1411: b = self._buffer._b
__pyx_t_3 = __pyx_v_self->_buffer->_b; __pyx_v_b = __pyx_t_3;
1412:
+1413: if PyLong_CheckExact(<PyObject*>port):
__pyx_t_4 = PyLong_CheckExact(((PyObject *)__pyx_v_port));
if (__pyx_t_4) {
/* … */
goto __pyx_L3;
}
+1414: port_str = str(port)
__pyx_t_2 = __Pyx_PyObject_Str(__pyx_v_port); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1414, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_v_port_str = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
+1415: elif PyUnicode_CheckExact(<PyObject*>port):
__pyx_t_4 = PyUnicode_CheckExact(((PyObject *)__pyx_v_port));
if (likely(__pyx_t_4)) {
/* … */
goto __pyx_L3;
}
+1416: port_str = port
if (!(likely(PyUnicode_CheckExact(__pyx_v_port))||((__pyx_v_port) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_v_port))) __PYX_ERR(0, 1416, __pyx_L1_error) __pyx_t_2 = __pyx_v_port; __Pyx_INCREF(__pyx_t_2); __pyx_v_port_str = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0;
1417: else:
+1418: raise TypeError(
/*else*/ { /* … */ __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1418, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1418, __pyx_L1_error) } __pyx_L3:;
+1419: f'port must be an int or a str, not {_fqn(type(port))}')
__pyx_t_2 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_port)))); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_1 = __Pyx_PyUnicode_Unicode(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_t_2 = __Pyx_PyUnicode_Concat(__pyx_kp_u_port_must_be_an_int_or_a_str_not, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1419, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1420:
+1421: str_to_utf8(b, <PyObject*>host, &host_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_host), (&__pyx_v_host_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1421, __pyx_L1_error)
+1422: str_to_utf8(b, <PyObject*>port_str, &port_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_port_str), (&__pyx_v_port_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1422, __pyx_L1_error)
+1423: self._opts = line_sender_opts_new_service(host_utf8, port_utf8)
__pyx_v_self->_opts = line_sender_opts_new_service(__pyx_v_host_utf8, __pyx_v_port_utf8);
1424:
+1425: if interface is not None:
__pyx_t_4 = (__pyx_v_interface != ((PyObject*)Py_None)); if (__pyx_t_4) { /* … */ }
+1426: str_to_utf8(b, <PyObject*>interface, &interface_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_interface), (&__pyx_v_interface_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1426, __pyx_L1_error)
+1427: line_sender_opts_net_interface(self._opts, interface_utf8)
line_sender_opts_net_interface(__pyx_v_self->_opts, __pyx_v_interface_utf8);
1428:
+1429: if auth is not None:
__pyx_t_4 = (__pyx_v_auth != ((PyObject*)Py_None)); if (__pyx_t_4) { /* … */ }
+1430: (a_key_id,
if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1430, __pyx_L1_error) if (!(likely(PyUnicode_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_2))) __PYX_ERR(0, 1430, __pyx_L1_error) if (!(likely(PyUnicode_CheckExact(__pyx_t_6))||((__pyx_t_6) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_6))) __PYX_ERR(0, 1430, __pyx_L1_error) if (!(likely(PyUnicode_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_7))) __PYX_ERR(0, 1430, __pyx_L1_error) __pyx_v_a_key_id = ((PyObject*)__pyx_t_1); __pyx_t_1 = 0; __pyx_v_a_priv_key = ((PyObject*)__pyx_t_2); __pyx_t_2 = 0; __pyx_v_a_pub_key_x = ((PyObject*)__pyx_t_6); __pyx_t_6 = 0; __pyx_v_a_pub_key_y = ((PyObject*)__pyx_t_7); __pyx_t_7 = 0;
1431: a_priv_key,
1432: a_pub_key_x,
+1433: a_pub_key_y) = auth
if (likely(__pyx_v_auth != Py_None)) { PyObject* sequence = __pyx_v_auth; Py_ssize_t size = __Pyx_PySequence_SIZE(sequence); if (unlikely(size != 4)) { if (size > 4) __Pyx_RaiseTooManyValuesError(4); else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); __PYX_ERR(0, 1430, __pyx_L1_error) } #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_1 = PyTuple_GET_ITEM(sequence, 0); __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1); __pyx_t_6 = PyTuple_GET_ITEM(sequence, 2); __pyx_t_7 = PyTuple_GET_ITEM(sequence, 3); __Pyx_INCREF(__pyx_t_1); __Pyx_INCREF(__pyx_t_2); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(__pyx_t_7); #else { Py_ssize_t i; PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7}; for (i=0; i < 4; i++) { PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) __PYX_ERR(0, 1430, __pyx_L1_error) __Pyx_GOTREF(item); *(temps[i]) = item; } } #endif } else { __Pyx_RaiseNoneNotIterableError(); __PYX_ERR(0, 1430, __pyx_L1_error) }
+1434: str_to_utf8(b, <PyObject*>a_key_id, &a_key_id_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_a_key_id), (&__pyx_v_a_key_id_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1434, __pyx_L1_error)
+1435: str_to_utf8(b, <PyObject*>a_priv_key, &a_priv_key_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_a_priv_key), (&__pyx_v_a_priv_key_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1435, __pyx_L1_error)
+1436: str_to_utf8(b, <PyObject*>a_pub_key_x, &a_pub_key_x_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_a_pub_key_x), (&__pyx_v_a_pub_key_x_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1436, __pyx_L1_error)
+1437: str_to_utf8(b, <PyObject*>a_pub_key_y, &a_pub_key_y_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_a_pub_key_y), (&__pyx_v_a_pub_key_y_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1437, __pyx_L1_error)
+1438: line_sender_opts_auth(
line_sender_opts_auth(__pyx_v_self->_opts, __pyx_v_a_key_id_utf8, __pyx_v_a_priv_key_utf8, __pyx_v_a_pub_key_x_utf8, __pyx_v_a_pub_key_y_utf8);
1439: self._opts,
1440: a_key_id_utf8,
1441: a_priv_key_utf8,
1442: a_pub_key_x_utf8,
1443: a_pub_key_y_utf8)
1444:
+1445: if tls:
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_tls); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1445, __pyx_L1_error) if (__pyx_t_4) { /* … */ }
+1446: if tls is True:
__pyx_t_4 = (__pyx_v_tls == Py_True); if (__pyx_t_4) { /* … */ goto __pyx_L7; }
+1447: line_sender_opts_tls_webpki_and_os_roots(self._opts)
line_sender_opts_tls_webpki_and_os_roots(__pyx_v_self->_opts);
+1448: elif isinstance(tls, str):
__pyx_t_4 = PyUnicode_Check(__pyx_v_tls);
if (__pyx_t_4) {
/* … */
goto __pyx_L7;
}
+1449: if tls == 'webpki_roots':
__pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_tls, __pyx_n_u_webpki_roots, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1449, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L8; }
+1450: line_sender_opts_tls(self._opts)
line_sender_opts_tls(__pyx_v_self->_opts);
+1451: elif tls == 'os_roots':
__pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_tls, __pyx_n_u_os_roots, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1451, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L8; }
+1452: line_sender_opts_tls_os_roots(self._opts)
line_sender_opts_tls_os_roots(__pyx_v_self->_opts);
+1453: elif tls == 'webpki_and_os_roots':
__pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_tls, __pyx_n_u_webpki_and_os_roots, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1453, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L8; }
+1454: line_sender_opts_tls_webpki_and_os_roots(self._opts)
line_sender_opts_tls_webpki_and_os_roots(__pyx_v_self->_opts);
+1455: elif tls == 'insecure_skip_verify':
__pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_v_tls, __pyx_n_u_insecure_skip_verify, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1455, __pyx_L1_error) if (__pyx_t_4) { /* … */ goto __pyx_L8; }
+1456: line_sender_opts_tls_insecure_skip_verify(self._opts)
line_sender_opts_tls_insecure_skip_verify(__pyx_v_self->_opts);
1457: else:
+1458: str_to_utf8(b, <PyObject*>tls, &ca_utf8)
/*else*/ {
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_tls), (&__pyx_v_ca_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1458, __pyx_L1_error)
+1459: line_sender_opts_tls_ca(self._opts, ca_utf8)
line_sender_opts_tls_ca(__pyx_v_self->_opts, __pyx_v_ca_utf8); } __pyx_L8:;
+1460: elif isinstance(tls, pathlib.Path):
__Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_pathlib); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_Path); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1460, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_4 = PyObject_IsInstance(__pyx_v_tls, __pyx_t_6); if (unlikely(__pyx_t_4 == ((int)-1))) __PYX_ERR(0, 1460, __pyx_L1_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (likely(__pyx_t_4)) { /* … */ goto __pyx_L7; }
+1461: tls = str(tls)
__pyx_t_6 = __Pyx_PyObject_Str(__pyx_v_tls); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1461, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF_SET(__pyx_v_tls, __pyx_t_6); __pyx_t_6 = 0;
+1462: str_to_utf8(b, <PyObject*>tls, &ca_utf8)
__pyx_t_5 = __pyx_f_7questdb_7ingress_str_to_utf8(__pyx_v_b, ((PyObject *)__pyx_v_tls), (&__pyx_v_ca_utf8)); if (unlikely(__pyx_t_5 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1462, __pyx_L1_error)
+1463: line_sender_opts_tls_ca(self._opts, ca_utf8)
line_sender_opts_tls_ca(__pyx_v_self->_opts, __pyx_v_ca_utf8);
1464: else:
+1465: raise TypeError(
/*else*/ { /* … */ __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_TypeError, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1465, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 1465, __pyx_L1_error) } __pyx_L7:;
+1466: 'tls must be a bool, a path or string pointing to CA file '
__pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_tls_must_be_a_bool_a_path_or_str, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1466, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1467: f'or "insecure_skip_verify", not {_fqn(type(tls))}')
__pyx_t_6 = __pyx_f_7questdb_7ingress__fqn(((PyTypeObject*)((PyObject *)Py_TYPE(__pyx_v_tls)))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1467, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1468:
+1469: if read_timeout is not None:
__pyx_t_7 = __Pyx_PyInt_From_uint64_t(__pyx_v_read_timeout); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1469, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_4 = (__pyx_t_7 != Py_None); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (__pyx_t_4) { /* … */ }
+1470: line_sender_opts_read_timeout(self._opts, read_timeout)
line_sender_opts_read_timeout(__pyx_v_self->_opts, __pyx_v_read_timeout);
1471:
+1472: self._auto_flush_enabled = not not auto_flush
__pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_auto_flush); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1472, __pyx_L1_error) __pyx_v_self->_auto_flush_enabled = (!(!__pyx_t_4));
+1473: self._auto_flush_watermark = int(auto_flush) \
__pyx_t_7 = __Pyx_PyNumber_Int(__pyx_v_auto_flush); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = PyInt_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 1473, __pyx_L1_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_8 = __pyx_t_9; } else { __pyx_t_8 = 0; } __pyx_v_self->_auto_flush_watermark = __pyx_t_8;
+1474: if self._auto_flush_enabled else 0
if (__pyx_v_self->_auto_flush_enabled) {
+1475: if self._auto_flush_watermark < 0:
__pyx_t_4 = (__pyx_v_self->_auto_flush_watermark < 0); if (unlikely(__pyx_t_4)) { /* … */ }
+1476: raise ValueError(
__pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_ValueError, __pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1476, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 1476, __pyx_L1_error)
+1477: 'auto_flush_watermark must be >= 0, '
__pyx_t_6 = __Pyx_PyUnicode_Concat(__pyx_kp_u_auto_flush_watermark_must_be_0_n, __pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1477, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+1478: f'not {self._auto_flush_watermark}')
__pyx_t_7 = __Pyx_PyUnicode_From_Py_ssize_t(__pyx_v_self->_auto_flush_watermark, 0, ' ', 'd'); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1478, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_7);
1479:
+1480: qdb_pystr_buf_clear(b)
qdb_pystr_buf_clear(__pyx_v_b);
1481:
+1482: def new_buffer(self):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_3new_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_2new_buffer, "\n Make a new configured buffer.\n\n The buffer is set up with the configured `init_capacity` and\n `max_name_len`.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_3new_buffer = {"new_buffer", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_3new_buffer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_2new_buffer}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_3new_buffer(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("new_buffer (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("new_buffer", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "new_buffer", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_2new_buffer(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_2new_buffer(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Sender.new_buffer", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_3new_buffer, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_new_buffer, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__67)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1482, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_new_buffer, __pyx_t_18) < 0) __PYX_ERR(0, 1482, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); /* … */ __pyx_codeobj__67 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_new_buffer, 1482, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__67)) __PYX_ERR(0, 1482, __pyx_L1_error)
1483: """
1484: Make a new configured buffer.
1485:
1486: The buffer is set up with the configured `init_capacity` and
1487: `max_name_len`.
1488: """
+1489: return Buffer(
__Pyx_XDECREF(__pyx_r); /* … */ __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_7questdb_7ingress_Buffer), __pyx_empty_tuple, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1489, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; __pyx_t_2 = 0; goto __pyx_L0;
+1490: init_capacity=self._init_capacity,
__pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_init_capacity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_init_capacity, __pyx_t_2) < 0) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+1491: max_name_len=self._max_name_len)
__pyx_t_2 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_max_name_len); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1491, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_max_name_len, __pyx_t_2) < 0) __PYX_ERR(0, 1490, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1492:
+1493: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_13init_capacity_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_13init_capacity_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_13init_capacity___get__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_13init_capacity___get__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.init_capacity.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1494: def init_capacity(self) -> int:
1495: """The initial capacity of the sender's internal buffer."""
+1496: return self._init_capacity
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_init_capacity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1496, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1497:
+1498: @property
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_12max_name_len_1__get__(PyObject *__pyx_v_self); /*proto*/ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_12max_name_len_1__get__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_12max_name_len___get__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_12max_name_len___get__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.max_name_len.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1499: def max_name_len(self) -> int:
1500: """Maximum length of a table or column name."""
+1501: return self._max_name_len
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyInt_FromSize_t(__pyx_v_self->_max_name_len); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1501, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1502:
+1503: def connect(self):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_5connect(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_4connect, "\n Connect to the QuestDB server.\n\n This method is synchronous and will block until the connection is\n established.\n\n If the connection is set up with authentication and/or TLS, this\n method will return only *after* the handshake(s) is/are complete.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_5connect = {"connect", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_5connect, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_4connect}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_5connect(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("connect (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("connect", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "connect", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_4connect(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_4connect(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { struct line_sender_error *__pyx_v_err; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.Sender.connect", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__68 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_err); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 1503, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__68); __Pyx_GIVEREF(__pyx_tuple__68); /* … */ __pyx_t_18 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_5connect, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_connect, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__69)); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1503, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_connect, __pyx_t_18) < 0) __PYX_ERR(0, 1503, __pyx_L1_error) __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); __pyx_codeobj__69 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__68, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_connect, 1503, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__69)) __PYX_ERR(0, 1503, __pyx_L1_error)
1504: """
1505: Connect to the QuestDB server.
1506:
1507: This method is synchronous and will block until the connection is
1508: established.
1509:
1510: If the connection is set up with authentication and/or TLS, this
1511: method will return only *after* the handshake(s) is/are complete.
1512: """
+1513: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+1514: if self._opts == NULL:
__pyx_t_1 = (__pyx_v_self->_opts == NULL); if (unlikely(__pyx_t_1)) { /* … */ }
+1515: raise IngressError(
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_IngressError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
+1516: IngressErrorCode.InvalidApiCall,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InvalidApiCall); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1516, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_5, __pyx_kp_u_connect_can_t_be_called_after_cl}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_3, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1515, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; } __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1515, __pyx_L1_error)
1517: 'connect() can\'t be called after close().')
+1518: self._impl = line_sender_connect(self._opts, &err)
__pyx_v_self->_impl = line_sender_connect(__pyx_v_self->_opts, (&__pyx_v_err));
+1519: if self._impl == NULL:
__pyx_t_1 = (__pyx_v_self->_impl == NULL); if (unlikely(__pyx_t_1)) { /* … */ }
+1520: raise c_err_to_py(err)
__pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py(__pyx_v_err); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1520, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1520, __pyx_L1_error)
+1521: line_sender_opts_free(self._opts)
line_sender_opts_free(__pyx_v_self->_opts);
+1522: self._opts = NULL
__pyx_v_self->_opts = NULL;
1523:
1524: # Request callbacks when rows are complete.
+1525: if self._buffer is not None:
__pyx_t_1 = (((PyObject *)__pyx_v_self->_buffer) != Py_None); if (__pyx_t_1) { /* … */ }
+1526: self._buffer._row_complete_sender = PyWeakref_NewRef(self, None)
__pyx_t_2 = PyWeakref_NewRef(((PyObject *)__pyx_v_self), Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1526, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __Pyx_GOTREF(__pyx_v_self->_buffer->_row_complete_sender); __Pyx_DECREF(__pyx_v_self->_buffer->_row_complete_sender); __pyx_v_self->_buffer->_row_complete_sender = __pyx_t_2; __pyx_t_2 = 0;
1527:
+1528: def __enter__(self) -> Sender:
/* Python wrapper */ static struct __pyx_obj_7questdb_7ingress_Sender *__pyx_pw_7questdb_7ingress_6Sender_7__enter__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_6__enter__, "Call :func:`Sender.connect` at the start of a ``with`` block."); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_7__enter__ = {"__enter__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_7__enter__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_6__enter__}; static struct __pyx_obj_7questdb_7ingress_Sender *__pyx_pw_7questdb_7ingress_6Sender_7__enter__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; struct __pyx_obj_7questdb_7ingress_Sender *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); if (unlikely(__pyx_nargs > 0)) { __Pyx_RaiseArgtupleInvalid("__enter__", 1, 0, 0, __pyx_nargs); return NULL;} if (unlikely(__pyx_kwds) && __Pyx_NumKwargs_FASTCALL(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__enter__", 0))) return NULL; __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_6__enter__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static struct __pyx_obj_7questdb_7ingress_Sender *__pyx_pf_7questdb_7ingress_6Sender_6__enter__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { struct __pyx_obj_7questdb_7ingress_Sender *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_AddTraceback("questdb.ingress.Sender.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF((PyObject *)__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_return, __pyx_n_s_Sender) < 0) __PYX_ERR(0, 1528, __pyx_L1_error) __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_7__enter__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender___enter, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__70)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_17, __pyx_t_18); __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_enter, __pyx_t_17) < 0) __PYX_ERR(0, 1528, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); /* … */ __pyx_codeobj__70 = (PyObject*)__Pyx_PyCode_New(1, 0, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__42, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_enter, 1528, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__70)) __PYX_ERR(0, 1528, __pyx_L1_error)
1529: """Call :func:`Sender.connect` at the start of a ``with`` block."""
+1530: self.connect()
__pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_connect); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_t_3 = NULL; __pyx_t_4 = 0; #if CYTHON_UNPACK_METHODS if (likely(PyMethod_Check(__pyx_t_2))) { __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_3)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_3); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_4 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_4, 0+__pyx_t_4); __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1530, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+1531: return self
__Pyx_XDECREF((PyObject *)__pyx_r); __Pyx_INCREF((PyObject *)__pyx_v_self); __pyx_r = __pyx_v_self; goto __pyx_L0;
1532:
+1533: def __str__(self) -> str:
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_9__str__(PyObject *__pyx_v_self); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_8__str__, "\n Inspect the contents of the internal buffer.\n\n The ``str`` value returned represents the unsent data.\n\n Also see :func:`Sender.__len__`.\n "); #if CYTHON_UPDATE_DESCRIPTOR_DOC struct wrapperbase __pyx_wrapperbase_7questdb_7ingress_6Sender_8__str__; #endif static PyObject *__pyx_pw_7questdb_7ingress_6Sender_9__str__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__str__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_8__str__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_8__str__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.__str__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
1534: """
1535: Inspect the contents of the internal buffer.
1536:
1537: The ``str`` value returned represents the unsent data.
1538:
1539: Also see :func:`Sender.__len__`.
1540: """
+1541: return str(self._buffer)
__Pyx_XDECREF(__pyx_r); __pyx_t_1 = __Pyx_PyObject_Str(((PyObject *)__pyx_v_self->_buffer)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1541, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0;
1542:
+1543: def __len__(self) -> int:
/* Python wrapper */ static Py_ssize_t __pyx_pw_7questdb_7ingress_6Sender_11__len__(PyObject *__pyx_v_self); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_10__len__, "\n Number of bytes of unsent data in the internal buffer.\n\n Equivalent (but cheaper) to ``len(str(sender))``.\n "); #if CYTHON_UPDATE_DESCRIPTOR_DOC struct wrapperbase __pyx_wrapperbase_7questdb_7ingress_6Sender_10__len__; #endif static Py_ssize_t __pyx_pw_7questdb_7ingress_6Sender_11__len__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; Py_ssize_t __pyx_r; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__len__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_10__len__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static Py_ssize_t __pyx_pf_7questdb_7ingress_6Sender_10__len__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { Py_ssize_t __pyx_r; /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
1544: """
1545: Number of bytes of unsent data in the internal buffer.
1546:
1547: Equivalent (but cheaper) to ``len(str(sender))``.
1548: """
+1549: return len(self._buffer)
__pyx_t_1 = ((PyObject *)__pyx_v_self->_buffer); __Pyx_INCREF(__pyx_t_1); __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1549, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_r = __pyx_t_2; goto __pyx_L0;
1550:
+1551: def row(self,
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_13row(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_12row, "\n Write a row to the internal buffer.\n\n This may be sent automatically depending on the ``auto_flush`` setting\n in the constructor.\n\n Refer to the :func:`Buffer.row` documentation for details on arguments.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_13row = {"row", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_13row, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_12row}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_13row(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_symbols = 0; PyObject *__pyx_v_columns = 0; PyObject *__pyx_v_at = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("row (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_table_name,&__pyx_n_s_symbols,&__pyx_n_s_columns,&__pyx_n_s_at,0}; PyObject* values[4] = {0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_12row(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, PyObject *__pyx_v_table_name, PyObject *__pyx_v_symbols, PyObject *__pyx_v_columns, PyObject *__pyx_v_at) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_AddTraceback("questdb.ingress.Sender.row", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_t_17 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_table_name, __pyx_n_s_str) < 0) __PYX_ERR(0, 1551, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_symbols, __pyx_kp_s_Optional_Dict_str_str) < 0) __PYX_ERR(0, 1551, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_columns, __pyx_kp_s_Optional_Dict_str_Union_bool_int) < 0) __PYX_ERR(0, 1551, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_at, __pyx_kp_s_Union_None_TimestampNanos_dateti) < 0) __PYX_ERR(0, 1551, __pyx_L1_error) __pyx_t_19 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_13row, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_row, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__71)); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1551, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_19, __pyx_t_17); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_19, __pyx_t_18); __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_row, __pyx_t_19) < 0) __PYX_ERR(0, 1551, __pyx_L1_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); /* … */ __pyx_codeobj__71 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 5, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__61, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_row, 1551, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__71)) __PYX_ERR(0, 1551, __pyx_L1_error)
1552: table_name: str,
1553: *,
+1554: symbols: Optional[Dict[str, str]]=None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_symbols, Py_None) < 0) __PYX_ERR(0, 1551, __pyx_L1_error)
1555: columns: Optional[Dict[
1556: str,
+1557: Union[bool, int, float, str, TimestampMicros, datetime]]]=None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_columns, Py_None) < 0) __PYX_ERR(0, 1551, __pyx_L1_error)
+1558: at: Union[None, TimestampNanos, datetime]=None):
values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_table_name)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1551, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 3)) { Py_ssize_t index; for (index = 1; index < 4 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1551, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "row") < 0)) __PYX_ERR(0, 1551, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_table_name = ((PyObject*)values[0]); __pyx_v_symbols = ((PyObject*)values[1]); __pyx_v_columns = ((PyObject*)values[2]); __pyx_v_at = values[3]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("row", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1551, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.row", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table_name), (&PyUnicode_Type), 0, "table_name", 1))) __PYX_ERR(0, 1552, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_symbols), (&PyDict_Type), 1, "symbols", 1))) __PYX_ERR(0, 1554, __pyx_L1_error) if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_columns), (&PyDict_Type), 1, "columns", 1))) __PYX_ERR(0, 1555, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_12row(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_table_name, __pyx_v_symbols, __pyx_v_columns, __pyx_v_at); /* … */ if (PyDict_SetItem(__pyx_t_17, __pyx_n_s_at, Py_None) < 0) __PYX_ERR(0, 1551, __pyx_L1_error)
1559: """
1560: Write a row to the internal buffer.
1561:
1562: This may be sent automatically depending on the ``auto_flush`` setting
1563: in the constructor.
1564:
1565: Refer to the :func:`Buffer.row` documentation for details on arguments.
1566: """
+1567: self._buffer.row(table_name, symbols=symbols, columns=columns, at=at)
__pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self->_buffer), __pyx_n_s_row); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_INCREF(__pyx_v_table_name); __Pyx_GIVEREF(__pyx_v_table_name); if (__Pyx_PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_table_name)) __PYX_ERR(0, 1567, __pyx_L1_error); __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_symbols, __pyx_v_symbols) < 0) __PYX_ERR(0, 1567, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_columns, __pyx_v_columns) < 0) __PYX_ERR(0, 1567, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_3, __pyx_n_s_at, __pyx_v_at) < 0) __PYX_ERR(0, 1567, __pyx_L1_error) __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1567, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1568:
+1569: def dataframe(
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_15dataframe(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_14dataframe, "\n Write a Pandas DataFrame to the internal buffer.\n\n Example:\n\n .. code-block:: python\n\n import pandas as pd\n import questdb.ingress as qi\n\n df = pd.DataFrame({\n 'car': pd.Categorical(['Nic 42', 'Eddi', 'Nic 42', 'Eddi']),\n 'position': [1, 2, 1, 2],\n 'speed': [89.3, 98.2, 3, 4],\n 'lat_gforce': [0.1, -0.2, -0.6, 0.4],\n 'accelleration': [0.1, -0.2, 0.6, 4.4],\n 'tyre_pressure': [2.6, 2.5, 2.6, 2.5],\n 'ts': [\n pd.Timestamp('2022-08-09 13:56:00'),\n pd.Timestamp('2022-08-09 13:56:01'),\n pd.Timestamp('2022-08-09 13:56:02'),\n pd.Timestamp('2022-08-09 13:56:03')]})\n\n with qi.Sender('localhost', 9000) as sender:\n sender.dataframe(df, table_name='race_metrics', at='ts')\n\n This method builds on top of the :func:`Buffer.dataframe` method.\n See its documentation for details on arguments.\n\n Additionally, this method also supports auto-flushing the buffer\n as specified in the ``Sender``'s ``auto_flush`` constructor argument.\n Auto-flushing is implemented incrementally, meanting that when\n calling ``sender.dataframe(df)`` with a large ``df``, the sender may\n have sent some of the rows to the server already whist the rest of the\n rows are going to be sent at the next auto-flush or next explicit call\n to :func:`Sender.flush`.\n\n In case of data errors with auto-flushing enabled, some of the rows\n may have been transmitted to the server already.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_15dataframe = {"dataframe", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_15dataframe, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_14dataframe}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_15dataframe(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_df = 0; PyObject *__pyx_v_table_name = 0; PyObject *__pyx_v_table_name_col = 0; PyObject *__pyx_v_symbols = 0; PyObject *__pyx_v_at = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("dataframe (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_df,&__pyx_n_s_table_name,&__pyx_n_s_table_name_col,&__pyx_n_s_symbols,&__pyx_n_s_at,0}; PyObject* values[5] = {0,0,0,0,0}; /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_14dataframe(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, PyObject *__pyx_v_df, PyObject *__pyx_v_table_name, PyObject *__pyx_v_table_name_col, PyObject *__pyx_v_symbols, PyObject *__pyx_v_at) { struct __pyx_t_7questdb_7ingress_auto_flush_t __pyx_v_af; PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("questdb.ingress.Sender.dataframe", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__72 = PyTuple_Pack(7, __pyx_n_s_self, __pyx_n_s_df, __pyx_n_s_table_name, __pyx_n_s_table_name_col, __pyx_n_s_symbols, __pyx_n_s_at, __pyx_n_s_af); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 1569, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__72); __Pyx_GIVEREF(__pyx_tuple__72); /* … */ __pyx_t_19 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_19); /* … */ __pyx_t_18 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_18); if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_table_name, __pyx_kp_s_Optional_str) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_table_name_col, __pyx_kp_s_Union_None_int_str) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_symbols, __pyx_kp_s_Union_str_bool_List_int_List_str) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_18, __pyx_n_s_at, __pyx_kp_s_Union_None_int_str_TimestampNano) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_15dataframe, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_dataframe, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__73)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1569, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_17, __pyx_t_19); __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_17, __pyx_t_18); __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0; if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_dataframe, __pyx_t_17) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); __pyx_codeobj__73 = (PyObject*)__Pyx_PyCode_New(2, 0, 4, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__72, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_dataframe, 1569, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__73)) __PYX_ERR(0, 1569, __pyx_L1_error)
1570: self,
1571: df, # : pd.DataFrame
1572: *,
+1573: table_name: Optional[str] = None,
values[1] = __Pyx_Arg_NewRef_FASTCALL(((PyObject*)Py_None)); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_table_name, Py_None) < 0) __PYX_ERR(0, 1569, __pyx_L1_error)
+1574: table_name_col: Union[None, int, str] = None,
values[2] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); values[3] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)__pyx_n_u_auto)); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_table_name_col, Py_None) < 0) __PYX_ERR(0, 1569, __pyx_L1_error) if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_symbols, __pyx_n_u_auto) < 0) __PYX_ERR(0, 1569, __pyx_L1_error)
1575: symbols: Union[str, bool, List[int], List[str]] = 'auto',
+1576: at: Union[None, int, str, TimestampNanos, datetime] = None):
values[4] = __Pyx_Arg_NewRef_FASTCALL(((PyObject *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_df)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1569, __pyx_L3_error) else goto __pyx_L5_argtuple_error; } if (kw_args > 0 && likely(kw_args <= 4)) { Py_ssize_t index; for (index = 1; index < 5 && kw_args > 0; index++) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, *__pyx_pyargnames[index]); if (value) { values[index] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1569, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "dataframe") < 0)) __PYX_ERR(0, 1569, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 1)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); } __pyx_v_df = values[0]; __pyx_v_table_name = ((PyObject*)values[1]); __pyx_v_table_name_col = values[2]; __pyx_v_symbols = values[3]; __pyx_v_at = values[4]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("dataframe", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1569, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.dataframe", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_table_name), (&PyUnicode_Type), 1, "table_name", 1))) __PYX_ERR(0, 1573, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_14dataframe(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_df, __pyx_v_table_name, __pyx_v_table_name_col, __pyx_v_symbols, __pyx_v_at); /* … */ if (PyDict_SetItem(__pyx_t_19, __pyx_n_s_at, Py_None) < 0) __PYX_ERR(0, 1569, __pyx_L1_error)
1577: """
1578: Write a Pandas DataFrame to the internal buffer.
1579:
1580: Example:
1581:
1582: .. code-block:: python
1583:
1584: import pandas as pd
1585: import questdb.ingress as qi
1586:
1587: df = pd.DataFrame({
1588: 'car': pd.Categorical(['Nic 42', 'Eddi', 'Nic 42', 'Eddi']),
1589: 'position': [1, 2, 1, 2],
1590: 'speed': [89.3, 98.2, 3, 4],
1591: 'lat_gforce': [0.1, -0.2, -0.6, 0.4],
1592: 'accelleration': [0.1, -0.2, 0.6, 4.4],
1593: 'tyre_pressure': [2.6, 2.5, 2.6, 2.5],
1594: 'ts': [
1595: pd.Timestamp('2022-08-09 13:56:00'),
1596: pd.Timestamp('2022-08-09 13:56:01'),
1597: pd.Timestamp('2022-08-09 13:56:02'),
1598: pd.Timestamp('2022-08-09 13:56:03')]})
1599:
1600: with qi.Sender('localhost', 9000) as sender:
1601: sender.dataframe(df, table_name='race_metrics', at='ts')
1602:
1603: This method builds on top of the :func:`Buffer.dataframe` method.
1604: See its documentation for details on arguments.
1605:
1606: Additionally, this method also supports auto-flushing the buffer
1607: as specified in the ``Sender``'s ``auto_flush`` constructor argument.
1608: Auto-flushing is implemented incrementally, meanting that when
1609: calling ``sender.dataframe(df)`` with a large ``df``, the sender may
1610: have sent some of the rows to the server already whist the rest of the
1611: rows are going to be sent at the next auto-flush or next explicit call
1612: to :func:`Sender.flush`.
1613:
1614: In case of data errors with auto-flushing enabled, some of the rows
1615: may have been transmitted to the server already.
1616: """
+1617: cdef auto_flush_t af = auto_flush_blank()
__pyx_v_af = __pyx_f_7questdb_7ingress_auto_flush_blank();
+1618: if self._auto_flush_enabled:
if (__pyx_v_self->_auto_flush_enabled) { /* … */ }
+1619: af.sender = self._impl
__pyx_t_1 = __pyx_v_self->_impl; __pyx_v_af.sender = __pyx_t_1;
+1620: af.watermark = self._auto_flush_watermark
__pyx_t_2 = __pyx_v_self->_auto_flush_watermark; __pyx_v_af.watermark = __pyx_t_2;
+1621: _dataframe(
__pyx_t_3 = __pyx_f_7questdb_7ingress__dataframe(__pyx_v_af, __pyx_v_self->_buffer->_impl, __pyx_v_self->_buffer->_b, __pyx_v_df, __pyx_v_table_name, __pyx_v_table_name_col, __pyx_v_symbols, __pyx_v_at); if (unlikely(__pyx_t_3 == ((__pyx_t_7questdb_7ingress_void_int)-1))) __PYX_ERR(0, 1621, __pyx_L1_error)
1622: af,
1623: self._buffer._impl,
1624: self._buffer._b,
1625: df,
1626: table_name,
1627: table_name_col,
1628: symbols,
1629: at)
1630:
+1631: cpdef flush(self, Buffer buffer=None, bint clear=True):
static PyObject *__pyx_pw_7questdb_7ingress_6Sender_17flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_7questdb_7ingress_6Sender_flush(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_7questdb_7ingress_6Sender_flush *__pyx_optional_args) { struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_buffer = ((struct __pyx_obj_7questdb_7ingress_Buffer *)Py_None); int __pyx_v_clear = ((int)1); struct line_sender *__pyx_v_sender; struct line_sender_error *__pyx_v_err; struct line_sender_buffer *__pyx_v_c_buf; PyThreadState *__pyx_v_gs; int __pyx_v_ok; PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_buffer = __pyx_optional_args->buffer; if (__pyx_optional_args->__pyx_n > 1) { __pyx_v_clear = __pyx_optional_args->clear; } } } /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_flush); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7questdb_7ingress_6Sender_17flush)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_clear); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_5, ((PyObject *)__pyx_v_buffer), __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.Sender.flush", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_17flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_16flush, "\n If called with no arguments, immediately flushes the internal buffer.\n\n Alternatively you can flush a buffer that was constructed explicitly\n by passing ``buffer``.\n\n The buffer will be cleared by default, unless ``clear`` is set to\n ``False``.\n\n This method does nothing if the provided or internal buffer is empty.\n\n :param buffer: The buffer to flush. If ``None``, the internal buffer\n is flushed.\n\n :param clear: If ``True``, the flushed buffer is cleared (default).\n If ``False``, the flushed buffer is left in the internal buffer.\n Note that ``clear=False`` is only supported if ``buffer`` is also\n specified.\n\n The Python GIL is released during the network IO operation.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_17flush = {"flush", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_17flush, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_16flush}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_17flush(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_buffer = 0; int __pyx_v_clear; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("flush (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_buffer,&__pyx_n_s_clear,0}; PyObject* values[2] = {0,0}; values[0] = __Pyx_Arg_NewRef_FASTCALL((PyObject *)((struct __pyx_obj_7questdb_7ingress_Buffer *)Py_None)); if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_buffer); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1631, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_clear); if (value) { values[1] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1631, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "flush") < 0)) __PYX_ERR(0, 1631, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_buffer = ((struct __pyx_obj_7questdb_7ingress_Buffer *)values[0]); if (values[1]) { __pyx_v_clear = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_clear == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1631, __pyx_L3_error) } else { __pyx_v_clear = ((int)1); } } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("flush", 0, 0, 2, __pyx_nargs); __PYX_ERR(0, 1631, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.flush", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_buffer), __pyx_ptype_7questdb_7ingress_Buffer, 1, "buffer", 0))) __PYX_ERR(0, 1631, __pyx_L1_error) __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_16flush(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_buffer, __pyx_v_clear); /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __pyx_r = NULL; __pyx_L0:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_16flush(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, struct __pyx_obj_7questdb_7ingress_Buffer *__pyx_v_buffer, int __pyx_v_clear) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 2; __pyx_t_2.buffer = __pyx_v_buffer; __pyx_t_2.clear = __pyx_v_clear; __pyx_t_1 = __pyx_vtabptr_7questdb_7ingress_Sender->flush(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.flush", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__74 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_buffer, __pyx_n_s_clear); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__74); __Pyx_GIVEREF(__pyx_tuple__74); __pyx_codeobj__75 = (PyObject*)__Pyx_PyCode_New(3, 0, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__74, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_flush, 1631, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__75)) __PYX_ERR(0, 1631, __pyx_L1_error) /* … */ __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_17flush, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_flush, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__75)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_17, __pyx_tuple__76); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_flush, __pyx_t_17) < 0) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); __pyx_tuple__76 = PyTuple_Pack(2, Py_None, Py_True); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 1631, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__76); __Pyx_GIVEREF(__pyx_tuple__76); /* … */ struct __pyx_opt_args_7questdb_7ingress_6Sender_flush { int __pyx_n; struct __pyx_obj_7questdb_7ingress_Buffer *buffer; int clear; };
1632: """
1633: If called with no arguments, immediately flushes the internal buffer.
1634:
1635: Alternatively you can flush a buffer that was constructed explicitly
1636: by passing ``buffer``.
1637:
1638: The buffer will be cleared by default, unless ``clear`` is set to
1639: ``False``.
1640:
1641: This method does nothing if the provided or internal buffer is empty.
1642:
1643: :param buffer: The buffer to flush. If ``None``, the internal buffer
1644: is flushed.
1645:
1646: :param clear: If ``True``, the flushed buffer is cleared (default).
1647: If ``False``, the flushed buffer is left in the internal buffer.
1648: Note that ``clear=False`` is only supported if ``buffer`` is also
1649: specified.
1650:
1651: The Python GIL is released during the network IO operation.
1652: """
+1653: cdef line_sender* sender = self._impl
__pyx_t_7 = __pyx_v_self->_impl; __pyx_v_sender = __pyx_t_7;
+1654: cdef line_sender_error* err = NULL
__pyx_v_err = NULL;
+1655: cdef line_sender_buffer* c_buf = NULL
__pyx_v_c_buf = NULL;
+1656: cdef PyThreadState* gs = NULL # GIL state. NULL means we have the GIL.
__pyx_v_gs = NULL;
+1657: cdef bint ok = False
__pyx_v_ok = 0;
1658:
+1659: if buffer is None and not clear:
__pyx_t_9 = (((PyObject *)__pyx_v_buffer) == Py_None); if (__pyx_t_9) { } else { __pyx_t_8 = __pyx_t_9; goto __pyx_L4_bool_binop_done; } __pyx_t_9 = (!__pyx_v_clear); __pyx_t_8 = __pyx_t_9; __pyx_L4_bool_binop_done:; if (unlikely(__pyx_t_8)) { /* … */ }
+1660: raise ValueError('The internal buffer must always be cleared.')
__pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__36, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1660, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1660, __pyx_L1_error) /* … */ __pyx_tuple__36 = PyTuple_Pack(1, __pyx_kp_u_The_internal_buffer_must_always); if (unlikely(!__pyx_tuple__36)) __PYX_ERR(0, 1660, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__36); __Pyx_GIVEREF(__pyx_tuple__36);
1661:
+1662: if sender == NULL:
__pyx_t_8 = (__pyx_v_sender == NULL); if (unlikely(__pyx_t_8)) { /* … */ }
+1663: raise IngressError(
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_IngressError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+1664: IngressErrorCode.InvalidApiCall,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_IngressErrorCode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_InvalidApiCall); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1664, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_2))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_2, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_3, __pyx_kp_u_flush_can_t_be_called_Not_connec}; __pyx_t_1 = __Pyx_PyObject_FastCall(__pyx_t_2, __pyx_callargs+1-__pyx_t_6, 2+__pyx_t_6); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1663, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; } __Pyx_Raise(__pyx_t_1, 0, 0, 0); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __PYX_ERR(0, 1663, __pyx_L1_error)
1665: 'flush() can\'t be called: Not connected.')
+1666: if buffer is not None:
__pyx_t_8 = (((PyObject *)__pyx_v_buffer) != Py_None); if (__pyx_t_8) { /* … */ goto __pyx_L7; }
+1667: c_buf = buffer._impl
__pyx_t_10 = __pyx_v_buffer->_impl; __pyx_v_c_buf = __pyx_t_10;
1668: else:
+1669: c_buf = self._buffer._impl
/*else*/ { __pyx_t_10 = __pyx_v_self->_buffer->_impl; __pyx_v_c_buf = __pyx_t_10; } __pyx_L7:;
+1670: if line_sender_buffer_size(c_buf) == 0:
__pyx_t_8 = (line_sender_buffer_size(__pyx_v_c_buf) == 0); if (__pyx_t_8) { /* … */ }
+1671: return
__Pyx_XDECREF(__pyx_r); __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0;
1672:
1673: # We might be blocking on IO, so temporarily release the GIL.
+1674: _ensure_doesnt_have_gil(&gs)
__pyx_t_8 = __pyx_f_7questdb_7ingress__ensure_doesnt_have_gil((&__pyx_v_gs)); if (unlikely(__pyx_t_8 == ((int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1674, __pyx_L1_error)
+1675: if clear:
if (__pyx_v_clear) { /* … */ goto __pyx_L9; }
+1676: ok = line_sender_flush(sender, c_buf, &err)
__pyx_v_ok = line_sender_flush(__pyx_v_sender, __pyx_v_c_buf, (&__pyx_v_err));
1677: else:
+1678: ok = line_sender_flush_and_keep(sender, c_buf, &err)
/*else*/ { __pyx_v_ok = line_sender_flush_and_keep(__pyx_v_sender, __pyx_v_c_buf, (&__pyx_v_err)); } __pyx_L9:;
+1679: _ensure_has_gil(&gs)
__pyx_f_7questdb_7ingress__ensure_has_gil((&__pyx_v_gs)); if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1679, __pyx_L1_error)
+1680: if not ok:
__pyx_t_8 = (!__pyx_v_ok); if (__pyx_t_8) { /* … */ }
+1681: if c_buf == self._buffer._impl:
__pyx_t_8 = (__pyx_v_c_buf == __pyx_v_self->_buffer->_impl); if (__pyx_t_8) { /* … */ }
1682: # Prevent a follow-up call to `.close(flush=True)` (as is
1683: # usually called from `__exit__`) to raise after the sender
1684: # entered an error state following a failed call to `.flush()`.
1685: # Note: In this case `clear` is always `True`.
+1686: line_sender_buffer_clear(c_buf)
line_sender_buffer_clear(__pyx_v_c_buf);
+1687: raise c_err_to_py_fmt(err, _FLUSH_FMT)
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_FLUSH_FMT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("unicode", __pyx_t_1))) __PYX_ERR(0, 1687, __pyx_L1_error) __pyx_t_2 = __pyx_f_7questdb_7ingress_c_err_to_py_fmt(__pyx_v_err, ((PyObject*)__pyx_t_1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1687, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_Raise(__pyx_t_2, 0, 0, 0); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __PYX_ERR(0, 1687, __pyx_L1_error)
1688:
+1689: cdef _close(self):
static PyObject *__pyx_f_7questdb_7ingress_6Sender__close(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; }
+1690: self._buffer = None
__Pyx_INCREF(Py_None); __Pyx_GIVEREF(Py_None); __Pyx_GOTREF((PyObject *)__pyx_v_self->_buffer); __Pyx_DECREF((PyObject *)__pyx_v_self->_buffer); __pyx_v_self->_buffer = ((struct __pyx_obj_7questdb_7ingress_Buffer *)Py_None);
+1691: line_sender_opts_free(self._opts)
line_sender_opts_free(__pyx_v_self->_opts);
+1692: self._opts = NULL
__pyx_v_self->_opts = NULL;
+1693: line_sender_close(self._impl)
line_sender_close(__pyx_v_self->_impl);
+1694: self._impl = NULL
__pyx_v_self->_impl = NULL;
1695:
+1696: cpdef close(self, bint flush=True):
static PyObject *__pyx_pw_7questdb_7ingress_6Sender_19close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ static PyObject *__pyx_f_7questdb_7ingress_6Sender_close(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, int __pyx_skip_dispatch, struct __pyx_opt_args_7questdb_7ingress_6Sender_close *__pyx_optional_args) { int __pyx_v_flush = ((int)1); PyObject *__pyx_r = NULL; if (__pyx_optional_args) { if (__pyx_optional_args->__pyx_n > 0) { __pyx_v_flush = __pyx_optional_args->flush; } } /* Check if called by wrapper */ if (unlikely(__pyx_skip_dispatch)) ; /* Check if overridden in Python */ else if (unlikely((Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0) || __Pyx_PyType_HasFeature(Py_TYPE(((PyObject *)__pyx_v_self)), (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)))) { #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS static PY_UINT64_T __pyx_tp_dict_version = __PYX_DICT_VERSION_INIT, __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; if (unlikely(!__Pyx_object_dict_version_matches(((PyObject *)__pyx_v_self), __pyx_tp_dict_version, __pyx_obj_dict_version))) { PY_UINT64_T __pyx_typedict_guard = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); #endif __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (!__Pyx_IsSameCFunction(__pyx_t_1, (void*) __pyx_pw_7questdb_7ingress_6Sender_19close)) { __Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_v_flush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; __pyx_t_6 = 0; #if CYTHON_UNPACK_METHODS if (unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); __pyx_t_6 = 1; } } #endif { PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_3}; __pyx_t_2 = __Pyx_PyObject_FastCall(__pyx_t_4, __pyx_callargs+1-__pyx_t_6, 1+__pyx_t_6); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __pyx_r = __pyx_t_2; __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L0; } #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS __pyx_tp_dict_version = __Pyx_get_tp_dict_version(((PyObject *)__pyx_v_self)); __pyx_obj_dict_version = __Pyx_get_object_dict_version(((PyObject *)__pyx_v_self)); if (unlikely(__pyx_typedict_guard != __pyx_tp_dict_version)) { __pyx_tp_dict_version = __pyx_obj_dict_version = __PYX_DICT_VERSION_INIT; } #endif __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS } #endif } /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_AddTraceback("questdb.ingress.Sender.close", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = 0; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_19close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_18close, "\n Disconnect.\n\n This method is idempotent and can be called repeatedly.\n\n Once a sender is closed, it can't be re-used.\n\n :param bool flush: If ``True``, flush the internal buffer before closing.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_19close = {"close", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_19close, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_18close}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_19close(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { int __pyx_v_flush; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("close (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_flush,0}; PyObject* values[1] = {0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_flush); if (value) { values[0] = __Pyx_Arg_NewRef_FASTCALL(value); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1696, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "close") < 0)) __PYX_ERR(0, 1696, __pyx_L3_error) } } else { switch (__pyx_nargs) { case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } if (values[0]) { __pyx_v_flush = __Pyx_PyObject_IsTrue(values[0]); if (unlikely((__pyx_v_flush == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 1696, __pyx_L3_error) } else { __pyx_v_flush = ((int)1); } } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("close", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 1696, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.close", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_18close(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_flush); /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_18close(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, int __pyx_v_flush) { PyObject *__pyx_r = NULL; __Pyx_XDECREF(__pyx_r); __pyx_t_2.__pyx_n = 1; __pyx_t_2.flush = __pyx_v_flush; __pyx_t_1 = __pyx_vtabptr_7questdb_7ingress_Sender->close(__pyx_v_self, 1, &__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __pyx_r = __pyx_t_1; __pyx_t_1 = 0; goto __pyx_L0; /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_AddTraceback("questdb.ingress.Sender.close", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__77 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_flush); if (unlikely(!__pyx_tuple__77)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__77); __Pyx_GIVEREF(__pyx_tuple__77); __pyx_codeobj__78 = (PyObject*)__Pyx_PyCode_New(2, 0, 0, 2, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__77, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_close, 1696, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__78)) __PYX_ERR(0, 1696, __pyx_L1_error) /* … */ __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_19close, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender_close, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__78)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_17, __pyx_tuple__79); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_close, __pyx_t_17) < 0) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); __pyx_tuple__79 = PyTuple_Pack(1, Py_True); if (unlikely(!__pyx_tuple__79)) __PYX_ERR(0, 1696, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__79); __Pyx_GIVEREF(__pyx_tuple__79); /* … */ struct __pyx_opt_args_7questdb_7ingress_6Sender_close { int __pyx_n; int flush; };
1697: """
1698: Disconnect.
1699:
1700: This method is idempotent and can be called repeatedly.
1701:
1702: Once a sender is closed, it can't be re-used.
1703:
1704: :param bool flush: If ``True``, flush the internal buffer before closing.
1705: """
+1706: try:
/*try:*/ {
+1707: if (flush and (self._impl != NULL) and
if (__pyx_v_flush) { } else { __pyx_t_7 = __pyx_v_flush; goto __pyx_L7_bool_binop_done; } __pyx_t_8 = (__pyx_v_self->_impl != NULL); if (__pyx_t_8) { } else { __pyx_t_7 = __pyx_t_8; goto __pyx_L7_bool_binop_done; } /* … */ if (__pyx_t_7) { /* … */ } }
+1708: (not line_sender_must_close(self._impl))):
__pyx_t_8 = (!line_sender_must_close(__pyx_v_self->_impl)); __pyx_t_7 = __pyx_t_8; __pyx_L7_bool_binop_done:;
+1709: self.flush(None, True)
__pyx_t_9.__pyx_n = 2; __pyx_t_9.buffer = ((struct __pyx_obj_7questdb_7ingress_Buffer *)Py_None); __pyx_t_9.clear = 1; __pyx_t_1 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_self->__pyx_vtab)->flush(__pyx_v_self, 0, &__pyx_t_9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1709, __pyx_L4_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1710: finally:
+1711: self._close()
/*finally:*/ { /*normal exit:*/{ __pyx_t_1 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_self->__pyx_vtab)->_close(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; goto __pyx_L5; } __pyx_L4_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14); __Pyx_XGOTREF(__pyx_t_12); __Pyx_XGOTREF(__pyx_t_13); __Pyx_XGOTREF(__pyx_t_14); __Pyx_XGOTREF(__pyx_t_15); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __pyx_t_6 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename; { __pyx_t_1 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_self->__pyx_vtab)->_close(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L11_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XGIVEREF(__pyx_t_12); __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14); __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_lineno = __pyx_t_6; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11; goto __pyx_L1_error; __pyx_L11_error:; if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_15); __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17); } __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0; __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; goto __pyx_L1_error; } __pyx_L5:; }
1712:
+1713: def __exit__(self, exc_type, _exc_val, _exc_tb):
/* Python wrapper */ static PyObject *__pyx_pw_7questdb_7ingress_6Sender_21__exit__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ); /*proto*/ PyDoc_STRVAR(__pyx_doc_7questdb_7ingress_6Sender_20__exit__, "\n Flush pending and disconnect at the end of a ``with`` block.\n\n If the ``with`` block raises an exception, any pending data will\n *NOT* be flushed.\n\n This is implemented by calling :func:`Sender.close`.\n "); static PyMethodDef __pyx_mdef_7questdb_7ingress_6Sender_21__exit__ = {"__exit__", (PyCFunction)(void*)(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_7questdb_7ingress_6Sender_21__exit__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_7questdb_7ingress_6Sender_20__exit__}; static PyObject *__pyx_pw_7questdb_7ingress_6Sender_21__exit__(PyObject *__pyx_v_self, #if CYTHON_METH_FASTCALL PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds #else PyObject *__pyx_args, PyObject *__pyx_kwds #endif ) { PyObject *__pyx_v_exc_type = 0; CYTHON_UNUSED PyObject *__pyx_v__exc_val = 0; CYTHON_UNUSED PyObject *__pyx_v__exc_tb = 0; #if !CYTHON_METH_FASTCALL CYTHON_UNUSED Py_ssize_t __pyx_nargs; #endif CYTHON_UNUSED PyObject *const *__pyx_kwvalues; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0); #if !CYTHON_METH_FASTCALL #if CYTHON_ASSUME_SAFE_MACROS __pyx_nargs = PyTuple_GET_SIZE(__pyx_args); #else __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL; #endif #endif __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs); { PyObject **__pyx_pyargnames[] = {&__pyx_n_s_exc_type,&__pyx_n_s_exc_val,&__pyx_n_s_exc_tb,0}; PyObject* values[3] = {0,0,0}; if (__pyx_kwds) { Py_ssize_t kw_args; switch (__pyx_nargs) { case 3: values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = __Pyx_NumKwargs_FASTCALL(__pyx_kwds); switch (__pyx_nargs) { case 0: if (likely((values[0] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exc_type)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[0]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1713, __pyx_L3_error) else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (likely((values[1] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exc_val)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[1]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1713, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); __PYX_ERR(0, 1713, __pyx_L3_error) } CYTHON_FALLTHROUGH; case 2: if (likely((values[2] = __Pyx_GetKwValue_FASTCALL(__pyx_kwds, __pyx_kwvalues, __pyx_n_s_exc_tb)) != 0)) { (void)__Pyx_Arg_NewRef_FASTCALL(values[2]); kw_args--; } else if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1713, __pyx_L3_error) else { __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); __PYX_ERR(0, 1713, __pyx_L3_error) } } if (unlikely(kw_args > 0)) { const Py_ssize_t kwd_pos_args = __pyx_nargs; if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values + 0, kwd_pos_args, "__exit__") < 0)) __PYX_ERR(0, 1713, __pyx_L3_error) } } else if (unlikely(__pyx_nargs != 3)) { goto __pyx_L5_argtuple_error; } else { values[0] = __Pyx_Arg_FASTCALL(__pyx_args, 0); values[1] = __Pyx_Arg_FASTCALL(__pyx_args, 1); values[2] = __Pyx_Arg_FASTCALL(__pyx_args, 2); } __pyx_v_exc_type = values[0]; __pyx_v__exc_val = values[1]; __pyx_v__exc_tb = values[2]; } goto __pyx_L6_skip; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 1713, __pyx_L3_error) __pyx_L6_skip:; goto __pyx_L4_argument_unpacking_done; __pyx_L3_error:; { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_AddTraceback("questdb.ingress.Sender.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_7questdb_7ingress_6Sender_20__exit__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self), __pyx_v_exc_type, __pyx_v__exc_val, __pyx_v__exc_tb); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ { Py_ssize_t __pyx_temp; for (__pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) { __Pyx_Arg_XDECREF_FASTCALL(values[__pyx_temp]); } } __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_7questdb_7ingress_6Sender_20__exit__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self, PyObject *__pyx_v_exc_type, CYTHON_UNUSED PyObject *__pyx_v__exc_val, CYTHON_UNUSED PyObject *__pyx_v__exc_tb) { PyObject *__pyx_r = NULL; /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_AddTraceback("questdb.ingress.Sender.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__80 = PyTuple_Pack(4, __pyx_n_s_self, __pyx_n_s_exc_type, __pyx_n_s_exc_val, __pyx_n_s_exc_tb); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__80); __Pyx_GIVEREF(__pyx_tuple__80); /* … */ __pyx_t_17 = __Pyx_CyFunction_New(&__pyx_mdef_7questdb_7ingress_6Sender_21__exit__, __Pyx_CYFUNCTION_CCLASS, __pyx_n_s_Sender___exit, NULL, __pyx_n_s_questdb_ingress, __pyx_d, ((PyObject *)__pyx_codeobj__81)); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_17); if (__Pyx_SetItemOnTypeDict((PyObject *)__pyx_ptype_7questdb_7ingress_Sender, __pyx_n_s_exit, __pyx_t_17) < 0) __PYX_ERR(0, 1713, __pyx_L1_error) __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0; PyType_Modified(__pyx_ptype_7questdb_7ingress_Sender); __pyx_codeobj__81 = (PyObject*)__Pyx_PyCode_New(4, 0, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__80, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_questdb_ingress_pyx, __pyx_n_s_exit, 1713, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__81)) __PYX_ERR(0, 1713, __pyx_L1_error)
1714: """
1715: Flush pending and disconnect at the end of a ``with`` block.
1716:
1717: If the ``with`` block raises an exception, any pending data will
1718: *NOT* be flushed.
1719:
1720: This is implemented by calling :func:`Sender.close`.
1721: """
+1722: self.close(not exc_type)
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_exc_type); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1722, __pyx_L1_error) __pyx_t_3.__pyx_n = 1; __pyx_t_3.flush = (!__pyx_t_1); __pyx_t_2 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_self->__pyx_vtab)->close(__pyx_v_self, 0, &__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1723:
+1724: def __dealloc__(self):
/* Python wrapper */ static void __pyx_pw_7questdb_7ingress_6Sender_23__dealloc__(PyObject *__pyx_v_self); /*proto*/ static void __pyx_pw_7questdb_7ingress_6Sender_23__dealloc__(PyObject *__pyx_v_self) { CYTHON_UNUSED PyObject *const *__pyx_kwvalues; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0); __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs); __pyx_pf_7questdb_7ingress_6Sender_22__dealloc__(((struct __pyx_obj_7questdb_7ingress_Sender *)__pyx_v_self)); /* function exit code */ __Pyx_RefNannyFinishContext(); } static void __pyx_pf_7questdb_7ingress_6Sender_22__dealloc__(struct __pyx_obj_7questdb_7ingress_Sender *__pyx_v_self) { /* … */ /* function exit code */ goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_1); __Pyx_WriteUnraisable("questdb.ingress.Sender.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); __pyx_L0:; __Pyx_RefNannyFinishContext(); }
+1725: self._close()
__pyx_t_1 = ((struct __pyx_vtabstruct_7questdb_7ingress_Sender *)__pyx_v_self->__pyx_vtab)->_close(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1725, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;