Changeset: aeac9df35cf8 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=aeac9df35cf8 Modified Files: sql/backends/monet5/UDF/pyapi/conversion.c sql/backends/monet5/UDF/pyapi/convert_loops.h Branch: default Log Message:
Merge with Nov2019 diffs (84 lines): diff --git a/sql/backends/monet5/UDF/pyapi/conversion.c b/sql/backends/monet5/UDF/pyapi/conversion.c --- a/sql/backends/monet5/UDF/pyapi/conversion.c +++ b/sql/backends/monet5/UDF/pyapi/conversion.c @@ -50,13 +50,11 @@ PyObject *PyArrayObject_FromScalar(PyInp switch (inp->bat_type) { case TYPE_void: - vararray = PyArray_Arange(0, 1, 1, #if SIZEOF_OID == SIZEOF_INT - NPY_UINT + vararray = PyArray_Arange(0, 1, 1, NPY_UINT); #else - NPY_ULONGLONG + vararray = PyArray_Arange(0, 1, 1, NPY_ULONGLONG); #endif - ); break; case TYPE_oid: vararray = PyInt_FromLong((long)(*(oid *)inp->dataptr)); @@ -223,22 +221,18 @@ PyObject *PyArrayObject_FromBAT(PyInput } else { switch (inp->bat_type) { case TYPE_void: - BAT_TO_NP_CREATE_ALWAYS(b, #if SIZEOF_OID == SIZEOF_INT - NPY_UINT + BAT_TO_NP_CREATE_ALWAYS(b, NPY_UINT); #else - NPY_ULONGLONG + BAT_TO_NP_CREATE_ALWAYS(b, NPY_ULONGLONG); #endif - ); break; case TYPE_oid: - BAT_TO_NP(b, oid, #if SIZEOF_OID == SIZEOF_INT - NPY_UINT32 + BAT_TO_NP(b, oid, NPY_UINT32); #else - NPY_UINT64 + BAT_TO_NP(b, oid, NPY_UINT64); #endif - ); break; case TYPE_bit: BAT_TO_NP(b, bit, NPY_INT8); diff --git a/sql/backends/monet5/UDF/pyapi/convert_loops.h b/sql/backends/monet5/UDF/pyapi/convert_loops.h --- a/sql/backends/monet5/UDF/pyapi/convert_loops.h +++ b/sql/backends/monet5/UDF/pyapi/convert_loops.h @@ -13,19 +13,23 @@ */ #define BAT_TO_NP_CREATE_ALWAYS(bat, nptpe) \ - vararray = PyArray_Arange(0, (double)bat->batCount, 1, nptpe); + do { \ + vararray = PyArray_Arange(0, (double)bat->batCount, 1, nptpe); \ + } while(0) \ #define BAT_TO_NP(bat, mtpe, nptpe) \ - if (copy) { \ - vararray = PyArray_EMPTY(1, elements, nptpe, 0); \ - memcpy(PyArray_DATA((PyArrayObject *)vararray), Tloc(bat, 0), \ - sizeof(mtpe) * (t_end - t_start)); \ - } else { \ - vararray = \ - PyArray_New(&PyArray_Type, 1, elements, nptpe, NULL, \ - &((mtpe *)Tloc(bat, 0))[t_start], 0, \ - NPY_ARRAY_CARRAY || !NPY_ARRAY_WRITEABLE, NULL); \ - } + do { \ + if (copy) { \ + vararray = PyArray_EMPTY(1, elements, nptpe, 0); \ + memcpy(PyArray_DATA((PyArrayObject *)vararray), Tloc(bat, 0), \ + sizeof(mtpe) * (t_end - t_start)); \ + } else { \ + vararray = \ + PyArray_New(&PyArray_Type, 1, elements, nptpe, NULL, \ + &((mtpe *)Tloc(bat, 0))[t_start], 0, \ + NPY_ARRAY_CARRAY || !NPY_ARRAY_WRITEABLE, NULL); \ + } \ + } while(0) \ // This #define creates a new BAT with the internal data and mask from a Numpy // array, without copying the data _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list