Changeset: 8d6ecf7ab86c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8d6ecf7ab86c
Modified Files:
sql/backends/monet5/UDF/pyapi/conversion.c
sql/backends/monet5/UDF/pyapi/pyapi.c
sql/backends/monet5/UDF/pyapi/pytypes.c
Branch: Nov2019
Log Message:
Improved 32 vs 64 bit mapping between gdk void and oid types with numpy types
diffs (114 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,7 +50,13 @@ PyObject *PyArrayObject_FromScalar(PyInp
switch (inp->bat_type) {
case TYPE_void:
- vararray = PyArray_Arange(0, 1, 1, NPY_ULONGLONG);
+ vararray = PyArray_Arange(0, 1, 1,
+#if SIZEOF_OID == SIZEOF_INT
+
NPY_UINT
+#else
+
NPY_ULONGLONG
+#endif
+ );
break;
case TYPE_oid:
vararray = PyInt_FromLong((long)(*(oid *)inp->dataptr));
@@ -217,10 +223,22 @@ PyObject *PyArrayObject_FromBAT(PyInput
} else {
switch (inp->bat_type) {
case TYPE_void:
- BAT_TO_NP_CREATE_ALWAYS(b, NPY_ULONGLONG);
+ BAT_TO_NP_CREATE_ALWAYS(b,
+#if SIZEOF_OID == SIZEOF_INT
+ NPY_UINT
+#else
+ NPY_ULONGLONG
+#endif
+ );
break;
case TYPE_oid:
- BAT_TO_NP(b, oid, NPY_ULONG);
+ BAT_TO_NP(b, oid,
+#if SIZEOF_OID == SIZEOF_INT
+ NPY_UINT32
+#else
+ NPY_UINT64
+#endif
+ );
break;
case TYPE_bit:
BAT_TO_NP(b, bit, NPY_INT8);
diff --git a/sql/backends/monet5/UDF/pyapi/pyapi.c
b/sql/backends/monet5/UDF/pyapi/pyapi.c
--- a/sql/backends/monet5/UDF/pyapi/pyapi.c
+++ b/sql/backends/monet5/UDF/pyapi/pyapi.c
@@ -1508,9 +1508,28 @@ static void ComputeParallelAggregation(A
npy_intp elements[1] = {group_elements};
switch (input.bat_type) {
case TYPE_void:
+ vararray = PyArray_New(
+ &PyArray_Type, 1,
elements,
+#if SIZEOF_OID == SIZEOF_INT
+ NPY_UINT
+#else
+ NPY_ULONGLONG
+#endif
+ ,
+ NULL,
+ ((oid
***)(*p->split_bats))[group_it][i], 0,
+ NPY_ARRAY_CARRAY ||
!NPY_ARRAY_WRITEABLE, NULL);
+ break;
case TYPE_oid:
vararray = PyArray_New(
- &PyArray_Type, 1,
elements, NPY_INT64, NULL,
+ &PyArray_Type, 1,
elements,
+#if SIZEOF_OID == SIZEOF_INT
+ NPY_UINT32
+#else
+ NPY_UINT64
+#endif
+ ,
+ NULL,
((oid
***)(*p->split_bats))[group_it][i], 0,
NPY_ARRAY_CARRAY ||
!NPY_ARRAY_WRITEABLE, NULL);
break;
diff --git a/sql/backends/monet5/UDF/pyapi/pytypes.c
b/sql/backends/monet5/UDF/pyapi/pytypes.c
--- a/sql/backends/monet5/UDF/pyapi/pytypes.c
+++ b/sql/backends/monet5/UDF/pyapi/pytypes.c
@@ -159,7 +159,8 @@ int PyType_ToBat(int type)
#endif
case NPY_LONGLONG:
return TYPE_lng;
- case NPY_ULONG:
+ case NPY_UINT32:
+ case NPY_UINT64:
return TYPE_oid;
case NPY_FLOAT16:
case NPY_FLOAT:
@@ -183,7 +184,11 @@ int BatType_ToPyType(int type)
}
switch (type) {
case TYPE_void:
+#if SIZEOF_OID == SIZEOF_INT
+ return NPY_UINT;
+#else
return NPY_ULONGLONG;
+#endif
case TYPE_bit:
return NPY_BOOL;
case TYPE_bte:
@@ -201,7 +206,11 @@ int BatType_ToPyType(int type)
case TYPE_str:
return NPY_UNICODE;
case TYPE_oid:
- return NPY_ULONG;
+#if SIZEOF_OID == SIZEOF_INT
+ return NPY_UINT32;
+#else
+ return NPY_UINT64;
+#endif
#ifdef HAVE_HGE
case TYPE_hge:
return NPY_FLOAT64;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list